Completed
Branch update-venue-ui (4b9c7e)
by
unknown
02:27
created
core/data_migration_scripts/EE_DMS_Core_4_1_0.dms.php 2 patches
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
 // unfortunately, this needs to be done upon INCLUSION of this file,
10 10
 // instead of construction, because it only gets constructed on first page load
11 11
 // (all other times it gets resurrected from a wordpress option)
12
-$stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*');
12
+$stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14
-if (! empty($stages)) {
14
+if ( ! empty($stages)) {
15 15
     foreach ($stages as $filepath) {
16 16
         $matches = array();
17 17
         preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18
-        $class_to_filepath[ $matches[1] ] = $filepath;
18
+        $class_to_filepath[$matches[1]] = $filepath;
19 19
     }
20 20
 }
21 21
 // give addons a chance to autoload their stages too
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     private function _checkin_table_exists()
88 88
     {
89 89
         global $wpdb;
90
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
90
+        $results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'");
91 91
         if ($results) {
92 92
             return true;
93 93
         } else {
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
         if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) {
104 104
 //          echo "$version_string can be migrated fro";
105 105
             return true;
106
-        } elseif (! $version_string) {
106
+        } elseif ( ! $version_string) {
107 107
 //          echo "no version string provided: $version_string";
108 108
             // no version string provided... this must be pre 4.1
109 109
             // because since 4.1 we're
110
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
110
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
111 111
         } else {
112 112
 //          echo "$version_string doesnt apply";
113 113
             return false;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     public function schema_changes_before_migration()
120 120
     {
121 121
         // relies on 4.1's EEH_Activation::create_table
122
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
122
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
123 123
         $table_name = 'esp_answer';
124 124
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
125 125
 					REG_ID int(10) unsigned NOT NULL,
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
     public function insert_default_states()
504 504
     {
505 505
         global $wpdb;
506
-        $state_table = $wpdb->prefix . "esp_state";
506
+        $state_table = $wpdb->prefix."esp_state";
507 507
         if ($this->_get_table_analysis()->tableExists($state_table)) {
508
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
508
+            $SQL = "SELECT COUNT('STA_ID') FROM ".$state_table;
509 509
             $states = $wpdb->get_var($SQL);
510
-            if (! $states) {
511
-                $SQL = "INSERT INTO " . $state_table . "
510
+            if ( ! $states) {
511
+                $SQL = "INSERT INTO ".$state_table."
512 512
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
513 513
 				(1, 'US', 'AK', 'Alaska', 1),
514 514
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -596,12 +596,12 @@  discard block
 block discarded – undo
596 596
     public function insert_default_countries()
597 597
     {
598 598
         global $wpdb;
599
-        $country_table = $wpdb->prefix . "esp_country";
599
+        $country_table = $wpdb->prefix."esp_country";
600 600
         if ($this->_get_table_analysis()->tableExists($country_table)) {
601
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
601
+            $SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table;
602 602
             $countries = $wpdb->get_var($SQL);
603
-            if (! $countries) {
604
-                $SQL = "INSERT INTO " . $country_table . "
603
+            if ( ! $countries) {
604
+                $SQL = "INSERT INTO ".$country_table."
605 605
 				(CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES
606 606
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
607 607
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -846,17 +846,17 @@  discard block
 block discarded – undo
846 846
     public function insert_default_price_types()
847 847
     {
848 848
         global $wpdb;
849
-        $price_type_table = $wpdb->prefix . "esp_price_type";
849
+        $price_type_table = $wpdb->prefix."esp_price_type";
850 850
         if ($this->_get_table_analysis()->tableExists($price_type_table)) {
851
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
851
+            $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
852 852
             $price_types_exist = $wpdb->get_var($SQL);
853
-            if (! $price_types_exist) {
853
+            if ( ! $price_types_exist) {
854 854
                 $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
855
-							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
856
-							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
857
-							(3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
858
-							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
859
-							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
855
+							(1, '".esc_html__('Base Price', 'event_espresso')."', 1,  0, 0, 0),
856
+							(2, '" . esc_html__('Percent Discount', 'event_espresso')."', 2,  1, 20, 0),
857
+							(3, '" . esc_html__('Fixed Discount', 'event_espresso')."', 2,  0, 30, 0),
858
+							(4, '" . esc_html__('Percent Surcharge', 'event_espresso')."', 3,  1, 40, 0),
859
+							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso')."', 3,  0, 50, 0);";
860 860
                 $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
861 861
                 $wpdb->query($SQL);
862 862
             }
@@ -878,11 +878,11 @@  discard block
 block discarded – undo
878 878
     public function insert_default_prices()
879 879
     {
880 880
         global $wpdb;
881
-        $price_table = $wpdb->prefix . "esp_price";
881
+        $price_table = $wpdb->prefix."esp_price";
882 882
         if ($this->_get_table_analysis()->tableExists($price_table)) {
883
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
883
+            $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
884 884
             $prices_exist = $wpdb->get_var($SQL);
885
-            if (! $prices_exist) {
885
+            if ( ! $prices_exist) {
886 886
                 $SQL = "INSERT INTO $price_table
887 887
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
888 888
 							(1, 1, '0.00', 'Free Admission', '', 1, null, 0, 0, 0);";
@@ -904,11 +904,11 @@  discard block
 block discarded – undo
904 904
     public function insert_default_tickets()
905 905
     {
906 906
         global $wpdb;
907
-        $ticket_table = $wpdb->prefix . "esp_ticket";
907
+        $ticket_table = $wpdb->prefix."esp_ticket";
908 908
         if ($this->_get_table_analysis()->tableExists($ticket_table)) {
909
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
909
+            $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
910 910
             $tickets_exist = $wpdb->get_var($SQL);
911
-            if (! $tickets_exist) {
911
+            if ( ! $tickets_exist) {
912 912
                 $SQL = "INSERT INTO $ticket_table
913 913
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES
914 914
 					( 1, 0, '"
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
                 $wpdb->query($SQL);
919 919
             }
920 920
         }
921
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
921
+        $ticket_price_table = $wpdb->prefix."esp_ticket_price";
922 922
         if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
923
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
923
+            $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
924 924
             $ticket_prc_exist = $wpdb->get_var($SQL);
925
-            if (! $ticket_prc_exist) {
925
+            if ( ! $ticket_prc_exist) {
926 926
                 $SQL = "INSERT INTO $ticket_price_table
927 927
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
928 928
 				( 1, 1, 1 )
@@ -946,11 +946,11 @@  discard block
 block discarded – undo
946 946
      */
947 947
     public function get_or_create_country($country_name)
948 948
     {
949
-        if (! $country_name) {
949
+        if ( ! $country_name) {
950 950
             throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
951 951
         }
952 952
         global $wpdb;
953
-        $country_table = $wpdb->prefix . "esp_country";
953
+        $country_table = $wpdb->prefix."esp_country";
954 954
         if (is_int($country_name)) {
955 955
             $country_name = $this->get_iso_from_3_1_country_id($country_name);
956 956
         }
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 			CNT_ISO LIKE %s OR
959 959
 			CNT_ISO3 LIKE %s OR
960 960
 			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
961
-        if (! $country) {
961
+        if ( ! $country) {
962 962
             // insert a new one then
963 963
             $cols_n_values = array(
964 964
                     'CNT_ISO'         => $this->_find_available_country_iso(2),
@@ -978,28 +978,28 @@  discard block
 block discarded – undo
978 978
                     'CNT_active'      => true,
979 979
             );
980 980
             $data_types = array(
981
-                    '%s',// CNT_ISO
982
-                    '%s',// CNT_ISO3
983
-                    '%d',// RGN_ID
984
-                    '%s',// CNT_name
985
-                    '%s',// CNT_cur_code
986
-                    '%s',// CNT_cur_single
987
-                    '%s',// CNT_cur_plural
988
-                    '%s',// CNT_cur_sign
989
-                    '%d',// CNT_cur_sign_b4
990
-                    '%d',// CNT_cur_dec_plc
991
-                    '%s',// CNT_cur_dec_mrk
992
-                    '%s',// CNT_cur_thsnds
993
-                    '%s',// CNT_tel_code
994
-                    '%d',// CNT_is_EU
995
-                    '%d',// CNT_active
981
+                    '%s', // CNT_ISO
982
+                    '%s', // CNT_ISO3
983
+                    '%d', // RGN_ID
984
+                    '%s', // CNT_name
985
+                    '%s', // CNT_cur_code
986
+                    '%s', // CNT_cur_single
987
+                    '%s', // CNT_cur_plural
988
+                    '%s', // CNT_cur_sign
989
+                    '%d', // CNT_cur_sign_b4
990
+                    '%d', // CNT_cur_dec_plc
991
+                    '%s', // CNT_cur_dec_mrk
992
+                    '%s', // CNT_cur_thsnds
993
+                    '%s', // CNT_tel_code
994
+                    '%d', // CNT_is_EU
995
+                    '%d', // CNT_active
996 996
             );
997 997
             $success = $wpdb->insert(
998 998
                 $country_table,
999 999
                 $cols_n_values,
1000 1000
                 $data_types
1001 1001
             );
1002
-            if (! $success) {
1002
+            if ( ! $success) {
1003 1003
                 throw new EE_Error($this->_create_error_message_for_db_insertion(
1004 1004
                     'N/A',
1005 1005
                     array('country_id' => $country_name),
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
     private function _find_available_country_iso($num_letters = 2)
1025 1025
     {
1026 1026
         global $wpdb;
1027
-        $country_table = $wpdb->prefix . "esp_country";
1027
+        $country_table = $wpdb->prefix."esp_country";
1028 1028
         $attempts = 0;
1029 1029
         do {
1030 1030
             $current_iso = strtoupper(wp_generate_password($num_letters, false));
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
             // keep going until we find an available country code, or we arbitrarily
1036 1036
             // decide we've tried this enough. Somehow they have way too many countries
1037 1037
             // (probably because they're mis-using the EE3 country_id like a custom question)
1038
-        } while (intval($country_with_that_iso) && $attempts < 200);
1038
+        }while (intval($country_with_that_iso) && $attempts < 200);
1039 1039
         return $current_iso;
1040 1040
     }
1041 1041
 
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
      */
1052 1052
     public function get_or_create_state($state_name, $country_name = '')
1053 1053
     {
1054
-        if (! $state_name) {
1054
+        if ( ! $state_name) {
1055 1055
             throw new EE_Error(esc_html__(
1056 1056
                 "Could not get-or-create state because no state name was provided",
1057 1057
                 "event_espresso"
@@ -1064,12 +1064,12 @@  discard block
 block discarded – undo
1064 1064
             $country_iso = $this->get_default_country_iso();
1065 1065
         }
1066 1066
         global $wpdb;
1067
-        $state_table = $wpdb->prefix . "esp_state";
1067
+        $state_table = $wpdb->prefix."esp_state";
1068 1068
         $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1069 1069
 			(STA_abbrev LIKE %s OR
1070 1070
 			STA_name LIKE %s) AND
1071 1071
 			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1072
-        if (! $state) {
1072
+        if ( ! $state) {
1073 1073
             // insert a new one then
1074 1074
             $cols_n_values = array(
1075 1075
                     'CNT_ISO'    => $country_iso,
@@ -1078,13 +1078,13 @@  discard block
 block discarded – undo
1078 1078
                     'STA_active' => true,
1079 1079
             );
1080 1080
             $data_types = array(
1081
-                    '%s',// CNT_ISO
1082
-                    '%s',// STA_abbrev
1083
-                    '%s',// STA_name
1084
-                    '%d',// STA_active
1081
+                    '%s', // CNT_ISO
1082
+                    '%s', // STA_abbrev
1083
+                    '%s', // STA_name
1084
+                    '%d', // STA_active
1085 1085
             );
1086 1086
             $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1087
-            if (! $success) {
1087
+            if ( ! $success) {
1088 1088
                 throw new EE_Error($this->_create_error_message_for_db_insertion(
1089 1089
                     'N/A',
1090 1090
                     array('state' => $state_name, 'country_id' => $country_name),
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
     {
1114 1114
         $matches = array();
1115 1115
         preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1116
-        if (! $matches || count($matches) < 3) {
1116
+        if ( ! $matches || count($matches) < 3) {
1117 1117
             $hour = '00';
1118 1118
             $minutes = '00';
1119 1119
         } else {
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
                     'Declined'         => 'RPP',
1419 1419
             );
1420 1420
         }
1421
-        return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1421
+        return isset($mapping[$payment_status]) ? $mapping[$payment_status] : 'RNA';
1422 1422
     }
1423 1423
 
1424 1424
 
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
         if ($guid) {
1443 1443
             // check for an existing attachment post with this guid
1444 1444
             $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1445
-            if (! $attachment_post_id) {
1445
+            if ( ! $attachment_post_id) {
1446 1446
                 // post thumbnail with that GUID doesn't exist, we should create one
1447 1447
                 $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1448 1448
                 $created_attachment_post = true;
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
         $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1478 1478
         // do a head request to verify the file exists
1479 1479
         $head_response = wp_remote_head($original_guid);
1480
-        if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1480
+        if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1481 1481
             return $original_guid;
1482 1482
         } else {
1483 1483
             return $guid_in_old_event;
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
      */
1498 1498
     private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1499 1499
     {
1500
-        if (! $guid) {
1500
+        if ( ! $guid) {
1501 1501
             $migration_stage->add_error(sprintf(esc_html__(
1502 1502
                 "Cannot create image attachment for a blank GUID!",
1503 1503
                 "event_espresso"
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
         // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1510 1510
         if (strpos($guid, $wp_upload_dir['url']) === false) {
1511 1511
             // image is located remotely. download it and place it in the uploads directory
1512
-            if (! is_readable($guid)) {
1512
+            if ( ! is_readable($guid)) {
1513 1513
                 $migration_stage->add_error(sprintf(esc_html__(
1514 1514
                     "Could not create image attachment from non-existent file: %s",
1515 1515
                     "event_espresso"
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
                 ), $guid));
1525 1525
                 return false;
1526 1526
             }
1527
-            $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1527
+            $local_filepath = $wp_upload_dir['path'].'/'.basename($guid);
1528 1528
             $savefile = fopen($local_filepath, 'w');
1529 1529
             fwrite($savefile, $contents);
1530 1530
             fclose($savefile);
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
                 'post_status'    => 'inherit',
1541 1541
         );
1542 1542
         $attach_id = wp_insert_attachment($attachment, $guid);
1543
-        if (! $attach_id) {
1543
+        if ( ! $attach_id) {
1544 1544
             $migration_stage->add_error(sprintf(esc_html__(
1545 1545
                 "Could not create image attachment post from image '%s'. Attachment data was %s.",
1546 1546
                 "event_espresso"
@@ -1549,9 +1549,9 @@  discard block
 block discarded – undo
1549 1549
         }
1550 1550
         // you must first include the image.php file
1551 1551
         // for the function wp_generate_attachment_metadata() to work
1552
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1552
+        require_once(ABSPATH.'wp-admin/includes/image.php');
1553 1553
         $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1554
-        if (! $attach_data) {
1554
+        if ( ! $attach_data) {
1555 1555
             $migration_stage->add_error(sprintf(esc_html__(
1556 1556
                 "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1557 1557
                 "event_espresso"
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
             return $attach_id;
1560 1560
         }
1561 1561
         $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1562
-        if (! $metadata_save_result) {
1562
+        if ( ! $metadata_save_result) {
1563 1563
             $migration_stage->add_error(sprintf(esc_html__(
1564 1564
                 "Could not update attachment metadata for attachment %d with data %s",
1565 1565
                 "event_espresso"
@@ -1605,10 +1605,10 @@  discard block
 block discarded – undo
1605 1605
         $timezone = null
1606 1606
     ) {
1607 1607
         $original_tz = $timezone;
1608
-        if (! $timezone) {
1608
+        if ( ! $timezone) {
1609 1609
             $timezone = $this->_get_wp_timezone();
1610 1610
         }
1611
-        if (! $timezone) {
1611
+        if ( ! $timezone) {
1612 1612
             $stage->add_error(sprintf(
1613 1613
                 esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1614 1614
                 $original_tz,
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
         );
1742 1742
         add_filter(
1743 1743
             'FHEE__ee_migration_page__migration_options_template',
1744
-            array($this,'use_migration_options_from_ee3_template')
1744
+            array($this, 'use_migration_options_from_ee3_template')
1745 1745
         );
1746 1746
     }
1747 1747
 
@@ -1807,6 +1807,6 @@  discard block
 block discarded – undo
1807 1807
      */
1808 1808
     public function use_migration_options_from_ee3_template($template_filepath)
1809 1809
     {
1810
-        return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1810
+        return EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee3.template.php';
1811 1811
     }
1812 1812
 }
Please login to merge, or discard this patch.
Indentation   +1178 added lines, -1178 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 $stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14 14
 if (! empty($stages)) {
15
-    foreach ($stages as $filepath) {
16
-        $matches = array();
17
-        preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18
-        $class_to_filepath[ $matches[1] ] = $filepath;
19
-    }
15
+	foreach ($stages as $filepath) {
16
+		$matches = array();
17
+		preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18
+		$class_to_filepath[ $matches[1] ] = $filepath;
19
+	}
20 20
 }
21 21
 // give addons a chance to autoload their stages too
22 22
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath);
@@ -44,91 +44,91 @@  discard block
 block discarded – undo
44 44
 
45 45
 
46 46
 
47
-    /**
48
-     * EE_DMS_Core_4_1_0 constructor.
49
-     *
50
-     * @param TableManager  $table_manager
51
-     * @param TableAnalysis $table_analysis
52
-     */
53
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
54
-    {
55
-        $this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso");
56
-        $this->_priority = 10;
57
-        $this->_migration_stages = array(
58
-                new EE_DMS_4_1_0_org_options(),
59
-                new EE_DMS_4_1_0_shortcodes(),
60
-                new EE_DMS_4_1_0_gateways(),
61
-                new EE_DMS_4_1_0_events(),
62
-                new EE_DMS_4_1_0_prices(),
63
-                new EE_DMS_4_1_0_category_details(),
64
-                new EE_DMS_4_1_0_event_category(),
65
-                new EE_DMS_4_1_0_venues(),
66
-                new EE_DMS_4_1_0_event_venue(),
67
-                new EE_DMS_4_1_0_question_groups(),
68
-                new EE_DMS_4_1_0_questions(),
69
-                new EE_DMS_4_1_0_question_group_question(),
70
-                new EE_DMS_4_1_0_event_question_group(),
71
-                new EE_DMS_4_1_0_attendees(),
72
-                new EE_DMS_4_1_0_line_items(),
73
-                new EE_DMS_4_1_0_answers(),
74
-                new EE_DMS_4_1_0_checkins(),
75
-        );
76
-        parent::__construct($table_manager, $table_analysis);
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
83
-     *
84
-     * @global wpdb $wpdb
85
-     * @return boolean
86
-     */
87
-    private function _checkin_table_exists()
88
-    {
89
-        global $wpdb;
90
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
91
-        if ($results) {
92
-            return true;
93
-        } else {
94
-            return false;
95
-        }
96
-    }
97
-
98
-
99
-
100
-    public function can_migrate_from_version($version_array)
101
-    {
102
-        $version_string = $version_array['Core'];
103
-        if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) {
47
+	/**
48
+	 * EE_DMS_Core_4_1_0 constructor.
49
+	 *
50
+	 * @param TableManager  $table_manager
51
+	 * @param TableAnalysis $table_analysis
52
+	 */
53
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
54
+	{
55
+		$this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso");
56
+		$this->_priority = 10;
57
+		$this->_migration_stages = array(
58
+				new EE_DMS_4_1_0_org_options(),
59
+				new EE_DMS_4_1_0_shortcodes(),
60
+				new EE_DMS_4_1_0_gateways(),
61
+				new EE_DMS_4_1_0_events(),
62
+				new EE_DMS_4_1_0_prices(),
63
+				new EE_DMS_4_1_0_category_details(),
64
+				new EE_DMS_4_1_0_event_category(),
65
+				new EE_DMS_4_1_0_venues(),
66
+				new EE_DMS_4_1_0_event_venue(),
67
+				new EE_DMS_4_1_0_question_groups(),
68
+				new EE_DMS_4_1_0_questions(),
69
+				new EE_DMS_4_1_0_question_group_question(),
70
+				new EE_DMS_4_1_0_event_question_group(),
71
+				new EE_DMS_4_1_0_attendees(),
72
+				new EE_DMS_4_1_0_line_items(),
73
+				new EE_DMS_4_1_0_answers(),
74
+				new EE_DMS_4_1_0_checkins(),
75
+		);
76
+		parent::__construct($table_manager, $table_analysis);
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
83
+	 *
84
+	 * @global wpdb $wpdb
85
+	 * @return boolean
86
+	 */
87
+	private function _checkin_table_exists()
88
+	{
89
+		global $wpdb;
90
+		$results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
91
+		if ($results) {
92
+			return true;
93
+		} else {
94
+			return false;
95
+		}
96
+	}
97
+
98
+
99
+
100
+	public function can_migrate_from_version($version_array)
101
+	{
102
+		$version_string = $version_array['Core'];
103
+		if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) {
104 104
 //          echo "$version_string can be migrated fro";
105
-            return true;
106
-        } elseif (! $version_string) {
105
+			return true;
106
+		} elseif (! $version_string) {
107 107
 //          echo "no version string provided: $version_string";
108
-            // no version string provided... this must be pre 4.1
109
-            // because since 4.1 we're
110
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
111
-        } else {
108
+			// no version string provided... this must be pre 4.1
109
+			// because since 4.1 we're
110
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
111
+		} else {
112 112
 //          echo "$version_string doesnt apply";
113
-            return false;
114
-        }
115
-    }
113
+			return false;
114
+		}
115
+	}
116 116
 
117 117
 
118 118
 
119
-    public function schema_changes_before_migration()
120
-    {
121
-        // relies on 4.1's EEH_Activation::create_table
122
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
123
-        $table_name = 'esp_answer';
124
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
119
+	public function schema_changes_before_migration()
120
+	{
121
+		// relies on 4.1's EEH_Activation::create_table
122
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
123
+		$table_name = 'esp_answer';
124
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
125 125
 					REG_ID int(10) unsigned NOT NULL,
126 126
 					QST_ID int(10) unsigned NOT NULL,
127 127
 					ANS_value text NOT NULL,
128 128
 					PRIMARY KEY  (ANS_ID)";
129
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
130
-        $table_name = 'esp_attendee_meta';
131
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
129
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
130
+		$table_name = 'esp_attendee_meta';
131
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
132 132
 						ATT_ID bigint(20) unsigned NOT NULL,
133 133
 						ATT_fname varchar(45) NOT NULL,
134 134
 						ATT_lname varchar(45) NOT NULL,
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 								KEY ATT_fname (ATT_fname),
145 145
 								KEY ATT_lname (ATT_lname),
146 146
 								KEY ATT_email (ATT_email(191))";
147
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
148
-        $table_name = 'esp_country';
149
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
147
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
148
+		$table_name = 'esp_country';
149
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
150 150
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
151 151
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
152 152
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 					  CNT_is_EU tinyint(1) DEFAULT '0',
163 163
 					  CNT_active tinyint(1) DEFAULT '0',
164 164
 					  PRIMARY KEY  (CNT_ISO)";
165
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
166
-        $table_name = 'esp_datetime';
167
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
165
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
166
+		$table_name = 'esp_datetime';
167
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
168 168
 				  EVT_ID bigint(20) unsigned NOT NULL,
169 169
 				  DTT_EVT_start datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
170 170
 				  DTT_EVT_end datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 						PRIMARY KEY  (DTT_ID),
178 178
 						KEY EVT_ID (EVT_ID),
179 179
 						KEY DTT_is_primary (DTT_is_primary)";
180
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
181
-        $table_name = 'esp_event_meta';
182
-        $sql = "
180
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
181
+		$table_name = 'esp_event_meta';
182
+		$sql = "
183 183
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
184 184
 			EVT_ID bigint(20) unsigned NOT NULL,
185 185
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -194,31 +194,31 @@  discard block
 block discarded – undo
194 194
 			EVT_external_URL varchar(200) NULL,
195 195
 			EVT_donations tinyint(1) NULL,
196 196
 			PRIMARY KEY  (EVTM_ID)";
197
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
198
-        $table_name = 'esp_event_question_group';
199
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
197
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
198
+		$table_name = 'esp_event_question_group';
199
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
200 200
 					EVT_ID bigint(20) unsigned NOT NULL,
201 201
 					QSG_ID int(10) unsigned NOT NULL,
202 202
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
203 203
 					PRIMARY KEY  (EQG_ID)";
204
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
205
-        $table_name = 'esp_event_venue';
206
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
204
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
205
+		$table_name = 'esp_event_venue';
206
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
207 207
 				EVT_ID bigint(20) unsigned NOT NULL,
208 208
 				VNU_ID bigint(20) unsigned NOT NULL,
209 209
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
210 210
 				PRIMARY KEY  (EVV_ID)";
211
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
212
-        $table_name = 'esp_extra_meta';
213
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
211
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
212
+		$table_name = 'esp_extra_meta';
213
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
214 214
 				OBJ_ID int(11) DEFAULT NULL,
215 215
 				EXM_type varchar(45) DEFAULT NULL,
216 216
 				EXM_key varchar(45) DEFAULT NULL,
217 217
 				EXM_value text,
218 218
 				PRIMARY KEY  (EXM_ID)";
219
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
220
-        $table_name = 'esp_line_item';
221
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
219
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
220
+		$table_name = 'esp_line_item';
221
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
222 222
 				LIN_code varchar(245) NOT NULL DEFAULT '',
223 223
 				TXN_ID int(11) DEFAULT NULL,
224 224
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -234,18 +234,18 @@  discard block
 block discarded – undo
234 234
 				OBJ_ID int(11) DEFAULT NULL,
235 235
 				OBJ_type varchar(45)DEFAULT NULL,
236 236
 				PRIMARY KEY  (LIN_ID)";
237
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
238
-        $table_name = 'esp_message_template';
239
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
237
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
238
+		$table_name = 'esp_message_template';
239
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
240 240
 					GRP_ID int(10) unsigned NOT NULL,
241 241
 					MTP_context varchar(50) NOT NULL,
242 242
 					MTP_template_field varchar(30) NOT NULL,
243 243
 					MTP_content text NOT NULL,
244 244
 					PRIMARY KEY  (MTP_ID),
245 245
 					KEY GRP_ID (GRP_ID)";
246
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
-        $table_name = 'esp_message_template_group';
248
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
246
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
+		$table_name = 'esp_message_template_group';
248
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
249 249
 					EVT_ID bigint(20) unsigned DEFAULT NULL,
250 250
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
251 251
 					MTP_messenger varchar(30) NOT NULL,
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 					PRIMARY KEY  (GRP_ID),
258 258
 					KEY EVT_ID (EVT_ID),
259 259
 					KEY MTP_user_id (MTP_user_id)";
260
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
261
-        $table_name = 'esp_payment';
262
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
260
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
261
+		$table_name = 'esp_payment';
262
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
263 263
 					TXN_ID int(10) unsigned DEFAULT NULL,
264 264
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
265 265
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 					PRIMARY KEY  (PAY_ID),
276 276
 					KEY TXN_ID (TXN_ID),
277 277
 					KEY PAY_timestamp (PAY_timestamp)";
278
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
279
-        $table_name = "esp_ticket";
280
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
278
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
279
+		$table_name = "esp_ticket";
280
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
281 281
 					  TTM_ID int(10) unsigned NOT NULL,
282 282
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
283 283
 					  TKT_description text NOT NULL,
@@ -296,28 +296,28 @@  discard block
 block discarded – undo
296 296
 					  TKT_parent int(10) unsigned DEFAULT '0',
297 297
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
298 298
 					  PRIMARY KEY  (TKT_ID)";
299
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
300
-        $table_name = "esp_ticket_price";
301
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
299
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
300
+		$table_name = "esp_ticket_price";
301
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
302 302
 					  TKT_ID int(10) unsigned NOT NULL,
303 303
 					  PRC_ID int(10) unsigned NOT NULL,
304 304
 					  PRIMARY KEY  (TKP_ID)";
305
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
306
-        $table_name = "esp_datetime_ticket";
307
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
305
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
306
+		$table_name = "esp_datetime_ticket";
307
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
308 308
 					  DTT_ID int(10) unsigned NOT NULL,
309 309
 					  TKT_ID int(10) unsigned NOT NULL,
310 310
 					  PRIMARY KEY  (DTK_ID)";
311
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
312
-        $table_name = "esp_ticket_template";
313
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
311
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
312
+		$table_name = "esp_ticket_template";
313
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
314 314
 					  TTM_name varchar(45) NOT NULL,
315 315
 					  TTM_description text,
316 316
 					  TTM_file varchar(45),
317 317
 					  PRIMARY KEY  (TTM_ID)";
318
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
319
-        $table_name = "esp_price";
320
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
318
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
319
+		$table_name = "esp_price";
320
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
321 321
 					  PRT_ID tinyint(3) unsigned NOT NULL,
322 322
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
323 323
 					  PRC_name varchar(245) NOT NULL,
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
 					  PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0',
329 329
 					  PRC_parent int(10) unsigned DEFAULT 0,
330 330
 					  PRIMARY KEY  (PRC_ID)";
331
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
332
-        $table_name = "esp_price_type";
333
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
331
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
332
+		$table_name = "esp_price_type";
333
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
334 334
 				  PRT_name varchar(45) NOT NULL,
335 335
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
336 336
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
339 339
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
340 340
 				  PRIMARY KEY  (PRT_ID)";
341
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
342
-        $table_name = 'esp_question';
343
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
341
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
342
+		$table_name = 'esp_question';
343
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
344 344
 					QST_display_text text NOT NULL,
345 345
 					QST_admin_label varchar(255) NOT NULL,
346 346
 					QST_system varchar(25) DEFAULT NULL,
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 					QST_wp_user bigint(20) unsigned NULL,
353 353
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
354 354
 					PRIMARY KEY  (QST_ID)';
355
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
356
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
357
-        $table_name = 'esp_question_group';
358
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
355
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
356
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
357
+		$table_name = 'esp_question_group';
358
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
359 359
 					QSG_name varchar(255) NOT NULL,
360 360
 					QSG_identifier varchar(100) NOT NULL,
361 361
 					QSG_desc text NULL,
@@ -366,23 +366,23 @@  discard block
 block discarded – undo
366 366
 					QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
367 367
 					PRIMARY KEY  (QSG_ID),
368 368
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
369
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
370
-        $table_name = 'esp_question_group_question';
371
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
369
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
370
+		$table_name = 'esp_question_group_question';
371
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
372 372
 					QSG_ID int(10) unsigned NOT NULL,
373 373
 					QST_ID int(10) unsigned NOT NULL,
374 374
 					PRIMARY KEY  (QGQ_ID) ";
375
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
-        $table_name = 'esp_question_option';
377
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
375
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
+		$table_name = 'esp_question_option';
377
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
378 378
 					QSO_value varchar(255) NOT NULL,
379 379
 					QSO_desc text NOT NULL,
380 380
 					QST_ID int(10) unsigned NOT NULL,
381 381
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
382 382
 					PRIMARY KEY  (QSO_ID)";
383
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
384
-        $table_name = 'esp_registration';
385
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
383
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
384
+		$table_name = 'esp_registration';
385
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
386 386
 					  EVT_ID bigint(20) unsigned NOT NULL,
387 387
 					  ATT_ID bigint(20) unsigned NOT NULL,
388 388
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -405,25 +405,25 @@  discard block
 block discarded – undo
405 405
 					  KEY STS_ID (STS_ID),
406 406
 					  KEY REG_url_link (REG_url_link),
407 407
 					  KEY REG_code (REG_code)";
408
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
409
-        $table_name = 'esp_checkin';
410
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
408
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
409
+		$table_name = 'esp_checkin';
410
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
411 411
 					REG_ID int(10) unsigned NOT NULL,
412 412
 					DTT_ID int(10) unsigned NOT NULL,
413 413
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
414 414
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
415 415
 					PRIMARY KEY  (CHK_ID)";
416
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
417
-        $table_name = 'esp_state';
418
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
416
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
417
+		$table_name = 'esp_state';
418
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
419 419
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
420 420
 					  STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL,
421 421
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
422 422
 					  STA_active tinyint(1) DEFAULT '1',
423 423
 					  PRIMARY KEY  (STA_ID)";
424
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
425
-        $table_name = 'esp_status';
426
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
424
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
425
+		$table_name = 'esp_status';
426
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
427 427
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
428 428
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
429 429
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -431,9 +431,9 @@  discard block
 block discarded – undo
431 431
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
432 432
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
433 433
 					  KEY STS_type (STS_type)";
434
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
435
-        $table_name = 'esp_transaction';
436
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
434
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
435
+		$table_name = 'esp_transaction';
436
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
437 437
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
438 438
 					  TXN_total decimal(10,3) DEFAULT '0.00',
439 439
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -443,9 +443,9 @@  discard block
 block discarded – undo
443 443
 					  PRIMARY KEY  (TXN_ID),
444 444
 					  KEY TXN_timestamp (TXN_timestamp),
445 445
 					  KEY STS_ID (STS_ID)";
446
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
447
-        $table_name = 'esp_venue_meta';
448
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
446
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
447
+		$table_name = 'esp_venue_meta';
448
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
449 449
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
450 450
 			VNU_address varchar(255) DEFAULT NULL,
451 451
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -463,52 +463,52 @@  discard block
 block discarded – undo
463 463
 			PRIMARY KEY  (VNUM_ID),
464 464
 			KEY STA_ID (STA_ID),
465 465
 			KEY CNT_ISO (CNT_ISO)";
466
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
467
-        // setting up the default stats and countries is also essential for the data migrations to run
468
-        // (because many need to convert old string states to foreign keys into the states table)
469
-        $this->insert_default_states();
470
-        $this->insert_default_countries();
471
-        // setting up default prices, price types, and tickets is also essential for the price migrations
472
-        $this->insert_default_price_types();
473
-        $this->insert_default_prices();
474
-        $this->insert_default_tickets();
475
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
476
-        EE_Config::instance()->update_espresso_config(false, true);
477
-        return true;
478
-    }
479
-
480
-
481
-
482
-    /**
483
-     * Yes we could have cleaned up the ee3 tables here. But just in case someone
484
-     * didn't backup their DB, and decides they want ot keep using EE3, we'll
485
-     * leave them for now. Mayeb remove them in 4.5 or something.
486
-     *
487
-     * @return boolean
488
-     */
489
-    public function schema_changes_after_migration()
490
-    {
491
-        return true;
492
-    }
493
-
494
-
495
-
496
-    /**
497
-     * insert_default_states
498
-     *
499
-     * @access public
500
-     * @static
501
-     * @return void
502
-     */
503
-    public function insert_default_states()
504
-    {
505
-        global $wpdb;
506
-        $state_table = $wpdb->prefix . "esp_state";
507
-        if ($this->_get_table_analysis()->tableExists($state_table)) {
508
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
509
-            $states = $wpdb->get_var($SQL);
510
-            if (! $states) {
511
-                $SQL = "INSERT INTO " . $state_table . "
466
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
467
+		// setting up the default stats and countries is also essential for the data migrations to run
468
+		// (because many need to convert old string states to foreign keys into the states table)
469
+		$this->insert_default_states();
470
+		$this->insert_default_countries();
471
+		// setting up default prices, price types, and tickets is also essential for the price migrations
472
+		$this->insert_default_price_types();
473
+		$this->insert_default_prices();
474
+		$this->insert_default_tickets();
475
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
476
+		EE_Config::instance()->update_espresso_config(false, true);
477
+		return true;
478
+	}
479
+
480
+
481
+
482
+	/**
483
+	 * Yes we could have cleaned up the ee3 tables here. But just in case someone
484
+	 * didn't backup their DB, and decides they want ot keep using EE3, we'll
485
+	 * leave them for now. Mayeb remove them in 4.5 or something.
486
+	 *
487
+	 * @return boolean
488
+	 */
489
+	public function schema_changes_after_migration()
490
+	{
491
+		return true;
492
+	}
493
+
494
+
495
+
496
+	/**
497
+	 * insert_default_states
498
+	 *
499
+	 * @access public
500
+	 * @static
501
+	 * @return void
502
+	 */
503
+	public function insert_default_states()
504
+	{
505
+		global $wpdb;
506
+		$state_table = $wpdb->prefix . "esp_state";
507
+		if ($this->_get_table_analysis()->tableExists($state_table)) {
508
+			$SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
509
+			$states = $wpdb->get_var($SQL);
510
+			if (! $states) {
511
+				$SQL = "INSERT INTO " . $state_table . "
512 512
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
513 513
 				(1, 'US', 'AK', 'Alaska', 1),
514 514
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -582,29 +582,29 @@  discard block
 block discarded – undo
582 582
 				(70, 'CA', 'NT', 'Northwest Territories', 1),
583 583
 				(71, 'CA', 'NU', 'Nunavut', 1),
584 584
 				(72, 'CA', 'YT', 'Yukon', 1);";
585
-                $wpdb->query($SQL);
586
-            }
587
-        }
588
-    }
589
-
590
-
591
-
592
-    /**
593
-     * insert_default_countries
594
-     *
595
-     * @access public
596
-     * @static
597
-     * @return void
598
-     */
599
-    public function insert_default_countries()
600
-    {
601
-        global $wpdb;
602
-        $country_table = $wpdb->prefix . "esp_country";
603
-        if ($this->_get_table_analysis()->tableExists($country_table)) {
604
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
605
-            $countries = $wpdb->get_var($SQL);
606
-            if (! $countries) {
607
-                $SQL = "INSERT INTO " . $country_table . "
585
+				$wpdb->query($SQL);
586
+			}
587
+		}
588
+	}
589
+
590
+
591
+
592
+	/**
593
+	 * insert_default_countries
594
+	 *
595
+	 * @access public
596
+	 * @static
597
+	 * @return void
598
+	 */
599
+	public function insert_default_countries()
600
+	{
601
+		global $wpdb;
602
+		$country_table = $wpdb->prefix . "esp_country";
603
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
604
+			$SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
605
+			$countries = $wpdb->get_var($SQL);
606
+			if (! $countries) {
607
+				$SQL = "INSERT INTO " . $country_table . "
608 608
 				(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
609 609
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
610 610
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -832,984 +832,984 @@  discard block
 block discarded – undo
832 832
 				('ZA', 'ZAF', 0, 'South Africa', 'ZAR', 'Rand', 'Rands', 'R', 1, 2, '+27', 0, 0),
833 833
 				('ZM', 'ZMB', 0, 'Zambia', 'ZMK', 'Kwacha', 'Kwachas', '', 1, 2, '+260', 0, 0),
834 834
 				('ZW', 'ZWE', 0, 'Zimbabwe', 'ZWD', 'Dollar', 'Dollars', 'Z$', 1, 2, '+263', 0, 0);";
835
-                $wpdb->query($SQL);
836
-            }
837
-        }
838
-    }
839
-
840
-
841
-
842
-    /**
843
-     * insert_default_price_types
844
-     *
845
-     * @access public
846
-     * @static
847
-     * @return void
848
-     */
849
-    public function insert_default_price_types()
850
-    {
851
-        global $wpdb;
852
-        $price_type_table = $wpdb->prefix . "esp_price_type";
853
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
854
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
855
-            $price_types_exist = $wpdb->get_var($SQL);
856
-            if (! $price_types_exist) {
857
-                $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
835
+				$wpdb->query($SQL);
836
+			}
837
+		}
838
+	}
839
+
840
+
841
+
842
+	/**
843
+	 * insert_default_price_types
844
+	 *
845
+	 * @access public
846
+	 * @static
847
+	 * @return void
848
+	 */
849
+	public function insert_default_price_types()
850
+	{
851
+		global $wpdb;
852
+		$price_type_table = $wpdb->prefix . "esp_price_type";
853
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
854
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
855
+			$price_types_exist = $wpdb->get_var($SQL);
856
+			if (! $price_types_exist) {
857
+				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
858 858
 							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
859 859
 							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
860 860
 							(3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
861 861
 							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
862 862
 							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
863
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
864
-                $wpdb->query($SQL);
865
-            }
866
-        }
867
-    }
868
-
869
-
870
-
871
-    /**
872
-     * insert_default_prices. We assume we're upgrading to regular here.
873
-     * If we're INSTALLING 4.1 CAF, then we add a few extra default prices
874
-     * when EEH_Activaion's initialize_db_content is called via  ahook in
875
-     * EE_BRewing_regular
876
-     *
877
-     * @access public
878
-     * @static
879
-     * @return void
880
-     */
881
-    public function insert_default_prices()
882
-    {
883
-        global $wpdb;
884
-        $price_table = $wpdb->prefix . "esp_price";
885
-        if ($this->_get_table_analysis()->tableExists($price_table)) {
886
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
887
-            $prices_exist = $wpdb->get_var($SQL);
888
-            if (! $prices_exist) {
889
-                $SQL = "INSERT INTO $price_table
863
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
864
+				$wpdb->query($SQL);
865
+			}
866
+		}
867
+	}
868
+
869
+
870
+
871
+	/**
872
+	 * insert_default_prices. We assume we're upgrading to regular here.
873
+	 * If we're INSTALLING 4.1 CAF, then we add a few extra default prices
874
+	 * when EEH_Activaion's initialize_db_content is called via  ahook in
875
+	 * EE_BRewing_regular
876
+	 *
877
+	 * @access public
878
+	 * @static
879
+	 * @return void
880
+	 */
881
+	public function insert_default_prices()
882
+	{
883
+		global $wpdb;
884
+		$price_table = $wpdb->prefix . "esp_price";
885
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
886
+			$SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
887
+			$prices_exist = $wpdb->get_var($SQL);
888
+			if (! $prices_exist) {
889
+				$SQL = "INSERT INTO $price_table
890 890
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
891 891
 							(1, 1, '0.00', 'Free Admission', '', 1, null, 0, 0, 0);";
892
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
893
-                $wpdb->query($SQL);
894
-            }
895
-        }
896
-    }
897
-
898
-
899
-
900
-    /**
901
-     * insert default ticket
902
-     *
903
-     * @access public
904
-     * @static
905
-     * @return void
906
-     */
907
-    public function insert_default_tickets()
908
-    {
909
-        global $wpdb;
910
-        $ticket_table = $wpdb->prefix . "esp_ticket";
911
-        if ($this->_get_table_analysis()->tableExists($ticket_table)) {
912
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
913
-            $tickets_exist = $wpdb->get_var($SQL);
914
-            if (! $tickets_exist) {
915
-                $SQL = "INSERT INTO $ticket_table
892
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
893
+				$wpdb->query($SQL);
894
+			}
895
+		}
896
+	}
897
+
898
+
899
+
900
+	/**
901
+	 * insert default ticket
902
+	 *
903
+	 * @access public
904
+	 * @static
905
+	 * @return void
906
+	 */
907
+	public function insert_default_tickets()
908
+	{
909
+		global $wpdb;
910
+		$ticket_table = $wpdb->prefix . "esp_ticket";
911
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
912
+			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
913
+			$tickets_exist = $wpdb->get_var($SQL);
914
+			if (! $tickets_exist) {
915
+				$SQL = "INSERT INTO $ticket_table
916 916
 					( 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
917 917
 					( 1, 0, '"
918
-                       . esc_html__("Free Ticket", "event_espresso")
919
-                       . "', '', 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);";
920
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
921
-                $wpdb->query($SQL);
922
-            }
923
-        }
924
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
925
-        if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
926
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
927
-            $ticket_prc_exist = $wpdb->get_var($SQL);
928
-            if (! $ticket_prc_exist) {
929
-                $SQL = "INSERT INTO $ticket_price_table
918
+					   . esc_html__("Free Ticket", "event_espresso")
919
+					   . "', '', 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);";
920
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
921
+				$wpdb->query($SQL);
922
+			}
923
+		}
924
+		$ticket_price_table = $wpdb->prefix . "esp_ticket_price";
925
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
926
+			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
927
+			$ticket_prc_exist = $wpdb->get_var($SQL);
928
+			if (! $ticket_prc_exist) {
929
+				$SQL = "INSERT INTO $ticket_price_table
930 930
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
931 931
 				( 1, 1, 1 )
932 932
 				";
933
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
934
-                $wpdb->query($SQL);
935
-            }
936
-        }
937
-    }
938
-
939
-
940
-
941
-    /**
942
-     * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
943
-     * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
944
-     * country ID (int), a 2-letter ISO, 3-letter ISO, or name
945
-     *
946
-     * @global type  $wpdb
947
-     * @param string $country_name
948
-     * @return array where keys are columns, values are column values
949
-     */
950
-    public function get_or_create_country($country_name)
951
-    {
952
-        if (! $country_name) {
953
-            throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
954
-        }
955
-        global $wpdb;
956
-        $country_table = $wpdb->prefix . "esp_country";
957
-        if (is_int($country_name)) {
958
-            $country_name = $this->get_iso_from_3_1_country_id($country_name);
959
-        }
960
-        $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
933
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
934
+				$wpdb->query($SQL);
935
+			}
936
+		}
937
+	}
938
+
939
+
940
+
941
+	/**
942
+	 * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
943
+	 * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
944
+	 * country ID (int), a 2-letter ISO, 3-letter ISO, or name
945
+	 *
946
+	 * @global type  $wpdb
947
+	 * @param string $country_name
948
+	 * @return array where keys are columns, values are column values
949
+	 */
950
+	public function get_or_create_country($country_name)
951
+	{
952
+		if (! $country_name) {
953
+			throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
954
+		}
955
+		global $wpdb;
956
+		$country_table = $wpdb->prefix . "esp_country";
957
+		if (is_int($country_name)) {
958
+			$country_name = $this->get_iso_from_3_1_country_id($country_name);
959
+		}
960
+		$country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
961 961
 			CNT_ISO LIKE %s OR
962 962
 			CNT_ISO3 LIKE %s OR
963 963
 			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
964
-        if (! $country) {
965
-            // insert a new one then
966
-            $cols_n_values = array(
967
-                    'CNT_ISO'         => $this->_find_available_country_iso(2),
968
-                    'CNT_ISO3'        => $this->_find_available_country_iso(3),
969
-                    'RGN_ID'          => 0,
970
-                    'CNT_name'        => $country_name,
971
-                    'CNT_cur_code'    => 'USD',
972
-                    'CNT_cur_single'  => 'Dollar',
973
-                    'CNT_cur_plural'  => 'Dollars',
974
-                    'CNT_cur_sign'    => '&#36;',
975
-                    'CNT_cur_sign_b4' => true,
976
-                    'CNT_cur_dec_plc' => 2,
977
-                    'CNT_cur_dec_mrk' => '.',
978
-                    'CNT_cur_thsnds'  => ',',
979
-                    'CNT_tel_code'    => '+1',
980
-                    'CNT_is_EU'       => false,
981
-                    'CNT_active'      => true,
982
-            );
983
-            $data_types = array(
984
-                    '%s',// CNT_ISO
985
-                    '%s',// CNT_ISO3
986
-                    '%d',// RGN_ID
987
-                    '%s',// CNT_name
988
-                    '%s',// CNT_cur_code
989
-                    '%s',// CNT_cur_single
990
-                    '%s',// CNT_cur_plural
991
-                    '%s',// CNT_cur_sign
992
-                    '%d',// CNT_cur_sign_b4
993
-                    '%d',// CNT_cur_dec_plc
994
-                    '%s',// CNT_cur_dec_mrk
995
-                    '%s',// CNT_cur_thsnds
996
-                    '%s',// CNT_tel_code
997
-                    '%d',// CNT_is_EU
998
-                    '%d',// CNT_active
999
-            );
1000
-            $success = $wpdb->insert(
1001
-                $country_table,
1002
-                $cols_n_values,
1003
-                $data_types
1004
-            );
1005
-            if (! $success) {
1006
-                throw new EE_Error($this->_create_error_message_for_db_insertion(
1007
-                    'N/A',
1008
-                    array('country_id' => $country_name),
1009
-                    $country_table,
1010
-                    $cols_n_values,
1011
-                    $data_types
1012
-                ));
1013
-            }
1014
-            $country = $cols_n_values;
1015
-        }
1016
-        return $country;
1017
-    }
1018
-
1019
-
1020
-
1021
-    /**
1022
-     * finds a country iso which hasnt been used yet
1023
-     *
1024
-     * @global type $wpdb
1025
-     * @return string
1026
-     */
1027
-    private function _find_available_country_iso($num_letters = 2)
1028
-    {
1029
-        global $wpdb;
1030
-        $country_table = $wpdb->prefix . "esp_country";
1031
-        $attempts = 0;
1032
-        do {
1033
-            $current_iso = strtoupper(wp_generate_password($num_letters, false));
1034
-            $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1035
-                                                                   . $country_table
1036
-                                                                   . " WHERE CNT_ISO=%s", $current_iso));
1037
-            $attempts++;
1038
-            // keep going until we find an available country code, or we arbitrarily
1039
-            // decide we've tried this enough. Somehow they have way too many countries
1040
-            // (probably because they're mis-using the EE3 country_id like a custom question)
1041
-        } while (intval($country_with_that_iso) && $attempts < 200);
1042
-        return $current_iso;
1043
-    }
1044
-
1045
-
1046
-
1047
-    /**
1048
-     * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1049
-     * is independent of outside code which can change in future versions of EE
1050
-     *
1051
-     * @global type  $wpdb
1052
-     * @param string $state_name
1053
-     * @return array where keys are columns, values are column values
1054
-     */
1055
-    public function get_or_create_state($state_name, $country_name = '')
1056
-    {
1057
-        if (! $state_name) {
1058
-            throw new EE_Error(esc_html__(
1059
-                "Could not get-or-create state because no state name was provided",
1060
-                "event_espresso"
1061
-            ));
1062
-        }
1063
-        try {
1064
-            $country = $this->get_or_create_country($country_name);
1065
-            $country_iso = $country['CNT_ISO'];
1066
-        } catch (EE_Error $e) {
1067
-            $country_iso = $this->get_default_country_iso();
1068
-        }
1069
-        global $wpdb;
1070
-        $state_table = $wpdb->prefix . "esp_state";
1071
-        $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
964
+		if (! $country) {
965
+			// insert a new one then
966
+			$cols_n_values = array(
967
+					'CNT_ISO'         => $this->_find_available_country_iso(2),
968
+					'CNT_ISO3'        => $this->_find_available_country_iso(3),
969
+					'RGN_ID'          => 0,
970
+					'CNT_name'        => $country_name,
971
+					'CNT_cur_code'    => 'USD',
972
+					'CNT_cur_single'  => 'Dollar',
973
+					'CNT_cur_plural'  => 'Dollars',
974
+					'CNT_cur_sign'    => '&#36;',
975
+					'CNT_cur_sign_b4' => true,
976
+					'CNT_cur_dec_plc' => 2,
977
+					'CNT_cur_dec_mrk' => '.',
978
+					'CNT_cur_thsnds'  => ',',
979
+					'CNT_tel_code'    => '+1',
980
+					'CNT_is_EU'       => false,
981
+					'CNT_active'      => true,
982
+			);
983
+			$data_types = array(
984
+					'%s',// CNT_ISO
985
+					'%s',// CNT_ISO3
986
+					'%d',// RGN_ID
987
+					'%s',// CNT_name
988
+					'%s',// CNT_cur_code
989
+					'%s',// CNT_cur_single
990
+					'%s',// CNT_cur_plural
991
+					'%s',// CNT_cur_sign
992
+					'%d',// CNT_cur_sign_b4
993
+					'%d',// CNT_cur_dec_plc
994
+					'%s',// CNT_cur_dec_mrk
995
+					'%s',// CNT_cur_thsnds
996
+					'%s',// CNT_tel_code
997
+					'%d',// CNT_is_EU
998
+					'%d',// CNT_active
999
+			);
1000
+			$success = $wpdb->insert(
1001
+				$country_table,
1002
+				$cols_n_values,
1003
+				$data_types
1004
+			);
1005
+			if (! $success) {
1006
+				throw new EE_Error($this->_create_error_message_for_db_insertion(
1007
+					'N/A',
1008
+					array('country_id' => $country_name),
1009
+					$country_table,
1010
+					$cols_n_values,
1011
+					$data_types
1012
+				));
1013
+			}
1014
+			$country = $cols_n_values;
1015
+		}
1016
+		return $country;
1017
+	}
1018
+
1019
+
1020
+
1021
+	/**
1022
+	 * finds a country iso which hasnt been used yet
1023
+	 *
1024
+	 * @global type $wpdb
1025
+	 * @return string
1026
+	 */
1027
+	private function _find_available_country_iso($num_letters = 2)
1028
+	{
1029
+		global $wpdb;
1030
+		$country_table = $wpdb->prefix . "esp_country";
1031
+		$attempts = 0;
1032
+		do {
1033
+			$current_iso = strtoupper(wp_generate_password($num_letters, false));
1034
+			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1035
+																   . $country_table
1036
+																   . " WHERE CNT_ISO=%s", $current_iso));
1037
+			$attempts++;
1038
+			// keep going until we find an available country code, or we arbitrarily
1039
+			// decide we've tried this enough. Somehow they have way too many countries
1040
+			// (probably because they're mis-using the EE3 country_id like a custom question)
1041
+		} while (intval($country_with_that_iso) && $attempts < 200);
1042
+		return $current_iso;
1043
+	}
1044
+
1045
+
1046
+
1047
+	/**
1048
+	 * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1049
+	 * is independent of outside code which can change in future versions of EE
1050
+	 *
1051
+	 * @global type  $wpdb
1052
+	 * @param string $state_name
1053
+	 * @return array where keys are columns, values are column values
1054
+	 */
1055
+	public function get_or_create_state($state_name, $country_name = '')
1056
+	{
1057
+		if (! $state_name) {
1058
+			throw new EE_Error(esc_html__(
1059
+				"Could not get-or-create state because no state name was provided",
1060
+				"event_espresso"
1061
+			));
1062
+		}
1063
+		try {
1064
+			$country = $this->get_or_create_country($country_name);
1065
+			$country_iso = $country['CNT_ISO'];
1066
+		} catch (EE_Error $e) {
1067
+			$country_iso = $this->get_default_country_iso();
1068
+		}
1069
+		global $wpdb;
1070
+		$state_table = $wpdb->prefix . "esp_state";
1071
+		$state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1072 1072
 			(STA_abbrev LIKE %s OR
1073 1073
 			STA_name LIKE %s) AND
1074 1074
 			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1075
-        if (! $state) {
1076
-            // insert a new one then
1077
-            $cols_n_values = array(
1078
-                    'CNT_ISO'    => $country_iso,
1079
-                    'STA_abbrev' => substr($state_name, 0, 6),
1080
-                    'STA_name'   => $state_name,
1081
-                    'STA_active' => true,
1082
-            );
1083
-            $data_types = array(
1084
-                    '%s',// CNT_ISO
1085
-                    '%s',// STA_abbrev
1086
-                    '%s',// STA_name
1087
-                    '%d',// STA_active
1088
-            );
1089
-            $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1090
-            if (! $success) {
1091
-                throw new EE_Error($this->_create_error_message_for_db_insertion(
1092
-                    'N/A',
1093
-                    array('state' => $state_name, 'country_id' => $country_name),
1094
-                    $state_table,
1095
-                    $cols_n_values,
1096
-                    $data_types
1097
-                ));
1098
-            }
1099
-            $state = $cols_n_values;
1100
-            $state['STA_ID'] = $wpdb->insert_id;
1101
-        }
1102
-        return $state;
1103
-    }
1104
-
1105
-
1106
-
1107
-    /**
1108
-     * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1109
-     * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1110
-     *
1111
-     * @param type $timeString
1112
-     * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1113
-     *                with leading zeros)
1114
-     */
1115
-    public function convertTimeFromAMPM($timeString)
1116
-    {
1117
-        $matches = array();
1118
-        preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1119
-        if (! $matches || count($matches) < 3) {
1120
-            $hour = '00';
1121
-            $minutes = '00';
1122
-        } else {
1123
-            $hour = intval($matches[1]);
1124
-            $minutes = $matches[2];
1125
-        }
1126
-        if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1127
-            $hour = intval($hour) + 12;
1128
-        }
1129
-        $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1130
-        $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1131
-        return "$hour:$minutes";
1132
-    }
1133
-
1134
-
1135
-
1136
-    /**
1137
-     * Gets the ISO3 fora country given its 3.1 country ID.
1138
-     *
1139
-     * @param int $country_id
1140
-     * @return string the country's ISO3 code
1141
-     */
1142
-    public function get_iso_from_3_1_country_id($country_id)
1143
-    {
1144
-        $old_countries = array(
1145
-                array(64, 'United States', 'US', 'USA', 1),
1146
-                array(15, 'Australia', 'AU', 'AUS', 1),
1147
-                array(39, 'Canada', 'CA', 'CAN', 1),
1148
-                array(171, 'United Kingdom', 'GB', 'GBR', 1),
1149
-                array(70, 'France', 'FR', 'FRA', 2),
1150
-                array(111, 'Italy', 'IT', 'ITA', 2),
1151
-                array(63, 'Spain', 'ES', 'ESP', 2),
1152
-                array(1, 'Afghanistan', 'AF', 'AFG', 1),
1153
-                array(2, 'Albania', 'AL', 'ALB', 1),
1154
-                array(3, 'Germany', 'DE', 'DEU', 2),
1155
-                array(198, 'Switzerland', 'CH', 'CHE', 1),
1156
-                array(87, 'Netherlands', 'NL', 'NLD', 2),
1157
-                array(197, 'Sweden', 'SE', 'SWE', 1),
1158
-                array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1159
-                array(4, 'Andorra', 'AD', 'AND', 2),
1160
-                array(5, 'Angola', 'AO', 'AGO', 1),
1161
-                array(6, 'Anguilla', 'AI', 'AIA', 1),
1162
-                array(7, 'Antarctica', 'AQ', 'ATA', 1),
1163
-                array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1164
-                array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1165
-                array(11, 'Algeria', 'DZ', 'DZA', 1),
1166
-                array(12, 'Argentina', 'AR', 'ARG', 1),
1167
-                array(13, 'Armenia', 'AM', 'ARM', 1),
1168
-                array(14, 'Aruba', 'AW', 'ABW', 1),
1169
-                array(16, 'Austria', 'AT', 'AUT', 2),
1170
-                array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1171
-                array(18, 'Bahamas', 'BS', 'BHS', 1),
1172
-                array(19, 'Bahrain', 'BH', 'BHR', 1),
1173
-                array(20, 'Bangladesh', 'BD', 'BGD', 1),
1174
-                array(21, 'Barbados', 'BB', 'BRB', 1),
1175
-                array(22, 'Belgium ', 'BE', 'BEL', 2),
1176
-                array(23, 'Belize', 'BZ', 'BLZ', 1),
1177
-                array(24, 'Benin', 'BJ', 'BEN', 1),
1178
-                array(25, 'Bermudas', 'BM', 'BMU', 1),
1179
-                array(26, 'Belarus', 'BY', 'BLR', 1),
1180
-                array(27, 'Bolivia', 'BO', 'BOL', 1),
1181
-                array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1182
-                array(29, 'Botswana', 'BW', 'BWA', 1),
1183
-                array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1184
-                array(30, 'Brazil', 'BR', 'BRA', 1),
1185
-                array(31, 'Brunei', 'BN', 'BRN', 1),
1186
-                array(32, 'Bulgaria', 'BG', 'BGR', 1),
1187
-                array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1188
-                array(34, 'Burundi', 'BI', 'BDI', 1),
1189
-                array(35, 'Bhutan', 'BT', 'BTN', 1),
1190
-                array(36, 'Cape Verde', 'CV', 'CPV', 1),
1191
-                array(37, 'Cambodia', 'KH', 'KHM', 1),
1192
-                array(38, 'Cameroon', 'CM', 'CMR', 1),
1193
-                array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1194
-                array(172, 'Central African Republic', 'CF', 'CAF', 1),
1195
-                array(40, 'Chad', 'TD', 'TCD', 1),
1196
-                array(41, 'Chile', 'CL', 'CHL', 1),
1197
-                array(42, 'China', 'CN', 'CHN', 1),
1198
-                array(105, 'Christmas Island', 'CX', 'CXR', 1),
1199
-                array(43, 'Cyprus', 'CY', 'CYP', 2),
1200
-                array(99, 'Cocos Island', 'CC', 'CCK', 1),
1201
-                array(100, 'Cook Islands', 'CK', 'COK', 1),
1202
-                array(44, 'Colombia', 'CO', 'COL', 1),
1203
-                array(45, 'Comoros', 'KM', 'COM', 1),
1204
-                array(46, 'Congo', 'CG', 'COG', 1),
1205
-                array(47, 'North Korea', 'KP', 'PRK', 1),
1206
-                array(50, 'Costa Rica', 'CR', 'CRI', 1),
1207
-                array(51, 'Croatia', 'HR', 'HRV', 1),
1208
-                array(52, 'Cuba', 'CU', 'CUB', 1),
1209
-                array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1210
-                array(53, 'Denmark', 'DK', 'DNK', 1),
1211
-                array(54, 'Djibouti', 'DJ', 'DJI', 1),
1212
-                array(55, 'Dominica', 'DM', 'DMA', 1),
1213
-                array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1214
-                array(56, 'Ecuador', 'EC', 'ECU', 1),
1215
-                array(57, 'Egypt', 'EG', 'EGY', 1),
1216
-                array(58, 'El Salvador', 'SV', 'SLV', 1),
1217
-                array(60, 'Eritrea', 'ER', 'ERI', 1),
1218
-                array(61, 'Slovakia', 'SK', 'SVK', 2),
1219
-                array(62, 'Slovenia', 'SI', 'SVN', 2),
1220
-                array(65, 'Estonia', 'EE', 'EST', 2),
1221
-                array(66, 'Ethiopia', 'ET', 'ETH', 1),
1222
-                array(102, 'Faroe islands', 'FO', 'FRO', 1),
1223
-                array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1224
-                array(67, 'Fiji', 'FJ', 'FJI', 1),
1225
-                array(69, 'Finland', 'FI', 'FIN', 2),
1226
-                array(71, 'Gabon', 'GA', 'GAB', 1),
1227
-                array(72, 'Gambia', 'GM', 'GMB', 1),
1228
-                array(73, 'Georgia', 'GE', 'GEO', 1),
1229
-                array(74, 'Ghana', 'GH', 'GHA', 1),
1230
-                array(75, 'Gibraltar', 'GI', 'GIB', 1),
1231
-                array(76, 'Greece', 'GR', 'GRC', 2),
1232
-                array(77, 'Grenada', 'GD', 'GRD', 1),
1233
-                array(78, 'Greenland', 'GL', 'GRL', 1),
1234
-                array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1235
-                array(80, 'Guam', 'GU', 'GUM', 1),
1236
-                array(81, 'Guatemala', 'GT', 'GTM', 1),
1237
-                array(82, 'Guinea', 'GN', 'GIN', 1),
1238
-                array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1239
-                array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1240
-                array(85, 'Guyana', 'GY', 'GUY', 1),
1241
-                array(86, 'Haiti', 'HT', 'HTI', 1),
1242
-                array(88, 'Honduras', 'HN', 'HND', 1),
1243
-                array(89, 'Hong Kong', 'HK', 'HKG', 1),
1244
-                array(90, 'Hungary', 'HU', 'HUN', 1),
1245
-                array(91, 'India', 'IN', 'IND', 1),
1246
-                array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1247
-                array(92, 'Indonesia', 'ID', 'IDN', 1),
1248
-                array(93, 'Iraq', 'IQ', 'IRQ', 1),
1249
-                array(94, 'Iran', 'IR', 'IRN', 1),
1250
-                array(95, 'Ireland', 'IE', 'IRL', 2),
1251
-                array(97, 'Iceland', 'IS', 'ISL', 1),
1252
-                array(110, 'Israel', 'IL', 'ISR', 1),
1253
-                array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1254
-                array(112, 'Jamaica', 'JM', 'JAM', 1),
1255
-                array(113, 'Japan', 'JP', 'JPN', 1),
1256
-                array(114, 'Jordan', 'JO', 'JOR', 1),
1257
-                array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1258
-                array(116, 'Kenya', 'KE', 'KEN', 1),
1259
-                array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1260
-                array(118, 'Kiribati', 'KI', 'KIR', 1),
1261
-                array(48, 'South Korea', 'KR', 'KOR', 1),
1262
-                array(228, 'Kosovo', 'XK', 'XKV', 2),
1263
-                // 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
1264
-                array(119, 'Kuwait', 'KW', 'KWT', 1),
1265
-                array(120, 'Laos', 'LA', 'LAO', 1),
1266
-                array(121, 'Latvia', 'LV', 'LVA', 2),
1267
-                array(122, 'Lesotho', 'LS', 'LSO', 1),
1268
-                array(123, 'Lebanon', 'LB', 'LBN', 1),
1269
-                array(124, 'Liberia', 'LR', 'LBR', 1),
1270
-                array(125, 'Libya', 'LY', 'LBY', 1),
1271
-                array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1272
-                array(127, 'Lithuania', 'LT', 'LTU', 2),
1273
-                array(128, 'Luxemburg', 'LU', 'LUX', 2),
1274
-                array(129, 'Macao', 'MO', 'MAC', 1),
1275
-                array(130, 'Macedonia', 'MK', 'MKD', 1),
1276
-                array(131, 'Madagascar', 'MG', 'MDG', 1),
1277
-                array(132, 'Malaysia', 'MY', 'MYS', 1),
1278
-                array(133, 'Malawi', 'MW', 'MWI', 1),
1279
-                array(134, 'Maldivas', 'MV', 'MDV', 1),
1280
-                array(135, 'Mali', 'ML', 'MLI', 1),
1281
-                array(136, 'Malta', 'MT', 'MLT', 2),
1282
-                array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1283
-                array(137, 'Morocco', 'MA', 'MAR', 1),
1284
-                array(104, 'Marshall islands', 'MH', 'MHL', 1),
1285
-                array(138, 'Martinique', 'MQ', 'MTQ', 1),
1286
-                array(139, 'Mauritius', 'MU', 'MUS', 1),
1287
-                array(140, 'Mauritania', 'MR', 'MRT', 1),
1288
-                array(141, 'Mayote', 'YT', 'MYT', 2),
1289
-                array(142, 'Mexico', 'MX', 'MEX', 1),
1290
-                array(143, 'Micronesia', 'FM', 'FSM', 1),
1291
-                array(144, 'Moldova', 'MD', 'MDA', 1),
1292
-                array(145, 'Monaco', 'MC', 'MCO', 2),
1293
-                array(146, 'Mongolia', 'MN', 'MNG', 1),
1294
-                array(147, 'Montserrat', 'MS', 'MSR', 1),
1295
-                array(227, 'Montenegro', 'ME', 'MNE', 2),
1296
-                array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1297
-                array(149, 'Myanmar', 'MM', 'MMR', 1),
1298
-                array(150, 'Namibia', 'NA', 'NAM', 1),
1299
-                array(151, 'Nauru', 'NR', 'NRU', 1),
1300
-                array(152, 'Nepal', 'NP', 'NPL', 1),
1301
-                array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1302
-                array(153, 'Nicaragua', 'NI', 'NIC', 1),
1303
-                array(154, 'Niger', 'NE', 'NER', 1),
1304
-                array(155, 'Nigeria', 'NG', 'NGA', 1),
1305
-                array(156, 'Niue', 'NU', 'NIU', 1),
1306
-                array(157, 'Norway', 'NO', 'NOR', 1),
1307
-                array(158, 'New Caledonia', 'NC', 'NCL', 1),
1308
-                array(159, 'New Zealand', 'NZ', 'NZL', 1),
1309
-                array(160, 'Oman', 'OM', 'OMN', 1),
1310
-                array(161, 'Pakistan', 'PK', 'PAK', 1),
1311
-                array(162, 'Palau', 'PW', 'PLW', 1),
1312
-                array(163, 'Panama', 'PA', 'PAN', 1),
1313
-                array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1314
-                array(165, 'Paraguay', 'PY', 'PRY', 1),
1315
-                array(166, 'Peru', 'PE', 'PER', 1),
1316
-                array(68, 'Philippines', 'PH', 'PHL', 1),
1317
-                array(167, 'Poland', 'PL', 'POL', 1),
1318
-                array(168, 'Portugal', 'PT', 'PRT', 2),
1319
-                array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1320
-                array(170, 'Qatar', 'QA', 'QAT', 1),
1321
-                array(176, 'Rwanda', 'RW', 'RWA', 1),
1322
-                array(177, 'Romania', 'RO', 'ROM', 2),
1323
-                array(178, 'Russia', 'RU', 'RUS', 1),
1324
-                array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1325
-                array(180, 'Samoa', 'WS', 'WSM', 1),
1326
-                array(181, 'American Samoa', 'AS', 'ASM', 1),
1327
-                array(183, 'San Marino', 'SM', 'SMR', 2),
1328
-                array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1329
-                array(185, 'Saint Helena', 'SH', 'SHN', 1),
1330
-                array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1331
-                array(188, 'Senegal', 'SN', 'SEN', 1),
1332
-                array(189, 'Seychelles', 'SC', 'SYC', 1),
1333
-                array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1334
-                array(191, 'Singapore', 'SG', 'SGP', 1),
1335
-                array(192, 'Syria', 'SY', 'SYR', 1),
1336
-                array(193, 'Somalia', 'SO', 'SOM', 1),
1337
-                array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1338
-                array(195, 'South Africa', 'ZA', 'ZAF', 1),
1339
-                array(196, 'Sudan', 'SD', 'SDN', 1),
1340
-                array(199, 'Suriname', 'SR', 'SUR', 1),
1341
-                array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1342
-                array(201, 'Thailand', 'TH', 'THA', 1),
1343
-                array(202, 'Taiwan', 'TW', 'TWN', 1),
1344
-                array(203, 'Tanzania', 'TZ', 'TZA', 1),
1345
-                array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1346
-                array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1347
-                array(207, 'Togo', 'TG', 'TGO', 1),
1348
-                array(208, 'Tokelau', 'TK', 'TKL', 1),
1349
-                array(209, 'Tonga', 'TO', 'TON', 1),
1350
-                array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1351
-                array(211, 'Tunisia', 'TN', 'TUN', 1),
1352
-                array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1353
-                array(213, 'Turkey', 'TR', 'TUR', 1),
1354
-                array(214, 'Tuvalu', 'TV', 'TUV', 1),
1355
-                array(215, 'Ukraine', 'UA', 'UKR', 1),
1356
-                array(216, 'Uganda', 'UG', 'UGA', 1),
1357
-                array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1358
-                array(217, 'Uruguay', 'UY', 'URY', 1),
1359
-                array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1360
-                array(219, 'Vanuatu', 'VU', 'VUT', 1),
1361
-                array(220, 'Vatican City', 'VA', 'VAT', 2),
1362
-                array(221, 'Venezuela', 'VE', 'VEN', 1),
1363
-                array(222, 'Vietnam', 'VN', 'VNM', 1),
1364
-                array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1365
-                array(223, 'Yemen', 'YE', 'YEM', 1),
1366
-                array(225, 'Zambia', 'ZM', 'ZMB', 1),
1367
-                array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1368
-        );
1369
-        $country_iso = 'US';
1370
-        foreach ($old_countries as $country_array) {
1371
-            // note: index 0 is the 3.1 country ID
1372
-            if ($country_array[0] == $country_id) {
1373
-                // note: index 2 is the ISO
1374
-                $country_iso = $country_array[2];
1375
-                break;
1376
-            }
1377
-        }
1378
-        return $country_iso;
1379
-    }
1380
-
1381
-
1382
-
1383
-    /**
1384
-     * Gets the ISO3 for the
1385
-     *
1386
-     * @return string
1387
-     */
1388
-    public function get_default_country_iso()
1389
-    {
1390
-        $old_org_options = get_option('events_organization_settings');
1391
-        $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1392
-        return $iso;
1393
-    }
1394
-
1395
-
1396
-
1397
-    /**
1398
-     * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1399
-     *
1400
-     * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1401
-     * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1402
-     *                                                  default payment status, the event's default payment status, or
1403
-     *                                                  the attendee's payment status) required pre-approval.
1404
-     * @return string STS_ID for use in 4.1
1405
-     */
1406
-    public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1407
-    {
1408
-        // EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1409
-        if ($this_thing_required_pre_approval) {
1410
-            return 'RNA';
1411
-        } else {
1412
-            $mapping = $default_reg_stati_conversions = array(
1413
-                    'Completed'        => 'RAP',
1414
-                    ''                 => 'RPP',
1415
-                    'Incomplete'       => 'RPP',
1416
-                    'Pending'          => 'RAP',
1417
-                    // stati that only occurred on 3.1 attendees:
1418
-                    'Payment Declined' => 'RPP',
1419
-                    'Not Completed'    => 'RPP',
1420
-                    'Cancelled'        => 'RPP',
1421
-                    'Declined'         => 'RPP',
1422
-            );
1423
-        }
1424
-        return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1425
-    }
1426
-
1427
-
1428
-
1429
-    /**
1430
-     * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1431
-     * and sets it as the featured image on the CPT event
1432
-     *
1433
-     * @param type                            $old_event
1434
-     * @param type                            $new_cpt_id
1435
-     * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1436
-     * @return boolean whether or not we had to do the big job of creating an image attachment
1437
-     */
1438
-    public function convert_image_url_to_attachment_and_attach_to_post(
1439
-        $guid,
1440
-        $new_cpt_id,
1441
-        EE_Data_Migration_Script_Stage $migration_stage
1442
-    ) {
1443
-        $created_attachment_post = false;
1444
-        $guid = $this->_get_original_guid($guid);
1445
-        if ($guid) {
1446
-            // check for an existing attachment post with this guid
1447
-            $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1448
-            if (! $attachment_post_id) {
1449
-                // post thumbnail with that GUID doesn't exist, we should create one
1450
-                $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1451
-                $created_attachment_post = true;
1452
-            }
1453
-            // double-check we actually have an attachment post
1454
-            if ($attachment_post_id) {
1455
-                update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1456
-            } else {
1457
-                $migration_stage->add_error(sprintf(esc_html__(
1458
-                    "Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1459
-                    "event_espresso"
1460
-                ), $guid, $new_cpt_id, $attachment_post_id));
1461
-            }
1462
-        }
1463
-        return $created_attachment_post;
1464
-    }
1465
-
1466
-
1467
-
1468
-    /**
1469
-     * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1470
-     * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1471
-     * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1472
-     * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1473
-     * exists
1474
-     *
1475
-     * @param string $guid_in_old_event
1476
-     * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1477
-     */
1478
-    private function _get_original_guid($guid_in_old_event)
1479
-    {
1480
-        $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1481
-        // do a head request to verify the file exists
1482
-        $head_response = wp_remote_head($original_guid);
1483
-        if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1484
-            return $original_guid;
1485
-        } else {
1486
-            return $guid_in_old_event;
1487
-        }
1488
-    }
1489
-
1490
-
1491
-
1492
-    /**
1493
-     * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1494
-     * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1495
-     * thumbnails)
1496
-     *
1497
-     * @param type                           $guid
1498
-     * @param EE_Data_Migration_Script_Stage $migration_stage
1499
-     * @return int
1500
-     */
1501
-    private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1502
-    {
1503
-        if (! $guid) {
1504
-            $migration_stage->add_error(sprintf(esc_html__(
1505
-                "Cannot create image attachment for a blank GUID!",
1506
-                "event_espresso"
1507
-            )));
1508
-            return 0;
1509
-        }
1510
-        $wp_filetype = wp_check_filetype(basename($guid), null);
1511
-        $wp_upload_dir = wp_upload_dir();
1512
-        // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1513
-        if (strpos($guid, $wp_upload_dir['url']) === false) {
1514
-            // image is located remotely. download it and place it in the uploads directory
1515
-            if (! is_readable($guid)) {
1516
-                $migration_stage->add_error(sprintf(esc_html__(
1517
-                    "Could not create image attachment from non-existent file: %s",
1518
-                    "event_espresso"
1519
-                ), $guid));
1520
-                return 0;
1521
-            }
1522
-            $contents = file_get_contents($guid);
1523
-            if ($contents === false) {
1524
-                $migration_stage->add_error(sprintf(esc_html__(
1525
-                    "Could not read image at %s, and therefore couldnt create an attachment post for it.",
1526
-                    "event_espresso"
1527
-                ), $guid));
1528
-                return false;
1529
-            }
1530
-            $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1531
-            $savefile = fopen($local_filepath, 'w');
1532
-            fwrite($savefile, $contents);
1533
-            fclose($savefile);
1534
-            $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1535
-        } else {
1536
-            $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1537
-        }
1538
-        $attachment = array(
1539
-                'guid'           => $guid,
1540
-                'post_mime_type' => $wp_filetype['type'],
1541
-                'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1542
-                'post_content'   => '',
1543
-                'post_status'    => 'inherit',
1544
-        );
1545
-        $attach_id = wp_insert_attachment($attachment, $guid);
1546
-        if (! $attach_id) {
1547
-            $migration_stage->add_error(sprintf(esc_html__(
1548
-                "Could not create image attachment post from image '%s'. Attachment data was %s.",
1549
-                "event_espresso"
1550
-            ), $guid, $this->_json_encode($attachment)));
1551
-            return $attach_id;
1552
-        }
1553
-        // you must first include the image.php file
1554
-        // for the function wp_generate_attachment_metadata() to work
1555
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1556
-        $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1557
-        if (! $attach_data) {
1558
-            $migration_stage->add_error(sprintf(esc_html__(
1559
-                "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1560
-                "event_espresso"
1561
-            ), $attach_id, $local_filepath, $guid));
1562
-            return $attach_id;
1563
-        }
1564
-        $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1565
-        if (! $metadata_save_result) {
1566
-            $migration_stage->add_error(sprintf(esc_html__(
1567
-                "Could not update attachment metadata for attachment %d with data %s",
1568
-                "event_espresso"
1569
-            ), $attach_id, $this->_json_encode($attach_data)));
1570
-        }
1571
-        return $attach_id;
1572
-    }
1573
-
1574
-
1575
-
1576
-    /**
1577
-     * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1578
-     * and returns its ID.
1579
-     *
1580
-     * @global type  $wpdb
1581
-     * @param string $guid
1582
-     * @return int
1583
-     */
1584
-    private function _get_image_attachment_id_by_GUID($guid)
1585
-    {
1586
-        global $wpdb;
1587
-        $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1588
-        return $attachment_id;
1589
-    }
1590
-
1591
-
1592
-
1593
-    /**
1594
-     * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1595
-     * (and optionally a timezone; if none is given, the wp default is used)
1596
-     *
1597
-     * @param EE_Data_Migration_Script_base $stage
1598
-     * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1599
-     *                                                   UTC time for
1600
-     * @param string                        $DATETIME_string
1601
-     * @param string                        $timezone
1602
-     * @return string
1603
-     */
1604
-    public function convert_date_string_to_utc(
1605
-        EE_Data_Migration_Script_Stage $stage,
1606
-        $row_of_data,
1607
-        $DATETIME_string,
1608
-        $timezone = null
1609
-    ) {
1610
-        $original_tz = $timezone;
1611
-        if (! $timezone) {
1612
-            $timezone = $this->_get_wp_timezone();
1613
-        }
1614
-        if (! $timezone) {
1615
-            $stage->add_error(sprintf(
1616
-                esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1617
-                $original_tz,
1618
-                $row_of_data
1619
-            ));
1620
-            $timezone = 'UTC';
1621
-        }
1622
-        try {
1623
-            $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1624
-            EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC'));
1625
-        } catch (Exception $e) {
1626
-            $stage->add_error(sprintf(esc_html__(
1627
-                "Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1628
-                "event_espresso"
1629
-            ), $DATETIME_string, $timezone));
1630
-            $date_obj = new DateTime();
1631
-        }
1632
-        return $date_obj->format('Y-m-d H:i:s');
1633
-    }
1634
-
1635
-
1636
-
1637
-    /**
1638
-     * Gets the default timezone string from wordpress (even if they set a gmt offset)
1639
-     *
1640
-     * @return string
1641
-     */
1642
-    private function _get_wp_timezone()
1643
-    {
1644
-        $timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1645
-        // if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1646
-        if (empty($timezone)) {
1647
-            // let's get a the WordPress UTC offset
1648
-            $offset = get_option('gmt_offset');
1649
-            $timezone = $this->timezone_convert_to_string_from_offset($offset);
1650
-        }
1651
-        return $timezone;
1652
-    }
1653
-
1654
-
1655
-
1656
-    /**
1657
-     * Gets the wordpress timezone string from a UTC offset
1658
-     *
1659
-     * @param int $offset
1660
-     * @return boolean
1661
-     */
1662
-    private function timezone_convert_to_string_from_offset($offset)
1663
-    {
1664
-        // 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
1665
-        $offset *= 3600; // convert hour offset to seconds
1666
-        $abbrarray = timezone_abbreviations_list();
1667
-        foreach ($abbrarray as $abbr) {
1668
-            foreach ($abbr as $city) {
1669
-                if ($city['offset'] == $offset) {
1670
-                    return $city['timezone_id'];
1671
-                }
1672
-            }
1673
-        }
1674
-        return false;
1675
-    }
1676
-
1677
-
1678
-
1679
-    public function migration_page_hooks()
1680
-    {
1681
-        add_filter(
1682
-            'FHEE__ee_migration_page__header',
1683
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1684
-            10,
1685
-            3
1686
-        );
1687
-        add_filter(
1688
-            'FHEE__ee_migration_page__p_after_header',
1689
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1690
-            10,
1691
-            2
1692
-        );
1693
-        add_filter(
1694
-            'FHEE__ee_migration_page__option_1_main',
1695
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1696
-            10,
1697
-            3
1698
-        );
1699
-        add_filter(
1700
-            'FHEE__ee_migration_page__option_1_button_text',
1701
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1702
-            10,
1703
-            3
1704
-        );
1705
-        add_action(
1706
-            'AHEE__ee_migration_page__option_1_extra_details',
1707
-            array($this, '_migration_page_hook_option_1_extra_details'),
1708
-            10,
1709
-            3
1710
-        );
1711
-        add_filter(
1712
-            'FHEE__ee_migration_page__option_2_main',
1713
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1714
-            10,
1715
-            4
1716
-        );
1717
-        add_filter(
1718
-            'FHEE__ee_migration_page__option_2_button_text',
1719
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1720
-            10,
1721
-            2
1722
-        );
1723
-        add_filter(
1724
-            'FHEE__ee_migration_page__option_2_details',
1725
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1726
-            10,
1727
-            2
1728
-        );
1729
-        add_action(
1730
-            'AHEE__ee_migration_page__after_migration_options_table',
1731
-            array($this, '_migration_page_hook_after_migration_options_table')
1732
-        );
1733
-        add_filter(
1734
-            'FHEE__ee_migration_page__done_migration_header',
1735
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1736
-            10,
1737
-            2
1738
-        );
1739
-        add_filter(
1740
-            'FHEE__ee_migration_page__p_after_done_migration_header',
1741
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1742
-            10,
1743
-            2
1744
-        );
1745
-        add_filter(
1746
-            'FHEE__ee_migration_page__migration_options_template',
1747
-            array($this,'use_migration_options_from_ee3_template')
1748
-        );
1749
-    }
1750
-
1751
-
1752
-
1753
-    public function _migrate_page_hook_simplify_version_strings(
1754
-        $old_content,
1755
-        $current_db_state,
1756
-        $next_db_state,
1757
-        $ultimate_db_state = null
1758
-    ) {
1759
-        return str_replace(
1760
-            array($current_db_state, $next_db_state, $ultimate_db_state),
1761
-            array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')),
1762
-            $old_content
1763
-        );
1764
-    }
1765
-
1766
-
1767
-
1768
-    public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1769
-    {
1770
-        return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content);
1771
-    }
1772
-
1773
-
1774
-
1775
-    public function _migration_page_hook_option_1_extra_details()
1776
-    {
1777
-        ?>
1075
+		if (! $state) {
1076
+			// insert a new one then
1077
+			$cols_n_values = array(
1078
+					'CNT_ISO'    => $country_iso,
1079
+					'STA_abbrev' => substr($state_name, 0, 6),
1080
+					'STA_name'   => $state_name,
1081
+					'STA_active' => true,
1082
+			);
1083
+			$data_types = array(
1084
+					'%s',// CNT_ISO
1085
+					'%s',// STA_abbrev
1086
+					'%s',// STA_name
1087
+					'%d',// STA_active
1088
+			);
1089
+			$success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1090
+			if (! $success) {
1091
+				throw new EE_Error($this->_create_error_message_for_db_insertion(
1092
+					'N/A',
1093
+					array('state' => $state_name, 'country_id' => $country_name),
1094
+					$state_table,
1095
+					$cols_n_values,
1096
+					$data_types
1097
+				));
1098
+			}
1099
+			$state = $cols_n_values;
1100
+			$state['STA_ID'] = $wpdb->insert_id;
1101
+		}
1102
+		return $state;
1103
+	}
1104
+
1105
+
1106
+
1107
+	/**
1108
+	 * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1109
+	 * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1110
+	 *
1111
+	 * @param type $timeString
1112
+	 * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1113
+	 *                with leading zeros)
1114
+	 */
1115
+	public function convertTimeFromAMPM($timeString)
1116
+	{
1117
+		$matches = array();
1118
+		preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1119
+		if (! $matches || count($matches) < 3) {
1120
+			$hour = '00';
1121
+			$minutes = '00';
1122
+		} else {
1123
+			$hour = intval($matches[1]);
1124
+			$minutes = $matches[2];
1125
+		}
1126
+		if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1127
+			$hour = intval($hour) + 12;
1128
+		}
1129
+		$hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1130
+		$minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1131
+		return "$hour:$minutes";
1132
+	}
1133
+
1134
+
1135
+
1136
+	/**
1137
+	 * Gets the ISO3 fora country given its 3.1 country ID.
1138
+	 *
1139
+	 * @param int $country_id
1140
+	 * @return string the country's ISO3 code
1141
+	 */
1142
+	public function get_iso_from_3_1_country_id($country_id)
1143
+	{
1144
+		$old_countries = array(
1145
+				array(64, 'United States', 'US', 'USA', 1),
1146
+				array(15, 'Australia', 'AU', 'AUS', 1),
1147
+				array(39, 'Canada', 'CA', 'CAN', 1),
1148
+				array(171, 'United Kingdom', 'GB', 'GBR', 1),
1149
+				array(70, 'France', 'FR', 'FRA', 2),
1150
+				array(111, 'Italy', 'IT', 'ITA', 2),
1151
+				array(63, 'Spain', 'ES', 'ESP', 2),
1152
+				array(1, 'Afghanistan', 'AF', 'AFG', 1),
1153
+				array(2, 'Albania', 'AL', 'ALB', 1),
1154
+				array(3, 'Germany', 'DE', 'DEU', 2),
1155
+				array(198, 'Switzerland', 'CH', 'CHE', 1),
1156
+				array(87, 'Netherlands', 'NL', 'NLD', 2),
1157
+				array(197, 'Sweden', 'SE', 'SWE', 1),
1158
+				array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1159
+				array(4, 'Andorra', 'AD', 'AND', 2),
1160
+				array(5, 'Angola', 'AO', 'AGO', 1),
1161
+				array(6, 'Anguilla', 'AI', 'AIA', 1),
1162
+				array(7, 'Antarctica', 'AQ', 'ATA', 1),
1163
+				array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1164
+				array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1165
+				array(11, 'Algeria', 'DZ', 'DZA', 1),
1166
+				array(12, 'Argentina', 'AR', 'ARG', 1),
1167
+				array(13, 'Armenia', 'AM', 'ARM', 1),
1168
+				array(14, 'Aruba', 'AW', 'ABW', 1),
1169
+				array(16, 'Austria', 'AT', 'AUT', 2),
1170
+				array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1171
+				array(18, 'Bahamas', 'BS', 'BHS', 1),
1172
+				array(19, 'Bahrain', 'BH', 'BHR', 1),
1173
+				array(20, 'Bangladesh', 'BD', 'BGD', 1),
1174
+				array(21, 'Barbados', 'BB', 'BRB', 1),
1175
+				array(22, 'Belgium ', 'BE', 'BEL', 2),
1176
+				array(23, 'Belize', 'BZ', 'BLZ', 1),
1177
+				array(24, 'Benin', 'BJ', 'BEN', 1),
1178
+				array(25, 'Bermudas', 'BM', 'BMU', 1),
1179
+				array(26, 'Belarus', 'BY', 'BLR', 1),
1180
+				array(27, 'Bolivia', 'BO', 'BOL', 1),
1181
+				array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1182
+				array(29, 'Botswana', 'BW', 'BWA', 1),
1183
+				array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1184
+				array(30, 'Brazil', 'BR', 'BRA', 1),
1185
+				array(31, 'Brunei', 'BN', 'BRN', 1),
1186
+				array(32, 'Bulgaria', 'BG', 'BGR', 1),
1187
+				array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1188
+				array(34, 'Burundi', 'BI', 'BDI', 1),
1189
+				array(35, 'Bhutan', 'BT', 'BTN', 1),
1190
+				array(36, 'Cape Verde', 'CV', 'CPV', 1),
1191
+				array(37, 'Cambodia', 'KH', 'KHM', 1),
1192
+				array(38, 'Cameroon', 'CM', 'CMR', 1),
1193
+				array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1194
+				array(172, 'Central African Republic', 'CF', 'CAF', 1),
1195
+				array(40, 'Chad', 'TD', 'TCD', 1),
1196
+				array(41, 'Chile', 'CL', 'CHL', 1),
1197
+				array(42, 'China', 'CN', 'CHN', 1),
1198
+				array(105, 'Christmas Island', 'CX', 'CXR', 1),
1199
+				array(43, 'Cyprus', 'CY', 'CYP', 2),
1200
+				array(99, 'Cocos Island', 'CC', 'CCK', 1),
1201
+				array(100, 'Cook Islands', 'CK', 'COK', 1),
1202
+				array(44, 'Colombia', 'CO', 'COL', 1),
1203
+				array(45, 'Comoros', 'KM', 'COM', 1),
1204
+				array(46, 'Congo', 'CG', 'COG', 1),
1205
+				array(47, 'North Korea', 'KP', 'PRK', 1),
1206
+				array(50, 'Costa Rica', 'CR', 'CRI', 1),
1207
+				array(51, 'Croatia', 'HR', 'HRV', 1),
1208
+				array(52, 'Cuba', 'CU', 'CUB', 1),
1209
+				array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1210
+				array(53, 'Denmark', 'DK', 'DNK', 1),
1211
+				array(54, 'Djibouti', 'DJ', 'DJI', 1),
1212
+				array(55, 'Dominica', 'DM', 'DMA', 1),
1213
+				array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1214
+				array(56, 'Ecuador', 'EC', 'ECU', 1),
1215
+				array(57, 'Egypt', 'EG', 'EGY', 1),
1216
+				array(58, 'El Salvador', 'SV', 'SLV', 1),
1217
+				array(60, 'Eritrea', 'ER', 'ERI', 1),
1218
+				array(61, 'Slovakia', 'SK', 'SVK', 2),
1219
+				array(62, 'Slovenia', 'SI', 'SVN', 2),
1220
+				array(65, 'Estonia', 'EE', 'EST', 2),
1221
+				array(66, 'Ethiopia', 'ET', 'ETH', 1),
1222
+				array(102, 'Faroe islands', 'FO', 'FRO', 1),
1223
+				array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1224
+				array(67, 'Fiji', 'FJ', 'FJI', 1),
1225
+				array(69, 'Finland', 'FI', 'FIN', 2),
1226
+				array(71, 'Gabon', 'GA', 'GAB', 1),
1227
+				array(72, 'Gambia', 'GM', 'GMB', 1),
1228
+				array(73, 'Georgia', 'GE', 'GEO', 1),
1229
+				array(74, 'Ghana', 'GH', 'GHA', 1),
1230
+				array(75, 'Gibraltar', 'GI', 'GIB', 1),
1231
+				array(76, 'Greece', 'GR', 'GRC', 2),
1232
+				array(77, 'Grenada', 'GD', 'GRD', 1),
1233
+				array(78, 'Greenland', 'GL', 'GRL', 1),
1234
+				array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1235
+				array(80, 'Guam', 'GU', 'GUM', 1),
1236
+				array(81, 'Guatemala', 'GT', 'GTM', 1),
1237
+				array(82, 'Guinea', 'GN', 'GIN', 1),
1238
+				array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1239
+				array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1240
+				array(85, 'Guyana', 'GY', 'GUY', 1),
1241
+				array(86, 'Haiti', 'HT', 'HTI', 1),
1242
+				array(88, 'Honduras', 'HN', 'HND', 1),
1243
+				array(89, 'Hong Kong', 'HK', 'HKG', 1),
1244
+				array(90, 'Hungary', 'HU', 'HUN', 1),
1245
+				array(91, 'India', 'IN', 'IND', 1),
1246
+				array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1247
+				array(92, 'Indonesia', 'ID', 'IDN', 1),
1248
+				array(93, 'Iraq', 'IQ', 'IRQ', 1),
1249
+				array(94, 'Iran', 'IR', 'IRN', 1),
1250
+				array(95, 'Ireland', 'IE', 'IRL', 2),
1251
+				array(97, 'Iceland', 'IS', 'ISL', 1),
1252
+				array(110, 'Israel', 'IL', 'ISR', 1),
1253
+				array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1254
+				array(112, 'Jamaica', 'JM', 'JAM', 1),
1255
+				array(113, 'Japan', 'JP', 'JPN', 1),
1256
+				array(114, 'Jordan', 'JO', 'JOR', 1),
1257
+				array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1258
+				array(116, 'Kenya', 'KE', 'KEN', 1),
1259
+				array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1260
+				array(118, 'Kiribati', 'KI', 'KIR', 1),
1261
+				array(48, 'South Korea', 'KR', 'KOR', 1),
1262
+				array(228, 'Kosovo', 'XK', 'XKV', 2),
1263
+				// 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
1264
+				array(119, 'Kuwait', 'KW', 'KWT', 1),
1265
+				array(120, 'Laos', 'LA', 'LAO', 1),
1266
+				array(121, 'Latvia', 'LV', 'LVA', 2),
1267
+				array(122, 'Lesotho', 'LS', 'LSO', 1),
1268
+				array(123, 'Lebanon', 'LB', 'LBN', 1),
1269
+				array(124, 'Liberia', 'LR', 'LBR', 1),
1270
+				array(125, 'Libya', 'LY', 'LBY', 1),
1271
+				array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1272
+				array(127, 'Lithuania', 'LT', 'LTU', 2),
1273
+				array(128, 'Luxemburg', 'LU', 'LUX', 2),
1274
+				array(129, 'Macao', 'MO', 'MAC', 1),
1275
+				array(130, 'Macedonia', 'MK', 'MKD', 1),
1276
+				array(131, 'Madagascar', 'MG', 'MDG', 1),
1277
+				array(132, 'Malaysia', 'MY', 'MYS', 1),
1278
+				array(133, 'Malawi', 'MW', 'MWI', 1),
1279
+				array(134, 'Maldivas', 'MV', 'MDV', 1),
1280
+				array(135, 'Mali', 'ML', 'MLI', 1),
1281
+				array(136, 'Malta', 'MT', 'MLT', 2),
1282
+				array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1283
+				array(137, 'Morocco', 'MA', 'MAR', 1),
1284
+				array(104, 'Marshall islands', 'MH', 'MHL', 1),
1285
+				array(138, 'Martinique', 'MQ', 'MTQ', 1),
1286
+				array(139, 'Mauritius', 'MU', 'MUS', 1),
1287
+				array(140, 'Mauritania', 'MR', 'MRT', 1),
1288
+				array(141, 'Mayote', 'YT', 'MYT', 2),
1289
+				array(142, 'Mexico', 'MX', 'MEX', 1),
1290
+				array(143, 'Micronesia', 'FM', 'FSM', 1),
1291
+				array(144, 'Moldova', 'MD', 'MDA', 1),
1292
+				array(145, 'Monaco', 'MC', 'MCO', 2),
1293
+				array(146, 'Mongolia', 'MN', 'MNG', 1),
1294
+				array(147, 'Montserrat', 'MS', 'MSR', 1),
1295
+				array(227, 'Montenegro', 'ME', 'MNE', 2),
1296
+				array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1297
+				array(149, 'Myanmar', 'MM', 'MMR', 1),
1298
+				array(150, 'Namibia', 'NA', 'NAM', 1),
1299
+				array(151, 'Nauru', 'NR', 'NRU', 1),
1300
+				array(152, 'Nepal', 'NP', 'NPL', 1),
1301
+				array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1302
+				array(153, 'Nicaragua', 'NI', 'NIC', 1),
1303
+				array(154, 'Niger', 'NE', 'NER', 1),
1304
+				array(155, 'Nigeria', 'NG', 'NGA', 1),
1305
+				array(156, 'Niue', 'NU', 'NIU', 1),
1306
+				array(157, 'Norway', 'NO', 'NOR', 1),
1307
+				array(158, 'New Caledonia', 'NC', 'NCL', 1),
1308
+				array(159, 'New Zealand', 'NZ', 'NZL', 1),
1309
+				array(160, 'Oman', 'OM', 'OMN', 1),
1310
+				array(161, 'Pakistan', 'PK', 'PAK', 1),
1311
+				array(162, 'Palau', 'PW', 'PLW', 1),
1312
+				array(163, 'Panama', 'PA', 'PAN', 1),
1313
+				array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1314
+				array(165, 'Paraguay', 'PY', 'PRY', 1),
1315
+				array(166, 'Peru', 'PE', 'PER', 1),
1316
+				array(68, 'Philippines', 'PH', 'PHL', 1),
1317
+				array(167, 'Poland', 'PL', 'POL', 1),
1318
+				array(168, 'Portugal', 'PT', 'PRT', 2),
1319
+				array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1320
+				array(170, 'Qatar', 'QA', 'QAT', 1),
1321
+				array(176, 'Rwanda', 'RW', 'RWA', 1),
1322
+				array(177, 'Romania', 'RO', 'ROM', 2),
1323
+				array(178, 'Russia', 'RU', 'RUS', 1),
1324
+				array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1325
+				array(180, 'Samoa', 'WS', 'WSM', 1),
1326
+				array(181, 'American Samoa', 'AS', 'ASM', 1),
1327
+				array(183, 'San Marino', 'SM', 'SMR', 2),
1328
+				array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1329
+				array(185, 'Saint Helena', 'SH', 'SHN', 1),
1330
+				array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1331
+				array(188, 'Senegal', 'SN', 'SEN', 1),
1332
+				array(189, 'Seychelles', 'SC', 'SYC', 1),
1333
+				array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1334
+				array(191, 'Singapore', 'SG', 'SGP', 1),
1335
+				array(192, 'Syria', 'SY', 'SYR', 1),
1336
+				array(193, 'Somalia', 'SO', 'SOM', 1),
1337
+				array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1338
+				array(195, 'South Africa', 'ZA', 'ZAF', 1),
1339
+				array(196, 'Sudan', 'SD', 'SDN', 1),
1340
+				array(199, 'Suriname', 'SR', 'SUR', 1),
1341
+				array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1342
+				array(201, 'Thailand', 'TH', 'THA', 1),
1343
+				array(202, 'Taiwan', 'TW', 'TWN', 1),
1344
+				array(203, 'Tanzania', 'TZ', 'TZA', 1),
1345
+				array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1346
+				array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1347
+				array(207, 'Togo', 'TG', 'TGO', 1),
1348
+				array(208, 'Tokelau', 'TK', 'TKL', 1),
1349
+				array(209, 'Tonga', 'TO', 'TON', 1),
1350
+				array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1351
+				array(211, 'Tunisia', 'TN', 'TUN', 1),
1352
+				array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1353
+				array(213, 'Turkey', 'TR', 'TUR', 1),
1354
+				array(214, 'Tuvalu', 'TV', 'TUV', 1),
1355
+				array(215, 'Ukraine', 'UA', 'UKR', 1),
1356
+				array(216, 'Uganda', 'UG', 'UGA', 1),
1357
+				array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1358
+				array(217, 'Uruguay', 'UY', 'URY', 1),
1359
+				array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1360
+				array(219, 'Vanuatu', 'VU', 'VUT', 1),
1361
+				array(220, 'Vatican City', 'VA', 'VAT', 2),
1362
+				array(221, 'Venezuela', 'VE', 'VEN', 1),
1363
+				array(222, 'Vietnam', 'VN', 'VNM', 1),
1364
+				array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1365
+				array(223, 'Yemen', 'YE', 'YEM', 1),
1366
+				array(225, 'Zambia', 'ZM', 'ZMB', 1),
1367
+				array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1368
+		);
1369
+		$country_iso = 'US';
1370
+		foreach ($old_countries as $country_array) {
1371
+			// note: index 0 is the 3.1 country ID
1372
+			if ($country_array[0] == $country_id) {
1373
+				// note: index 2 is the ISO
1374
+				$country_iso = $country_array[2];
1375
+				break;
1376
+			}
1377
+		}
1378
+		return $country_iso;
1379
+	}
1380
+
1381
+
1382
+
1383
+	/**
1384
+	 * Gets the ISO3 for the
1385
+	 *
1386
+	 * @return string
1387
+	 */
1388
+	public function get_default_country_iso()
1389
+	{
1390
+		$old_org_options = get_option('events_organization_settings');
1391
+		$iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1392
+		return $iso;
1393
+	}
1394
+
1395
+
1396
+
1397
+	/**
1398
+	 * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1399
+	 *
1400
+	 * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1401
+	 * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1402
+	 *                                                  default payment status, the event's default payment status, or
1403
+	 *                                                  the attendee's payment status) required pre-approval.
1404
+	 * @return string STS_ID for use in 4.1
1405
+	 */
1406
+	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1407
+	{
1408
+		// EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1409
+		if ($this_thing_required_pre_approval) {
1410
+			return 'RNA';
1411
+		} else {
1412
+			$mapping = $default_reg_stati_conversions = array(
1413
+					'Completed'        => 'RAP',
1414
+					''                 => 'RPP',
1415
+					'Incomplete'       => 'RPP',
1416
+					'Pending'          => 'RAP',
1417
+					// stati that only occurred on 3.1 attendees:
1418
+					'Payment Declined' => 'RPP',
1419
+					'Not Completed'    => 'RPP',
1420
+					'Cancelled'        => 'RPP',
1421
+					'Declined'         => 'RPP',
1422
+			);
1423
+		}
1424
+		return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1425
+	}
1426
+
1427
+
1428
+
1429
+	/**
1430
+	 * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1431
+	 * and sets it as the featured image on the CPT event
1432
+	 *
1433
+	 * @param type                            $old_event
1434
+	 * @param type                            $new_cpt_id
1435
+	 * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1436
+	 * @return boolean whether or not we had to do the big job of creating an image attachment
1437
+	 */
1438
+	public function convert_image_url_to_attachment_and_attach_to_post(
1439
+		$guid,
1440
+		$new_cpt_id,
1441
+		EE_Data_Migration_Script_Stage $migration_stage
1442
+	) {
1443
+		$created_attachment_post = false;
1444
+		$guid = $this->_get_original_guid($guid);
1445
+		if ($guid) {
1446
+			// check for an existing attachment post with this guid
1447
+			$attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1448
+			if (! $attachment_post_id) {
1449
+				// post thumbnail with that GUID doesn't exist, we should create one
1450
+				$attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1451
+				$created_attachment_post = true;
1452
+			}
1453
+			// double-check we actually have an attachment post
1454
+			if ($attachment_post_id) {
1455
+				update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1456
+			} else {
1457
+				$migration_stage->add_error(sprintf(esc_html__(
1458
+					"Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1459
+					"event_espresso"
1460
+				), $guid, $new_cpt_id, $attachment_post_id));
1461
+			}
1462
+		}
1463
+		return $created_attachment_post;
1464
+	}
1465
+
1466
+
1467
+
1468
+	/**
1469
+	 * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1470
+	 * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1471
+	 * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1472
+	 * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1473
+	 * exists
1474
+	 *
1475
+	 * @param string $guid_in_old_event
1476
+	 * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1477
+	 */
1478
+	private function _get_original_guid($guid_in_old_event)
1479
+	{
1480
+		$original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1481
+		// do a head request to verify the file exists
1482
+		$head_response = wp_remote_head($original_guid);
1483
+		if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1484
+			return $original_guid;
1485
+		} else {
1486
+			return $guid_in_old_event;
1487
+		}
1488
+	}
1489
+
1490
+
1491
+
1492
+	/**
1493
+	 * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1494
+	 * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1495
+	 * thumbnails)
1496
+	 *
1497
+	 * @param type                           $guid
1498
+	 * @param EE_Data_Migration_Script_Stage $migration_stage
1499
+	 * @return int
1500
+	 */
1501
+	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1502
+	{
1503
+		if (! $guid) {
1504
+			$migration_stage->add_error(sprintf(esc_html__(
1505
+				"Cannot create image attachment for a blank GUID!",
1506
+				"event_espresso"
1507
+			)));
1508
+			return 0;
1509
+		}
1510
+		$wp_filetype = wp_check_filetype(basename($guid), null);
1511
+		$wp_upload_dir = wp_upload_dir();
1512
+		// if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1513
+		if (strpos($guid, $wp_upload_dir['url']) === false) {
1514
+			// image is located remotely. download it and place it in the uploads directory
1515
+			if (! is_readable($guid)) {
1516
+				$migration_stage->add_error(sprintf(esc_html__(
1517
+					"Could not create image attachment from non-existent file: %s",
1518
+					"event_espresso"
1519
+				), $guid));
1520
+				return 0;
1521
+			}
1522
+			$contents = file_get_contents($guid);
1523
+			if ($contents === false) {
1524
+				$migration_stage->add_error(sprintf(esc_html__(
1525
+					"Could not read image at %s, and therefore couldnt create an attachment post for it.",
1526
+					"event_espresso"
1527
+				), $guid));
1528
+				return false;
1529
+			}
1530
+			$local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1531
+			$savefile = fopen($local_filepath, 'w');
1532
+			fwrite($savefile, $contents);
1533
+			fclose($savefile);
1534
+			$guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1535
+		} else {
1536
+			$local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1537
+		}
1538
+		$attachment = array(
1539
+				'guid'           => $guid,
1540
+				'post_mime_type' => $wp_filetype['type'],
1541
+				'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1542
+				'post_content'   => '',
1543
+				'post_status'    => 'inherit',
1544
+		);
1545
+		$attach_id = wp_insert_attachment($attachment, $guid);
1546
+		if (! $attach_id) {
1547
+			$migration_stage->add_error(sprintf(esc_html__(
1548
+				"Could not create image attachment post from image '%s'. Attachment data was %s.",
1549
+				"event_espresso"
1550
+			), $guid, $this->_json_encode($attachment)));
1551
+			return $attach_id;
1552
+		}
1553
+		// you must first include the image.php file
1554
+		// for the function wp_generate_attachment_metadata() to work
1555
+		require_once(ABSPATH . 'wp-admin/includes/image.php');
1556
+		$attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1557
+		if (! $attach_data) {
1558
+			$migration_stage->add_error(sprintf(esc_html__(
1559
+				"Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1560
+				"event_espresso"
1561
+			), $attach_id, $local_filepath, $guid));
1562
+			return $attach_id;
1563
+		}
1564
+		$metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1565
+		if (! $metadata_save_result) {
1566
+			$migration_stage->add_error(sprintf(esc_html__(
1567
+				"Could not update attachment metadata for attachment %d with data %s",
1568
+				"event_espresso"
1569
+			), $attach_id, $this->_json_encode($attach_data)));
1570
+		}
1571
+		return $attach_id;
1572
+	}
1573
+
1574
+
1575
+
1576
+	/**
1577
+	 * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1578
+	 * and returns its ID.
1579
+	 *
1580
+	 * @global type  $wpdb
1581
+	 * @param string $guid
1582
+	 * @return int
1583
+	 */
1584
+	private function _get_image_attachment_id_by_GUID($guid)
1585
+	{
1586
+		global $wpdb;
1587
+		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1588
+		return $attachment_id;
1589
+	}
1590
+
1591
+
1592
+
1593
+	/**
1594
+	 * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1595
+	 * (and optionally a timezone; if none is given, the wp default is used)
1596
+	 *
1597
+	 * @param EE_Data_Migration_Script_base $stage
1598
+	 * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1599
+	 *                                                   UTC time for
1600
+	 * @param string                        $DATETIME_string
1601
+	 * @param string                        $timezone
1602
+	 * @return string
1603
+	 */
1604
+	public function convert_date_string_to_utc(
1605
+		EE_Data_Migration_Script_Stage $stage,
1606
+		$row_of_data,
1607
+		$DATETIME_string,
1608
+		$timezone = null
1609
+	) {
1610
+		$original_tz = $timezone;
1611
+		if (! $timezone) {
1612
+			$timezone = $this->_get_wp_timezone();
1613
+		}
1614
+		if (! $timezone) {
1615
+			$stage->add_error(sprintf(
1616
+				esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1617
+				$original_tz,
1618
+				$row_of_data
1619
+			));
1620
+			$timezone = 'UTC';
1621
+		}
1622
+		try {
1623
+			$date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1624
+			EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC'));
1625
+		} catch (Exception $e) {
1626
+			$stage->add_error(sprintf(esc_html__(
1627
+				"Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1628
+				"event_espresso"
1629
+			), $DATETIME_string, $timezone));
1630
+			$date_obj = new DateTime();
1631
+		}
1632
+		return $date_obj->format('Y-m-d H:i:s');
1633
+	}
1634
+
1635
+
1636
+
1637
+	/**
1638
+	 * Gets the default timezone string from wordpress (even if they set a gmt offset)
1639
+	 *
1640
+	 * @return string
1641
+	 */
1642
+	private function _get_wp_timezone()
1643
+	{
1644
+		$timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1645
+		// if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1646
+		if (empty($timezone)) {
1647
+			// let's get a the WordPress UTC offset
1648
+			$offset = get_option('gmt_offset');
1649
+			$timezone = $this->timezone_convert_to_string_from_offset($offset);
1650
+		}
1651
+		return $timezone;
1652
+	}
1653
+
1654
+
1655
+
1656
+	/**
1657
+	 * Gets the wordpress timezone string from a UTC offset
1658
+	 *
1659
+	 * @param int $offset
1660
+	 * @return boolean
1661
+	 */
1662
+	private function timezone_convert_to_string_from_offset($offset)
1663
+	{
1664
+		// 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
1665
+		$offset *= 3600; // convert hour offset to seconds
1666
+		$abbrarray = timezone_abbreviations_list();
1667
+		foreach ($abbrarray as $abbr) {
1668
+			foreach ($abbr as $city) {
1669
+				if ($city['offset'] == $offset) {
1670
+					return $city['timezone_id'];
1671
+				}
1672
+			}
1673
+		}
1674
+		return false;
1675
+	}
1676
+
1677
+
1678
+
1679
+	public function migration_page_hooks()
1680
+	{
1681
+		add_filter(
1682
+			'FHEE__ee_migration_page__header',
1683
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1684
+			10,
1685
+			3
1686
+		);
1687
+		add_filter(
1688
+			'FHEE__ee_migration_page__p_after_header',
1689
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1690
+			10,
1691
+			2
1692
+		);
1693
+		add_filter(
1694
+			'FHEE__ee_migration_page__option_1_main',
1695
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1696
+			10,
1697
+			3
1698
+		);
1699
+		add_filter(
1700
+			'FHEE__ee_migration_page__option_1_button_text',
1701
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1702
+			10,
1703
+			3
1704
+		);
1705
+		add_action(
1706
+			'AHEE__ee_migration_page__option_1_extra_details',
1707
+			array($this, '_migration_page_hook_option_1_extra_details'),
1708
+			10,
1709
+			3
1710
+		);
1711
+		add_filter(
1712
+			'FHEE__ee_migration_page__option_2_main',
1713
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1714
+			10,
1715
+			4
1716
+		);
1717
+		add_filter(
1718
+			'FHEE__ee_migration_page__option_2_button_text',
1719
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1720
+			10,
1721
+			2
1722
+		);
1723
+		add_filter(
1724
+			'FHEE__ee_migration_page__option_2_details',
1725
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1726
+			10,
1727
+			2
1728
+		);
1729
+		add_action(
1730
+			'AHEE__ee_migration_page__after_migration_options_table',
1731
+			array($this, '_migration_page_hook_after_migration_options_table')
1732
+		);
1733
+		add_filter(
1734
+			'FHEE__ee_migration_page__done_migration_header',
1735
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1736
+			10,
1737
+			2
1738
+		);
1739
+		add_filter(
1740
+			'FHEE__ee_migration_page__p_after_done_migration_header',
1741
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1742
+			10,
1743
+			2
1744
+		);
1745
+		add_filter(
1746
+			'FHEE__ee_migration_page__migration_options_template',
1747
+			array($this,'use_migration_options_from_ee3_template')
1748
+		);
1749
+	}
1750
+
1751
+
1752
+
1753
+	public function _migrate_page_hook_simplify_version_strings(
1754
+		$old_content,
1755
+		$current_db_state,
1756
+		$next_db_state,
1757
+		$ultimate_db_state = null
1758
+	) {
1759
+		return str_replace(
1760
+			array($current_db_state, $next_db_state, $ultimate_db_state),
1761
+			array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')),
1762
+			$old_content
1763
+		);
1764
+	}
1765
+
1766
+
1767
+
1768
+	public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1769
+	{
1770
+		return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content);
1771
+	}
1772
+
1773
+
1774
+
1775
+	public function _migration_page_hook_option_1_extra_details()
1776
+	{
1777
+		?>
1778 1778
         <p><?php printf(esc_html__(
1779
-            "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",
1780
-            "event_espresso"
1781
-        )); ?></p><?php
1782
-    }
1779
+			"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",
1780
+			"event_espresso"
1781
+		)); ?></p><?php
1782
+	}
1783 1783
 
1784 1784
 
1785 1785
 
1786
-    public function _migration_page_hook_after_migration_options_table()
1787
-    {
1788
-        ?><p class="ee-attention">
1786
+	public function _migration_page_hook_after_migration_options_table()
1787
+	{
1788
+		?><p class="ee-attention">
1789 1789
         <strong><span class="reminder-spn">
1790 1790
                 <?php _e(
1791
-                    "Important note to those using Event Espresso 3 addons: ",
1792
-                    "event_espresso"
1793
-                ); ?></span></strong>
1791
+					"Important note to those using Event Espresso 3 addons: ",
1792
+					"event_espresso"
1793
+				); ?></span></strong>
1794 1794
         <br/>
1795 1795
         <?php _e(
1796
-            "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.",
1797
-            "event_espresso"
1798
-        ); ?>
1796
+			"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.",
1797
+			"event_espresso"
1798
+		); ?>
1799 1799
         </p><?php
1800
-    }
1800
+	}
1801 1801
 
1802 1802
 
1803 1803
 
1804
-    /**
1805
-     * When showing the migration options, show more options and info than normal (ie, give folks the option
1806
-     * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because
1807
-     * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea).
1808
-     * @param $template_filepath
1809
-     * @return string
1810
-     */
1811
-    public function use_migration_options_from_ee3_template($template_filepath)
1812
-    {
1813
-        return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1814
-    }
1804
+	/**
1805
+	 * When showing the migration options, show more options and info than normal (ie, give folks the option
1806
+	 * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because
1807
+	 * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea).
1808
+	 * @param $template_filepath
1809
+	 * @return string
1810
+	 */
1811
+	public function use_migration_options_from_ee3_template($template_filepath)
1812
+	{
1813
+		return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1814
+	}
1815 1815
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_3_0.dms.php 2 patches
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 $stages = glob(EE_CORE . 'data_migration_scripts/4_3_0_stages/*');
15 15
 $class_to_filepath = array();
16 16
 if (! empty($stages)) {
17
-    foreach ($stages as $filepath) {
18
-        $matches = array();
19
-        preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-        $class_to_filepath[ $matches[1] ] = $filepath;
21
-    }
17
+	foreach ($stages as $filepath) {
18
+		$matches = array();
19
+		preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
+		$class_to_filepath[ $matches[1] ] = $filepath;
21
+	}
22 22
 }
23 23
 // give addons a chance to autoload their stages too
24 24
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_3_0__autoloaded_stages', $class_to_filepath);
@@ -31,56 +31,56 @@  discard block
 block discarded – undo
31 31
 
32 32
 
33 33
 
34
-    /**
35
-     * EE_DMS_Core_4_3_0 constructor.
36
-     *
37
-     * @param TableManager  $table_manager
38
-     * @param TableAnalysis $table_analysis
39
-     */
40
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
41
-    {
42
-        $this->_pretty_name = __("Data Update to Event Espresso 4.3.0", "event_espresso");
43
-        $this->_priority = 10;
44
-        $this->_migration_stages = array(
45
-            new EE_DMS_4_3_0_question_option_order(),
46
-            new EE_DMS_4_3_0_event_message_templates(),
47
-        );
48
-        parent::__construct($table_manager, $table_analysis);
49
-    }
34
+	/**
35
+	 * EE_DMS_Core_4_3_0 constructor.
36
+	 *
37
+	 * @param TableManager  $table_manager
38
+	 * @param TableAnalysis $table_analysis
39
+	 */
40
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
41
+	{
42
+		$this->_pretty_name = __("Data Update to Event Espresso 4.3.0", "event_espresso");
43
+		$this->_priority = 10;
44
+		$this->_migration_stages = array(
45
+			new EE_DMS_4_3_0_question_option_order(),
46
+			new EE_DMS_4_3_0_event_message_templates(),
47
+		);
48
+		parent::__construct($table_manager, $table_analysis);
49
+	}
50 50
 
51 51
 
52 52
 
53
-    public function can_migrate_from_version($version_array)
54
-    {
55
-        $version_string = $version_array['Core'];
56
-        if (version_compare($version_string, '4.3.0.decaf', '<') && version_compare($version_string, '4.2.0.decaf', '>=')) {
53
+	public function can_migrate_from_version($version_array)
54
+	{
55
+		$version_string = $version_array['Core'];
56
+		if (version_compare($version_string, '4.3.0.decaf', '<') && version_compare($version_string, '4.2.0.decaf', '>=')) {
57 57
 //          echo "$version_string can be migrated fro";
58
-            return true;
59
-        } elseif (! $version_string) {
58
+			return true;
59
+		} elseif (! $version_string) {
60 60
 //          echo "no version string provided: $version_string";
61
-            // no version string provided... this must be pre 4.2
62
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
63
-        } else {
61
+			// no version string provided... this must be pre 4.2
62
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
63
+		} else {
64 64
 //          echo "$version_string doesnt apply";
65
-            return false;
66
-        }
67
-    }
65
+			return false;
66
+		}
67
+	}
68 68
 
69 69
 
70 70
 
71
-    public function schema_changes_before_migration()
72
-    {
73
-        // relies on 4.1's EEH_Activation::create_table
74
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
75
-        $table_name = 'esp_answer';
76
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
71
+	public function schema_changes_before_migration()
72
+	{
73
+		// relies on 4.1's EEH_Activation::create_table
74
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
75
+		$table_name = 'esp_answer';
76
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
77 77
 					REG_ID int(10) unsigned NOT NULL,
78 78
 					QST_ID int(10) unsigned NOT NULL,
79 79
 					ANS_value text NOT NULL,
80 80
 					PRIMARY KEY  (ANS_ID)";
81
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
82
-        $table_name = 'esp_attendee_meta';
83
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
81
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
82
+		$table_name = 'esp_attendee_meta';
83
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
84 84
 						ATT_ID bigint(20) unsigned NOT NULL,
85 85
 						ATT_fname varchar(45) NOT NULL,
86 86
 						ATT_lname varchar(45) NOT	NULL,
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 								KEY ATT_fname (ATT_fname),
97 97
 								KEY ATT_lname (ATT_lname),
98 98
 								KEY ATT_email (ATT_email(191))";
99
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
100
-        $table_name = 'esp_country';
101
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
99
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
100
+		$table_name = 'esp_country';
101
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
102 102
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
103 103
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
104 104
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 					  CNT_is_EU tinyint(1) DEFAULT '0',
115 115
 					  CNT_active tinyint(1) DEFAULT '0',
116 116
 					  PRIMARY KEY  (CNT_ISO)";
117
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
118
-        $table_name = 'esp_datetime';
119
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
117
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
118
+		$table_name = 'esp_datetime';
119
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
120 120
 				  EVT_ID bigint(20) unsigned NOT NULL,
121 121
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
122 122
 				  DTT_description text NOT NULL,
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 						PRIMARY KEY  (DTT_ID),
132 132
 						KEY EVT_ID (EVT_ID),
133 133
 						KEY DTT_is_primary (DTT_is_primary)";
134
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
-        $table_name = 'esp_event_meta';
136
-        $sql = "
134
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
+		$table_name = 'esp_event_meta';
136
+		$sql = "
137 137
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
138 138
 			EVT_ID bigint(20) unsigned NOT NULL,
139 139
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -148,31 +148,31 @@  discard block
 block discarded – undo
148 148
 			EVT_external_URL varchar(200) NULL,
149 149
 			EVT_donations tinyint(1) NULL,
150 150
 			PRIMARY KEY  (EVTM_ID)";
151
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
152
-        $table_name = 'esp_event_question_group';
153
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
151
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
152
+		$table_name = 'esp_event_question_group';
153
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
154 154
 					EVT_ID bigint(20) unsigned NOT NULL,
155 155
 					QSG_ID int(10) unsigned NOT NULL,
156 156
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
157 157
 					PRIMARY KEY  (EQG_ID)";
158
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
159
-        $table_name = 'esp_event_venue';
160
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
158
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
159
+		$table_name = 'esp_event_venue';
160
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
161 161
 				EVT_ID bigint(20) unsigned NOT NULL,
162 162
 				VNU_ID bigint(20) unsigned NOT NULL,
163 163
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
164 164
 				PRIMARY KEY  (EVV_ID)";
165
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
166
-        $table_name = 'esp_extra_meta';
167
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
165
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
166
+		$table_name = 'esp_extra_meta';
167
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
168 168
 				OBJ_ID int(11) DEFAULT NULL,
169 169
 				EXM_type varchar(45) DEFAULT NULL,
170 170
 				EXM_key varchar(45) DEFAULT NULL,
171 171
 				EXM_value text,
172 172
 				PRIMARY KEY  (EXM_ID)";
173
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
174
-        $table_name = 'esp_line_item';
175
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
173
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
174
+		$table_name = 'esp_line_item';
175
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
176 176
 				LIN_code varchar(245) NOT NULL DEFAULT '',
177 177
 				TXN_ID int(11) DEFAULT NULL,
178 178
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -188,19 +188,19 @@  discard block
 block discarded – undo
188 188
 				OBJ_ID int(11) DEFAULT NULL,
189 189
 				OBJ_type varchar(45)DEFAULT NULL,
190 190
 				PRIMARY KEY  (LIN_ID)";
191
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
192
-        $table_name = 'esp_message_template';
193
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
191
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
192
+		$table_name = 'esp_message_template';
193
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
194 194
 					GRP_ID int(10) unsigned NOT NULL,
195 195
 					MTP_context varchar(50) NOT NULL,
196 196
 					MTP_template_field varchar(30) NOT NULL,
197 197
 					MTP_content text NOT NULL,
198 198
 					PRIMARY KEY  (MTP_ID),
199 199
 					KEY GRP_ID (GRP_ID)";
200
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
201
-        $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
202
-        $table_name = 'esp_message_template_group';
203
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
200
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
201
+		$this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
202
+		$table_name = 'esp_message_template_group';
203
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
204 204
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
205 205
 					MTP_name varchar(245) NOT NULL DEFAULT '',
206 206
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -212,17 +212,17 @@  discard block
 block discarded – undo
212 212
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
213 213
 					PRIMARY KEY  (GRP_ID),
214 214
 					KEY MTP_user_id (MTP_user_id)";
215
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
216
-        $table_name = 'esp_event_message_template';
217
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
215
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
216
+		$table_name = 'esp_event_message_template';
217
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
218 218
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
219 219
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
220 220
 					PRIMARY KEY  (EMT_ID),
221 221
 					KEY EVT_ID (EVT_ID),
222 222
 					KEY GRP_ID (GRP_ID)";
223
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
224
-        $table_name = 'esp_payment';
225
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
223
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
224
+		$table_name = 'esp_payment';
225
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
226 226
 					TXN_ID int(10) unsigned DEFAULT NULL,
227 227
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
228 228
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 					PRIMARY KEY  (PAY_ID),
239 239
 					KEY TXN_ID (TXN_ID),
240 240
 					KEY PAY_timestamp (PAY_timestamp)";
241
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
242
-        $table_name = "esp_ticket";
243
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
241
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
242
+		$table_name = "esp_ticket";
243
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
244 244
 					  TTM_ID int(10) unsigned NOT NULL,
245 245
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
246 246
 					  TKT_description text NOT NULL,
@@ -260,28 +260,28 @@  discard block
 block discarded – undo
260 260
 					  TKT_parent int(10) unsigned DEFAULT '0',
261 261
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
262 262
 					  PRIMARY KEY  (TKT_ID)";
263
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
264
-        $table_name = "esp_ticket_price";
265
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
263
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
264
+		$table_name = "esp_ticket_price";
265
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
266 266
 					  TKT_ID int(10) unsigned NOT NULL,
267 267
 					  PRC_ID int(10) unsigned NOT NULL,
268 268
 					  PRIMARY KEY  (TKP_ID)";
269
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
270
-        $table_name = "esp_datetime_ticket";
271
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
269
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
270
+		$table_name = "esp_datetime_ticket";
271
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
272 272
 					  DTT_ID int(10) unsigned NOT NULL,
273 273
 					  TKT_ID int(10) unsigned NOT NULL,
274 274
 					  PRIMARY KEY  (DTK_ID)";
275
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
276
-        $table_name = "esp_ticket_template";
277
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
275
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
276
+		$table_name = "esp_ticket_template";
277
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
278 278
 					  TTM_name varchar(45) NOT NULL,
279 279
 					  TTM_description text,
280 280
 					  TTM_file varchar(45),
281 281
 					  PRIMARY KEY  (TTM_ID)";
282
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
283
-        $table_name = "esp_price";
284
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
282
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
283
+		$table_name = "esp_price";
284
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
285 285
 					  PRT_ID tinyint(3) unsigned NOT NULL,
286 286
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
287 287
 					  PRC_name varchar(245) NOT NULL,
@@ -292,9 +292,9 @@  discard block
 block discarded – undo
292 292
 					  PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0',
293 293
 					  PRC_parent int(10) unsigned DEFAULT 0,
294 294
 					  PRIMARY KEY  (PRC_ID)";
295
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
296
-        $table_name = "esp_price_type";
297
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
295
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
296
+		$table_name = "esp_price_type";
297
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
298 298
 				  PRT_name varchar(45) NOT NULL,
299 299
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
300 300
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
303 303
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
304 304
 				  PRIMARY KEY  (PRT_ID)";
305
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
306
-        $table_name = 'esp_question';
307
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
305
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
306
+		$table_name = 'esp_question';
307
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
308 308
 					QST_display_text text NOT NULL,
309 309
 					QST_admin_label varchar(255) NOT NULL,
310 310
 					QST_system varchar(25) DEFAULT NULL,
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 					QST_wp_user bigint(20) unsigned NULL,
317 317
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
318 318
 					PRIMARY KEY  (QST_ID)';
319
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
320
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
321
-        $table_name = 'esp_question_group';
322
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
319
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
320
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
321
+		$table_name = 'esp_question_group';
322
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
323 323
 					QSG_name varchar(255) NOT NULL,
324 324
 					QSG_identifier varchar(100) NOT NULL,
325 325
 					QSG_desc text NULL,
@@ -330,25 +330,25 @@  discard block
 block discarded – undo
330 330
 					QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
331 331
 					PRIMARY KEY  (QSG_ID),
332 332
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
333
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
334
-        $table_name = 'esp_question_group_question';
335
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
333
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
334
+		$table_name = 'esp_question_group_question';
335
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
336 336
 					QSG_ID int(10) unsigned NOT NULL,
337 337
 					QST_ID int(10) unsigned NOT NULL,
338 338
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
339 339
 					PRIMARY KEY  (QGQ_ID) ";
340
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
-        $table_name = 'esp_question_option';
342
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
340
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
+		$table_name = 'esp_question_option';
342
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343 343
 					QSO_value varchar(255) NOT NULL,
344 344
 					QSO_desc text NOT NULL,
345 345
 					QST_ID int(10) unsigned NOT NULL,
346 346
 					QSO_order int(10) unsigned NOT NULL DEFAULT 0,
347 347
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
348 348
 					PRIMARY KEY  (QSO_ID)";
349
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
350
-        $table_name = 'esp_registration';
351
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
349
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
350
+		$table_name = 'esp_registration';
351
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
352 352
 					  EVT_ID bigint(20) unsigned NOT NULL,
353 353
 					  ATT_ID bigint(20) unsigned NOT NULL,
354 354
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -371,25 +371,25 @@  discard block
 block discarded – undo
371 371
 					  KEY STS_ID (STS_ID),
372 372
 					  KEY REG_url_link (REG_url_link),
373 373
 					  KEY REG_code (REG_code)";
374
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
375
-        $table_name = 'esp_checkin';
376
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
374
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
375
+		$table_name = 'esp_checkin';
376
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
377 377
 					REG_ID int(10) unsigned NOT NULL,
378 378
 					DTT_ID int(10) unsigned NOT NULL,
379 379
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
380 380
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
381 381
 					PRIMARY KEY  (CHK_ID)";
382
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
383
-        $table_name = 'esp_state';
384
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
382
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
383
+		$table_name = 'esp_state';
384
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
385 385
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
386 386
 					  STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL,
387 387
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
388 388
 					  STA_active tinyint(1) DEFAULT '1',
389 389
 					  PRIMARY KEY  (STA_ID)";
390
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
391
-        $table_name = 'esp_status';
392
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
390
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
391
+		$table_name = 'esp_status';
392
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
393 393
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
394 394
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
395 395
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
398 398
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
399 399
 					  KEY STS_type (STS_type)";
400
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
401
-        $table_name = 'esp_transaction';
402
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
400
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
401
+		$table_name = 'esp_transaction';
402
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
403 403
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
404 404
 					  TXN_total decimal(10,3) DEFAULT '0.00',
405 405
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
 					  PRIMARY KEY  (TXN_ID),
410 410
 					  KEY TXN_timestamp (TXN_timestamp),
411 411
 					  KEY STS_ID (STS_ID)";
412
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
413
-        $table_name = 'esp_venue_meta';
414
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
412
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
413
+		$table_name = 'esp_venue_meta';
414
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
415 415
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
416 416
 			VNU_address varchar(255) DEFAULT NULL,
417 417
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -429,77 +429,77 @@  discard block
 block discarded – undo
429 429
 			PRIMARY KEY  (VNUM_ID),
430 430
 			KEY STA_ID (STA_ID),
431 431
 			KEY CNT_ISO (CNT_ISO)";
432
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
433
-        $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
434
-        // setting up the DEFAULT stats and countries is also essential for the data migrations to run
435
-        // (because many need to convert old string states to foreign keys into the states table)
436
-        $script_with_defaults->insert_default_states();
437
-        $script_with_defaults->insert_default_countries();
438
-        // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
439
-        $script_with_defaults->insert_default_price_types();
440
-        $script_with_defaults->insert_default_prices();
441
-        // but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's
442
-        $this->insert_default_tickets();
443
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
444
-        EE_Config::instance()->update_espresso_config(false, true);
445
-        return true;
446
-    }
432
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
433
+		$script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
434
+		// setting up the DEFAULT stats and countries is also essential for the data migrations to run
435
+		// (because many need to convert old string states to foreign keys into the states table)
436
+		$script_with_defaults->insert_default_states();
437
+		$script_with_defaults->insert_default_countries();
438
+		// setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
439
+		$script_with_defaults->insert_default_price_types();
440
+		$script_with_defaults->insert_default_prices();
441
+		// but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's
442
+		$this->insert_default_tickets();
443
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
444
+		EE_Config::instance()->update_espresso_config(false, true);
445
+		return true;
446
+	}
447 447
 
448 448
 
449 449
 
450
-    /**
451
-     * @return boolean
452
-     */
453
-    public function schema_changes_after_migration()
454
-    {
455
-        return true;
456
-    }
450
+	/**
451
+	 * @return boolean
452
+	 */
453
+	public function schema_changes_after_migration()
454
+	{
455
+		return true;
456
+	}
457 457
 
458 458
 
459 459
 
460
-    public function migration_page_hooks()
461
-    {
462
-    }
460
+	public function migration_page_hooks()
461
+	{
462
+	}
463 463
 
464 464
 
465 465
 
466
-    /**
467
-     * insert DEFAULT ticket
468
-     * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field
469
-     *
470
-     * @access public
471
-     * @static
472
-     * @return void
473
-     */
474
-    public function insert_default_tickets()
475
-    {
476
-        global $wpdb;
477
-        $ticket_table = $wpdb->prefix . "esp_ticket";
478
-        if ($this->_get_table_analysis()->tableExists($ticket_table)) {
479
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
480
-            $tickets_exist = $wpdb->get_var($SQL);
481
-            if (! $tickets_exist) {
482
-                $SQL = "INSERT INTO $ticket_table
466
+	/**
467
+	 * insert DEFAULT ticket
468
+	 * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field
469
+	 *
470
+	 * @access public
471
+	 * @static
472
+	 * @return void
473
+	 */
474
+	public function insert_default_tickets()
475
+	{
476
+		global $wpdb;
477
+		$ticket_table = $wpdb->prefix . "esp_ticket";
478
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
479
+			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
480
+			$tickets_exist = $wpdb->get_var($SQL);
481
+			if (! $tickets_exist) {
482
+				$SQL = "INSERT INTO $ticket_table
483 483
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES
484 484
 					( 1, 0, '"
485
-                       . __("Free Ticket", "event_espresso")
486
-                       . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
487
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
488
-                $wpdb->query($SQL);
489
-            }
490
-        }
491
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
492
-        if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
493
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
494
-            $ticket_prc_exist = $wpdb->get_var($SQL);
495
-            if (! $ticket_prc_exist) {
496
-                $SQL = "INSERT INTO $ticket_price_table
485
+					   . __("Free Ticket", "event_espresso")
486
+					   . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
487
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
488
+				$wpdb->query($SQL);
489
+			}
490
+		}
491
+		$ticket_price_table = $wpdb->prefix . "esp_ticket_price";
492
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
493
+			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
494
+			$ticket_prc_exist = $wpdb->get_var($SQL);
495
+			if (! $ticket_prc_exist) {
496
+				$SQL = "INSERT INTO $ticket_price_table
497 497
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
498 498
 				( 1, 1, 1 )
499 499
 				";
500
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
501
-                $wpdb->query($SQL);
502
-            }
503
-        }
504
-    }
500
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
501
+				$wpdb->query($SQL);
502
+			}
503
+		}
504
+	}
505 505
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 // unfortunately, this needs to be done upon INCLUSION of this file,
12 12
 // instead of construction, because it only gets constructed on first page load
13 13
 // (all other times it gets resurrected from a wordpress option)
14
-$stages = glob(EE_CORE . 'data_migration_scripts/4_3_0_stages/*');
14
+$stages = glob(EE_CORE.'data_migration_scripts/4_3_0_stages/*');
15 15
 $class_to_filepath = array();
16
-if (! empty($stages)) {
16
+if ( ! empty($stages)) {
17 17
     foreach ($stages as $filepath) {
18 18
         $matches = array();
19 19
         preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-        $class_to_filepath[ $matches[1] ] = $filepath;
20
+        $class_to_filepath[$matches[1]] = $filepath;
21 21
     }
22 22
 }
23 23
 // give addons a chance to autoload their stages too
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
         if (version_compare($version_string, '4.3.0.decaf', '<') && version_compare($version_string, '4.2.0.decaf', '>=')) {
57 57
 //          echo "$version_string can be migrated fro";
58 58
             return true;
59
-        } elseif (! $version_string) {
59
+        } elseif ( ! $version_string) {
60 60
 //          echo "no version string provided: $version_string";
61 61
             // no version string provided... this must be pre 4.2
62
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
62
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
63 63
         } else {
64 64
 //          echo "$version_string doesnt apply";
65 65
             return false;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     public function schema_changes_before_migration()
72 72
     {
73 73
         // relies on 4.1's EEH_Activation::create_table
74
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
74
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
75 75
         $table_name = 'esp_answer';
76 76
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
77 77
 					REG_ID int(10) unsigned NOT NULL,
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
     public function insert_default_tickets()
475 475
     {
476 476
         global $wpdb;
477
-        $ticket_table = $wpdb->prefix . "esp_ticket";
477
+        $ticket_table = $wpdb->prefix."esp_ticket";
478 478
         if ($this->_get_table_analysis()->tableExists($ticket_table)) {
479
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
479
+            $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
480 480
             $tickets_exist = $wpdb->get_var($SQL);
481
-            if (! $tickets_exist) {
481
+            if ( ! $tickets_exist) {
482 482
                 $SQL = "INSERT INTO $ticket_table
483 483
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES
484 484
 					( 1, 0, '"
@@ -488,11 +488,11 @@  discard block
 block discarded – undo
488 488
                 $wpdb->query($SQL);
489 489
             }
490 490
         }
491
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
491
+        $ticket_price_table = $wpdb->prefix."esp_ticket_price";
492 492
         if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
493
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
493
+            $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
494 494
             $ticket_prc_exist = $wpdb->get_var($SQL);
495
-            if (! $ticket_prc_exist) {
495
+            if ( ! $ticket_prc_exist) {
496 496
                 $SQL = "INSERT INTO $ticket_price_table
497 497
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
498 498
 				( 1, 1, 1 )
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_6_0.dms.php 2 patches
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*');
15 15
 $class_to_filepath = array();
16 16
 foreach ($stages as $filepath) {
17
-    $matches = array();
18
-    preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19
-    $class_to_filepath[ $matches[1] ] = $filepath;
17
+	$matches = array();
18
+	preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19
+	$class_to_filepath[ $matches[1] ] = $filepath;
20 20
 }
21 21
 // give addons a chance to autoload their stages too
22 22
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath);
@@ -35,69 +35,69 @@  discard block
 block discarded – undo
35 35
 class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base
36 36
 {
37 37
 
38
-    /**
39
-     * return EE_DMS_Core_4_6_0
40
-     *
41
-     * @param TableManager  $table_manager
42
-     * @param TableAnalysis $table_analysis
43
-     */
44
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
45
-    {
46
-        $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso");
47
-        $this->_priority = 10;
48
-        $this->_migration_stages = array(
49
-            new EE_DMS_4_6_0_gateways(),
50
-            new EE_DMS_4_6_0_question_types(),
51
-            new EE_DMS_4_6_0_country_system_question(),
52
-            new EE_DMS_4_6_0_state_system_question(),
53
-            new EE_DMS_4_6_0_billing_info(),
54
-            new EE_DMS_4_6_0_transactions(),
55
-            new EE_DMS_4_6_0_payments(),
56
-            new EE_DMS_4_6_0_invoice_settings(),
57
-        );
58
-        parent::__construct($table_manager, $table_analysis);
59
-    }
38
+	/**
39
+	 * return EE_DMS_Core_4_6_0
40
+	 *
41
+	 * @param TableManager  $table_manager
42
+	 * @param TableAnalysis $table_analysis
43
+	 */
44
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
45
+	{
46
+		$this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso");
47
+		$this->_priority = 10;
48
+		$this->_migration_stages = array(
49
+			new EE_DMS_4_6_0_gateways(),
50
+			new EE_DMS_4_6_0_question_types(),
51
+			new EE_DMS_4_6_0_country_system_question(),
52
+			new EE_DMS_4_6_0_state_system_question(),
53
+			new EE_DMS_4_6_0_billing_info(),
54
+			new EE_DMS_4_6_0_transactions(),
55
+			new EE_DMS_4_6_0_payments(),
56
+			new EE_DMS_4_6_0_invoice_settings(),
57
+		);
58
+		parent::__construct($table_manager, $table_analysis);
59
+	}
60 60
 
61 61
 
62 62
 
63
-    /**
64
-     * @param array $version_array
65
-     * @return bool
66
-     */
67
-    public function can_migrate_from_version($version_array)
68
-    {
69
-        $version_string = $version_array['Core'];
70
-        if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) {
63
+	/**
64
+	 * @param array $version_array
65
+	 * @return bool
66
+	 */
67
+	public function can_migrate_from_version($version_array)
68
+	{
69
+		$version_string = $version_array['Core'];
70
+		if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) {
71 71
 //          echo "$version_string can be migrated from";
72
-            return true;
73
-        } elseif (! $version_string) {
72
+			return true;
73
+		} elseif (! $version_string) {
74 74
 //          echo "no version string provided: $version_string";
75
-            // no version string provided... this must be pre 4.3
76
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
77
-        } else {
75
+			// no version string provided... this must be pre 4.3
76
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
77
+		} else {
78 78
 //          echo "$version_string doesnt apply";
79
-            return false;
80
-        }
81
-    }
79
+			return false;
80
+		}
81
+	}
82 82
 
83 83
 
84 84
 
85
-    /**
86
-     * @return bool
87
-     */
88
-    public function schema_changes_before_migration()
89
-    {
90
-        // relies on 4.1's EEH_Activation::create_table
91
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
-        $table_name = 'esp_answer';
93
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
85
+	/**
86
+	 * @return bool
87
+	 */
88
+	public function schema_changes_before_migration()
89
+	{
90
+		// relies on 4.1's EEH_Activation::create_table
91
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
+		$table_name = 'esp_answer';
93
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
94 94
 					REG_ID int(10) unsigned NOT NULL,
95 95
 					QST_ID int(10) unsigned NOT NULL,
96 96
 					ANS_value text NOT NULL,
97 97
 					PRIMARY KEY  (ANS_ID)";
98
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
99
-        $table_name = 'esp_attendee_meta';
100
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
98
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
99
+		$table_name = 'esp_attendee_meta';
100
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
101 101
 						ATT_ID bigint(20) unsigned NOT NULL,
102 102
 						ATT_fname varchar(45) NOT NULL,
103 103
 						ATT_lname varchar(45) NOT	NULL,
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 								KEY ATT_fname (ATT_fname),
114 114
 								KEY ATT_lname (ATT_lname),
115 115
 								KEY ATT_email (ATT_email(191))";
116
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
117
-        $table_name = 'esp_country';
118
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
116
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
117
+		$table_name = 'esp_country';
118
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
119 119
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
120 120
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
121 121
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -131,24 +131,24 @@  discard block
 block discarded – undo
131 131
 					  CNT_is_EU tinyint(1) DEFAULT '0',
132 132
 					  CNT_active tinyint(1) DEFAULT '0',
133 133
 					  PRIMARY KEY  (CNT_ISO)";
134
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
-        $table_name = 'esp_currency';
136
-        $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
134
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
+		$table_name = 'esp_currency';
136
+		$sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
137 137
 				CUR_single varchar(45) COLLATE utf8_bin DEFAULT 'dollar',
138 138
 				CUR_plural varchar(45) COLLATE utf8_bin DEFAULT 'dollars',
139 139
 				CUR_sign varchar(45) COLLATE utf8_bin DEFAULT '$',
140 140
 				CUR_dec_plc varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
141 141
 				CUR_active tinyint(1) DEFAULT '0',
142 142
 				PRIMARY KEY  (CUR_code)";
143
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
144
-        $table_name = 'esp_currency_payment_method';
145
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
143
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
144
+		$table_name = 'esp_currency_payment_method';
145
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
146 146
 				CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
147 147
 				PMD_ID int(11) NOT NULL,
148 148
 				PRIMARY KEY  (CPM_ID)";
149
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
150
-        $table_name = 'esp_datetime';
151
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
149
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
150
+		$table_name = 'esp_datetime';
151
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
152 152
 				  EVT_ID bigint(20) unsigned NOT NULL,
153 153
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
154 154
 				  DTT_description text NOT NULL,
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 						PRIMARY KEY  (DTT_ID),
164 164
 						KEY EVT_ID (EVT_ID),
165 165
 						KEY DTT_is_primary (DTT_is_primary)";
166
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
167
-        $table_name = 'esp_event_meta';
168
-        $sql = "
166
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
167
+		$table_name = 'esp_event_meta';
168
+		$sql = "
169 169
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
170 170
 			EVT_ID bigint(20) unsigned NOT NULL,
171 171
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -180,31 +180,31 @@  discard block
 block discarded – undo
180 180
 			EVT_external_URL varchar(200) NULL,
181 181
 			EVT_donations tinyint(1) NULL,
182 182
 			PRIMARY KEY  (EVTM_ID)";
183
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
184
-        $table_name = 'esp_event_question_group';
185
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
183
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
184
+		$table_name = 'esp_event_question_group';
185
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
186 186
 					EVT_ID bigint(20) unsigned NOT NULL,
187 187
 					QSG_ID int(10) unsigned NOT NULL,
188 188
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
189 189
 					PRIMARY KEY  (EQG_ID)";
190
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
191
-        $table_name = 'esp_event_venue';
192
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
190
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
191
+		$table_name = 'esp_event_venue';
192
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
193 193
 				EVT_ID bigint(20) unsigned NOT NULL,
194 194
 				VNU_ID bigint(20) unsigned NOT NULL,
195 195
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
196 196
 				PRIMARY KEY  (EVV_ID)";
197
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
198
-        $table_name = 'esp_extra_meta';
199
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
197
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
198
+		$table_name = 'esp_extra_meta';
199
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
200 200
 				OBJ_ID int(11) DEFAULT NULL,
201 201
 				EXM_type varchar(45) DEFAULT NULL,
202 202
 				EXM_key varchar(45) DEFAULT NULL,
203 203
 				EXM_value text,
204 204
 				PRIMARY KEY  (EXM_ID)";
205
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
206
-        $table_name = 'esp_line_item';
207
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
205
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
206
+		$table_name = 'esp_line_item';
207
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
208 208
 				LIN_code varchar(245) NOT NULL DEFAULT '',
209 209
 				TXN_ID int(11) DEFAULT NULL,
210 210
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 				OBJ_ID int(11) DEFAULT NULL,
221 221
 				OBJ_type varchar(45)DEFAULT NULL,
222 222
 				PRIMARY KEY  (LIN_ID)";
223
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
224
-        $table_name = 'esp_log';
225
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
223
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
224
+		$table_name = 'esp_log';
225
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
226 226
 				LOG_time datetime DEFAULT NULL,
227 227
 				OBJ_ID varchar(45) DEFAULT NULL,
228 228
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -230,19 +230,19 @@  discard block
 block discarded – undo
230 230
 				LOG_message text,
231 231
 				LOG_wp_user int(11) DEFAULT NULL,
232 232
 				PRIMARY KEY  (LOG_ID)";
233
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
234
-        $table_name = 'esp_message_template';
235
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
233
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
234
+		$table_name = 'esp_message_template';
235
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
236 236
 					GRP_ID int(10) unsigned NOT NULL,
237 237
 					MTP_context varchar(50) NOT NULL,
238 238
 					MTP_template_field varchar(30) NOT NULL,
239 239
 					MTP_content text NOT NULL,
240 240
 					PRIMARY KEY  (MTP_ID),
241 241
 					KEY GRP_ID (GRP_ID)";
242
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
243
-        $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
244
-        $table_name = 'esp_message_template_group';
245
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
242
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
243
+		$this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
244
+		$table_name = 'esp_message_template_group';
245
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
246 246
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
247 247
 					MTP_name varchar(245) NOT NULL DEFAULT '',
248 248
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -254,17 +254,17 @@  discard block
 block discarded – undo
254 254
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
255 255
 					PRIMARY KEY  (GRP_ID),
256 256
 					KEY MTP_user_id (MTP_user_id)";
257
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
258
-        $table_name = 'esp_event_message_template';
259
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
257
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
258
+		$table_name = 'esp_event_message_template';
259
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
260 260
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
261 261
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
262 262
 					PRIMARY KEY  (EMT_ID),
263 263
 					KEY EVT_ID (EVT_ID),
264 264
 					KEY GRP_ID (GRP_ID)";
265
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
266
-        $table_name = 'esp_payment';
267
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
265
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
266
+		$table_name = 'esp_payment';
267
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
268 268
 					TXN_ID int(10) unsigned DEFAULT NULL,
269 269
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
270 270
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
 					PRIMARY KEY  (PAY_ID),
282 282
 					KEY TXN_ID (TXN_ID),
283 283
 					KEY PAY_timestamp (PAY_timestamp)";
284
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
285
-        $table_name = 'esp_payment_method';
286
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
284
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
285
+		$table_name = 'esp_payment_method';
286
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
287 287
 				PMD_type varchar(124) DEFAULT NULL,
288 288
 				PMD_name varchar(255) DEFAULT NULL,
289 289
 				PMD_desc text,
@@ -298,28 +298,28 @@  discard block
 block discarded – undo
298 298
 				PMD_scope varchar(255) NULL DEFAULT 'frontend',
299 299
 				PRIMARY KEY  (PMD_ID),
300 300
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)";
301
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
302
-        $table_name = "esp_ticket_price";
303
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
301
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
302
+		$table_name = "esp_ticket_price";
303
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
304 304
 					  TKT_ID int(10) unsigned NOT NULL,
305 305
 					  PRC_ID int(10) unsigned NOT NULL,
306 306
 					  PRIMARY KEY  (TKP_ID)";
307
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
308
-        $table_name = "esp_datetime_ticket";
309
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
307
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
308
+		$table_name = "esp_datetime_ticket";
309
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
310 310
 					  DTT_ID int(10) unsigned NOT NULL,
311 311
 					  TKT_ID int(10) unsigned NOT NULL,
312 312
 					  PRIMARY KEY  (DTK_ID)";
313
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
314
-        $table_name = "esp_ticket_template";
315
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
313
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
314
+		$table_name = "esp_ticket_template";
315
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
316 316
 					  TTM_name varchar(45) NOT NULL,
317 317
 					  TTM_description text,
318 318
 					  TTM_file varchar(45),
319 319
 					  PRIMARY KEY  (TTM_ID)";
320
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
321
-        $table_name = 'esp_question';
322
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
320
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
321
+		$table_name = 'esp_question';
322
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
323 323
 					QST_display_text text NOT NULL,
324 324
 					QST_admin_label varchar(255) NOT NULL,
325 325
 					QST_system varchar(25) DEFAULT NULL,
@@ -331,25 +331,25 @@  discard block
 block discarded – undo
331 331
 					QST_wp_user bigint(20) unsigned NULL,
332 332
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
333 333
 					PRIMARY KEY  (QST_ID)';
334
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
335
-        $table_name = 'esp_question_group_question';
336
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
334
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
335
+		$table_name = 'esp_question_group_question';
336
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
337 337
 					QSG_ID int(10) unsigned NOT NULL,
338 338
 					QST_ID int(10) unsigned NOT NULL,
339 339
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
340 340
 					PRIMARY KEY  (QGQ_ID) ";
341
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
342
-        $table_name = 'esp_question_option';
343
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
341
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
342
+		$table_name = 'esp_question_option';
343
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
344 344
 					QSO_value varchar(255) NOT NULL,
345 345
 					QSO_desc text NOT NULL,
346 346
 					QST_ID int(10) unsigned NOT NULL,
347 347
 					QSO_order int(10) unsigned NOT NULL DEFAULT 0,
348 348
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
349 349
 					PRIMARY KEY  (QSO_ID)";
350
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
351
-        $table_name = 'esp_registration';
352
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
351
+		$table_name = 'esp_registration';
352
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
353 353
 					  EVT_ID bigint(20) unsigned NOT NULL,
354 354
 					  ATT_ID bigint(20) unsigned NOT NULL,
355 355
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -372,25 +372,25 @@  discard block
 block discarded – undo
372 372
 					  KEY STS_ID (STS_ID),
373 373
 					  KEY REG_url_link (REG_url_link),
374 374
 					  KEY REG_code (REG_code)";
375
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
376
-        $table_name = 'esp_checkin';
377
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
375
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
376
+		$table_name = 'esp_checkin';
377
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
378 378
 					REG_ID int(10) unsigned NOT NULL,
379 379
 					DTT_ID int(10) unsigned NOT NULL,
380 380
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
381 381
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
382 382
 					PRIMARY KEY  (CHK_ID)";
383
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
384
-        $table_name = 'esp_state';
385
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
383
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
384
+		$table_name = 'esp_state';
385
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
386 386
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
387 387
 					  STA_abbrev varchar(24) COLLATE utf8_bin NOT NULL,
388 388
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
389 389
 					  STA_active tinyint(1) DEFAULT '1',
390 390
 					  PRIMARY KEY  (STA_ID)";
391
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
-        $table_name = 'esp_status';
393
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
391
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
+		$table_name = 'esp_status';
393
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
394 394
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
395 395
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
396 396
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -398,9 +398,9 @@  discard block
 block discarded – undo
398 398
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
399 399
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
400 400
 					  KEY STS_type (STS_type)";
401
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
402
-        $table_name = 'esp_transaction';
403
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
401
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
402
+		$table_name = 'esp_transaction';
403
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
404 404
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
405 405
 					  TXN_total decimal(10,3) DEFAULT '0.00',
406 406
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 					  PRIMARY KEY  (TXN_ID),
413 413
 					  KEY TXN_timestamp (TXN_timestamp),
414 414
 					  KEY STS_ID (STS_ID)";
415
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
416
-        $table_name = 'esp_venue_meta';
417
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
415
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
416
+		$table_name = 'esp_venue_meta';
417
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
418 418
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
419 419
 			VNU_address varchar(255) DEFAULT NULL,
420 420
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
 			PRIMARY KEY  (VNUM_ID),
433 433
 			KEY STA_ID (STA_ID),
434 434
 			KEY CNT_ISO (CNT_ISO)";
435
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
436
-        // modified tables
437
-        $table_name = "esp_price";
438
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
435
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
436
+		// modified tables
437
+		$table_name = "esp_price";
438
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
439 439
 					  PRT_ID tinyint(3) unsigned NOT NULL,
440 440
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
441 441
 					  PRC_name varchar(245) NOT NULL,
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 					  PRC_wp_user bigint(20) unsigned NULL,
448 448
 					  PRC_parent int(10) unsigned DEFAULT 0,
449 449
 					  PRIMARY KEY  (PRC_ID)";
450
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
451
-        $table_name = "esp_price_type";
452
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
450
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
451
+		$table_name = "esp_price_type";
452
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
453 453
 				  PRT_name varchar(45) NOT NULL,
454 454
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
455 455
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
459 459
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
460 460
 				  PRIMARY KEY  (PRT_ID)";
461
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
462
-        $table_name = "esp_ticket";
463
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
461
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
462
+		$table_name = "esp_ticket";
463
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
464 464
 					  TTM_ID int(10) unsigned NOT NULL,
465 465
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
466 466
 					  TKT_description text NOT NULL,
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 					  TKT_parent int(10) unsigned DEFAULT '0',
482 482
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
483 483
 					  PRIMARY KEY  (TKT_ID)";
484
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
485
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
486
-        $table_name = 'esp_question_group';
487
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
484
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
485
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
486
+		$table_name = 'esp_question_group';
487
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
488 488
 					QSG_name varchar(255) NOT NULL,
489 489
 					QSG_identifier varchar(100) NOT NULL,
490 490
 					QSG_desc text NULL,
@@ -496,124 +496,124 @@  discard block
 block discarded – undo
496 496
 					QSG_wp_user bigint(20) unsigned NULL,
497 497
 					PRIMARY KEY  (QSG_ID),
498 498
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
499
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
500
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
501
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
502
-        // (because many need to convert old string states to foreign keys into the states table)
503
-        $script_4_1_defaults->insert_default_states();
504
-        $script_4_1_defaults->insert_default_countries();
505
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
506
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
507
-        $script_4_5_defaults->insert_default_price_types();
508
-        $script_4_5_defaults->insert_default_prices();
509
-        $script_4_5_defaults->insert_default_tickets();
510
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here
511
-        EE_Config::instance()->update_espresso_config(false, true);
512
-        $this->add_default_admin_only_payments();
513
-        $this->insert_default_currencies();
514
-        return true;
515
-    }
499
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
500
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
501
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
502
+		// (because many need to convert old string states to foreign keys into the states table)
503
+		$script_4_1_defaults->insert_default_states();
504
+		$script_4_1_defaults->insert_default_countries();
505
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
506
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
507
+		$script_4_5_defaults->insert_default_price_types();
508
+		$script_4_5_defaults->insert_default_prices();
509
+		$script_4_5_defaults->insert_default_tickets();
510
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen here
511
+		EE_Config::instance()->update_espresso_config(false, true);
512
+		$this->add_default_admin_only_payments();
513
+		$this->insert_default_currencies();
514
+		return true;
515
+	}
516 516
 
517 517
 
518 518
 
519
-    /**
520
-     * @return boolean
521
-     */
522
-    public function schema_changes_after_migration()
523
-    {
524
-        return true;
525
-    }
519
+	/**
520
+	 * @return boolean
521
+	 */
522
+	public function schema_changes_after_migration()
523
+	{
524
+		return true;
525
+	}
526 526
 
527 527
 
528 528
 
529
-    public function migration_page_hooks()
530
-    {
531
-    }
529
+	public function migration_page_hooks()
530
+	{
531
+	}
532 532
 
533 533
 
534 534
 
535
-    public function add_default_admin_only_payments()
536
-    {
537
-        global $wpdb;
538
-        $table_name = $wpdb->prefix . "esp_payment_method";
539
-        $user_id = EEH_Activation::get_default_creator_id();
540
-        if ($this->_get_table_analysis()->tableExists($table_name)) {
541
-            $SQL = "SELECT COUNT( * ) FROM $table_name";
542
-            $existing_payment_methods = $wpdb->get_var($SQL);
543
-            $default_admin_only_payment_methods = apply_filters(
544
-                'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods',
545
-                array(
546
-                    (string) __("Bank", 'event_espresso')        => __("Bank Draft", 'event_espresso'),
547
-                    (string) __("Cash", 'event_espresso')        => __("Cash Delivered Physically", 'event_espresso'),
548
-                    (string) __("Check", 'event_espresso')       => __("Paper Check", 'event_espresso'),
549
-                    (string) __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'),
550
-                    (string) __("Debit Card", 'event_espresso')  => __("Offline Debit Payment", 'event_espresso'),
551
-                    (string) __("Invoice", 'event_espresso')     => __(
552
-                        "Invoice received with monies included",
553
-                        'event_espresso'
554
-                    ),
555
-                    (string) __("Money Order", 'event_espresso') => '',
556
-                    (string) __("Paypal", 'event_espresso')      => __("Paypal eCheck, Invoice, etc", 'event_espresso'),
557
-                    (string) __('Other', 'event_espresso')       => __('Other method of payment', 'event_espresso'),
558
-                )
559
-            );
560
-            // make sure we hae payment method records for the following
561
-            // so admins can record payments for them from the admin page
562
-            foreach ($default_admin_only_payment_methods as $nicename => $description) {
563
-                $slug = sanitize_key($nicename);
564
-                // check that such a payment method exists
565
-                $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
566
-                if (! $exists) {
567
-                    $values = array(
568
-                        'PMD_type'       => 'Admin_Only',
569
-                        'PMD_name'       => $nicename,
570
-                        'PMD_admin_name' => $nicename,
571
-                        'PMD_admin_desc' => $description,
572
-                        'PMD_slug'       => $slug,
573
-                        'PMD_wp_user'    => $user_id,
574
-                        'PMD_scope'      => serialize(array('ADMIN')),
575
-                    );
576
-                    $success = $wpdb->insert(
577
-                        $table_name,
578
-                        $values,
579
-                        array(
580
-                            '%s',// PMD_type
581
-                            '%s',// PMD_name
582
-                            '%s',// PMD_admin_name
583
-                            '%s',// PMD_admin_desc
584
-                            '%s',// PMD_slug
585
-                            '%d',// PMD_wp_user
586
-                            '%s',// PMD_scope
587
-                        )
588
-                    );
589
-                    if (! $success) {
590
-                        $this->add_error(sprintf(__(
591
-                            "Could not insert new admin-only payment method with values %s during migration",
592
-                            "event_espresso"
593
-                        ), $this->_json_encode($values)));
594
-                    }
595
-                }
596
-            }
597
-        }
598
-    }
535
+	public function add_default_admin_only_payments()
536
+	{
537
+		global $wpdb;
538
+		$table_name = $wpdb->prefix . "esp_payment_method";
539
+		$user_id = EEH_Activation::get_default_creator_id();
540
+		if ($this->_get_table_analysis()->tableExists($table_name)) {
541
+			$SQL = "SELECT COUNT( * ) FROM $table_name";
542
+			$existing_payment_methods = $wpdb->get_var($SQL);
543
+			$default_admin_only_payment_methods = apply_filters(
544
+				'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods',
545
+				array(
546
+					(string) __("Bank", 'event_espresso')        => __("Bank Draft", 'event_espresso'),
547
+					(string) __("Cash", 'event_espresso')        => __("Cash Delivered Physically", 'event_espresso'),
548
+					(string) __("Check", 'event_espresso')       => __("Paper Check", 'event_espresso'),
549
+					(string) __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'),
550
+					(string) __("Debit Card", 'event_espresso')  => __("Offline Debit Payment", 'event_espresso'),
551
+					(string) __("Invoice", 'event_espresso')     => __(
552
+						"Invoice received with monies included",
553
+						'event_espresso'
554
+					),
555
+					(string) __("Money Order", 'event_espresso') => '',
556
+					(string) __("Paypal", 'event_espresso')      => __("Paypal eCheck, Invoice, etc", 'event_espresso'),
557
+					(string) __('Other', 'event_espresso')       => __('Other method of payment', 'event_espresso'),
558
+				)
559
+			);
560
+			// make sure we hae payment method records for the following
561
+			// so admins can record payments for them from the admin page
562
+			foreach ($default_admin_only_payment_methods as $nicename => $description) {
563
+				$slug = sanitize_key($nicename);
564
+				// check that such a payment method exists
565
+				$exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
566
+				if (! $exists) {
567
+					$values = array(
568
+						'PMD_type'       => 'Admin_Only',
569
+						'PMD_name'       => $nicename,
570
+						'PMD_admin_name' => $nicename,
571
+						'PMD_admin_desc' => $description,
572
+						'PMD_slug'       => $slug,
573
+						'PMD_wp_user'    => $user_id,
574
+						'PMD_scope'      => serialize(array('ADMIN')),
575
+					);
576
+					$success = $wpdb->insert(
577
+						$table_name,
578
+						$values,
579
+						array(
580
+							'%s',// PMD_type
581
+							'%s',// PMD_name
582
+							'%s',// PMD_admin_name
583
+							'%s',// PMD_admin_desc
584
+							'%s',// PMD_slug
585
+							'%d',// PMD_wp_user
586
+							'%s',// PMD_scope
587
+						)
588
+					);
589
+					if (! $success) {
590
+						$this->add_error(sprintf(__(
591
+							"Could not insert new admin-only payment method with values %s during migration",
592
+							"event_espresso"
593
+						), $this->_json_encode($values)));
594
+					}
595
+				}
596
+			}
597
+		}
598
+	}
599 599
 
600 600
 
601 601
 
602
-    /**
603
-     * insert_default_countries
604
-     *
605
-     * @static
606
-     * @return void
607
-     */
608
-    public function insert_default_currencies()
609
-    {
610
-        global $wpdb;
611
-        $currency_table = $wpdb->prefix . "esp_currency";
612
-        if ($this->_get_table_analysis()->tableExists($currency_table)) {
613
-            $SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
614
-            $countries = $wpdb->get_var($SQL);
615
-            if (! $countries) {
616
-                $SQL = "INSERT INTO $currency_table
602
+	/**
603
+	 * insert_default_countries
604
+	 *
605
+	 * @static
606
+	 * @return void
607
+	 */
608
+	public function insert_default_currencies()
609
+	{
610
+		global $wpdb;
611
+		$currency_table = $wpdb->prefix . "esp_currency";
612
+		if ($this->_get_table_analysis()->tableExists($currency_table)) {
613
+			$SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
614
+			$countries = $wpdb->get_var($SQL);
615
+			if (! $countries) {
616
+				$SQL = "INSERT INTO $currency_table
617 617
 				( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES
618 618
 				( 'EUR',  'Euro',  'Euros',  '€',  2,1),
619 619
 				( 'AED',  'Dirham',  'Dirhams', 'د.إ',2,1),
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
 				( 'ZAR',  'Rand',  'Rands',  'R',  2,1),
768 768
 				( 'ZMK',  'Kwacha',  'Kwachas',  '',  2,1),
769 769
 				( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);";
770
-                $wpdb->query($SQL);
771
-            }
772
-        }
773
-    }
770
+				$wpdb->query($SQL);
771
+			}
772
+		}
773
+	}
774 774
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 // unfortunately, this needs to be done upon INCLUSION of this file,
12 12
 // instead of construction, because it only gets constructed on first page load
13 13
 // (all other times it gets resurrected from a wordpress option)
14
-$stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*');
14
+$stages = glob(EE_CORE.'data_migration_scripts/4_6_0_stages/*');
15 15
 $class_to_filepath = array();
16 16
 foreach ($stages as $filepath) {
17 17
     $matches = array();
18 18
     preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19
-    $class_to_filepath[ $matches[1] ] = $filepath;
19
+    $class_to_filepath[$matches[1]] = $filepath;
20 20
 }
21 21
 // give addons a chance to autoload their stages too
22 22
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath);
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
         if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) {
71 71
 //          echo "$version_string can be migrated from";
72 72
             return true;
73
-        } elseif (! $version_string) {
73
+        } elseif ( ! $version_string) {
74 74
 //          echo "no version string provided: $version_string";
75 75
             // no version string provided... this must be pre 4.3
76
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
76
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
77 77
         } else {
78 78
 //          echo "$version_string doesnt apply";
79 79
             return false;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     public function schema_changes_before_migration()
89 89
     {
90 90
         // relies on 4.1's EEH_Activation::create_table
91
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
91
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
92 92
         $table_name = 'esp_answer';
93 93
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
94 94
 					REG_ID int(10) unsigned NOT NULL,
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     public function add_default_admin_only_payments()
536 536
     {
537 537
         global $wpdb;
538
-        $table_name = $wpdb->prefix . "esp_payment_method";
538
+        $table_name = $wpdb->prefix."esp_payment_method";
539 539
         $user_id = EEH_Activation::get_default_creator_id();
540 540
         if ($this->_get_table_analysis()->tableExists($table_name)) {
541 541
             $SQL = "SELECT COUNT( * ) FROM $table_name";
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
                 $slug = sanitize_key($nicename);
564 564
                 // check that such a payment method exists
565 565
                 $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
566
-                if (! $exists) {
566
+                if ( ! $exists) {
567 567
                     $values = array(
568 568
                         'PMD_type'       => 'Admin_Only',
569 569
                         'PMD_name'       => $nicename,
@@ -577,16 +577,16 @@  discard block
 block discarded – undo
577 577
                         $table_name,
578 578
                         $values,
579 579
                         array(
580
-                            '%s',// PMD_type
581
-                            '%s',// PMD_name
582
-                            '%s',// PMD_admin_name
583
-                            '%s',// PMD_admin_desc
584
-                            '%s',// PMD_slug
585
-                            '%d',// PMD_wp_user
586
-                            '%s',// PMD_scope
580
+                            '%s', // PMD_type
581
+                            '%s', // PMD_name
582
+                            '%s', // PMD_admin_name
583
+                            '%s', // PMD_admin_desc
584
+                            '%s', // PMD_slug
585
+                            '%d', // PMD_wp_user
586
+                            '%s', // PMD_scope
587 587
                         )
588 588
                     );
589
-                    if (! $success) {
589
+                    if ( ! $success) {
590 590
                         $this->add_error(sprintf(__(
591 591
                             "Could not insert new admin-only payment method with values %s during migration",
592 592
                             "event_espresso"
@@ -608,11 +608,11 @@  discard block
 block discarded – undo
608 608
     public function insert_default_currencies()
609 609
     {
610 610
         global $wpdb;
611
-        $currency_table = $wpdb->prefix . "esp_currency";
611
+        $currency_table = $wpdb->prefix."esp_currency";
612 612
         if ($this->_get_table_analysis()->tableExists($currency_table)) {
613 613
             $SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
614 614
             $countries = $wpdb->get_var($SQL);
615
-            if (! $countries) {
615
+            if ( ! $countries) {
616 616
                 $SQL = "INSERT INTO $currency_table
617 617
 				( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES
618 618
 				( 'EUR',  'Euro',  'Euros',  '€',  2,1),
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_2_0.dms.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 $stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*');
16 16
 $class_to_filepath = array();
17 17
 if (! empty($stages)) {
18
-    foreach ($stages as $filepath) {
19
-        $matches = array();
20
-        preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
-        $class_to_filepath[ $matches[1] ] = $filepath;
22
-    }
18
+	foreach ($stages as $filepath) {
19
+		$matches = array();
20
+		preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
+		$class_to_filepath[ $matches[1] ] = $filepath;
22
+	}
23 23
 }
24 24
 // give addons a chance to autoload their stages too
25 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_2_0__autoloaded_stages', $class_to_filepath);
@@ -32,57 +32,57 @@  discard block
 block discarded – undo
32 32
 
33 33
 
34 34
 
35
-    /**
36
-     * EE_DMS_Core_4_2_0 constructor.
37
-     *
38
-     * @param TableManager  $table_manager
39
-     * @param TableAnalysis $table_analysis
40
-     */
41
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
42
-    {
43
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso");
44
-        $this->_priority = 10;
45
-        $this->_migration_stages = array(
46
-            new EE_DMS_4_2_0_question_group_questions(),
47
-            new EE_DMS_4_2_0_datetime_fields(),
48
-        );
49
-        parent::__construct($table_manager, $table_analysis);
50
-    }
35
+	/**
36
+	 * EE_DMS_Core_4_2_0 constructor.
37
+	 *
38
+	 * @param TableManager  $table_manager
39
+	 * @param TableAnalysis $table_analysis
40
+	 */
41
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
42
+	{
43
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso");
44
+		$this->_priority = 10;
45
+		$this->_migration_stages = array(
46
+			new EE_DMS_4_2_0_question_group_questions(),
47
+			new EE_DMS_4_2_0_datetime_fields(),
48
+		);
49
+		parent::__construct($table_manager, $table_analysis);
50
+	}
51 51
 
52 52
 
53 53
 
54
-    public function can_migrate_from_version($version_array)
55
-    {
56
-        $version_string = $version_array['Core'];
57
-        if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) {
54
+	public function can_migrate_from_version($version_array)
55
+	{
56
+		$version_string = $version_array['Core'];
57
+		if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) {
58 58
 //          echo "$version_string can be migrated fro";
59
-            return true;
60
-        } elseif (! $version_string) {
59
+			return true;
60
+		} elseif (! $version_string) {
61 61
 //          echo "no version string provided: $version_string";
62
-            // no version string provided... this must be pre 4.1
63
-            // because since 4.1 we're
64
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
65
-        } else {
62
+			// no version string provided... this must be pre 4.1
63
+			// because since 4.1 we're
64
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
65
+		} else {
66 66
 //          echo "$version_string doesnt apply";
67
-            return false;
68
-        }
69
-    }
67
+			return false;
68
+		}
69
+	}
70 70
 
71 71
 
72 72
 
73
-    public function schema_changes_before_migration()
74
-    {
75
-        // relies on 4.1's EEH_Activation::create_table
76
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
77
-        $table_name = 'esp_answer';
78
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
73
+	public function schema_changes_before_migration()
74
+	{
75
+		// relies on 4.1's EEH_Activation::create_table
76
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
77
+		$table_name = 'esp_answer';
78
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
79 79
 					REG_ID int(10) unsigned NOT NULL,
80 80
 					QST_ID int(10) unsigned NOT NULL,
81 81
 					ANS_value text NOT NULL,
82 82
 					PRIMARY KEY  (ANS_ID)";
83
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
84
-        $table_name = 'esp_attendee_meta';
85
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
83
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
84
+		$table_name = 'esp_attendee_meta';
85
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
86 86
 						ATT_ID bigint(20) unsigned NOT NULL,
87 87
 						ATT_fname varchar(45) NOT NULL,
88 88
 						ATT_lname varchar(45) NOT	NULL,
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 								KEY ATT_fname (ATT_fname),
99 99
 								KEY ATT_lname (ATT_lname),
100 100
 								KEY ATT_email (ATT_email(191))";
101
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
102
-        $table_name = 'esp_country';
103
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
101
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
102
+		$table_name = 'esp_country';
103
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
104 104
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
105 105
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
106 106
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 					  CNT_is_EU tinyint(1) DEFAULT '0',
117 117
 					  CNT_active tinyint(1) DEFAULT '0',
118 118
 					  PRIMARY KEY  (CNT_ISO)";
119
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
120
-        $table_name = 'esp_datetime';
121
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
119
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
120
+		$table_name = 'esp_datetime';
121
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
122 122
 				  EVT_ID bigint(20) unsigned NOT NULL,
123 123
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
124 124
 				  DTT_description text NOT NULL,
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 						PRIMARY KEY  (DTT_ID),
134 134
 						KEY EVT_ID (EVT_ID),
135 135
 						KEY DTT_is_primary (DTT_is_primary)";
136
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
137
-        $table_name = 'esp_event_meta';
138
-        $sql = "
136
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
137
+		$table_name = 'esp_event_meta';
138
+		$sql = "
139 139
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
140 140
 			EVT_ID bigint(20) unsigned NOT NULL,
141 141
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -150,31 +150,31 @@  discard block
 block discarded – undo
150 150
 			EVT_external_URL varchar(200) NULL,
151 151
 			EVT_donations tinyint(1) NULL,
152 152
 			PRIMARY KEY  (EVTM_ID)";
153
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
154
-        $table_name = 'esp_event_question_group';
155
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
153
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
154
+		$table_name = 'esp_event_question_group';
155
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
156 156
 					EVT_ID bigint(20) unsigned NOT NULL,
157 157
 					QSG_ID int(10) unsigned NOT NULL,
158 158
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
159 159
 					PRIMARY KEY  (EQG_ID)";
160
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
161
-        $table_name = 'esp_event_venue';
162
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
160
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
161
+		$table_name = 'esp_event_venue';
162
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
163 163
 				EVT_ID bigint(20) unsigned NOT NULL,
164 164
 				VNU_ID bigint(20) unsigned NOT NULL,
165 165
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
166 166
 				PRIMARY KEY  (EVV_ID)";
167
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
168
-        $table_name = 'esp_extra_meta';
169
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
167
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
168
+		$table_name = 'esp_extra_meta';
169
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
170 170
 				OBJ_ID int(11) DEFAULT NULL,
171 171
 				EXM_type varchar(45) DEFAULT NULL,
172 172
 				EXM_key varchar(45) DEFAULT NULL,
173 173
 				EXM_value text,
174 174
 				PRIMARY KEY  (EXM_ID)";
175
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
176
-        $table_name = 'esp_line_item';
177
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
175
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
176
+		$table_name = 'esp_line_item';
177
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
178 178
 				LIN_code varchar(245) NOT NULL DEFAULT '',
179 179
 				TXN_ID int(11) DEFAULT NULL,
180 180
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -190,18 +190,18 @@  discard block
 block discarded – undo
190 190
 				OBJ_ID int(11) DEFAULT NULL,
191 191
 				OBJ_type varchar(45)DEFAULT NULL,
192 192
 				PRIMARY KEY  (LIN_ID)";
193
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
194
-        $table_name = 'esp_message_template';
195
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
193
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
194
+		$table_name = 'esp_message_template';
195
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
196 196
 					GRP_ID int(10) unsigned NOT NULL,
197 197
 					MTP_context varchar(50) NOT NULL,
198 198
 					MTP_template_field varchar(30) NOT NULL,
199 199
 					MTP_content text NOT NULL,
200 200
 					PRIMARY KEY  (MTP_ID),
201 201
 					KEY GRP_ID (GRP_ID)";
202
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
203
-        $table_name = 'esp_message_template_group';
204
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
202
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
203
+		$table_name = 'esp_message_template_group';
204
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
205 205
 					EVT_ID bigint(20) unsigned DEFAULT NULL,
206 206
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
207 207
 					MTP_messenger varchar(30) NOT NULL,
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 					PRIMARY KEY  (GRP_ID),
214 214
 					KEY EVT_ID (EVT_ID),
215 215
 					KEY MTP_user_id (MTP_user_id)";
216
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
217
-        $table_name = 'esp_payment';
218
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
216
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
217
+		$table_name = 'esp_payment';
218
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
219 219
 					TXN_ID int(10) unsigned DEFAULT NULL,
220 220
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
221 221
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 					PRIMARY KEY  (PAY_ID),
232 232
 					KEY TXN_ID (TXN_ID),
233 233
 					KEY PAY_timestamp (PAY_timestamp)";
234
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
235
-        $table_name = "esp_ticket";
236
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
234
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
235
+		$table_name = "esp_ticket";
236
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
237 237
 					  TTM_ID int(10) unsigned NOT NULL,
238 238
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
239 239
 					  TKT_description text NOT NULL,
@@ -252,28 +252,28 @@  discard block
 block discarded – undo
252 252
 					  TKT_parent int(10) unsigned DEFAULT '0',
253 253
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
254 254
 					  PRIMARY KEY  (TKT_ID)";
255
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
256
-        $table_name = "esp_ticket_price";
257
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
255
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
256
+		$table_name = "esp_ticket_price";
257
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
258 258
 					  TKT_ID int(10) unsigned NOT NULL,
259 259
 					  PRC_ID int(10) unsigned NOT NULL,
260 260
 					  PRIMARY KEY  (TKP_ID)";
261
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
262
-        $table_name = "esp_datetime_ticket";
263
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
261
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
262
+		$table_name = "esp_datetime_ticket";
263
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
264 264
 					  DTT_ID int(10) unsigned NOT NULL,
265 265
 					  TKT_ID int(10) unsigned NOT NULL,
266 266
 					  PRIMARY KEY  (DTK_ID)";
267
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
268
-        $table_name = "esp_ticket_template";
269
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
267
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
268
+		$table_name = "esp_ticket_template";
269
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
270 270
 					  TTM_name varchar(45) NOT NULL,
271 271
 					  TTM_description text,
272 272
 					  TTM_file varchar(45),
273 273
 					  PRIMARY KEY  (TTM_ID)";
274
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
275
-        $table_name = "esp_price";
276
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
274
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
275
+		$table_name = "esp_price";
276
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
277 277
 					  PRT_ID tinyint(3) unsigned NOT NULL,
278 278
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
279 279
 					  PRC_name varchar(245) NOT NULL,
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 					  PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0',
285 285
 					  PRC_parent int(10) unsigned DEFAULT 0,
286 286
 					  PRIMARY KEY  (PRC_ID)";
287
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
288
-        $table_name = "esp_price_type";
289
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
287
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
288
+		$table_name = "esp_price_type";
289
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
290 290
 				  PRT_name varchar(45) NOT NULL,
291 291
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
292 292
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
295 295
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
296 296
 				  PRIMARY KEY  (PRT_ID)";
297
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
298
-        $table_name = 'esp_question';
299
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
297
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
298
+		$table_name = 'esp_question';
299
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
300 300
 					QST_display_text text NOT NULL,
301 301
 					QST_admin_label varchar(255) NOT NULL,
302 302
 					QST_system varchar(25) DEFAULT NULL,
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 					QST_wp_user bigint(20) unsigned NULL,
309 309
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
310 310
 					PRIMARY KEY  (QST_ID)';
311
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
312
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
313
-        $table_name = 'esp_question_group';
314
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
311
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
312
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
313
+		$table_name = 'esp_question_group';
314
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
315 315
 					QSG_name varchar(255) NOT NULL,
316 316
 					QSG_identifier varchar(100) NOT NULL,
317 317
 					QSG_desc text NULL,
@@ -322,24 +322,24 @@  discard block
 block discarded – undo
322 322
 					QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
323 323
 					PRIMARY KEY  (QSG_ID),
324 324
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
325
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
326
-        $table_name = 'esp_question_group_question';
327
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
325
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
326
+		$table_name = 'esp_question_group_question';
327
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
328 328
 					QSG_ID int(10) unsigned NOT NULL,
329 329
 					QST_ID int(10) unsigned NOT NULL,
330 330
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
331 331
 					PRIMARY KEY  (QGQ_ID) ";
332
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
333
-        $table_name = 'esp_question_option';
334
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
332
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
333
+		$table_name = 'esp_question_option';
334
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
335 335
 					QSO_value varchar(255) NOT NULL,
336 336
 					QSO_desc text NOT NULL,
337 337
 					QST_ID int(10) unsigned NOT NULL,
338 338
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
339 339
 					PRIMARY KEY  (QSO_ID)";
340
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
-        $table_name = 'esp_registration';
342
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
340
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
+		$table_name = 'esp_registration';
342
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343 343
 					  EVT_ID bigint(20) unsigned NOT NULL,
344 344
 					  ATT_ID bigint(20) unsigned NOT NULL,
345 345
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -362,25 +362,25 @@  discard block
 block discarded – undo
362 362
 					  KEY STS_ID (STS_ID),
363 363
 					  KEY REG_url_link (REG_url_link),
364 364
 					  KEY REG_code (REG_code)";
365
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
366
-        $table_name = 'esp_checkin';
367
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
365
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
366
+		$table_name = 'esp_checkin';
367
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
368 368
 					REG_ID int(10) unsigned NOT NULL,
369 369
 					DTT_ID int(10) unsigned NOT NULL,
370 370
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
371 371
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
372 372
 					PRIMARY KEY  (CHK_ID)";
373
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
374
-        $table_name = 'esp_state';
375
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
373
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
374
+		$table_name = 'esp_state';
375
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
376 376
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
377 377
 					  STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL,
378 378
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
379 379
 					  STA_active tinyint(1) DEFAULT '1',
380 380
 					  PRIMARY KEY  (STA_ID)";
381
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
382
-        $table_name = 'esp_status';
383
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
381
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
382
+		$table_name = 'esp_status';
383
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
384 384
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
385 385
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
386 386
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
389 389
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
390 390
 					  KEY STS_type (STS_type)";
391
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
-        $table_name = 'esp_transaction';
393
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
391
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
+		$table_name = 'esp_transaction';
393
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
394 394
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
395 395
 					  TXN_total decimal(10,3) DEFAULT '0.00',
396 396
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 					  PRIMARY KEY  (TXN_ID),
401 401
 					  KEY TXN_timestamp (TXN_timestamp),
402 402
 					  KEY STS_ID (STS_ID)";
403
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
404
-        $table_name = 'esp_venue_meta';
405
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
403
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
404
+		$table_name = 'esp_venue_meta';
405
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
406 406
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
407 407
 			VNU_address varchar(255) DEFAULT NULL,
408 408
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -420,36 +420,36 @@  discard block
 block discarded – undo
420 420
 			PRIMARY KEY  (VNUM_ID),
421 421
 			KEY STA_ID (STA_ID),
422 422
 			KEY CNT_ISO (CNT_ISO)";
423
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
424
-        $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
425
-        // setting up the DEFAULT stats and countries is also essential for the data migrations to run
426
-        // (because many need to convert old string states to foreign keys into the states table)
427
-        $script_with_defaults->insert_default_states();
428
-        $script_with_defaults->insert_default_countries();
429
-        // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
430
-        $script_with_defaults->insert_default_price_types();
431
-        $script_with_defaults->insert_default_prices();
432
-        $script_with_defaults->insert_default_tickets();
433
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
434
-        EE_Config::instance()->update_espresso_config(false, true);
435
-        return true;
436
-    }
423
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
424
+		$script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
425
+		// setting up the DEFAULT stats and countries is also essential for the data migrations to run
426
+		// (because many need to convert old string states to foreign keys into the states table)
427
+		$script_with_defaults->insert_default_states();
428
+		$script_with_defaults->insert_default_countries();
429
+		// setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
430
+		$script_with_defaults->insert_default_price_types();
431
+		$script_with_defaults->insert_default_prices();
432
+		$script_with_defaults->insert_default_tickets();
433
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
434
+		EE_Config::instance()->update_espresso_config(false, true);
435
+		return true;
436
+	}
437 437
 
438 438
 
439 439
 
440
-    /**
441
-     * We COULD clean up the esp_question.QST_order field here. We'll leave it for now
442
-     *
443
-     * @return boolean
444
-     */
445
-    public function schema_changes_after_migration()
446
-    {
447
-        return true;
448
-    }
440
+	/**
441
+	 * We COULD clean up the esp_question.QST_order field here. We'll leave it for now
442
+	 *
443
+	 * @return boolean
444
+	 */
445
+	public function schema_changes_after_migration()
446
+	{
447
+		return true;
448
+	}
449 449
 
450 450
 
451 451
 
452
-    public function migration_page_hooks()
453
-    {
454
-    }
452
+	public function migration_page_hooks()
453
+	{
454
+	}
455 455
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
 // unfortunately, this needs to be done upon INCLUSION of this file,
13 13
 // instead of construction, because it only gets constructed on first page load
14 14
 // (all other times it gets resurrected from a wordpress option)
15
-$stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*');
15
+$stages = glob(EE_CORE.'data_migration_scripts/4_2_0_stages/*');
16 16
 $class_to_filepath = array();
17
-if (! empty($stages)) {
17
+if ( ! empty($stages)) {
18 18
     foreach ($stages as $filepath) {
19 19
         $matches = array();
20 20
         preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
-        $class_to_filepath[ $matches[1] ] = $filepath;
21
+        $class_to_filepath[$matches[1]] = $filepath;
22 22
     }
23 23
 }
24 24
 // give addons a chance to autoload their stages too
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
         if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) {
58 58
 //          echo "$version_string can be migrated fro";
59 59
             return true;
60
-        } elseif (! $version_string) {
60
+        } elseif ( ! $version_string) {
61 61
 //          echo "no version string provided: $version_string";
62 62
             // no version string provided... this must be pre 4.1
63 63
             // because since 4.1 we're
64
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
64
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
65 65
         } else {
66 66
 //          echo "$version_string doesnt apply";
67 67
             return false;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function schema_changes_before_migration()
74 74
     {
75 75
         // relies on 4.1's EEH_Activation::create_table
76
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
76
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
77 77
         $table_name = 'esp_answer';
78 78
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
79 79
 					REG_ID int(10) unsigned NOT NULL,
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorRow.php 1 patch
Indentation   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -18,373 +18,373 @@
 block discarded – undo
18 18
 abstract class TicketSelectorRow
19 19
 {
20 20
 
21
-    /**
22
-     * @var EE_Ticket $ticket
23
-     */
24
-    protected $ticket;
25
-
26
-    /**
27
-     * @var int $total_tickets
28
-     */
29
-    protected $total_tickets;
30
-
31
-    /**
32
-     * @var int $max_attendees
33
-     */
34
-    protected $max_attendees;
35
-
36
-    /**
37
-     * @var string $date_format
38
-     */
39
-    protected $date_format;
40
-
41
-    /**
42
-     * @var int $EVT_ID
43
-     */
44
-    protected $EVT_ID;
45
-
46
-    /**
47
-     * @var string $event_status
48
-     */
49
-    protected $event_status;
50
-
51
-    /**
52
-     * @var boolean $required_ticket_sold_out
53
-     */
54
-    protected $required_ticket_sold_out;
55
-
56
-    /**
57
-     * @var string $ticket_status_display
58
-     */
59
-    protected $ticket_status_display;
60
-
61
-    /**
62
-     * @var int $max
63
-     */
64
-    protected $max = 0;
65
-
66
-    /**
67
-     * @var int $min
68
-     */
69
-    protected $min = 0;
70
-
71
-    /**
72
-     * @var float $ticket_price
73
-     */
74
-    protected $ticket_price = 0.00;
75
-
76
-    /**
77
-     * @var bool $ticket_bundle
78
-     */
79
-    protected $ticket_bundle = false;
80
-
81
-    /**
82
-     * @var string $ticket_status_id
83
-     */
84
-    protected $ticket_status_id = EE_Ticket::sold_out;
85
-
86
-    /**
87
-     * @var string $ticket_status_html
88
-     */
89
-    protected $ticket_status_html = 'ticket-sales-sold-out';
90
-
91
-    /**
92
-     * @var string $status_class
93
-     */
94
-    protected $status_class = 'ticket-sales-sold-out lt-grey-text';
95
-
96
-
97
-    /**
98
-     * @param EE_Ticket $ticket
99
-     * @param int       $max_attendees
100
-     * @param string    $date_format
101
-     * @param string    $event_status
102
-     * @param bool      $required_ticket_sold_out
103
-     * @param int       $total_tickets
104
-     * @throws EE_Error
105
-     * @throws UnexpectedEntityException
106
-     */
107
-    public function __construct(
108
-        EE_Ticket $ticket,
109
-        $max_attendees,
110
-        $date_format,
111
-        $event_status,
112
-        $required_ticket_sold_out = false,
113
-        $total_tickets = 1
114
-    ) {
115
-        $this->ticket = $ticket;
116
-        $this->max_attendees = $max_attendees;
117
-        $this->date_format = $date_format;
118
-        $this->EVT_ID = $this->ticket->get_event_ID();
119
-        $this->event_status = $event_status;
120
-        $this->required_ticket_sold_out = $required_ticket_sold_out;
121
-        $this->total_tickets = $total_tickets;
122
-    }
123
-
124
-
125
-    /**
126
-     * getTicketStatusClasses
127
-     *
128
-     * @param int $remaining
129
-     * @return void
130
-     * @throws EE_Error
131
-     */
132
-    protected function setTicketStatusClasses($remaining = 0)
133
-    {
134
-        // if a previous required ticket with the same sale start date is sold out,
135
-        // then mark this ticket as sold out as well.
136
-        // tickets that go on sale at a later date than the required ticket  will NOT be affected
137
-        $this->ticket_status_id = $this->required_ticket_sold_out !== false
138
-                                  && $this->required_ticket_sold_out === $this->ticket->start_date()
139
-            ? EE_Ticket::sold_out
140
-            : $this->ticket->ticket_status();
141
-        $this->ticket_status_id = $this->event_status === EE_Datetime::sold_out
142
-            ? EE_Ticket::sold_out
143
-            : $this->ticket_status_id;
144
-        // If at admin area, display expired tickets as on sale.
145
-        $this->ticket_status_id = is_admin() && $this->ticket_status_id === EE_Ticket::expired
146
-            ? EE_Ticket::onsale
147
-            : $this->ticket_status_id;
148
-        // check ticket status
149
-        switch ($this->ticket_status_id) {
150
-            // sold_out
151
-            case EE_Ticket::sold_out:
152
-                $ticket_status_class = 'ticket-sales-sold-out';
153
-                $this->status_class = 'ticket-sales-sold-out lt-grey-text';
154
-                break;
155
-            // expired
156
-            case EE_Ticket::expired:
157
-                $ticket_status_class = 'ticket-sales-expired';
158
-                $this->status_class = 'ticket-sales-expired lt-grey-text';
159
-                break;
160
-            // archived
161
-            case EE_Ticket::archived:
162
-                $ticket_status_class = 'archived-ticket';
163
-                $this->status_class = 'archived-ticket hidden';
164
-                break;
165
-            // pending
166
-            case EE_Ticket::pending:
167
-                $ticket_status_class = 'ticket-pending';
168
-                $this->status_class = 'ticket-pending';
169
-                break;
170
-            // on sale
171
-            case EE_Ticket::onsale:
172
-            default:
173
-                $ticket_status_class = 'ticket-on-sale';
174
-                $this->status_class = 'ticket-on-sale';
175
-                break;
176
-        }
177
-        $this->ticket_status_html = EEH_HTML::span(
178
-            $this->ticket->ticket_status(true, ($remaining > 0)),
179
-            "{$ticket_status_class}-{$this->ticket->ID()}",
180
-            $ticket_status_class
181
-        );
182
-    }
183
-
184
-
185
-    /**
186
-     * @return string
187
-     */
188
-    public function getTicketStatusDisplay()
189
-    {
190
-        return $this->ticket_status_display;
191
-    }
192
-
193
-
194
-    /**
195
-     * setTicketStatusDisplay
196
-     *
197
-     * @param int $remaining
198
-     * @throws EE_Error
199
-     */
200
-    protected function setTicketStatusDisplay($remaining)
201
-    {
202
-        $this->ticket_status_display = '';
203
-
204
-        // now depending on the ticket and other circumstances...
205
-        if ($this->max_attendees === 0) {
206
-            // registration is CLOSED because admin set max attendees to ZERO
207
-            $this->ticket_status_display = $this->registrationClosed();
208
-        } elseif ($this->ticket_status_id === EE_Ticket::sold_out || $remaining === 0) {
209
-            // SOLD OUT - no tickets remaining
210
-            $this->ticket_status_display = $this->ticketsSoldOut();
211
-        } elseif ($this->ticket_status_id === EE_Ticket::expired || $this->ticket_status_id === EE_Ticket::archived) {
212
-            // expired or archived ticket
213
-            $this->ticket_status_display = $this->ticket_status_html;
214
-        } elseif ($this->ticket_status_id === EE_Ticket::pending) {
215
-            // ticket not on sale yet
216
-            $this->ticket_status_display = $this->ticketsSalesPending();
217
-        } elseif ($this->ticket->min() > $remaining) {
218
-            // min qty purchasable is less than tickets available
219
-            $this->ticket_status_display = $this->notEnoughTicketsAvailable();
220
-        }
221
-    }
222
-
223
-
224
-    /**
225
-     * registrationClosed
226
-     */
227
-    protected function registrationClosed()
228
-    {
229
-        return EEH_HTML::span(
230
-            apply_filters(
231
-                'FHEE__ticket_selector_chart_template__ticket_closed_msg',
232
-                __('Closed', 'event_espresso')
233
-            ),
234
-            '',
235
-            'sold-out'
236
-        );
237
-    }
238
-
239
-
240
-    /**
241
-     * ticketsSoldOut
242
-     */
243
-    protected function ticketsSoldOut()
244
-    {
245
-        return EEH_HTML::span(
246
-            apply_filters(
247
-                'FHEE__ticket_selector_chart_template__ticket_sold_out_msg',
248
-                __('Sold&nbsp;Out', 'event_espresso')
249
-            ),
250
-            '',
251
-            'sold-out'
252
-        );
253
-    }
254
-
255
-
256
-    /**
257
-     * ticketsSalesPending
258
-     *
259
-     * @throws EE_Error
260
-     */
261
-    protected function ticketsSalesPending()
262
-    {
263
-        return EEH_HTML::span(
264
-            EEH_HTML::span(
265
-                apply_filters(
266
-                    'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg',
267
-                    __('Goes&nbsp;On&nbsp;Sale', 'event_espresso')
268
-                ),
269
-                '',
270
-                'ticket-pending'
271
-            )
272
-            . EEH_HTML::br()
273
-            . EEH_HTML::span(
274
-                $this->ticket->get_i18n_datetime(
275
-                    'TKT_start_date',
276
-                    apply_filters(
277
-                        'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format',
278
-                        $this->date_format
279
-                    )
280
-                ),
281
-                '',
282
-                'small-text'
283
-            ),
284
-            '',
285
-            'ticket-pending-pg'
286
-        );
287
-    }
288
-
289
-
290
-    /**
291
-     * notEnoughTicketsAvailable
292
-     */
293
-    protected function notEnoughTicketsAvailable()
294
-    {
295
-        return EEH_HTML::div(
296
-            EEH_HTML::span(
297
-                apply_filters(
298
-                    'FHEE__ticket_selector_chart_template__ticket_not_available_msg',
299
-                    __('Not Available', 'event_espresso')
300
-                ),
301
-                '',
302
-                'archived-ticket small-text'
303
-            )
304
-            . EEH_HTML::br(),
305
-            '',
306
-            'archived-ticket-pg'
307
-        );
308
-    }
309
-
310
-
311
-    /**
312
-     * setTicketMinAndMax
313
-     *
314
-     * @param int $remaining
315
-     * @return void
316
-     * @throws EE_Error
317
-     */
318
-    protected function setTicketMinAndMax($remaining)
319
-    {
320
-        // offer the number of $tickets_remaining or $this->max_attendees, whichever is smaller
321
-        $this->max = min($remaining, $this->max_attendees);
322
-        // but... we also want to restrict the number of tickets by the ticket max setting,
323
-        // however, the max still can't be higher than what was just set above
324
-        $this->max = $this->ticket->max() > 0
325
-            ? min($this->ticket->max(), $this->max)
326
-            : $this->max;
327
-        // and we also want to restrict the minimum number of tickets by the ticket min setting
328
-        $this->min = $this->ticket->min() > 0
329
-            ? $this->ticket->min()
330
-            : 0;
331
-        // and if the ticket is required, then make sure that min qty is at least 1
332
-        $this->min = $this->ticket->required()
333
-            ? max($this->min, 1)
334
-            : $this->min;
335
-    }
336
-
337
-
338
-    /**
339
-     * Allow plugins to hook in and abort the generation and display of this row to do
340
-     * something elseif they want.
341
-     * For an addon to abort things, all they have to do is register a filter with this hook, and
342
-     * return a value that is NOT false.  Whatever is returned gets echoed instead of the
343
-     * current row.
344
-     *
345
-     * @return string|bool
346
-     */
347
-    protected function getFilteredRowHtml()
348
-    {
349
-        return apply_filters(
350
-            'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
351
-            false,
352
-            $this->ticket,
353
-            $this->max,
354
-            $this->min,
355
-            $this->required_ticket_sold_out,
356
-            $this->ticket_price,
357
-            $this->ticket_bundle,
358
-            $this->ticket_status_html,
359
-            $this->status_class,
360
-            $this
361
-        );
362
-    }
363
-
364
-
365
-    /**
366
-     * Allow plugins to hook in and abort the generation and display of the contents of this
367
-     * row to do something elseif they want.
368
-     * For an addon to abort things, all they have to do is register a filter with this hook, and
369
-     * return a value that is NOT false.  Whatever is returned gets echoed instead of the
370
-     * current row.
371
-     *
372
-     * @return string|bool
373
-     */
374
-    protected function getFilteredRowContents()
375
-    {
376
-        return apply_filters(
377
-            'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
378
-            false,
379
-            $this->ticket,
380
-            $this->max,
381
-            $this->min,
382
-            $this->required_ticket_sold_out,
383
-            $this->ticket_price,
384
-            $this->ticket_bundle,
385
-            $this->ticket_status_html,
386
-            $this->status_class,
387
-            $this
388
-        );
389
-    }
21
+	/**
22
+	 * @var EE_Ticket $ticket
23
+	 */
24
+	protected $ticket;
25
+
26
+	/**
27
+	 * @var int $total_tickets
28
+	 */
29
+	protected $total_tickets;
30
+
31
+	/**
32
+	 * @var int $max_attendees
33
+	 */
34
+	protected $max_attendees;
35
+
36
+	/**
37
+	 * @var string $date_format
38
+	 */
39
+	protected $date_format;
40
+
41
+	/**
42
+	 * @var int $EVT_ID
43
+	 */
44
+	protected $EVT_ID;
45
+
46
+	/**
47
+	 * @var string $event_status
48
+	 */
49
+	protected $event_status;
50
+
51
+	/**
52
+	 * @var boolean $required_ticket_sold_out
53
+	 */
54
+	protected $required_ticket_sold_out;
55
+
56
+	/**
57
+	 * @var string $ticket_status_display
58
+	 */
59
+	protected $ticket_status_display;
60
+
61
+	/**
62
+	 * @var int $max
63
+	 */
64
+	protected $max = 0;
65
+
66
+	/**
67
+	 * @var int $min
68
+	 */
69
+	protected $min = 0;
70
+
71
+	/**
72
+	 * @var float $ticket_price
73
+	 */
74
+	protected $ticket_price = 0.00;
75
+
76
+	/**
77
+	 * @var bool $ticket_bundle
78
+	 */
79
+	protected $ticket_bundle = false;
80
+
81
+	/**
82
+	 * @var string $ticket_status_id
83
+	 */
84
+	protected $ticket_status_id = EE_Ticket::sold_out;
85
+
86
+	/**
87
+	 * @var string $ticket_status_html
88
+	 */
89
+	protected $ticket_status_html = 'ticket-sales-sold-out';
90
+
91
+	/**
92
+	 * @var string $status_class
93
+	 */
94
+	protected $status_class = 'ticket-sales-sold-out lt-grey-text';
95
+
96
+
97
+	/**
98
+	 * @param EE_Ticket $ticket
99
+	 * @param int       $max_attendees
100
+	 * @param string    $date_format
101
+	 * @param string    $event_status
102
+	 * @param bool      $required_ticket_sold_out
103
+	 * @param int       $total_tickets
104
+	 * @throws EE_Error
105
+	 * @throws UnexpectedEntityException
106
+	 */
107
+	public function __construct(
108
+		EE_Ticket $ticket,
109
+		$max_attendees,
110
+		$date_format,
111
+		$event_status,
112
+		$required_ticket_sold_out = false,
113
+		$total_tickets = 1
114
+	) {
115
+		$this->ticket = $ticket;
116
+		$this->max_attendees = $max_attendees;
117
+		$this->date_format = $date_format;
118
+		$this->EVT_ID = $this->ticket->get_event_ID();
119
+		$this->event_status = $event_status;
120
+		$this->required_ticket_sold_out = $required_ticket_sold_out;
121
+		$this->total_tickets = $total_tickets;
122
+	}
123
+
124
+
125
+	/**
126
+	 * getTicketStatusClasses
127
+	 *
128
+	 * @param int $remaining
129
+	 * @return void
130
+	 * @throws EE_Error
131
+	 */
132
+	protected function setTicketStatusClasses($remaining = 0)
133
+	{
134
+		// if a previous required ticket with the same sale start date is sold out,
135
+		// then mark this ticket as sold out as well.
136
+		// tickets that go on sale at a later date than the required ticket  will NOT be affected
137
+		$this->ticket_status_id = $this->required_ticket_sold_out !== false
138
+								  && $this->required_ticket_sold_out === $this->ticket->start_date()
139
+			? EE_Ticket::sold_out
140
+			: $this->ticket->ticket_status();
141
+		$this->ticket_status_id = $this->event_status === EE_Datetime::sold_out
142
+			? EE_Ticket::sold_out
143
+			: $this->ticket_status_id;
144
+		// If at admin area, display expired tickets as on sale.
145
+		$this->ticket_status_id = is_admin() && $this->ticket_status_id === EE_Ticket::expired
146
+			? EE_Ticket::onsale
147
+			: $this->ticket_status_id;
148
+		// check ticket status
149
+		switch ($this->ticket_status_id) {
150
+			// sold_out
151
+			case EE_Ticket::sold_out:
152
+				$ticket_status_class = 'ticket-sales-sold-out';
153
+				$this->status_class = 'ticket-sales-sold-out lt-grey-text';
154
+				break;
155
+			// expired
156
+			case EE_Ticket::expired:
157
+				$ticket_status_class = 'ticket-sales-expired';
158
+				$this->status_class = 'ticket-sales-expired lt-grey-text';
159
+				break;
160
+			// archived
161
+			case EE_Ticket::archived:
162
+				$ticket_status_class = 'archived-ticket';
163
+				$this->status_class = 'archived-ticket hidden';
164
+				break;
165
+			// pending
166
+			case EE_Ticket::pending:
167
+				$ticket_status_class = 'ticket-pending';
168
+				$this->status_class = 'ticket-pending';
169
+				break;
170
+			// on sale
171
+			case EE_Ticket::onsale:
172
+			default:
173
+				$ticket_status_class = 'ticket-on-sale';
174
+				$this->status_class = 'ticket-on-sale';
175
+				break;
176
+		}
177
+		$this->ticket_status_html = EEH_HTML::span(
178
+			$this->ticket->ticket_status(true, ($remaining > 0)),
179
+			"{$ticket_status_class}-{$this->ticket->ID()}",
180
+			$ticket_status_class
181
+		);
182
+	}
183
+
184
+
185
+	/**
186
+	 * @return string
187
+	 */
188
+	public function getTicketStatusDisplay()
189
+	{
190
+		return $this->ticket_status_display;
191
+	}
192
+
193
+
194
+	/**
195
+	 * setTicketStatusDisplay
196
+	 *
197
+	 * @param int $remaining
198
+	 * @throws EE_Error
199
+	 */
200
+	protected function setTicketStatusDisplay($remaining)
201
+	{
202
+		$this->ticket_status_display = '';
203
+
204
+		// now depending on the ticket and other circumstances...
205
+		if ($this->max_attendees === 0) {
206
+			// registration is CLOSED because admin set max attendees to ZERO
207
+			$this->ticket_status_display = $this->registrationClosed();
208
+		} elseif ($this->ticket_status_id === EE_Ticket::sold_out || $remaining === 0) {
209
+			// SOLD OUT - no tickets remaining
210
+			$this->ticket_status_display = $this->ticketsSoldOut();
211
+		} elseif ($this->ticket_status_id === EE_Ticket::expired || $this->ticket_status_id === EE_Ticket::archived) {
212
+			// expired or archived ticket
213
+			$this->ticket_status_display = $this->ticket_status_html;
214
+		} elseif ($this->ticket_status_id === EE_Ticket::pending) {
215
+			// ticket not on sale yet
216
+			$this->ticket_status_display = $this->ticketsSalesPending();
217
+		} elseif ($this->ticket->min() > $remaining) {
218
+			// min qty purchasable is less than tickets available
219
+			$this->ticket_status_display = $this->notEnoughTicketsAvailable();
220
+		}
221
+	}
222
+
223
+
224
+	/**
225
+	 * registrationClosed
226
+	 */
227
+	protected function registrationClosed()
228
+	{
229
+		return EEH_HTML::span(
230
+			apply_filters(
231
+				'FHEE__ticket_selector_chart_template__ticket_closed_msg',
232
+				__('Closed', 'event_espresso')
233
+			),
234
+			'',
235
+			'sold-out'
236
+		);
237
+	}
238
+
239
+
240
+	/**
241
+	 * ticketsSoldOut
242
+	 */
243
+	protected function ticketsSoldOut()
244
+	{
245
+		return EEH_HTML::span(
246
+			apply_filters(
247
+				'FHEE__ticket_selector_chart_template__ticket_sold_out_msg',
248
+				__('Sold&nbsp;Out', 'event_espresso')
249
+			),
250
+			'',
251
+			'sold-out'
252
+		);
253
+	}
254
+
255
+
256
+	/**
257
+	 * ticketsSalesPending
258
+	 *
259
+	 * @throws EE_Error
260
+	 */
261
+	protected function ticketsSalesPending()
262
+	{
263
+		return EEH_HTML::span(
264
+			EEH_HTML::span(
265
+				apply_filters(
266
+					'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg',
267
+					__('Goes&nbsp;On&nbsp;Sale', 'event_espresso')
268
+				),
269
+				'',
270
+				'ticket-pending'
271
+			)
272
+			. EEH_HTML::br()
273
+			. EEH_HTML::span(
274
+				$this->ticket->get_i18n_datetime(
275
+					'TKT_start_date',
276
+					apply_filters(
277
+						'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format',
278
+						$this->date_format
279
+					)
280
+				),
281
+				'',
282
+				'small-text'
283
+			),
284
+			'',
285
+			'ticket-pending-pg'
286
+		);
287
+	}
288
+
289
+
290
+	/**
291
+	 * notEnoughTicketsAvailable
292
+	 */
293
+	protected function notEnoughTicketsAvailable()
294
+	{
295
+		return EEH_HTML::div(
296
+			EEH_HTML::span(
297
+				apply_filters(
298
+					'FHEE__ticket_selector_chart_template__ticket_not_available_msg',
299
+					__('Not Available', 'event_espresso')
300
+				),
301
+				'',
302
+				'archived-ticket small-text'
303
+			)
304
+			. EEH_HTML::br(),
305
+			'',
306
+			'archived-ticket-pg'
307
+		);
308
+	}
309
+
310
+
311
+	/**
312
+	 * setTicketMinAndMax
313
+	 *
314
+	 * @param int $remaining
315
+	 * @return void
316
+	 * @throws EE_Error
317
+	 */
318
+	protected function setTicketMinAndMax($remaining)
319
+	{
320
+		// offer the number of $tickets_remaining or $this->max_attendees, whichever is smaller
321
+		$this->max = min($remaining, $this->max_attendees);
322
+		// but... we also want to restrict the number of tickets by the ticket max setting,
323
+		// however, the max still can't be higher than what was just set above
324
+		$this->max = $this->ticket->max() > 0
325
+			? min($this->ticket->max(), $this->max)
326
+			: $this->max;
327
+		// and we also want to restrict the minimum number of tickets by the ticket min setting
328
+		$this->min = $this->ticket->min() > 0
329
+			? $this->ticket->min()
330
+			: 0;
331
+		// and if the ticket is required, then make sure that min qty is at least 1
332
+		$this->min = $this->ticket->required()
333
+			? max($this->min, 1)
334
+			: $this->min;
335
+	}
336
+
337
+
338
+	/**
339
+	 * Allow plugins to hook in and abort the generation and display of this row to do
340
+	 * something elseif they want.
341
+	 * For an addon to abort things, all they have to do is register a filter with this hook, and
342
+	 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
343
+	 * current row.
344
+	 *
345
+	 * @return string|bool
346
+	 */
347
+	protected function getFilteredRowHtml()
348
+	{
349
+		return apply_filters(
350
+			'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
351
+			false,
352
+			$this->ticket,
353
+			$this->max,
354
+			$this->min,
355
+			$this->required_ticket_sold_out,
356
+			$this->ticket_price,
357
+			$this->ticket_bundle,
358
+			$this->ticket_status_html,
359
+			$this->status_class,
360
+			$this
361
+		);
362
+	}
363
+
364
+
365
+	/**
366
+	 * Allow plugins to hook in and abort the generation and display of the contents of this
367
+	 * row to do something elseif they want.
368
+	 * For an addon to abort things, all they have to do is register a filter with this hook, and
369
+	 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
370
+	 * current row.
371
+	 *
372
+	 * @return string|bool
373
+	 */
374
+	protected function getFilteredRowContents()
375
+	{
376
+		return apply_filters(
377
+			'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
378
+			false,
379
+			$this->ticket,
380
+			$this->max,
381
+			$this->min,
382
+			$this->required_ticket_sold_out,
383
+			$this->ticket_price,
384
+			$this->ticket_bundle,
385
+			$this->ticket_status_html,
386
+			$this->status_class,
387
+			$this
388
+		);
389
+	}
390 390
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Recipient_List_Shortcodes.lib.php 2 patches
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -18,225 +18,225 @@
 block discarded – undo
18 18
 class EE_Recipient_List_Shortcodes extends EE_Shortcodes
19 19
 {
20 20
 
21
-    public function __construct()
22
-    {
23
-        parent::__construct();
24
-    }
25
-
26
-
27
-    protected function _init_props()
28
-    {
29
-        $this->label = __('Recipient List Shortcodes', 'event_espresso');
30
-        $this->description = __('All shortcodes specific to registrant recipients list type data.', 'event_espresso');
31
-        $this->_shortcodes = array(
32
-            '[RECIPIENT_TICKET_LIST]' => __(
33
-                'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.',
34
-                'event_espresso'
35
-            ),
36
-            '[RECIPIENT_DATETIME_LIST]' => __(
37
-                'Will output a list of datetimes that the person receiving this message has been registered for.',
38
-                'event_espresso'
39
-            ),
40
-        );
41
-    }
42
-
43
-
44
-    protected function _parser($shortcode)
45
-    {
46
-        switch ($shortcode) {
47
-            case '[RECIPIENT_TICKET_LIST]':
48
-                return $this->_get_recipient_ticket_list();
49
-                break;
50
-
51
-            case '[RECIPIENT_DATETIME_LIST]':
52
-                return $this->_get_recipient_datetime_list();
53
-                break;
54
-        }
55
-        return '';
56
-    }
57
-
58
-
59
-    /**
60
-     * figure out what the incoming data is and then return the appropriate parsed value
61
-     *
62
-     * @return string
63
-     */
64
-    private function _get_recipient_ticket_list()
65
-    {
66
-        $this->_validate_list_requirements();
67
-
68
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
69
-            return $this->_get_recipient_ticket_list_parsed($this->_data['data']);
70
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
71
-            return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']);
72
-        } else {
73
-            return '';
74
-        }
75
-    }
76
-
77
-
78
-    private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data)
79
-    {
80
-        // first get registrations just for this attendee.
81
-        $att = $data->att_obj;
82
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
83
-        $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
84
-            ? array($data->reg_obj) : $registrations_on_attendee;
85
-        $tkts = array();
86
-
87
-        // if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee.
88
-        // which means we want to get tickets for all events this addressee is a part of.
89
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
90
-            $valid_shortcodes = array(
91
-                'ticket',
92
-                'event_list',
93
-                'attendee_list',
94
-                'datetime_list',
95
-                'registration_details',
96
-                'attendee',
97
-                'recipient_details',
98
-            );
99
-            $template = $this->_data['template'];
100
-
101
-            // tickets will be tickets for all registrations on this attendee.
102
-            foreach ($registrations_on_attendee as $reg) {
103
-                if ($reg instanceof EE_Registration) {
104
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
105
-                        $data->registrations[ $reg->ID() ]
106
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
107
-                    ) ]['tkt_obj'] : null;
108
-                    if ($ticket instanceof EE_Ticket) {
109
-                        $tkts[ $ticket->ID() ] = $ticket;
110
-                    }
111
-                }
112
-            }
113
-        }
114
-
115
-        // if coming from the context of the event list parser, then let's return just the tickets for that event.
116
-        $event = $this->_data['data'];
117
-        if ($event instanceof EE_Event) {
118
-            $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details');
119
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
120
-                ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
121
-            // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
122
-            $template = str_replace('[EVENT_LIST]', '', $template);
123
-            // data will be tickets for this event for this recipient.
124
-            foreach ($registrations_on_attendee as $reg) {
125
-                if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
126
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
127
-                        $data->registrations[ $reg->ID() ]
128
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
129
-                    ) ]['tkt_obj'] : null;
130
-                    if ($ticket instanceof EE_Ticket) {
131
-                        $tkts[ $ticket->ID() ] = $ticket;
132
-                    }
133
-                }
134
-            }
135
-        }
136
-
137
-        $tkt_parsed = '';
138
-        foreach ($tkts as $ticket) {
139
-            $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
140
-                $template,
141
-                $ticket,
142
-                $valid_shortcodes,
143
-                $this->_extra_data
144
-            );
145
-        }
146
-        return $tkt_parsed;
147
-    }
148
-
149
-
150
-    /**
151
-     * figure out what the incoming data is and then return the appropriate parsed value
152
-     *
153
-     * @return string
154
-     */
155
-    private function _get_recipient_datetime_list()
156
-    {
157
-        $this->_validate_list_requirements();
158
-
159
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
160
-            return $this->_get_recipient_datetime_list_parsed($this->_data['data']);
161
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
162
-            return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']);
163
-        } else {
164
-            return '';
165
-        }
166
-    }
167
-
168
-
169
-    private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data)
170
-    {
171
-        // first get registrations just for this attendee.
172
-        $att = $data->att_obj;
173
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
174
-        $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
175
-            ? array($data->reg_obj)
176
-            : $registrations_on_attendee;
177
-        $valid_shortcodes = array('datetime', 'attendee', 'recipient_details');
178
-        $template = '';
179
-        $dtts = array();
180
-
181
-        // setup valid shortcodes depending on what the status of the $this->_data property is
182
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
183
-            $template = $this->_data['template'];
184
-
185
-            // dtts will be datetimes for all registrations on this attendee
186
-            foreach ($registrations_on_attendee as $reg) {
187
-                if ($reg instanceof EE_Registration) {
188
-                    $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array(
189
-                        $data->registrations[ $reg->ID() ]
190
-                    ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID(
191
-                    ) ]['dtt_objs'] : array();
192
-                    $dtt_objs = (array) $dtt_objs;
193
-                    foreach ($dtt_objs as $dtt_obj) {
194
-                        if ($dtt_obj instanceof EE_Datetime) {
195
-                            $dtts[ $dtt_obj->ID() ] = $dtt_obj;
196
-                        }
197
-                    }
198
-                }
199
-            }
200
-        }
201
-
202
-        // if coming from the context of the event list parser, then let's just return the datetimes for the specific event.
203
-        $event = $this->_data['data'];
204
-        if ($event instanceof EE_Event) {
205
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
206
-                ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
207
-
208
-            // data will be datetimes for this event for this recipient
209
-            foreach ($registrations_on_attendee as $reg) {
210
-                if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
211
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
212
-                        $data->registrations[ $reg->ID() ]
213
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
214
-                    ) ]['tkt_obj'] : null;
215
-                    if ($ticket instanceof EE_Ticket) {
216
-                        $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array(
217
-                            $data->tickets[ $ticket->ID() ]
218
-                        ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID(
219
-                        ) ]['dtt_objs'] : array();
220
-                        $dtt_objs = (array) $dtt_objs;
221
-                        foreach ($dtt_objs as $dtt_obj) {
222
-                            if ($dtt_obj instanceof EE_Datetime) {
223
-                                $dtts[ $dtt_obj->ID() ] = $dtt_obj;
224
-                            }
225
-                        }
226
-                    }
227
-                }
228
-            }
229
-        }
230
-
231
-        $dtt_parsed = '';
232
-        foreach ($dtts as $datetime) {
233
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
234
-                $template,
235
-                $datetime,
236
-                $valid_shortcodes,
237
-                $this->_extra_data
238
-            );
239
-        }
240
-        return $dtt_parsed;
241
-    }
21
+	public function __construct()
22
+	{
23
+		parent::__construct();
24
+	}
25
+
26
+
27
+	protected function _init_props()
28
+	{
29
+		$this->label = __('Recipient List Shortcodes', 'event_espresso');
30
+		$this->description = __('All shortcodes specific to registrant recipients list type data.', 'event_espresso');
31
+		$this->_shortcodes = array(
32
+			'[RECIPIENT_TICKET_LIST]' => __(
33
+				'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.',
34
+				'event_espresso'
35
+			),
36
+			'[RECIPIENT_DATETIME_LIST]' => __(
37
+				'Will output a list of datetimes that the person receiving this message has been registered for.',
38
+				'event_espresso'
39
+			),
40
+		);
41
+	}
42
+
43
+
44
+	protected function _parser($shortcode)
45
+	{
46
+		switch ($shortcode) {
47
+			case '[RECIPIENT_TICKET_LIST]':
48
+				return $this->_get_recipient_ticket_list();
49
+				break;
50
+
51
+			case '[RECIPIENT_DATETIME_LIST]':
52
+				return $this->_get_recipient_datetime_list();
53
+				break;
54
+		}
55
+		return '';
56
+	}
57
+
58
+
59
+	/**
60
+	 * figure out what the incoming data is and then return the appropriate parsed value
61
+	 *
62
+	 * @return string
63
+	 */
64
+	private function _get_recipient_ticket_list()
65
+	{
66
+		$this->_validate_list_requirements();
67
+
68
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
69
+			return $this->_get_recipient_ticket_list_parsed($this->_data['data']);
70
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
71
+			return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']);
72
+		} else {
73
+			return '';
74
+		}
75
+	}
76
+
77
+
78
+	private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data)
79
+	{
80
+		// first get registrations just for this attendee.
81
+		$att = $data->att_obj;
82
+		$registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
83
+		$registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
84
+			? array($data->reg_obj) : $registrations_on_attendee;
85
+		$tkts = array();
86
+
87
+		// if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee.
88
+		// which means we want to get tickets for all events this addressee is a part of.
89
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
90
+			$valid_shortcodes = array(
91
+				'ticket',
92
+				'event_list',
93
+				'attendee_list',
94
+				'datetime_list',
95
+				'registration_details',
96
+				'attendee',
97
+				'recipient_details',
98
+			);
99
+			$template = $this->_data['template'];
100
+
101
+			// tickets will be tickets for all registrations on this attendee.
102
+			foreach ($registrations_on_attendee as $reg) {
103
+				if ($reg instanceof EE_Registration) {
104
+					$ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
105
+						$data->registrations[ $reg->ID() ]
106
+					) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
107
+					) ]['tkt_obj'] : null;
108
+					if ($ticket instanceof EE_Ticket) {
109
+						$tkts[ $ticket->ID() ] = $ticket;
110
+					}
111
+				}
112
+			}
113
+		}
114
+
115
+		// if coming from the context of the event list parser, then let's return just the tickets for that event.
116
+		$event = $this->_data['data'];
117
+		if ($event instanceof EE_Event) {
118
+			$valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details');
119
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
120
+				? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
121
+			// let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
122
+			$template = str_replace('[EVENT_LIST]', '', $template);
123
+			// data will be tickets for this event for this recipient.
124
+			foreach ($registrations_on_attendee as $reg) {
125
+				if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
126
+					$ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
127
+						$data->registrations[ $reg->ID() ]
128
+					) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
129
+					) ]['tkt_obj'] : null;
130
+					if ($ticket instanceof EE_Ticket) {
131
+						$tkts[ $ticket->ID() ] = $ticket;
132
+					}
133
+				}
134
+			}
135
+		}
136
+
137
+		$tkt_parsed = '';
138
+		foreach ($tkts as $ticket) {
139
+			$tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
140
+				$template,
141
+				$ticket,
142
+				$valid_shortcodes,
143
+				$this->_extra_data
144
+			);
145
+		}
146
+		return $tkt_parsed;
147
+	}
148
+
149
+
150
+	/**
151
+	 * figure out what the incoming data is and then return the appropriate parsed value
152
+	 *
153
+	 * @return string
154
+	 */
155
+	private function _get_recipient_datetime_list()
156
+	{
157
+		$this->_validate_list_requirements();
158
+
159
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
160
+			return $this->_get_recipient_datetime_list_parsed($this->_data['data']);
161
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
162
+			return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']);
163
+		} else {
164
+			return '';
165
+		}
166
+	}
167
+
168
+
169
+	private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data)
170
+	{
171
+		// first get registrations just for this attendee.
172
+		$att = $data->att_obj;
173
+		$registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
174
+		$registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
175
+			? array($data->reg_obj)
176
+			: $registrations_on_attendee;
177
+		$valid_shortcodes = array('datetime', 'attendee', 'recipient_details');
178
+		$template = '';
179
+		$dtts = array();
180
+
181
+		// setup valid shortcodes depending on what the status of the $this->_data property is
182
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
183
+			$template = $this->_data['template'];
184
+
185
+			// dtts will be datetimes for all registrations on this attendee
186
+			foreach ($registrations_on_attendee as $reg) {
187
+				if ($reg instanceof EE_Registration) {
188
+					$dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array(
189
+						$data->registrations[ $reg->ID() ]
190
+					) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID(
191
+					) ]['dtt_objs'] : array();
192
+					$dtt_objs = (array) $dtt_objs;
193
+					foreach ($dtt_objs as $dtt_obj) {
194
+						if ($dtt_obj instanceof EE_Datetime) {
195
+							$dtts[ $dtt_obj->ID() ] = $dtt_obj;
196
+						}
197
+					}
198
+				}
199
+			}
200
+		}
201
+
202
+		// if coming from the context of the event list parser, then let's just return the datetimes for the specific event.
203
+		$event = $this->_data['data'];
204
+		if ($event instanceof EE_Event) {
205
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
206
+				? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
207
+
208
+			// data will be datetimes for this event for this recipient
209
+			foreach ($registrations_on_attendee as $reg) {
210
+				if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
211
+					$ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
212
+						$data->registrations[ $reg->ID() ]
213
+					) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
214
+					) ]['tkt_obj'] : null;
215
+					if ($ticket instanceof EE_Ticket) {
216
+						$dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array(
217
+							$data->tickets[ $ticket->ID() ]
218
+						) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID(
219
+						) ]['dtt_objs'] : array();
220
+						$dtt_objs = (array) $dtt_objs;
221
+						foreach ($dtt_objs as $dtt_obj) {
222
+							if ($dtt_obj instanceof EE_Datetime) {
223
+								$dtts[ $dtt_obj->ID() ] = $dtt_obj;
224
+							}
225
+						}
226
+					}
227
+				}
228
+			}
229
+		}
230
+
231
+		$dtt_parsed = '';
232
+		foreach ($dtts as $datetime) {
233
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
234
+				$template,
235
+				$datetime,
236
+				$valid_shortcodes,
237
+				$this->_extra_data
238
+			);
239
+		}
240
+		return $dtt_parsed;
241
+	}
242 242
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     {
80 80
         // first get registrations just for this attendee.
81 81
         $att = $data->att_obj;
82
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
82
+        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array();
83 83
         $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
84 84
             ? array($data->reg_obj) : $registrations_on_attendee;
85 85
         $tkts = array();
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
             // tickets will be tickets for all registrations on this attendee.
102 102
             foreach ($registrations_on_attendee as $reg) {
103 103
                 if ($reg instanceof EE_Registration) {
104
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
105
-                        $data->registrations[ $reg->ID() ]
106
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
107
-                    ) ]['tkt_obj'] : null;
104
+                    $ticket = isset($data->registrations[$reg->ID()]) && is_array(
105
+                        $data->registrations[$reg->ID()]
106
+                    ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID(
107
+                    )]['tkt_obj'] : null;
108 108
                     if ($ticket instanceof EE_Ticket) {
109
-                        $tkts[ $ticket->ID() ] = $ticket;
109
+                        $tkts[$ticket->ID()] = $ticket;
110 110
                     }
111 111
                 }
112 112
             }
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
             // data will be tickets for this event for this recipient.
124 124
             foreach ($registrations_on_attendee as $reg) {
125 125
                 if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
126
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
127
-                        $data->registrations[ $reg->ID() ]
128
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
129
-                    ) ]['tkt_obj'] : null;
126
+                    $ticket = isset($data->registrations[$reg->ID()]) && is_array(
127
+                        $data->registrations[$reg->ID()]
128
+                    ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID(
129
+                    )]['tkt_obj'] : null;
130 130
                     if ($ticket instanceof EE_Ticket) {
131
-                        $tkts[ $ticket->ID() ] = $ticket;
131
+                        $tkts[$ticket->ID()] = $ticket;
132 132
                     }
133 133
                 }
134 134
             }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     {
171 171
         // first get registrations just for this attendee.
172 172
         $att = $data->att_obj;
173
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
173
+        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array();
174 174
         $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
175 175
             ? array($data->reg_obj)
176 176
             : $registrations_on_attendee;
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
             // dtts will be datetimes for all registrations on this attendee
186 186
             foreach ($registrations_on_attendee as $reg) {
187 187
                 if ($reg instanceof EE_Registration) {
188
-                    $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array(
189
-                        $data->registrations[ $reg->ID() ]
190
-                    ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID(
191
-                    ) ]['dtt_objs'] : array();
188
+                    $dtt_objs = isset($data->registrations[$reg->ID()]) && is_array(
189
+                        $data->registrations[$reg->ID()]
190
+                    ) && isset($data->registrations[$reg->ID()]['dtt_objs']) ? $data->registrations[$reg->ID(
191
+                    )]['dtt_objs'] : array();
192 192
                     $dtt_objs = (array) $dtt_objs;
193 193
                     foreach ($dtt_objs as $dtt_obj) {
194 194
                         if ($dtt_obj instanceof EE_Datetime) {
195
-                            $dtts[ $dtt_obj->ID() ] = $dtt_obj;
195
+                            $dtts[$dtt_obj->ID()] = $dtt_obj;
196 196
                         }
197 197
                     }
198 198
                 }
@@ -208,19 +208,19 @@  discard block
 block discarded – undo
208 208
             // data will be datetimes for this event for this recipient
209 209
             foreach ($registrations_on_attendee as $reg) {
210 210
                 if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
211
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
212
-                        $data->registrations[ $reg->ID() ]
213
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
214
-                    ) ]['tkt_obj'] : null;
211
+                    $ticket = isset($data->registrations[$reg->ID()]) && is_array(
212
+                        $data->registrations[$reg->ID()]
213
+                    ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID(
214
+                    )]['tkt_obj'] : null;
215 215
                     if ($ticket instanceof EE_Ticket) {
216
-                        $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array(
217
-                            $data->tickets[ $ticket->ID() ]
218
-                        ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID(
219
-                        ) ]['dtt_objs'] : array();
216
+                        $dtt_objs = isset($data->tickets[$ticket->ID()]) && is_array(
217
+                            $data->tickets[$ticket->ID()]
218
+                        ) && isset($data->tickets[$ticket->ID()]['dtt_objs']) ? $data->tickets[$ticket->ID(
219
+                        )]['dtt_objs'] : array();
220 220
                         $dtt_objs = (array) $dtt_objs;
221 221
                         foreach ($dtt_objs as $dtt_obj) {
222 222
                             if ($dtt_obj instanceof EE_Datetime) {
223
-                                $dtts[ $dtt_obj->ID() ] = $dtt_obj;
223
+                                $dtts[$dtt_obj->ID()] = $dtt_obj;
224 224
                             }
225 225
                         }
226 226
                     }
Please login to merge, or discard this patch.
services/admin/registrations/list_table/page_header/DateFilterHeader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
                 $text .= '<span class="drk-grey-text">';
71 71
                 $text .= '<span class="dashicons dashicons-calendar"></span>';
72 72
                 $text .= $datetime->name();
73
-                $text .= ' ( ' . $datetime->start_date() . ' )';
73
+                $text .= ' ( '.$datetime->start_date().' )';
74 74
                 $text .= '</span></h3>';
75 75
             }
76 76
         }
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -23,58 +23,58 @@
 block discarded – undo
23 23
 class DateFilterHeader extends AdminPageHeaderDecorator
24 24
 {
25 25
 
26
-    /**
27
-     * @var EEM_Datetime $datetime_model
28
-     */
29
-    private $datetime_model;
26
+	/**
27
+	 * @var EEM_Datetime $datetime_model
28
+	 */
29
+	private $datetime_model;
30 30
 
31 31
 
32
-    /**
33
-     * DateFilterHeader constructor.
34
-     *
35
-     * @param RequestInterface $request
36
-     * @param EEM_Datetime     $datetime_model
37
-     */
38
-    public function __construct(RequestInterface $request, EEM_Datetime $datetime_model)
39
-    {
40
-        parent::__construct($request);
41
-        $this->datetime_model = $datetime_model;
42
-    }
32
+	/**
33
+	 * DateFilterHeader constructor.
34
+	 *
35
+	 * @param RequestInterface $request
36
+	 * @param EEM_Datetime     $datetime_model
37
+	 */
38
+	public function __construct(RequestInterface $request, EEM_Datetime $datetime_model)
39
+	{
40
+		parent::__construct($request);
41
+		$this->datetime_model = $datetime_model;
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * @param string $text
47
-     * @return string
48
-     * @throws EE_Error
49
-     * @throws InvalidDataTypeException
50
-     * @throws InvalidInterfaceException
51
-     * @throws InvalidArgumentException
52
-     * @throws ReflectionException
53
-     * @since 4.10.2.p
54
-     */
55
-    public function getHeaderText($text = '')
56
-    {
57
-        $DTT_ID = $this->request->getRequestParam('DTT_ID');
58
-        $DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID);
59
-        $DTT_ID = absint($DTT_ID);
60
-        if ($DTT_ID) {
61
-            $datetime = $this->datetime_model->get_one_by_ID($DTT_ID);
62
-            if ($datetime instanceof EE_Datetime && $text !== '') {
63
-                // remove the closing h3 heading tag if it exists
64
-                $text = str_replace(
65
-                    '</h3>',
66
-                    '',
67
-                    $text
68
-                );
69
-                $text .= '&nbsp; &nbsp; ';
70
-                $text .= '<span class="drk-grey-text">';
71
-                $text .= '<span class="dashicons dashicons-calendar"></span>';
72
-                $text .= $datetime->name();
73
-                $text .= ' ( ' . $datetime->start_date() . ' )';
74
-                $text .= '</span></h3>';
75
-            }
76
-        }
45
+	/**
46
+	 * @param string $text
47
+	 * @return string
48
+	 * @throws EE_Error
49
+	 * @throws InvalidDataTypeException
50
+	 * @throws InvalidInterfaceException
51
+	 * @throws InvalidArgumentException
52
+	 * @throws ReflectionException
53
+	 * @since 4.10.2.p
54
+	 */
55
+	public function getHeaderText($text = '')
56
+	{
57
+		$DTT_ID = $this->request->getRequestParam('DTT_ID');
58
+		$DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID);
59
+		$DTT_ID = absint($DTT_ID);
60
+		if ($DTT_ID) {
61
+			$datetime = $this->datetime_model->get_one_by_ID($DTT_ID);
62
+			if ($datetime instanceof EE_Datetime && $text !== '') {
63
+				// remove the closing h3 heading tag if it exists
64
+				$text = str_replace(
65
+					'</h3>',
66
+					'',
67
+					$text
68
+				);
69
+				$text .= '&nbsp; &nbsp; ';
70
+				$text .= '<span class="drk-grey-text">';
71
+				$text .= '<span class="dashicons dashicons-calendar"></span>';
72
+				$text .= $datetime->name();
73
+				$text .= ' ( ' . $datetime->start_date() . ' )';
74
+				$text .= '</span></h3>';
75
+			}
76
+		}
77 77
 
78
-        return $text;
79
-    }
78
+		return $text;
79
+	}
80 80
 }
Please login to merge, or discard this patch.
services/admin/registrations/list_table/page_header/TicketFilterHeader.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
         if ($TKT_ID) {
61 61
             $ticket = $this->ticket_model->get_one_by_ID($TKT_ID);
62 62
             if ($ticket instanceof EE_Ticket) {
63
-                $ticket_details = '<span class="ee-ticket-name">' . $ticket->name() . '</span> ';
63
+                $ticket_details = '<span class="ee-ticket-name">'.$ticket->name().'</span> ';
64 64
                 $ticket_details .= ! $ticket->is_free()
65
-                    ? '<span class="ee-ticket-price">' . $ticket->pretty_price() . '</span>'
65
+                    ? '<span class="ee-ticket-price">'.$ticket->pretty_price().'</span>'
66 66
                     : '<span class="reg-overview-free-event-spn">'
67 67
                       . __('free', 'event_espresso')
68 68
                       . '</span>';
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                 $text .= '&nbsp; &nbsp; ';
81 81
                 $text .= '<span class="drk-grey-text" style="font-size:.9em;">';
82 82
                 $text .= '<span class="dashicons dashicons-tickets-alt"></span>';
83
-                $text .= $ticket_details . '</span></h3>';
83
+                $text .= $ticket_details.'</span></h3>';
84 84
             }
85 85
         }
86 86
         return $text;
Please login to merge, or discard this patch.
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -23,65 +23,65 @@
 block discarded – undo
23 23
 class TicketFilterHeader extends AdminPageHeaderDecorator
24 24
 {
25 25
 
26
-    /**
27
-     * @var EEM_Ticket $ticket_model
28
-     */
29
-    private $ticket_model;
26
+	/**
27
+	 * @var EEM_Ticket $ticket_model
28
+	 */
29
+	private $ticket_model;
30 30
 
31 31
 
32
-    /**
33
-     * TicketFilterHeader constructor.
34
-     *
35
-     * @param RequestInterface $request
36
-     * @param EEM_Ticket       $ticket_model
37
-     */
38
-    public function __construct(RequestInterface $request, EEM_Ticket $ticket_model)
39
-    {
40
-        parent::__construct($request);
41
-        $this->ticket_model = $ticket_model;
42
-    }
32
+	/**
33
+	 * TicketFilterHeader constructor.
34
+	 *
35
+	 * @param RequestInterface $request
36
+	 * @param EEM_Ticket       $ticket_model
37
+	 */
38
+	public function __construct(RequestInterface $request, EEM_Ticket $ticket_model)
39
+	{
40
+		parent::__construct($request);
41
+		$this->ticket_model = $ticket_model;
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * @param string $text
47
-     * @return string
48
-     * @throws EE_Error
49
-     * @throws InvalidDataTypeException
50
-     * @throws InvalidInterfaceException
51
-     * @throws InvalidArgumentException
52
-     * @throws ReflectionException
53
-     * @since 4.10.2.p
54
-     */
55
-    public function getHeaderText($text = '')
56
-    {
57
-        $TKT_ID = $this->request->getRequestParam('TKT_ID');
58
-        $TKT_ID = $this->request->getRequestParam('ticket_id', $TKT_ID);
59
-        $TKT_ID = absint($TKT_ID);
60
-        if ($TKT_ID) {
61
-            $ticket = $this->ticket_model->get_one_by_ID($TKT_ID);
62
-            if ($ticket instanceof EE_Ticket) {
63
-                $ticket_details = '<span class="ee-ticket-name">' . $ticket->name() . '</span> ';
64
-                $ticket_details .= ! $ticket->is_free()
65
-                    ? '<span class="ee-ticket-price">' . $ticket->pretty_price() . '</span>'
66
-                    : '<span class="reg-overview-free-event-spn">'
67
-                      . __('free', 'event_espresso')
68
-                      . '</span>';
69
-                // remove the closing h3 heading tag if it exists
70
-                $text = str_replace(
71
-                    '</h3>',
72
-                    '',
73
-                    $text
74
-                );
75
-                if (empty($text)) {
76
-                    $text = '<h3 style="line-height:1.5em;">';
77
-                    $text .= esc_html__('Viewing registrations for ticket:', 'event_espresso');
78
-                }
79
-                $text .= '&nbsp; &nbsp; ';
80
-                $text .= '<span class="drk-grey-text" style="font-size:.9em;">';
81
-                $text .= '<span class="dashicons dashicons-tickets-alt"></span>';
82
-                $text .= $ticket_details . '</span></h3>';
83
-            }
84
-        }
85
-        return $text;
86
-    }
45
+	/**
46
+	 * @param string $text
47
+	 * @return string
48
+	 * @throws EE_Error
49
+	 * @throws InvalidDataTypeException
50
+	 * @throws InvalidInterfaceException
51
+	 * @throws InvalidArgumentException
52
+	 * @throws ReflectionException
53
+	 * @since 4.10.2.p
54
+	 */
55
+	public function getHeaderText($text = '')
56
+	{
57
+		$TKT_ID = $this->request->getRequestParam('TKT_ID');
58
+		$TKT_ID = $this->request->getRequestParam('ticket_id', $TKT_ID);
59
+		$TKT_ID = absint($TKT_ID);
60
+		if ($TKT_ID) {
61
+			$ticket = $this->ticket_model->get_one_by_ID($TKT_ID);
62
+			if ($ticket instanceof EE_Ticket) {
63
+				$ticket_details = '<span class="ee-ticket-name">' . $ticket->name() . '</span> ';
64
+				$ticket_details .= ! $ticket->is_free()
65
+					? '<span class="ee-ticket-price">' . $ticket->pretty_price() . '</span>'
66
+					: '<span class="reg-overview-free-event-spn">'
67
+					  . __('free', 'event_espresso')
68
+					  . '</span>';
69
+				// remove the closing h3 heading tag if it exists
70
+				$text = str_replace(
71
+					'</h3>',
72
+					'',
73
+					$text
74
+				);
75
+				if (empty($text)) {
76
+					$text = '<h3 style="line-height:1.5em;">';
77
+					$text .= esc_html__('Viewing registrations for ticket:', 'event_espresso');
78
+				}
79
+				$text .= '&nbsp; &nbsp; ';
80
+				$text .= '<span class="drk-grey-text" style="font-size:.9em;">';
81
+				$text .= '<span class="dashicons dashicons-tickets-alt"></span>';
82
+				$text .= $ticket_details . '</span></h3>';
83
+			}
84
+		}
85
+		return $text;
86
+	}
87 87
 }
Please login to merge, or discard this patch.
admin/registrations/list_table/page_header/AttendeeFilterHeader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,13 +59,13 @@
 block discarded – undo
59 59
                         'event_espresso'
60 60
                     ),
61 61
                     '<h3 style="line-height:1.5em;">',
62
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
62
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
63 63
                         array(
64 64
                             'action' => 'edit_attendee',
65 65
                             'post'   => $ATT_ID,
66 66
                         ),
67 67
                         REG_ADMIN_URL
68
-                    ) . '">' . $attendee->full_name() . '</a>',
68
+                    ).'">'.$attendee->full_name().'</a>',
69 69
                     '</h3>'
70 70
                 );
71 71
             }
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -20,56 +20,56 @@
 block discarded – undo
20 20
 class AttendeeFilterHeader extends AdminPageHeaderDecorator
21 21
 {
22 22
 
23
-    /**
24
-     * @var EEM_Attendee $attendee_model
25
-     */
26
-    private $attendee_model;
23
+	/**
24
+	 * @var EEM_Attendee $attendee_model
25
+	 */
26
+	private $attendee_model;
27 27
 
28 28
 
29
-    /**
30
-     * AttendeeFilterHeader constructor.
31
-     *
32
-     * @param RequestInterface $request
33
-     * @param EEM_Attendee     $attendee_model
34
-     */
35
-    public function __construct(RequestInterface $request, EEM_Attendee $attendee_model)
36
-    {
37
-        parent::__construct($request);
38
-        $this->attendee_model = $attendee_model;
39
-    }
29
+	/**
30
+	 * AttendeeFilterHeader constructor.
31
+	 *
32
+	 * @param RequestInterface $request
33
+	 * @param EEM_Attendee     $attendee_model
34
+	 */
35
+	public function __construct(RequestInterface $request, EEM_Attendee $attendee_model)
36
+	{
37
+		parent::__construct($request);
38
+		$this->attendee_model = $attendee_model;
39
+	}
40 40
 
41 41
 
42
-    /**
43
-     * @param string $text
44
-     * @return string
45
-     * @throws EE_Error
46
-     * @since 4.10.2.p
47
-     */
48
-    public function getHeaderText($text = '')
49
-    {
50
-        $ATT_ID = $this->request->getRequestParam('ATT_ID');
51
-        $ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID);
52
-        $ATT_ID = absint($ATT_ID);
53
-        if ($ATT_ID) {
54
-            $attendee = $this->attendee_model->get_one_by_ID($ATT_ID);
55
-            if ($attendee instanceof EE_Attendee) {
56
-                $text .= sprintf(
57
-                    esc_html__(
58
-                        '%1$s Viewing registrations for %2$s%3$s',
59
-                        'event_espresso'
60
-                    ),
61
-                    '<h3 style="line-height:1.5em;">',
62
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
63
-                        array(
64
-                            'action' => 'edit_attendee',
65
-                            'post'   => $ATT_ID,
66
-                        ),
67
-                        REG_ADMIN_URL
68
-                    ) . '">' . $attendee->full_name() . '</a>',
69
-                    '</h3>'
70
-                );
71
-            }
72
-        }
73
-        return $text;
74
-    }
42
+	/**
43
+	 * @param string $text
44
+	 * @return string
45
+	 * @throws EE_Error
46
+	 * @since 4.10.2.p
47
+	 */
48
+	public function getHeaderText($text = '')
49
+	{
50
+		$ATT_ID = $this->request->getRequestParam('ATT_ID');
51
+		$ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID);
52
+		$ATT_ID = absint($ATT_ID);
53
+		if ($ATT_ID) {
54
+			$attendee = $this->attendee_model->get_one_by_ID($ATT_ID);
55
+			if ($attendee instanceof EE_Attendee) {
56
+				$text .= sprintf(
57
+					esc_html__(
58
+						'%1$s Viewing registrations for %2$s%3$s',
59
+						'event_espresso'
60
+					),
61
+					'<h3 style="line-height:1.5em;">',
62
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
63
+						array(
64
+							'action' => 'edit_attendee',
65
+							'post'   => $ATT_ID,
66
+						),
67
+						REG_ADMIN_URL
68
+					) . '">' . $attendee->full_name() . '</a>',
69
+					'</h3>'
70
+				);
71
+			}
72
+		}
73
+		return $text;
74
+	}
75 75
 }
Please login to merge, or discard this patch.