Completed
Branch dependabot/npm_and_yarn/@wordp... (e9f48b)
by
unknown
60:52 queued 52:34
created
4_7_0_stages/EE_DMS_4_7_0_Registration_Payments.dmsstage.php 2 patches
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -12,225 +12,225 @@
 block discarded – undo
12 12
 class EE_DMS_4_7_0_Registration_Payments extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14 14
 
15
-    protected $_payment_table;
16
-
17
-    protected $_registration_table;
18
-
19
-    protected $_registration_payment_table;
20
-
21
-    public function __construct()
22
-    {
23
-        /** @type WPDB $wpdb */
24
-        global $wpdb;
25
-        $this->_pretty_name = __('Registration Payment Record Generation', 'event_espresso');
26
-        // define tables
27
-        $this->_old_table                                   = $wpdb->prefix . 'esp_transaction';
28
-        $this->_payment_table                       = $wpdb->prefix . 'esp_payment';
29
-        $this->_registration_table                  = $wpdb->prefix . 'esp_registration';
30
-        $this->_registration_payment_table  = $wpdb->prefix . 'esp_registration_payment';
31
-        // build SQL WHERE clauses
32
-        $this->_extra_where_sql = "WHERE STS_ID IN ( 'TIN', 'TCM' ) AND TXN_Total != '0.000'";
33
-        parent::__construct();
34
-    }
35
-
36
-
37
-
38
-    /**
39
-     * @param array $transaction
40
-     * @return void
41
-     */
42
-    protected function _migrate_old_row($transaction)
43
-    {
44
-        /** @type WPDB $wpdb */
45
-        global $wpdb;
46
-        $TXN_ID = absint($transaction['TXN_ID']);
47
-        if (! $TXN_ID) {
48
-            $this->add_error(
49
-                sprintf(
50
-                    __('Invalid transaction with ID=%1$d. Error: "%2$s"', 'event_espresso'),
51
-                    $TXN_ID,
52
-                    $wpdb->last_error
53
-                )
54
-            );
55
-            return;
56
-        }
57
-        // get all payments for the TXN
58
-        $payments = $this->_get_payments($TXN_ID);
59
-        if (empty($payments)) {
60
-            return;
61
-        }
62
-        // then the registrants
63
-        $registrations = $this->_get_registrations($TXN_ID);
64
-        if (empty($registrations)) {
65
-            return;
66
-        }
67
-        // now loop thru each payment and apply it to each of the registrations
68
-        foreach ($payments as $PAY_ID => $payment) {
69
-            if ($payment->STS_ID === 'PAP' && $payment->PAY_amount > 0) {
70
-                $this->_process_registration_payments($payment, $registrations);
71
-            }
72
-        }
73
-    }
74
-
75
-
76
-
77
-    /**
78
-     * _get_registrations
79
-     *
80
-     * @param int $TXN_ID
81
-     * @return array
82
-     */
83
-    protected function _get_registrations($TXN_ID)
84
-    {
85
-        /** @type WPDB $wpdb */
86
-        global $wpdb;
87
-        $SQL = "SELECT * FROM {$this->_registration_table} WHERE TXN_ID = %d AND STS_ID IN ( 'RPP', 'RAP' )";
88
-        return $wpdb->get_results($wpdb->prepare($SQL, $TXN_ID), OBJECT_K);
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * _get_payments
95
-     *
96
-     * @param int $TXN_ID
97
-     * @return array
98
-     */
99
-    protected function _get_payments($TXN_ID)
100
-    {
101
-        /** @type WPDB $wpdb */
102
-        global $wpdb;
103
-        return $wpdb->get_results($wpdb->prepare("SELECT * FROM {$this->_payment_table} WHERE TXN_ID = %d", $TXN_ID), OBJECT_K);
104
-    }
105
-
106
-
107
-
108
-    /**
109
-     * _get_possibly_updated_REG_paid
110
-     *
111
-     * @param int $REG_ID
112
-     * @return array
113
-     */
114
-    protected function _get_possibly_updated_REG_paid($REG_ID)
115
-    {
116
-        /** @type WPDB $wpdb */
117
-        global $wpdb;
118
-        return $wpdb->get_var($wpdb->prepare("SELECT REG_paid FROM {$this->_registration_table} WHERE REG_ID = %d", $REG_ID));
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * _process_registration_payments
125
-     *
126
-     * basically a copy of the "Sequential Registration Payment Application Strategy"  logic
127
-     * currently in EE_Payment_Processor::process_registration_payments()
128
-     *
129
-     * @param stdClass $payment
130
-     * @param array $registrations
131
-     * @return bool
132
-     */
133
-    protected function _process_registration_payments($payment, $registrations = array())
134
-    {
135
-        // how much is available to apply to registrations?
136
-        $available_payment_amount = $payment->PAY_amount;
137
-        foreach ($registrations as $REG_ID => $registration) {
138
-            // nothing left, then we are done here?
139
-            if (! $available_payment_amount > 0) {
140
-                break;
141
-            }
142
-            // ensure REG_final_price has a valid value, and skip if it turns out to be zero
143
-            $registration->REG_final_price = ! empty($registration->REG_final_price) ? (float) $registration->REG_final_price : 0.00;
144
-            if (! $registration->REG_final_price > 0) {
145
-                continue;
146
-            }
147
-            // because REG_paid may have been updated by a previous payment, we need to retrieve the value from the db
148
-            $possibly_updated_REG_paid = $this->_get_possibly_updated_REG_paid($REG_ID);
149
-            if (is_float($possibly_updated_REG_paid)) {
150
-                $registration->REG_paid = $possibly_updated_REG_paid;
151
-            }
152
-            // and ensure REG_paid has a valid value
153
-            $registration->REG_paid = ! empty($registration->REG_paid) ? (float) $registration->REG_paid : 0.00;
154
-            // calculate amount owing, and skip if it turns out to be zero
155
-            $owing = $registration->REG_final_price - $registration->REG_paid;
156
-            if (! $owing > 0) {
157
-                continue;
158
-            }
159
-            // don't allow payment amount to exceed the available payment amount, OR the amount owing
160
-            $payment_amount = min($available_payment_amount, $owing);
161
-            // update $available_payment_amount
162
-            $available_payment_amount = $available_payment_amount - $payment_amount;
163
-            // add relation between registration and payment and set amount
164
-            if ($this->_insert_registration_payment($registration->REG_ID, $payment->PAY_ID, $payment_amount)) {
165
-                // calculate and set new REG_paid
166
-                $registration->REG_paid = $registration->REG_paid + $payment_amount;
167
-                $this->_update_registration_paid($registration->REG_ID, $registration->REG_paid);
168
-            }
169
-        }
170
-    }
171
-
172
-
173
-
174
-    /**
175
-     * _insert_registration_payment
176
-     *
177
-     * @param int $REG_ID
178
-     * @param int $PAY_ID
179
-     * @param float $PAY_amount
180
-     * @return bool
181
-     */
182
-    protected function _insert_registration_payment($REG_ID = 0, $PAY_ID = 0, $PAY_amount = 0.00)
183
-    {
184
-        /** @type WPDB $wpdb */
185
-        global $wpdb;
186
-        $success = $wpdb->insert(
187
-            $this->_registration_payment_table,
188
-            array( 'REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount, ),  // data
189
-            array( '%f' )   // data format
190
-        );
191
-        if ($success === false) {
192
-            $this->add_error(
193
-                sprintf(
194
-                    __('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
195
-                    $REG_ID,
196
-                    $wpdb->last_error
197
-                )
198
-            );
199
-            return false;
200
-        }
201
-        return true;
202
-    }
203
-
204
-
205
-
206
-    /**
207
-     * _update_registration_paid
208
-     *
209
-     * @param int $REG_ID
210
-     * @param float $REG_paid
211
-     * @return bool
212
-     */
213
-    protected function _update_registration_paid($REG_ID = 0, $REG_paid = 0.00)
214
-    {
215
-        /** @type WPDB $wpdb */
216
-        global $wpdb;
217
-        $success = $wpdb->update(
218
-            $this->_registration_table,
219
-            array( 'REG_paid' => $REG_paid ),  // data
220
-            array( 'REG_ID' => $REG_ID ),  // where
221
-            array( '%f' ),   // data format
222
-            array( '%d' )  // where format
223
-        );
224
-        if ($success === false) {
225
-            $this->add_error(
226
-                sprintf(
227
-                    __('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
228
-                    $REG_ID,
229
-                    $wpdb->last_error
230
-                )
231
-            );
232
-            return false;
233
-        }
234
-        return true;
235
-    }
15
+	protected $_payment_table;
16
+
17
+	protected $_registration_table;
18
+
19
+	protected $_registration_payment_table;
20
+
21
+	public function __construct()
22
+	{
23
+		/** @type WPDB $wpdb */
24
+		global $wpdb;
25
+		$this->_pretty_name = __('Registration Payment Record Generation', 'event_espresso');
26
+		// define tables
27
+		$this->_old_table                                   = $wpdb->prefix . 'esp_transaction';
28
+		$this->_payment_table                       = $wpdb->prefix . 'esp_payment';
29
+		$this->_registration_table                  = $wpdb->prefix . 'esp_registration';
30
+		$this->_registration_payment_table  = $wpdb->prefix . 'esp_registration_payment';
31
+		// build SQL WHERE clauses
32
+		$this->_extra_where_sql = "WHERE STS_ID IN ( 'TIN', 'TCM' ) AND TXN_Total != '0.000'";
33
+		parent::__construct();
34
+	}
35
+
36
+
37
+
38
+	/**
39
+	 * @param array $transaction
40
+	 * @return void
41
+	 */
42
+	protected function _migrate_old_row($transaction)
43
+	{
44
+		/** @type WPDB $wpdb */
45
+		global $wpdb;
46
+		$TXN_ID = absint($transaction['TXN_ID']);
47
+		if (! $TXN_ID) {
48
+			$this->add_error(
49
+				sprintf(
50
+					__('Invalid transaction with ID=%1$d. Error: "%2$s"', 'event_espresso'),
51
+					$TXN_ID,
52
+					$wpdb->last_error
53
+				)
54
+			);
55
+			return;
56
+		}
57
+		// get all payments for the TXN
58
+		$payments = $this->_get_payments($TXN_ID);
59
+		if (empty($payments)) {
60
+			return;
61
+		}
62
+		// then the registrants
63
+		$registrations = $this->_get_registrations($TXN_ID);
64
+		if (empty($registrations)) {
65
+			return;
66
+		}
67
+		// now loop thru each payment and apply it to each of the registrations
68
+		foreach ($payments as $PAY_ID => $payment) {
69
+			if ($payment->STS_ID === 'PAP' && $payment->PAY_amount > 0) {
70
+				$this->_process_registration_payments($payment, $registrations);
71
+			}
72
+		}
73
+	}
74
+
75
+
76
+
77
+	/**
78
+	 * _get_registrations
79
+	 *
80
+	 * @param int $TXN_ID
81
+	 * @return array
82
+	 */
83
+	protected function _get_registrations($TXN_ID)
84
+	{
85
+		/** @type WPDB $wpdb */
86
+		global $wpdb;
87
+		$SQL = "SELECT * FROM {$this->_registration_table} WHERE TXN_ID = %d AND STS_ID IN ( 'RPP', 'RAP' )";
88
+		return $wpdb->get_results($wpdb->prepare($SQL, $TXN_ID), OBJECT_K);
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * _get_payments
95
+	 *
96
+	 * @param int $TXN_ID
97
+	 * @return array
98
+	 */
99
+	protected function _get_payments($TXN_ID)
100
+	{
101
+		/** @type WPDB $wpdb */
102
+		global $wpdb;
103
+		return $wpdb->get_results($wpdb->prepare("SELECT * FROM {$this->_payment_table} WHERE TXN_ID = %d", $TXN_ID), OBJECT_K);
104
+	}
105
+
106
+
107
+
108
+	/**
109
+	 * _get_possibly_updated_REG_paid
110
+	 *
111
+	 * @param int $REG_ID
112
+	 * @return array
113
+	 */
114
+	protected function _get_possibly_updated_REG_paid($REG_ID)
115
+	{
116
+		/** @type WPDB $wpdb */
117
+		global $wpdb;
118
+		return $wpdb->get_var($wpdb->prepare("SELECT REG_paid FROM {$this->_registration_table} WHERE REG_ID = %d", $REG_ID));
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * _process_registration_payments
125
+	 *
126
+	 * basically a copy of the "Sequential Registration Payment Application Strategy"  logic
127
+	 * currently in EE_Payment_Processor::process_registration_payments()
128
+	 *
129
+	 * @param stdClass $payment
130
+	 * @param array $registrations
131
+	 * @return bool
132
+	 */
133
+	protected function _process_registration_payments($payment, $registrations = array())
134
+	{
135
+		// how much is available to apply to registrations?
136
+		$available_payment_amount = $payment->PAY_amount;
137
+		foreach ($registrations as $REG_ID => $registration) {
138
+			// nothing left, then we are done here?
139
+			if (! $available_payment_amount > 0) {
140
+				break;
141
+			}
142
+			// ensure REG_final_price has a valid value, and skip if it turns out to be zero
143
+			$registration->REG_final_price = ! empty($registration->REG_final_price) ? (float) $registration->REG_final_price : 0.00;
144
+			if (! $registration->REG_final_price > 0) {
145
+				continue;
146
+			}
147
+			// because REG_paid may have been updated by a previous payment, we need to retrieve the value from the db
148
+			$possibly_updated_REG_paid = $this->_get_possibly_updated_REG_paid($REG_ID);
149
+			if (is_float($possibly_updated_REG_paid)) {
150
+				$registration->REG_paid = $possibly_updated_REG_paid;
151
+			}
152
+			// and ensure REG_paid has a valid value
153
+			$registration->REG_paid = ! empty($registration->REG_paid) ? (float) $registration->REG_paid : 0.00;
154
+			// calculate amount owing, and skip if it turns out to be zero
155
+			$owing = $registration->REG_final_price - $registration->REG_paid;
156
+			if (! $owing > 0) {
157
+				continue;
158
+			}
159
+			// don't allow payment amount to exceed the available payment amount, OR the amount owing
160
+			$payment_amount = min($available_payment_amount, $owing);
161
+			// update $available_payment_amount
162
+			$available_payment_amount = $available_payment_amount - $payment_amount;
163
+			// add relation between registration and payment and set amount
164
+			if ($this->_insert_registration_payment($registration->REG_ID, $payment->PAY_ID, $payment_amount)) {
165
+				// calculate and set new REG_paid
166
+				$registration->REG_paid = $registration->REG_paid + $payment_amount;
167
+				$this->_update_registration_paid($registration->REG_ID, $registration->REG_paid);
168
+			}
169
+		}
170
+	}
171
+
172
+
173
+
174
+	/**
175
+	 * _insert_registration_payment
176
+	 *
177
+	 * @param int $REG_ID
178
+	 * @param int $PAY_ID
179
+	 * @param float $PAY_amount
180
+	 * @return bool
181
+	 */
182
+	protected function _insert_registration_payment($REG_ID = 0, $PAY_ID = 0, $PAY_amount = 0.00)
183
+	{
184
+		/** @type WPDB $wpdb */
185
+		global $wpdb;
186
+		$success = $wpdb->insert(
187
+			$this->_registration_payment_table,
188
+			array( 'REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount, ),  // data
189
+			array( '%f' )   // data format
190
+		);
191
+		if ($success === false) {
192
+			$this->add_error(
193
+				sprintf(
194
+					__('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
195
+					$REG_ID,
196
+					$wpdb->last_error
197
+				)
198
+			);
199
+			return false;
200
+		}
201
+		return true;
202
+	}
203
+
204
+
205
+
206
+	/**
207
+	 * _update_registration_paid
208
+	 *
209
+	 * @param int $REG_ID
210
+	 * @param float $REG_paid
211
+	 * @return bool
212
+	 */
213
+	protected function _update_registration_paid($REG_ID = 0, $REG_paid = 0.00)
214
+	{
215
+		/** @type WPDB $wpdb */
216
+		global $wpdb;
217
+		$success = $wpdb->update(
218
+			$this->_registration_table,
219
+			array( 'REG_paid' => $REG_paid ),  // data
220
+			array( 'REG_ID' => $REG_ID ),  // where
221
+			array( '%f' ),   // data format
222
+			array( '%d' )  // where format
223
+		);
224
+		if ($success === false) {
225
+			$this->add_error(
226
+				sprintf(
227
+					__('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
228
+					$REG_ID,
229
+					$wpdb->last_error
230
+				)
231
+			);
232
+			return false;
233
+		}
234
+		return true;
235
+	}
236 236
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
         global $wpdb;
25 25
         $this->_pretty_name = __('Registration Payment Record Generation', 'event_espresso');
26 26
         // define tables
27
-        $this->_old_table                                   = $wpdb->prefix . 'esp_transaction';
28
-        $this->_payment_table                       = $wpdb->prefix . 'esp_payment';
29
-        $this->_registration_table                  = $wpdb->prefix . 'esp_registration';
30
-        $this->_registration_payment_table  = $wpdb->prefix . 'esp_registration_payment';
27
+        $this->_old_table = $wpdb->prefix.'esp_transaction';
28
+        $this->_payment_table                       = $wpdb->prefix.'esp_payment';
29
+        $this->_registration_table                  = $wpdb->prefix.'esp_registration';
30
+        $this->_registration_payment_table = $wpdb->prefix.'esp_registration_payment';
31 31
         // build SQL WHERE clauses
32 32
         $this->_extra_where_sql = "WHERE STS_ID IN ( 'TIN', 'TCM' ) AND TXN_Total != '0.000'";
33 33
         parent::__construct();
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         /** @type WPDB $wpdb */
45 45
         global $wpdb;
46 46
         $TXN_ID = absint($transaction['TXN_ID']);
47
-        if (! $TXN_ID) {
47
+        if ( ! $TXN_ID) {
48 48
             $this->add_error(
49 49
                 sprintf(
50 50
                     __('Invalid transaction with ID=%1$d. Error: "%2$s"', 'event_espresso'),
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
         $available_payment_amount = $payment->PAY_amount;
137 137
         foreach ($registrations as $REG_ID => $registration) {
138 138
             // nothing left, then we are done here?
139
-            if (! $available_payment_amount > 0) {
139
+            if ( ! $available_payment_amount > 0) {
140 140
                 break;
141 141
             }
142 142
             // ensure REG_final_price has a valid value, and skip if it turns out to be zero
143 143
             $registration->REG_final_price = ! empty($registration->REG_final_price) ? (float) $registration->REG_final_price : 0.00;
144
-            if (! $registration->REG_final_price > 0) {
144
+            if ( ! $registration->REG_final_price > 0) {
145 145
                 continue;
146 146
             }
147 147
             // because REG_paid may have been updated by a previous payment, we need to retrieve the value from the db
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             $registration->REG_paid = ! empty($registration->REG_paid) ? (float) $registration->REG_paid : 0.00;
154 154
             // calculate amount owing, and skip if it turns out to be zero
155 155
             $owing = $registration->REG_final_price - $registration->REG_paid;
156
-            if (! $owing > 0) {
156
+            if ( ! $owing > 0) {
157 157
                 continue;
158 158
             }
159 159
             // don't allow payment amount to exceed the available payment amount, OR the amount owing
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
         global $wpdb;
186 186
         $success = $wpdb->insert(
187 187
             $this->_registration_payment_table,
188
-            array( 'REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount, ),  // data
189
-            array( '%f' )   // data format
188
+            array('REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount,), // data
189
+            array('%f')   // data format
190 190
         );
191 191
         if ($success === false) {
192 192
             $this->add_error(
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
         global $wpdb;
217 217
         $success = $wpdb->update(
218 218
             $this->_registration_table,
219
-            array( 'REG_paid' => $REG_paid ),  // data
220
-            array( 'REG_ID' => $REG_ID ),  // where
221
-            array( '%f' ),   // data format
222
-            array( '%d' )  // where format
219
+            array('REG_paid' => $REG_paid), // data
220
+            array('REG_ID' => $REG_ID), // where
221
+            array('%f'), // data format
222
+            array('%d')  // where format
223 223
         );
224 224
         if ($success === false) {
225 225
             $this->add_error(
Please login to merge, or discard this patch.
4_7_0_stages/EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price.dmsstage.php 2 patches
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -12,73 +12,73 @@  discard block
 block discarded – undo
12 12
 class EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14 14
 
15
-    protected $_ticket_table;
16
-
17
-    protected $_line_item_table;
18
-
19
-    public function __construct()
20
-    {
21
-        /** @type WPDB $wpdb */
22
-        global $wpdb;
23
-        $this->_pretty_name = __('Registration Final Price Tax Calculations', 'event_espresso');
24
-        // define tables
25
-        $this->_old_table               = $wpdb->prefix . 'esp_registration';
26
-        $this->_ticket_table            = $wpdb->prefix . 'esp_ticket';
27
-        $this->_line_item_table     = $wpdb->prefix . 'esp_line_item';
28
-        parent::__construct();
29
-    }
30
-
31
-
32
-
33
-    /**
34
-     * @return string
35
-     */
36
-    protected function _get_rest_of_sql_for_query()
37
-    {
38
-        $SQL = "FROM {$this->_old_table} AS reg ";
39
-        $SQL .= "JOIN {$this->_ticket_table} as tkt ON reg.TKT_ID = tkt.TKT_ID ";
40
-        $SQL .= "JOIN {$this->_line_item_table} as line ON reg.TXN_ID = line.TXN_ID ";
41
-        $SQL .= "WHERE tkt.TKT_taxable = 1 ";
42
-        $SQL .= "AND line.LIN_code = 'total' ";
43
-        $SQL .= "AND reg.REG_final_price > 0 ";
44
-        return $SQL;
45
-    }
46
-
47
-
48
-
49
-    /**
50
-     * Counts the records to migrate; the public version may cache it
51
-     * @return int
52
-     */
53
-    public function _count_records_to_migrate()
54
-    {
55
-        /** @type WPDB $wpdb */
56
-        global $wpdb;
57
-        $SQL = "SELECT count( reg.REG_ID ) ";
58
-        $SQL .= $this->_get_rest_of_sql_for_query();
59
-        $count = $wpdb->get_var($SQL);
60
-        return $count;
61
-    }
62
-
63
-
64
-
65
-    /**
66
-     * Gets data for all registrations with taxable tickets in the esp_line_item table
67
-     * @global wpdb $wpdb
68
-     * @param int $limit
69
-     * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
70
-     */
71
-    protected function _get_rows($limit)
72
-    {
73
-        /** @type WPDB $wpdb */
74
-        global $wpdb;
75
-        $start_at_record = $this->count_records_migrated();
76
-        $SQL = "SELECT reg.REG_ID,  reg.REG_final_price, line.LIN_ID ";
77
-        $SQL .= $this->_get_rest_of_sql_for_query();
78
-        $SQL .= $wpdb->prepare("LIMIT %d, %d", $start_at_record, $limit);
79
-
80
-        // produces something like:
81
-        /*
15
+	protected $_ticket_table;
16
+
17
+	protected $_line_item_table;
18
+
19
+	public function __construct()
20
+	{
21
+		/** @type WPDB $wpdb */
22
+		global $wpdb;
23
+		$this->_pretty_name = __('Registration Final Price Tax Calculations', 'event_espresso');
24
+		// define tables
25
+		$this->_old_table               = $wpdb->prefix . 'esp_registration';
26
+		$this->_ticket_table            = $wpdb->prefix . 'esp_ticket';
27
+		$this->_line_item_table     = $wpdb->prefix . 'esp_line_item';
28
+		parent::__construct();
29
+	}
30
+
31
+
32
+
33
+	/**
34
+	 * @return string
35
+	 */
36
+	protected function _get_rest_of_sql_for_query()
37
+	{
38
+		$SQL = "FROM {$this->_old_table} AS reg ";
39
+		$SQL .= "JOIN {$this->_ticket_table} as tkt ON reg.TKT_ID = tkt.TKT_ID ";
40
+		$SQL .= "JOIN {$this->_line_item_table} as line ON reg.TXN_ID = line.TXN_ID ";
41
+		$SQL .= "WHERE tkt.TKT_taxable = 1 ";
42
+		$SQL .= "AND line.LIN_code = 'total' ";
43
+		$SQL .= "AND reg.REG_final_price > 0 ";
44
+		return $SQL;
45
+	}
46
+
47
+
48
+
49
+	/**
50
+	 * Counts the records to migrate; the public version may cache it
51
+	 * @return int
52
+	 */
53
+	public function _count_records_to_migrate()
54
+	{
55
+		/** @type WPDB $wpdb */
56
+		global $wpdb;
57
+		$SQL = "SELECT count( reg.REG_ID ) ";
58
+		$SQL .= $this->_get_rest_of_sql_for_query();
59
+		$count = $wpdb->get_var($SQL);
60
+		return $count;
61
+	}
62
+
63
+
64
+
65
+	/**
66
+	 * Gets data for all registrations with taxable tickets in the esp_line_item table
67
+	 * @global wpdb $wpdb
68
+	 * @param int $limit
69
+	 * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
70
+	 */
71
+	protected function _get_rows($limit)
72
+	{
73
+		/** @type WPDB $wpdb */
74
+		global $wpdb;
75
+		$start_at_record = $this->count_records_migrated();
76
+		$SQL = "SELECT reg.REG_ID,  reg.REG_final_price, line.LIN_ID ";
77
+		$SQL .= $this->_get_rest_of_sql_for_query();
78
+		$SQL .= $wpdb->prepare("LIMIT %d, %d", $start_at_record, $limit);
79
+
80
+		// produces something like:
81
+		/*
82 82
             SELECT
83 83
               reg.REG_ID,
84 84
               reg.REG_final_price,
@@ -95,137 +95,137 @@  discard block
 block discarded – undo
95 95
             LIMIT 1, 50
96 96
          */
97 97
 
98
-        return $wpdb->get_results($SQL, ARRAY_A);
99
-    }
100
-
101
-
102
-
103
-    /**
104
-     * @param array $row
105
-     * @return void
106
-     */
107
-    protected function _migrate_old_row($row)
108
-    {
109
-        /** @type WPDB $wpdb */
110
-        global $wpdb;
111
-        // ensure all required values are present
112
-        if (! isset($row['REG_ID'], $row['REG_final_price'], $row['LIN_ID'])) {
113
-            $this->add_error(
114
-                sprintf(
115
-                    __('Invalid query results returned with the following data:%1$s REG_ID=%2$d, REG_final_price=%3$d, LIN_ID=%4$f. Error: "%5$s"', 'event_espresso'),
116
-                    '<br />',
117
-                    isset($row['REG_ID']) ? $row['REG_ID'] : '',
118
-                    isset($row['REG_final_price']) ? $row['REG_final_price'] : '',
119
-                    isset($row['LIN_ID']) ? $row['LIN_ID'] : '',
120
-                    $wpdb->last_error
121
-                )
122
-            );
123
-            return;
124
-        }
125
-        // get tax subtotal
126
-        $tax_subtotal_line_item_ID = $this->_get_line_item_ID_for_tax_subtotal($row['LIN_ID']);
127
-        if (! $tax_subtotal_line_item_ID) {
128
-            $this->add_error(
129
-                sprintf(
130
-                    __('Invalid line item ID returned. Error: "%1$s"', 'event_espresso'),
131
-                    $wpdb->last_error
132
-                )
133
-            );
134
-            return;
135
-        }
136
-        // now get taxes
137
-        $taxes = $this->_get_tax_amounts($tax_subtotal_line_item_ID);
138
-        // apply taxes to registration final price
139
-        $this->_apply_taxes($row['REG_ID'], $row['REG_final_price'], $taxes);
140
-    }
141
-
142
-
143
-
144
-    /**
145
-     * _get_tax_subtotal
146
-     *
147
-     * @param int $LIN_ID
148
-     * @return int
149
-     */
150
-    protected function _get_line_item_ID_for_tax_subtotal($LIN_ID)
151
-    {
152
-        /** @type WPDB $wpdb */
153
-        global $wpdb;
154
-        $SQL = "SELECT LIN_ID ";
155
-        $SQL .= "FROM {$this->_line_item_table} ";
156
-        $SQL .= "WHERE LIN_parent = %d ";
157
-        $SQL .= "AND LIN_code = 'taxes'";
158
-        return $wpdb->get_var($wpdb->prepare($SQL, $LIN_ID));
159
-    }
160
-
161
-
162
-
163
-    /**
164
-     * _get_tax_subtotal
165
-     *
166
-     * @param int $LIN_ID
167
-     * @return array
168
-     */
169
-    protected function _get_tax_amounts($LIN_ID)
170
-    {
171
-        /** @type WPDB $wpdb */
172
-        global $wpdb;
173
-        $SQL = "SELECT LIN_percent ";
174
-        $SQL .= "FROM {$this->_line_item_table} ";
175
-        $SQL .= "WHERE LIN_parent = %d";
176
-        return $wpdb->get_results($wpdb->prepare($SQL, $LIN_ID), OBJECT_K);
177
-    }
178
-
179
-
180
-
181
-    /**
182
-     * _apply_taxes
183
-     *
184
-     * @param int $REG_ID
185
-     * @param float $final_price
186
-     * @param array $taxes
187
-     * @return void
188
-     */
189
-    protected function _apply_taxes($REG_ID = 0, $final_price = 0.00, $taxes = array())
190
-    {
191
-        if (is_array($taxes) && ! empty($taxes)) {
192
-            $total_taxes = 0;
193
-            foreach ($taxes as $tax) {
194
-                $total_taxes += $final_price * ( $tax->LIN_percent / 100 );
195
-            }
196
-            $final_price += $total_taxes;
197
-            $this->_update_registration_final_price($REG_ID, $final_price);
198
-        }
199
-    }
200
-
201
-
202
-
203
-    /**
204
-     * _update_registration_final_price
205
-     *
206
-     * @param int $REG_ID
207
-     * @param float $REG_final_price
208
-     * @return void
209
-     */
210
-    protected function _update_registration_final_price($REG_ID = 0, $REG_final_price = 0.00)
211
-    {
212
-        /** @type WPDB $wpdb */
213
-        global $wpdb;
214
-        $success = $wpdb->update(
215
-            $this->_old_table,
216
-            array( 'REG_final_price' => $REG_final_price ),  // data
217
-            array( 'REG_ID' => $REG_ID ),  // where
218
-            array( '%f' ),   // data format
219
-            array( '%d' )  // where format
220
-        );
221
-        if ($success === false) {
222
-            $this->add_error(
223
-                sprintf(
224
-                    __('Could not update registration final price value for registration ID=%1$d because "%2$s"', 'event_espresso'),
225
-                    $REG_ID,
226
-                    $wpdb->last_error
227
-                )
228
-            );
229
-        }
230
-    }
98
+		return $wpdb->get_results($SQL, ARRAY_A);
99
+	}
100
+
101
+
102
+
103
+	/**
104
+	 * @param array $row
105
+	 * @return void
106
+	 */
107
+	protected function _migrate_old_row($row)
108
+	{
109
+		/** @type WPDB $wpdb */
110
+		global $wpdb;
111
+		// ensure all required values are present
112
+		if (! isset($row['REG_ID'], $row['REG_final_price'], $row['LIN_ID'])) {
113
+			$this->add_error(
114
+				sprintf(
115
+					__('Invalid query results returned with the following data:%1$s REG_ID=%2$d, REG_final_price=%3$d, LIN_ID=%4$f. Error: "%5$s"', 'event_espresso'),
116
+					'<br />',
117
+					isset($row['REG_ID']) ? $row['REG_ID'] : '',
118
+					isset($row['REG_final_price']) ? $row['REG_final_price'] : '',
119
+					isset($row['LIN_ID']) ? $row['LIN_ID'] : '',
120
+					$wpdb->last_error
121
+				)
122
+			);
123
+			return;
124
+		}
125
+		// get tax subtotal
126
+		$tax_subtotal_line_item_ID = $this->_get_line_item_ID_for_tax_subtotal($row['LIN_ID']);
127
+		if (! $tax_subtotal_line_item_ID) {
128
+			$this->add_error(
129
+				sprintf(
130
+					__('Invalid line item ID returned. Error: "%1$s"', 'event_espresso'),
131
+					$wpdb->last_error
132
+				)
133
+			);
134
+			return;
135
+		}
136
+		// now get taxes
137
+		$taxes = $this->_get_tax_amounts($tax_subtotal_line_item_ID);
138
+		// apply taxes to registration final price
139
+		$this->_apply_taxes($row['REG_ID'], $row['REG_final_price'], $taxes);
140
+	}
141
+
142
+
143
+
144
+	/**
145
+	 * _get_tax_subtotal
146
+	 *
147
+	 * @param int $LIN_ID
148
+	 * @return int
149
+	 */
150
+	protected function _get_line_item_ID_for_tax_subtotal($LIN_ID)
151
+	{
152
+		/** @type WPDB $wpdb */
153
+		global $wpdb;
154
+		$SQL = "SELECT LIN_ID ";
155
+		$SQL .= "FROM {$this->_line_item_table} ";
156
+		$SQL .= "WHERE LIN_parent = %d ";
157
+		$SQL .= "AND LIN_code = 'taxes'";
158
+		return $wpdb->get_var($wpdb->prepare($SQL, $LIN_ID));
159
+	}
160
+
161
+
162
+
163
+	/**
164
+	 * _get_tax_subtotal
165
+	 *
166
+	 * @param int $LIN_ID
167
+	 * @return array
168
+	 */
169
+	protected function _get_tax_amounts($LIN_ID)
170
+	{
171
+		/** @type WPDB $wpdb */
172
+		global $wpdb;
173
+		$SQL = "SELECT LIN_percent ";
174
+		$SQL .= "FROM {$this->_line_item_table} ";
175
+		$SQL .= "WHERE LIN_parent = %d";
176
+		return $wpdb->get_results($wpdb->prepare($SQL, $LIN_ID), OBJECT_K);
177
+	}
178
+
179
+
180
+
181
+	/**
182
+	 * _apply_taxes
183
+	 *
184
+	 * @param int $REG_ID
185
+	 * @param float $final_price
186
+	 * @param array $taxes
187
+	 * @return void
188
+	 */
189
+	protected function _apply_taxes($REG_ID = 0, $final_price = 0.00, $taxes = array())
190
+	{
191
+		if (is_array($taxes) && ! empty($taxes)) {
192
+			$total_taxes = 0;
193
+			foreach ($taxes as $tax) {
194
+				$total_taxes += $final_price * ( $tax->LIN_percent / 100 );
195
+			}
196
+			$final_price += $total_taxes;
197
+			$this->_update_registration_final_price($REG_ID, $final_price);
198
+		}
199
+	}
200
+
201
+
202
+
203
+	/**
204
+	 * _update_registration_final_price
205
+	 *
206
+	 * @param int $REG_ID
207
+	 * @param float $REG_final_price
208
+	 * @return void
209
+	 */
210
+	protected function _update_registration_final_price($REG_ID = 0, $REG_final_price = 0.00)
211
+	{
212
+		/** @type WPDB $wpdb */
213
+		global $wpdb;
214
+		$success = $wpdb->update(
215
+			$this->_old_table,
216
+			array( 'REG_final_price' => $REG_final_price ),  // data
217
+			array( 'REG_ID' => $REG_ID ),  // where
218
+			array( '%f' ),   // data format
219
+			array( '%d' )  // where format
220
+		);
221
+		if ($success === false) {
222
+			$this->add_error(
223
+				sprintf(
224
+					__('Could not update registration final price value for registration ID=%1$d because "%2$s"', 'event_espresso'),
225
+					$REG_ID,
226
+					$wpdb->last_error
227
+				)
228
+			);
229
+		}
230
+	}
231 231
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
         global $wpdb;
23 23
         $this->_pretty_name = __('Registration Final Price Tax Calculations', 'event_espresso');
24 24
         // define tables
25
-        $this->_old_table               = $wpdb->prefix . 'esp_registration';
26
-        $this->_ticket_table            = $wpdb->prefix . 'esp_ticket';
27
-        $this->_line_item_table     = $wpdb->prefix . 'esp_line_item';
25
+        $this->_old_table               = $wpdb->prefix.'esp_registration';
26
+        $this->_ticket_table            = $wpdb->prefix.'esp_ticket';
27
+        $this->_line_item_table = $wpdb->prefix.'esp_line_item';
28 28
         parent::__construct();
29 29
     }
30 30
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         /** @type WPDB $wpdb */
110 110
         global $wpdb;
111 111
         // ensure all required values are present
112
-        if (! isset($row['REG_ID'], $row['REG_final_price'], $row['LIN_ID'])) {
112
+        if ( ! isset($row['REG_ID'], $row['REG_final_price'], $row['LIN_ID'])) {
113 113
             $this->add_error(
114 114
                 sprintf(
115 115
                     __('Invalid query results returned with the following data:%1$s REG_ID=%2$d, REG_final_price=%3$d, LIN_ID=%4$f. Error: "%5$s"', 'event_espresso'),
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         }
125 125
         // get tax subtotal
126 126
         $tax_subtotal_line_item_ID = $this->_get_line_item_ID_for_tax_subtotal($row['LIN_ID']);
127
-        if (! $tax_subtotal_line_item_ID) {
127
+        if ( ! $tax_subtotal_line_item_ID) {
128 128
             $this->add_error(
129 129
                 sprintf(
130 130
                     __('Invalid line item ID returned. Error: "%1$s"', 'event_espresso'),
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         if (is_array($taxes) && ! empty($taxes)) {
192 192
             $total_taxes = 0;
193 193
             foreach ($taxes as $tax) {
194
-                $total_taxes += $final_price * ( $tax->LIN_percent / 100 );
194
+                $total_taxes += $final_price * ($tax->LIN_percent / 100);
195 195
             }
196 196
             $final_price += $total_taxes;
197 197
             $this->_update_registration_final_price($REG_ID, $final_price);
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
         global $wpdb;
214 214
         $success = $wpdb->update(
215 215
             $this->_old_table,
216
-            array( 'REG_final_price' => $REG_final_price ),  // data
217
-            array( 'REG_ID' => $REG_ID ),  // where
218
-            array( '%f' ),   // data format
219
-            array( '%d' )  // where format
216
+            array('REG_final_price' => $REG_final_price), // data
217
+            array('REG_ID' => $REG_ID), // where
218
+            array('%f'), // data format
219
+            array('%d')  // where format
220 220
         );
221 221
         if ($success === false) {
222 222
             $this->add_error(
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Unknown_1_0_0.core.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -18,44 +18,44 @@
 block discarded – undo
18 18
 class EE_DMS_Unknown_1_0_0 extends EE_Data_Migration_Script_Base
19 19
 {
20 20
 
21
-    /**
22
-     * Returns whether or not this data migration script can operate on the given version of the database.
23
-     * Eg, if this migration script can migrate from 3.1.26 or higher (but not anything after 4.0.0), and
24
-     * it's passed a string like '3.1.38B', it should return true
25
-     *
26
-     * @param string $version_string
27
-     * @return boolean
28
-     */
29
-    public function can_migrate_from_version($version_string)
30
-    {
31
-        return false;
32
-    }
33
-
34
-    public function schema_changes_after_migration()
35
-    {
36
-        return;
37
-    }
38
-
39
-    public function schema_changes_before_migration()
40
-    {
41
-        return;
42
-    }
43
-
44
-
45
-    /**
46
-     * All children of this must call parent::__construct() at the end of their constructor or suffer the consequences!
47
-     *
48
-     * @param TableManager  $table_manager
49
-     * @param TableAnalysis $table_analysis
50
-     */
51
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
52
-    {
53
-        $this->_migration_stages = array();
54
-        $this->_pretty_name = __("Fatal Uncatchable Error Occurred", "event_espresso");
55
-        parent::__construct($table_manager, $table_analysis);
56
-    }
57
-
58
-    public function migration_page_hooks()
59
-    {
60
-    }
21
+	/**
22
+	 * Returns whether or not this data migration script can operate on the given version of the database.
23
+	 * Eg, if this migration script can migrate from 3.1.26 or higher (but not anything after 4.0.0), and
24
+	 * it's passed a string like '3.1.38B', it should return true
25
+	 *
26
+	 * @param string $version_string
27
+	 * @return boolean
28
+	 */
29
+	public function can_migrate_from_version($version_string)
30
+	{
31
+		return false;
32
+	}
33
+
34
+	public function schema_changes_after_migration()
35
+	{
36
+		return;
37
+	}
38
+
39
+	public function schema_changes_before_migration()
40
+	{
41
+		return;
42
+	}
43
+
44
+
45
+	/**
46
+	 * All children of this must call parent::__construct() at the end of their constructor or suffer the consequences!
47
+	 *
48
+	 * @param TableManager  $table_manager
49
+	 * @param TableAnalysis $table_analysis
50
+	 */
51
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
52
+	{
53
+		$this->_migration_stages = array();
54
+		$this->_pretty_name = __("Fatal Uncatchable Error Occurred", "event_espresso");
55
+		parent::__construct($table_manager, $table_analysis);
56
+	}
57
+
58
+	public function migration_page_hooks()
59
+	{
60
+	}
61 61
 }
Please login to merge, or discard this patch.
4_9_0_stages/EE_DMS_4_9_0_Answers_With_No_Registration.dmsstage.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -15,44 +15,44 @@
 block discarded – undo
15 15
 
16 16
 
17 17
 
18
-    /**
19
-     * Just initializes the status of the migration
20
-     *
21
-     * @return EE_DMS_4_9_0_Answers_With_No_Registration
22
-     */
23
-    public function __construct()
24
-    {
25
-        $this->_pretty_name = __('Answer Cleanup', 'event_espresso');
26
-        parent::__construct();
27
-    }
18
+	/**
19
+	 * Just initializes the status of the migration
20
+	 *
21
+	 * @return EE_DMS_4_9_0_Answers_With_No_Registration
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$this->_pretty_name = __('Answer Cleanup', 'event_espresso');
26
+		parent::__construct();
27
+	}
28 28
 
29
-    /**
30
-     * Counts the records to migrate; the public version may cache it
31
-     * @return int
32
-     */
33
-    protected function _count_records_to_migrate()
34
-    {
35
-        return 1;
36
-    }
29
+	/**
30
+	 * Counts the records to migrate; the public version may cache it
31
+	 * @return int
32
+	 */
33
+	protected function _count_records_to_migrate()
34
+	{
35
+		return 1;
36
+	}
37 37
 
38
-    /**
39
-     * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly.
40
-     * Note: it should not alter the count of items migrated. That is done in the public function that calls this.
41
-     * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it
42
-     * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50,
43
-     * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated)
44
-     * @param int $num_items_to_migrate
45
-     * @return int number of items ACTUALLY migrated
46
-     */
47
-    protected function _migration_step($num_items_to_migrate = 50)
48
-    {
49
-        global $wpdb;
50
-        $wpdb->delete(
51
-            $wpdb->prefix . 'esp_answer',
52
-            array( 'REG_ID' => 0 ),
53
-            array( '%d' )
54
-        );
55
-        $this->set_completed();
56
-        return 1;
57
-    }
38
+	/**
39
+	 * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly.
40
+	 * Note: it should not alter the count of items migrated. That is done in the public function that calls this.
41
+	 * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it
42
+	 * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50,
43
+	 * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated)
44
+	 * @param int $num_items_to_migrate
45
+	 * @return int number of items ACTUALLY migrated
46
+	 */
47
+	protected function _migration_step($num_items_to_migrate = 50)
48
+	{
49
+		global $wpdb;
50
+		$wpdb->delete(
51
+			$wpdb->prefix . 'esp_answer',
52
+			array( 'REG_ID' => 0 ),
53
+			array( '%d' )
54
+		);
55
+		$this->set_completed();
56
+		return 1;
57
+	}
58 58
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,9 +48,9 @@
 block discarded – undo
48 48
     {
49 49
         global $wpdb;
50 50
         $wpdb->delete(
51
-            $wpdb->prefix . 'esp_answer',
52
-            array( 'REG_ID' => 0 ),
53
-            array( '%d' )
51
+            $wpdb->prefix.'esp_answer',
52
+            array('REG_ID' => 0),
53
+            array('%d')
54 54
         );
55 55
         $this->set_completed();
56 56
         return 1;
Please login to merge, or discard this patch.
4_9_0_stages/EE_DMS_4_9_0_Email_System_Question.dmsstage.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -14,48 +14,48 @@
 block discarded – undo
14 14
 
15 15
 
16 16
 
17
-    /**
18
-     * Just initializes the status of the migration
19
-     *
20
-     * @return EE_DMS_4_9_0_Email_System_Question
21
-     */
22
-    public function __construct()
23
-    {
24
-        global $wpdb;
25
-        $this->_pretty_name = __('Email - System Question', 'event_espresso');
26
-        $this->_old_table = $wpdb->prefix.'esp_question';
27
-        $this->_extra_where_sql = "WHERE QST_system = 'email'";
28
-        parent::__construct();
29
-    }
17
+	/**
18
+	 * Just initializes the status of the migration
19
+	 *
20
+	 * @return EE_DMS_4_9_0_Email_System_Question
21
+	 */
22
+	public function __construct()
23
+	{
24
+		global $wpdb;
25
+		$this->_pretty_name = __('Email - System Question', 'event_espresso');
26
+		$this->_old_table = $wpdb->prefix.'esp_question';
27
+		$this->_extra_where_sql = "WHERE QST_system = 'email'";
28
+		parent::__construct();
29
+	}
30 30
 
31 31
 
32 32
 
33
-    /**
34
-     * updates the question with the new question type
35
-     * @param array $question an associative array where keys are column names and values are their values.
36
-     * @return null
37
-     */
38
-    protected function _migrate_old_row($question)
39
-    {
40
-        if ($question['QST_ID'] && $question['QST_system'] == 'email') {
41
-            global $wpdb;
42
-            $success = $wpdb->update(
43
-                $this->_old_table,
44
-                array( 'QST_type' => 'EMAIL' ),  // data
45
-                array( 'QST_ID' => $question['QST_ID'] ),  // where
46
-                array( '%s' ),   // data format
47
-                array( '%d' )  // where format
48
-            );
49
-            if (! $success) {
50
-                $this->add_error(
51
-                    sprintf(
52
-                        __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
53
-                        wp_json_encode($question['QST_system']),
54
-                        $question['QST_ID'],
55
-                        $wpdb->last_error
56
-                    )
57
-                );
58
-            }
59
-        }
60
-    }
33
+	/**
34
+	 * updates the question with the new question type
35
+	 * @param array $question an associative array where keys are column names and values are their values.
36
+	 * @return null
37
+	 */
38
+	protected function _migrate_old_row($question)
39
+	{
40
+		if ($question['QST_ID'] && $question['QST_system'] == 'email') {
41
+			global $wpdb;
42
+			$success = $wpdb->update(
43
+				$this->_old_table,
44
+				array( 'QST_type' => 'EMAIL' ),  // data
45
+				array( 'QST_ID' => $question['QST_ID'] ),  // where
46
+				array( '%s' ),   // data format
47
+				array( '%d' )  // where format
48
+			);
49
+			if (! $success) {
50
+				$this->add_error(
51
+					sprintf(
52
+						__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
53
+						wp_json_encode($question['QST_system']),
54
+						$question['QST_ID'],
55
+						$wpdb->last_error
56
+					)
57
+				);
58
+			}
59
+		}
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,12 +41,12 @@
 block discarded – undo
41 41
             global $wpdb;
42 42
             $success = $wpdb->update(
43 43
                 $this->_old_table,
44
-                array( 'QST_type' => 'EMAIL' ),  // data
45
-                array( 'QST_ID' => $question['QST_ID'] ),  // where
46
-                array( '%s' ),   // data format
47
-                array( '%d' )  // where format
44
+                array('QST_type' => 'EMAIL'), // data
45
+                array('QST_ID' => $question['QST_ID']), // where
46
+                array('%s'), // data format
47
+                array('%d')  // where format
48 48
             );
49
-            if (! $success) {
49
+            if ( ! $success) {
50 50
                 $this->add_error(
51 51
                     sprintf(
52 52
                         __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_8_0.dms.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 // unfortunately, this needs to be done upon INCLUSION of this file,
15 15
 // instead of construction, because it only gets constructed on first page load
16 16
 // (all other times it gets resurrected from a wordpress option)
17
-$stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*');
17
+$stages = glob(EE_CORE.'data_migration_scripts/4_8_0_stages/*');
18 18
 $class_to_filepath = array();
19 19
 foreach ($stages as $filepath) {
20 20
     $matches = array();
21 21
     preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
-    $class_to_filepath[ $matches[1] ] = $filepath;
22
+    $class_to_filepath[$matches[1]] = $filepath;
23 23
 }
24 24
 // give addons a chance to autoload their stages too
25 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath);
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
         if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) {
73 73
 //          echo "$version_string can be migrated from";
74 74
             return true;
75
-        } elseif (! $version_string) {
75
+        } elseif ( ! $version_string) {
76 76
 //          echo "no version string provided: $version_string";
77 77
             // no version string provided... this must be pre 4.3
78
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
78
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
79 79
         } else {
80 80
 //          echo "$version_string doesnt apply";
81 81
             return false;
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function schema_changes_before_migration()
91 91
     {
92
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
93 93
         $now_in_mysql = current_time('mysql', true);
94
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
94
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
95 95
         $table_name = 'esp_answer';
96 96
         $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
97 97
 					REG_ID int(10) unsigned NOT NULL,
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
             ),
688 688
         );
689 689
         global $wpdb;
690
-        $country_table = $wpdb->prefix . "esp_country";
690
+        $country_table = $wpdb->prefix."esp_country";
691 691
         $country_format = array(
692 692
             "CNT_ISO"         => '%s',
693 693
             "CNT_ISO3"        => '%s',
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
             foreach ($newer_countries as $country) {
708 708
                 $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
709 709
                 $countries = $wpdb->get_var($SQL);
710
-                if (! $countries) {
710
+                if ( ! $countries) {
711 711
                     $wpdb->insert(
712 712
                         $country_table,
713 713
                         array_combine(array_keys($country_format), $country),
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
             array('RSD', 'Dinar', 'Dinars', '', 3, 1),
735 735
         );
736 736
         global $wpdb;
737
-        $currency_table = $wpdb->prefix . "esp_currency";
737
+        $currency_table = $wpdb->prefix."esp_currency";
738 738
         $currency_format = array(
739 739
             "CUR_code"    => '%s',
740 740
             "CUR_single"  => '%s',
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
             foreach ($newer_currencies as $currency) {
748 748
                 $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
749 749
                 $countries = $wpdb->get_var($SQL);
750
-                if (! $countries) {
750
+                if ( ! $countries) {
751 751
                     $wpdb->insert(
752 752
                         $currency_table,
753 753
                         array_combine(array_keys($currency_format), $currency),
Please login to merge, or discard this patch.
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 $stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*');
18 18
 $class_to_filepath = array();
19 19
 foreach ($stages as $filepath) {
20
-    $matches = array();
21
-    preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
-    $class_to_filepath[ $matches[1] ] = $filepath;
20
+	$matches = array();
21
+	preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
+	$class_to_filepath[ $matches[1] ] = $filepath;
23 23
 }
24 24
 // give addons a chance to autoload their stages too
25 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath);
@@ -38,71 +38,71 @@  discard block
 block discarded – undo
38 38
 class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base
39 39
 {
40 40
 
41
-    /**
42
-     * return EE_DMS_Core_4_8_0
43
-     *
44
-     * @param TableManager  $table_manager
45
-     * @param TableAnalysis $table_analysis
46
-     */
47
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
48
-    {
49
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso");
50
-        $this->_priority = 10;
51
-        $this->_migration_stages = array(
52
-            new EE_DMS_4_8_0_pretax_totals(),
53
-            new EE_DMS_4_8_0_event_subtotals(),
54
-        );
55
-        parent::__construct($table_manager, $table_analysis);
56
-    }
41
+	/**
42
+	 * return EE_DMS_Core_4_8_0
43
+	 *
44
+	 * @param TableManager  $table_manager
45
+	 * @param TableAnalysis $table_analysis
46
+	 */
47
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
48
+	{
49
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso");
50
+		$this->_priority = 10;
51
+		$this->_migration_stages = array(
52
+			new EE_DMS_4_8_0_pretax_totals(),
53
+			new EE_DMS_4_8_0_event_subtotals(),
54
+		);
55
+		parent::__construct($table_manager, $table_analysis);
56
+	}
57 57
 
58 58
 
59 59
 
60
-    /**
61
-     * Because this is being done at basically the same time as the MER-ready branch
62
-     * of core, it's possible people might have installed MEr-ready branch first,
63
-     * and then this one, in which case we still want to perform this migration,
64
-     * even though the version might not have increased
65
-     *
66
-     * @param array $version_array
67
-     * @return bool
68
-     */
69
-    public function can_migrate_from_version($version_array)
70
-    {
71
-        $version_string = $version_array['Core'];
72
-        if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) {
60
+	/**
61
+	 * Because this is being done at basically the same time as the MER-ready branch
62
+	 * of core, it's possible people might have installed MEr-ready branch first,
63
+	 * and then this one, in which case we still want to perform this migration,
64
+	 * even though the version might not have increased
65
+	 *
66
+	 * @param array $version_array
67
+	 * @return bool
68
+	 */
69
+	public function can_migrate_from_version($version_array)
70
+	{
71
+		$version_string = $version_array['Core'];
72
+		if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) {
73 73
 //          echo "$version_string can be migrated from";
74
-            return true;
75
-        } elseif (! $version_string) {
74
+			return true;
75
+		} elseif (! $version_string) {
76 76
 //          echo "no version string provided: $version_string";
77
-            // no version string provided... this must be pre 4.3
78
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
79
-        } else {
77
+			// no version string provided... this must be pre 4.3
78
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
79
+		} else {
80 80
 //          echo "$version_string doesnt apply";
81
-            return false;
82
-        }
83
-    }
81
+			return false;
82
+		}
83
+	}
84 84
 
85 85
 
86 86
 
87
-    /**
88
-     * @return bool
89
-     */
90
-    public function schema_changes_before_migration()
91
-    {
92
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
93
-        $now_in_mysql = current_time('mysql', true);
94
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
-        $table_name = 'esp_answer';
96
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
87
+	/**
88
+	 * @return bool
89
+	 */
90
+	public function schema_changes_before_migration()
91
+	{
92
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
93
+		$now_in_mysql = current_time('mysql', true);
94
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
+		$table_name = 'esp_answer';
96
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
97 97
 					REG_ID int(10) unsigned NOT NULL,
98 98
 					QST_ID int(10) unsigned NOT NULL,
99 99
 					ANS_value text NOT NULL,
100 100
 					PRIMARY KEY  (ANS_ID),
101 101
 					KEY REG_ID (REG_ID),
102 102
 					KEY QST_ID (QST_ID)";
103
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
104
-        $table_name = 'esp_attendee_meta';
105
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
103
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
104
+		$table_name = 'esp_attendee_meta';
105
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
106 106
 						ATT_ID bigint(20) unsigned NOT NULL,
107 107
 						ATT_fname varchar(45) NOT NULL,
108 108
 						ATT_lname varchar(45) NOT	NULL,
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 							PRIMARY KEY  (ATTM_ID),
118 118
 								KEY ATT_ID (ATT_ID),
119 119
 								KEY ATT_email (ATT_email(191))";
120
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
121
-        $table_name = 'esp_country';
122
-        $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL,
120
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
121
+		$table_name = 'esp_country';
122
+		$sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL,
123 123
 					  CNT_ISO3 varchar(3) collate utf8_bin NOT NULL,
124 124
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
125 125
 					  CNT_name varchar(45) collate utf8_bin NOT NULL,
@@ -135,25 +135,25 @@  discard block
 block discarded – undo
135 135
 					  CNT_is_EU tinyint(1) DEFAULT '0',
136 136
 					  CNT_active tinyint(1) DEFAULT '0',
137 137
 					  PRIMARY KEY  (CNT_ISO)";
138
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
139
-        $table_name = 'esp_currency';
140
-        $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
138
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
139
+		$table_name = 'esp_currency';
140
+		$sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
141 141
 				CUR_single varchar(45) collate utf8_bin DEFAULT 'dollar',
142 142
 				CUR_plural varchar(45) collate utf8_bin DEFAULT 'dollars',
143 143
 				CUR_sign varchar(45) collate utf8_bin DEFAULT '$',
144 144
 				CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2',
145 145
 				CUR_active tinyint(1) DEFAULT '0',
146 146
 				PRIMARY KEY  (CUR_code)";
147
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
148
-        $table_name = 'esp_currency_payment_method';
149
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
147
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
148
+		$table_name = 'esp_currency_payment_method';
149
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
150 150
 				CUR_code varchar(6) collate utf8_bin NOT NULL,
151 151
 				PMD_ID int(11) NOT NULL,
152 152
 				PRIMARY KEY  (CPM_ID),
153 153
 				KEY PMD_ID (PMD_ID)";
154
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
155
-        $table_name = 'esp_datetime';
156
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
154
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
155
+		$table_name = 'esp_datetime';
156
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
157 157
 				  EVT_ID bigint(20) unsigned NOT NULL,
158 158
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
159 159
 				  DTT_description text NOT NULL,
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 						KEY DTT_EVT_start (DTT_EVT_start),
170 170
 						KEY EVT_ID (EVT_ID),
171 171
 						KEY DTT_is_primary (DTT_is_primary)";
172
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
173
-        $table_name = 'esp_event_meta';
174
-        $sql = "
172
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
173
+		$table_name = 'esp_event_meta';
174
+		$sql = "
175 175
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
176 176
 			EVT_ID bigint(20) unsigned NOT NULL,
177 177
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -187,34 +187,34 @@  discard block
 block discarded – undo
187 187
 			EVT_donations tinyint(1) NULL,
188 188
 			PRIMARY KEY  (EVTM_ID),
189 189
 			KEY EVT_ID (EVT_ID)";
190
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
191
-        $table_name = 'esp_event_question_group';
192
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
190
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
191
+		$table_name = 'esp_event_question_group';
192
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
193 193
 					EVT_ID bigint(20) unsigned NOT NULL,
194 194
 					QSG_ID int(10) unsigned NOT NULL,
195 195
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
196 196
 					PRIMARY KEY  (EQG_ID),
197 197
 					KEY EVT_ID (EVT_ID),
198 198
 					KEY QSG_ID (QSG_ID)";
199
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
200
-        $table_name = 'esp_event_venue';
201
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
199
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
200
+		$table_name = 'esp_event_venue';
201
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
202 202
 				EVT_ID bigint(20) unsigned NOT NULL,
203 203
 				VNU_ID bigint(20) unsigned NOT NULL,
204 204
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
205 205
 				PRIMARY KEY  (EVV_ID)";
206
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
207
-        $table_name = 'esp_extra_meta';
208
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
206
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
207
+		$table_name = 'esp_extra_meta';
208
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
209 209
 				OBJ_ID int(11) DEFAULT NULL,
210 210
 				EXM_type varchar(45) DEFAULT NULL,
211 211
 				EXM_key varchar(45) DEFAULT NULL,
212 212
 				EXM_value text,
213 213
 				PRIMARY KEY  (EXM_ID),
214 214
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
215
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
216
-        $table_name = 'esp_extra_join';
217
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
215
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
216
+		$table_name = 'esp_extra_join';
217
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
218 218
 				EXJ_first_model_id varchar(6) NOT NULL,
219 219
 				EXJ_first_model_name varchar(20) NOT NULL,
220 220
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 				PRIMARY KEY  (EXJ_ID),
223 223
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
224 224
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
225
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
226
-        $table_name = 'esp_line_item';
227
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
225
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
226
+		$table_name = 'esp_line_item';
227
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
228 228
 				LIN_code varchar(245) NOT NULL DEFAULT '',
229 229
 				TXN_ID int(11) DEFAULT NULL,
230 230
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 				PRIMARY KEY  (LIN_ID),
244 244
 				KEY LIN_code (LIN_code(191)),
245 245
 				KEY TXN_ID (TXN_ID)";
246
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
-        $table_name = 'esp_log';
248
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
246
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
+		$table_name = 'esp_log';
248
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
249 249
 				LOG_time datetime DEFAULT NULL,
250 250
 				OBJ_ID varchar(45) DEFAULT NULL,
251 251
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -256,18 +256,18 @@  discard block
 block discarded – undo
256 256
 				KEY LOG_time (LOG_time),
257 257
 				KEY OBJ (OBJ_type,OBJ_ID),
258 258
 				KEY LOG_type (LOG_type)";
259
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
260
-        $table_name = 'esp_message_template';
261
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
259
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
260
+		$table_name = 'esp_message_template';
261
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
262 262
 					GRP_ID int(10) unsigned NOT NULL,
263 263
 					MTP_context varchar(50) NOT NULL,
264 264
 					MTP_template_field varchar(30) NOT NULL,
265 265
 					MTP_content text NOT NULL,
266 266
 					PRIMARY KEY  (MTP_ID),
267 267
 					KEY GRP_ID (GRP_ID)";
268
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
269
-        $table_name = 'esp_message_template_group';
270
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
268
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
269
+		$table_name = 'esp_message_template_group';
270
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
271 271
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
272 272
 					MTP_name varchar(245) NOT NULL DEFAULT '',
273 273
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
280 280
 					PRIMARY KEY  (GRP_ID),
281 281
 					KEY MTP_user_id (MTP_user_id)";
282
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
283
-        $table_name = 'esp_event_message_template';
284
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
282
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
283
+		$table_name = 'esp_event_message_template';
284
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
285 285
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
286 286
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
287 287
 					PRIMARY KEY  (EMT_ID),
288 288
 					KEY EVT_ID (EVT_ID),
289 289
 					KEY GRP_ID (GRP_ID)";
290
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
-        $table_name = 'esp_payment';
292
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
290
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
+		$table_name = 'esp_payment';
292
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
293 293
 					TXN_ID int(10) unsigned DEFAULT NULL,
294 294
 					STS_ID varchar(3) collate utf8_bin DEFAULT NULL,
295 295
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
 					PRIMARY KEY  (PAY_ID),
307 307
 					KEY PAY_timestamp (PAY_timestamp),
308 308
 					KEY TXN_ID (TXN_ID)";
309
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
310
-        $table_name = 'esp_payment_method';
311
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
309
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
310
+		$table_name = 'esp_payment_method';
311
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
312 312
 				PMD_type varchar(124) DEFAULT NULL,
313 313
 				PMD_name varchar(255) DEFAULT NULL,
314 314
 				PMD_desc text,
@@ -324,32 +324,32 @@  discard block
 block discarded – undo
324 324
 				PRIMARY KEY  (PMD_ID),
325 325
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
326 326
 				KEY PMD_type (PMD_type)";
327
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
328
-        $table_name = "esp_ticket_price";
329
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
327
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
328
+		$table_name = "esp_ticket_price";
329
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
330 330
 					  TKT_ID int(10) unsigned NOT NULL,
331 331
 					  PRC_ID int(10) unsigned NOT NULL,
332 332
 					  PRIMARY KEY  (TKP_ID),
333 333
 					  KEY TKT_ID (TKT_ID),
334 334
 					  KEY PRC_ID (PRC_ID)";
335
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
336
-        $table_name = "esp_datetime_ticket";
337
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
335
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
336
+		$table_name = "esp_datetime_ticket";
337
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
338 338
 					  DTT_ID int(10) unsigned NOT NULL,
339 339
 					  TKT_ID int(10) unsigned NOT NULL,
340 340
 					  PRIMARY KEY  (DTK_ID),
341 341
 					  KEY DTT_ID (DTT_ID),
342 342
 					  KEY TKT_ID (TKT_ID)";
343
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
344
-        $table_name = "esp_ticket_template";
345
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
344
+		$table_name = "esp_ticket_template";
345
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
346 346
 					  TTM_name varchar(45) NOT NULL,
347 347
 					  TTM_description text,
348 348
 					  TTM_file varchar(45),
349 349
 					  PRIMARY KEY  (TTM_ID)";
350
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
-        $table_name = 'esp_question';
352
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
+		$table_name = 'esp_question';
352
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
353 353
 					QST_display_text text NOT NULL,
354 354
 					QST_admin_label varchar(255) NOT NULL,
355 355
 					QST_system varchar(25) NOT NULL DEFAULT "",
@@ -363,18 +363,18 @@  discard block
 block discarded – undo
363 363
 					QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
364 364
 					PRIMARY KEY  (QST_ID),
365 365
 					KEY QST_order (QST_order)';
366
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
367
-        $table_name = 'esp_question_group_question';
368
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
366
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
367
+		$table_name = 'esp_question_group_question';
368
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
369 369
 					QSG_ID int(10) unsigned NOT NULL,
370 370
 					QST_ID int(10) unsigned NOT NULL,
371 371
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
372 372
 					PRIMARY KEY  (QGQ_ID),
373 373
 					KEY QST_ID (QST_ID),
374 374
 					KEY QSG_ID_order (QSG_ID,QGQ_order)";
375
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
-        $table_name = 'esp_question_option';
377
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
375
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
+		$table_name = 'esp_question_option';
377
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
378 378
 					QSO_value varchar(255) NOT NULL,
379 379
 					QSO_desc text NOT NULL,
380 380
 					QST_ID int(10) unsigned NOT NULL,
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 					PRIMARY KEY  (QSO_ID),
385 385
 					KEY QST_ID (QST_ID),
386 386
 					KEY QSO_order (QSO_order)";
387
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
388
-        $table_name = 'esp_registration';
389
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
387
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
388
+		$table_name = 'esp_registration';
389
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
390 390
 					  EVT_ID bigint(20) unsigned NOT NULL,
391 391
 					  ATT_ID bigint(20) unsigned NOT NULL,
392 392
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 					  KEY TKT_ID (TKT_ID),
411 411
 					  KEY EVT_ID (EVT_ID),
412 412
 					  KEY STS_ID (STS_ID)";
413
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
414
-        $table_name = 'esp_registration_payment';
415
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
413
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
414
+		$table_name = 'esp_registration_payment';
415
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
416 416
 					  REG_ID int(10) unsigned NOT NULL,
417 417
 					  PAY_ID int(10) unsigned NULL,
418 418
 					  RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00',
419 419
 					  PRIMARY KEY  (RPY_ID),
420 420
 					  KEY REG_ID (REG_ID),
421 421
 					  KEY PAY_ID (PAY_ID)";
422
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
423
-        $table_name = 'esp_checkin';
424
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
422
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
423
+		$table_name = 'esp_checkin';
424
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
425 425
 					REG_ID int(10) unsigned NOT NULL,
426 426
 					DTT_ID int(10) unsigned NOT NULL,
427 427
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
 					PRIMARY KEY  (CHK_ID),
430 430
 					KEY REG_ID (REG_ID),
431 431
 					KEY DTT_ID (DTT_ID)";
432
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
433
-        $table_name = 'esp_state';
434
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
432
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
433
+		$table_name = 'esp_state';
434
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
435 435
 					  CNT_ISO varchar(2) collate utf8_bin NOT NULL,
436 436
 					  STA_abbrev varchar(24) collate utf8_bin NOT NULL,
437 437
 					  STA_name varchar(100) collate utf8_bin NOT NULL,
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
 					  PRIMARY KEY  (STA_ID),
440 440
 					  KEY STA_abbrev (STA_abbrev),
441 441
 					  KEY CNT_ISO (CNT_ISO)";
442
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
443
-        $table_name = 'esp_status';
444
-        $sql = "STS_ID varchar(3) NOT NULL,
442
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
443
+		$table_name = 'esp_status';
444
+		$sql = "STS_ID varchar(3) NOT NULL,
445 445
 					  STS_code varchar(45) NOT NULL,
446 446
 					  STS_type varchar(45) NOT NULL,
447 447
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
450 450
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
451 451
 					  KEY STS_type (STS_type)";
452
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
453
-        $table_name = 'esp_transaction';
454
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
452
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
453
+		$table_name = 'esp_transaction';
454
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
455 455
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
456 456
 					  TXN_total decimal(10,3) DEFAULT '0.00',
457 457
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -463,9 +463,9 @@  discard block
 block discarded – undo
463 463
 					  PRIMARY KEY  (TXN_ID),
464 464
 					  KEY TXN_timestamp (TXN_timestamp),
465 465
 					  KEY STS_ID (STS_ID)";
466
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
467
-        $table_name = 'esp_venue_meta';
468
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
466
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
467
+		$table_name = 'esp_venue_meta';
468
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
469 469
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
470 470
 			VNU_address varchar(255) DEFAULT NULL,
471 471
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
 			KEY VNU_ID (VNU_ID),
485 485
 			KEY STA_ID (STA_ID),
486 486
 			KEY CNT_ISO (CNT_ISO)";
487
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
488
-        // modified tables
489
-        $table_name = "esp_price";
490
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
487
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
488
+		// modified tables
489
+		$table_name = "esp_price";
490
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
491 491
 					  PRT_ID tinyint(3) unsigned NOT NULL,
492 492
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
493 493
 					  PRC_name varchar(245) NOT NULL,
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 					  PRC_parent int(10) unsigned DEFAULT 0,
501 501
 					  PRIMARY KEY  (PRC_ID),
502 502
 					  KEY PRT_ID (PRT_ID)";
503
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
504
-        $table_name = "esp_price_type";
505
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
503
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
504
+		$table_name = "esp_price_type";
505
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
506 506
 				  PRT_name varchar(45) NOT NULL,
507 507
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
508 508
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -511,9 +511,9 @@  discard block
 block discarded – undo
511 511
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
512 512
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
513 513
 				  PRIMARY KEY  (PRT_ID)";
514
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
515
-        $table_name = "esp_ticket";
516
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
514
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
515
+		$table_name = "esp_ticket";
516
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
517 517
 					  TTM_ID int(10) unsigned NOT NULL,
518 518
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
519 519
 					  TKT_description text NOT NULL,
@@ -535,9 +535,9 @@  discard block
 block discarded – undo
535 535
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
536 536
 					  PRIMARY KEY  (TKT_ID),
537 537
 					  KEY TKT_start_date (TKT_start_date)";
538
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
539
-        $table_name = 'esp_question_group';
540
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
538
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
539
+		$table_name = 'esp_question_group';
540
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
541 541
 					QSG_name varchar(255) NOT NULL,
542 542
 					QSG_identifier varchar(100) NOT NULL,
543 543
 					QSG_desc text NULL,
@@ -550,223 +550,223 @@  discard block
 block discarded – undo
550 550
 					PRIMARY KEY  (QSG_ID),
551 551
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
552 552
 					KEY QSG_order (QSG_order)';
553
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
554
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
555
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
556
-        // (because many need to convert old string states to foreign keys into the states table)
557
-        $script_4_1_defaults->insert_default_states();
558
-        $script_4_1_defaults->insert_default_countries();
559
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
560
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
561
-        $script_4_5_defaults->insert_default_price_types();
562
-        $script_4_5_defaults->insert_default_prices();
563
-        $script_4_5_defaults->insert_default_tickets();
564
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
565
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
566
-        $script_4_6_defaults->add_default_admin_only_payments();
567
-        $script_4_6_defaults->insert_default_currencies();
568
-        $this->verify_new_countries();
569
-        $this->verify_new_currencies();
570
-        return true;
571
-    }
553
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
554
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
555
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
556
+		// (because many need to convert old string states to foreign keys into the states table)
557
+		$script_4_1_defaults->insert_default_states();
558
+		$script_4_1_defaults->insert_default_countries();
559
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
560
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
561
+		$script_4_5_defaults->insert_default_price_types();
562
+		$script_4_5_defaults->insert_default_prices();
563
+		$script_4_5_defaults->insert_default_tickets();
564
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
565
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
566
+		$script_4_6_defaults->add_default_admin_only_payments();
567
+		$script_4_6_defaults->insert_default_currencies();
568
+		$this->verify_new_countries();
569
+		$this->verify_new_currencies();
570
+		return true;
571
+	}
572 572
 
573 573
 
574 574
 
575
-    /**
576
-     * @return boolean
577
-     */
578
-    public function schema_changes_after_migration()
579
-    {
580
-        $this->fix_non_default_taxes();
581
-        // this is actually the same as the last DMS
582
-        /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */
583
-        $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0');
584
-        return $script_4_7_defaults->schema_changes_after_migration();
585
-    }
575
+	/**
576
+	 * @return boolean
577
+	 */
578
+	public function schema_changes_after_migration()
579
+	{
580
+		$this->fix_non_default_taxes();
581
+		// this is actually the same as the last DMS
582
+		/** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */
583
+		$script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0');
584
+		return $script_4_7_defaults->schema_changes_after_migration();
585
+	}
586 586
 
587 587
 
588 588
 
589
-    public function migration_page_hooks()
590
-    {
591
-    }
589
+	public function migration_page_hooks()
590
+	{
591
+	}
592 592
 
593 593
 
594 594
 
595
-    /**
596
-     * verifies each of the new countries exists that somehow we missed in 4.1
597
-     */
598
-    public function verify_new_countries()
599
-    {
600
-        // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
601
-        // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
602
-        // currency symbols: http://www.xe.com/symbols.php
603
-        // CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active
604
-        // ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
605
-        $newer_countries = array(
606
-            array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
607
-            array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
608
-            array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
609
-            array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
610
-            array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
611
-            array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
612
-            array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
613
-            array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
614
-            array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0),
615
-            array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
616
-            array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
617
-            array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0),
618
-            array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
619
-            array(
620
-                'BQ',
621
-                'BES',
622
-                0,
623
-                'Bonaire, Saint Eustatius and Saba',
624
-                'USD',
625
-                'Dollar',
626
-                'Dollars',
627
-                '$',
628
-                1,
629
-                2,
630
-                '+599',
631
-                0,
632
-                0,
633
-            ),
634
-            array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0),
635
-            array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0),
636
-            array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0),
637
-            array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
638
-            array(
639
-                'HM',
640
-                'HMD',
641
-                0,
642
-                'Heard Island and McDonald Islands',
643
-                'AUD',
644
-                'Dollar',
645
-                'Dollars',
646
-                '$',
647
-                1,
648
-                2,
649
-                '+891',
650
-                0,
651
-                0,
652
-            ),
653
-            array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0),
654
-            array(
655
-                'GS',
656
-                'SGS',
657
-                0,
658
-                'South Georgia and the South Sandwich Islands',
659
-                'GBP',
660
-                'Pound',
661
-                'Pounds',
662
-                '£',
663
-                1,
664
-                2,
665
-                '+500',
666
-                0,
667
-                0,
668
-            ),
669
-            array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0),
670
-            array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0),
671
-            array(
672
-                'UM',
673
-                'UMI',
674
-                0,
675
-                'United States Minor Outlying Islands',
676
-                'USD',
677
-                'Dollar',
678
-                'Dollars',
679
-                '$',
680
-                1,
681
-                2,
682
-                '+1',
683
-                0,
684
-                0,
685
-            ),
686
-        );
687
-        global $wpdb;
688
-        $country_table = $wpdb->prefix . "esp_country";
689
-        $country_format = array(
690
-            "CNT_ISO"         => '%s',
691
-            "CNT_ISO3"        => '%s',
692
-            "RGN_ID"          => '%d',
693
-            "CNT_name"        => '%s',
694
-            "CNT_cur_code"    => '%s',
695
-            "CNT_cur_single"  => '%s',
696
-            "CNT_cur_plural"  => '%s',
697
-            "CNT_cur_sign"    => '%s',
698
-            "CNT_cur_sign_b4" => '%d',
699
-            "CNT_cur_dec_plc" => '%d',
700
-            "CNT_tel_code"    => '%s',
701
-            "CNT_is_EU"       => '%d',
702
-            "CNT_active"      => '%d',
703
-        );
704
-        if ($this->_get_table_analysis()->tableExists($country_table)) {
705
-            foreach ($newer_countries as $country) {
706
-                $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
707
-                $countries = $wpdb->get_var($SQL);
708
-                if (! $countries) {
709
-                    $wpdb->insert(
710
-                        $country_table,
711
-                        array_combine(array_keys($country_format), $country),
712
-                        $country_format
713
-                    );
714
-                }
715
-            }
716
-        }
717
-    }
595
+	/**
596
+	 * verifies each of the new countries exists that somehow we missed in 4.1
597
+	 */
598
+	public function verify_new_countries()
599
+	{
600
+		// a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
601
+		// how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
602
+		// currency symbols: http://www.xe.com/symbols.php
603
+		// CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active
604
+		// ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
605
+		$newer_countries = array(
606
+			array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
607
+			array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
608
+			array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
609
+			array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
610
+			array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
611
+			array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
612
+			array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
613
+			array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
614
+			array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0),
615
+			array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
616
+			array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
617
+			array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0),
618
+			array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
619
+			array(
620
+				'BQ',
621
+				'BES',
622
+				0,
623
+				'Bonaire, Saint Eustatius and Saba',
624
+				'USD',
625
+				'Dollar',
626
+				'Dollars',
627
+				'$',
628
+				1,
629
+				2,
630
+				'+599',
631
+				0,
632
+				0,
633
+			),
634
+			array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0),
635
+			array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0),
636
+			array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0),
637
+			array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
638
+			array(
639
+				'HM',
640
+				'HMD',
641
+				0,
642
+				'Heard Island and McDonald Islands',
643
+				'AUD',
644
+				'Dollar',
645
+				'Dollars',
646
+				'$',
647
+				1,
648
+				2,
649
+				'+891',
650
+				0,
651
+				0,
652
+			),
653
+			array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0),
654
+			array(
655
+				'GS',
656
+				'SGS',
657
+				0,
658
+				'South Georgia and the South Sandwich Islands',
659
+				'GBP',
660
+				'Pound',
661
+				'Pounds',
662
+				'£',
663
+				1,
664
+				2,
665
+				'+500',
666
+				0,
667
+				0,
668
+			),
669
+			array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0),
670
+			array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0),
671
+			array(
672
+				'UM',
673
+				'UMI',
674
+				0,
675
+				'United States Minor Outlying Islands',
676
+				'USD',
677
+				'Dollar',
678
+				'Dollars',
679
+				'$',
680
+				1,
681
+				2,
682
+				'+1',
683
+				0,
684
+				0,
685
+			),
686
+		);
687
+		global $wpdb;
688
+		$country_table = $wpdb->prefix . "esp_country";
689
+		$country_format = array(
690
+			"CNT_ISO"         => '%s',
691
+			"CNT_ISO3"        => '%s',
692
+			"RGN_ID"          => '%d',
693
+			"CNT_name"        => '%s',
694
+			"CNT_cur_code"    => '%s',
695
+			"CNT_cur_single"  => '%s',
696
+			"CNT_cur_plural"  => '%s',
697
+			"CNT_cur_sign"    => '%s',
698
+			"CNT_cur_sign_b4" => '%d',
699
+			"CNT_cur_dec_plc" => '%d',
700
+			"CNT_tel_code"    => '%s',
701
+			"CNT_is_EU"       => '%d',
702
+			"CNT_active"      => '%d',
703
+		);
704
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
705
+			foreach ($newer_countries as $country) {
706
+				$SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
707
+				$countries = $wpdb->get_var($SQL);
708
+				if (! $countries) {
709
+					$wpdb->insert(
710
+						$country_table,
711
+						array_combine(array_keys($country_format), $country),
712
+						$country_format
713
+					);
714
+				}
715
+			}
716
+		}
717
+	}
718 718
 
719 719
 
720 720
 
721
-    /**
722
-     * verifies each of the new currencies exists that somehow we missed in 4.6
723
-     */
724
-    public function verify_new_currencies()
725
-    {
726
-        // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
727
-        // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
728
-        // currency symbols: http://www.xe.com/symbols.php
729
-        // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
730
-        // ( 'EUR',  'Euro',  'Euros',  '€',  2,1),
731
-        $newer_currencies = array(
732
-            array('RSD', 'Dinar', 'Dinars', '', 3, 1),
733
-        );
734
-        global $wpdb;
735
-        $currency_table = $wpdb->prefix . "esp_currency";
736
-        $currency_format = array(
737
-            "CUR_code"    => '%s',
738
-            "CUR_single"  => '%s',
739
-            "CUR_plural"  => '%s',
740
-            "CUR_sign"    => '%s',
741
-            "CUR_dec_plc" => '%d',
742
-            "CUR_active"  => '%d',
743
-        );
744
-        if ($this->_get_table_analysis()->tableExists($currency_table)) {
745
-            foreach ($newer_currencies as $currency) {
746
-                $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
747
-                $countries = $wpdb->get_var($SQL);
748
-                if (! $countries) {
749
-                    $wpdb->insert(
750
-                        $currency_table,
751
-                        array_combine(array_keys($currency_format), $currency),
752
-                        $currency_format
753
-                    );
754
-                }
755
-            }
756
-        }
757
-    }
721
+	/**
722
+	 * verifies each of the new currencies exists that somehow we missed in 4.6
723
+	 */
724
+	public function verify_new_currencies()
725
+	{
726
+		// a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
727
+		// how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
728
+		// currency symbols: http://www.xe.com/symbols.php
729
+		// CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
730
+		// ( 'EUR',  'Euro',  'Euros',  '€',  2,1),
731
+		$newer_currencies = array(
732
+			array('RSD', 'Dinar', 'Dinars', '', 3, 1),
733
+		);
734
+		global $wpdb;
735
+		$currency_table = $wpdb->prefix . "esp_currency";
736
+		$currency_format = array(
737
+			"CUR_code"    => '%s',
738
+			"CUR_single"  => '%s',
739
+			"CUR_plural"  => '%s',
740
+			"CUR_sign"    => '%s',
741
+			"CUR_dec_plc" => '%d',
742
+			"CUR_active"  => '%d',
743
+		);
744
+		if ($this->_get_table_analysis()->tableExists($currency_table)) {
745
+			foreach ($newer_currencies as $currency) {
746
+				$SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
747
+				$countries = $wpdb->get_var($SQL);
748
+				if (! $countries) {
749
+					$wpdb->insert(
750
+						$currency_table,
751
+						array_combine(array_keys($currency_format), $currency),
752
+						$currency_format
753
+					);
754
+				}
755
+			}
756
+		}
757
+	}
758 758
 
759 759
 
760 760
 
761
-    /**
762
-     * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731
763
-     * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
764
-     * we should be able to stop doing this in 4.9
765
-     */
766
-    public function fix_non_default_taxes()
767
-    {
768
-        global $wpdb;
769
-        $query = $wpdb->prepare("UPDATE
761
+	/**
762
+	 * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731
763
+	 * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
764
+	 * we should be able to stop doing this in 4.9
765
+	 */
766
+	public function fix_non_default_taxes()
767
+	{
768
+		global $wpdb;
769
+		$query = $wpdb->prepare("UPDATE
770 770
 				{$wpdb->prefix}esp_price p INNER JOIN
771 771
 				{$wpdb->prefix}esp_price_type pt ON p.PRT_ID = pt.PRT_ID
772 772
 			SET
@@ -775,6 +775,6 @@  discard block
 block discarded – undo
775 775
 				p.PRC_is_default = 0 AND
776 776
 				pt.PBT_ID = %d
777 777
 					", EEM_Price_Type::base_type_tax);
778
-        $wpdb->query($query);
779
-    }
778
+		$wpdb->query($query);
779
+	}
780 780
 }
Please login to merge, or discard this patch.
4_1_0_stages/EE_DMS_4_1_0_category_details.dmsstage.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -8,53 +8,53 @@
 block discarded – undo
8 8
  */
9 9
 class EE_DMS_4_1_0_category_details extends EE_Data_Migration_Script_Stage
10 10
 {
11
-    private $_old_table;
12
-    private $_new_table;
13
-    private $_new_term_table;
14
-    public function _migration_step($num_items = 50)
15
-    {
16
-        global $wpdb;
17
-        $start_at_record = $this->count_records_migrated();
18
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
19
-        $items_actually_migrated = 0;
20
-        foreach ($rows as $category_detail_row) {
21
-            $term_and_taxonomy_ids = wp_insert_term(
22
-                stripslashes($category_detail_row['category_name']),
23
-                'espresso_event_categories',
24
-                array(
25
-                    'description'=>  stripslashes($category_detail_row['category_desc']),
26
-                    'slug'=>$category_detail_row['category_identifier']
27
-                )
28
-            );
29
-            if ($term_and_taxonomy_ids instanceof WP_Error) {
30
-                $this->add_error(sprintf(__("Could not create WP Term_Taxonomy from old category: %s. The Error was: %s", "event_espresso"), $this->_json_encode($category_detail_row), $term_and_taxonomy_ids->get_error_message()));
31
-                $items_actually_migrated++;
32
-                continue;
33
-            }
34
-            $term_id = $term_and_taxonomy_ids['term_id'];
35
-            $term_taxonomy_id = $term_and_taxonomy_ids['term_taxonomy_id'];
36
-            $this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_term_table, $term_id);
37
-            $this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_table, $term_taxonomy_id);
38
-            $items_actually_migrated++;
39
-        }
40
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
41
-            $this->set_completed();
42
-        }
43
-        return $items_actually_migrated;
44
-    }
45
-    public function _count_records_to_migrate()
46
-    {
47
-        global $wpdb;
48
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM $this->_old_table");
49
-        return $count;
50
-    }
51
-    public function __construct()
52
-    {
53
-        $this->_pretty_name = __("Category Details", "event_espresso");
54
-        global $wpdb;
55
-        $this->_old_table = $wpdb->prefix."events_category_detail";
56
-        $this->_new_table = $wpdb->prefix."term_taxonomy";
57
-        $this->_new_term_table = $wpdb->prefix."terms";
58
-        parent::__construct();
59
-    }
11
+	private $_old_table;
12
+	private $_new_table;
13
+	private $_new_term_table;
14
+	public function _migration_step($num_items = 50)
15
+	{
16
+		global $wpdb;
17
+		$start_at_record = $this->count_records_migrated();
18
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
19
+		$items_actually_migrated = 0;
20
+		foreach ($rows as $category_detail_row) {
21
+			$term_and_taxonomy_ids = wp_insert_term(
22
+				stripslashes($category_detail_row['category_name']),
23
+				'espresso_event_categories',
24
+				array(
25
+					'description'=>  stripslashes($category_detail_row['category_desc']),
26
+					'slug'=>$category_detail_row['category_identifier']
27
+				)
28
+			);
29
+			if ($term_and_taxonomy_ids instanceof WP_Error) {
30
+				$this->add_error(sprintf(__("Could not create WP Term_Taxonomy from old category: %s. The Error was: %s", "event_espresso"), $this->_json_encode($category_detail_row), $term_and_taxonomy_ids->get_error_message()));
31
+				$items_actually_migrated++;
32
+				continue;
33
+			}
34
+			$term_id = $term_and_taxonomy_ids['term_id'];
35
+			$term_taxonomy_id = $term_and_taxonomy_ids['term_taxonomy_id'];
36
+			$this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_term_table, $term_id);
37
+			$this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_table, $term_taxonomy_id);
38
+			$items_actually_migrated++;
39
+		}
40
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
41
+			$this->set_completed();
42
+		}
43
+		return $items_actually_migrated;
44
+	}
45
+	public function _count_records_to_migrate()
46
+	{
47
+		global $wpdb;
48
+		$count = $wpdb->get_var("SELECT COUNT(id) FROM $this->_old_table");
49
+		return $count;
50
+	}
51
+	public function __construct()
52
+	{
53
+		$this->_pretty_name = __("Category Details", "event_espresso");
54
+		global $wpdb;
55
+		$this->_old_table = $wpdb->prefix."events_category_detail";
56
+		$this->_new_table = $wpdb->prefix."term_taxonomy";
57
+		$this->_new_term_table = $wpdb->prefix."terms";
58
+		parent::__construct();
59
+	}
60 60
 }
Please login to merge, or discard this patch.
4_1_0_stages/EE_DMS_4_1_0_event_category.dmsstage.php 2 patches
Indentation   +76 added lines, -78 removed lines patch added patch discarded remove patch
@@ -24,87 +24,85 @@
 block discarded – undo
24 24
                 'term_taxonomy_id'=>new EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'),
25 25
                 'term_order'=>new EE_Integer_Field('term_order', __('Term Order','event_espresso'), false, 0)
26 26
             ));
27
-
28
-
29 27
  *
30 28
  */
31 29
 class EE_DMS_4_1_0_event_category extends EE_Data_Migration_Script_Stage
32 30
 {
33
-    private $_old_table;
34
-    private $_new_table;
35
-    public function _migration_step($num_items = 50)
36
-    {
37
-        global $wpdb;
38
-        $start_at_record = $this->count_records_migrated();
39
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
40
-        $items_actually_migrated = 0;
41
-        foreach ($rows as $event_venue_rel) {
42
-            $term_relation_id = $this->_add_relation_from_event_to_term_taxonomy($event_venue_rel);
43
-            if ($term_relation_id) {
44
-                $this->get_migration_script()->set_mapping($this->_old_table, $event_venue_rel['id'], $this->_new_table, $term_relation_id);
45
-            }
46
-            $items_actually_migrated++;
47
-        }
48
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
49
-            $this->set_completed();
50
-        }
51
-        return $items_actually_migrated;
52
-    }
53
-    public function _count_records_to_migrate()
54
-    {
55
-        global $wpdb;
56
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
57
-        return $count;
58
-    }
59
-    public function __construct()
60
-    {
61
-        global $wpdb;
62
-        $this->_old_table = $wpdb->prefix."events_category_rel";
63
-        $this->_new_table = $wpdb->prefix."term_relationships";
64
-        $this->_pretty_name = __("Event to Category (4.1 Term Relationships)", "event_espresso");
65
-        parent::__construct();
66
-    }
31
+	private $_old_table;
32
+	private $_new_table;
33
+	public function _migration_step($num_items = 50)
34
+	{
35
+		global $wpdb;
36
+		$start_at_record = $this->count_records_migrated();
37
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
38
+		$items_actually_migrated = 0;
39
+		foreach ($rows as $event_venue_rel) {
40
+			$term_relation_id = $this->_add_relation_from_event_to_term_taxonomy($event_venue_rel);
41
+			if ($term_relation_id) {
42
+				$this->get_migration_script()->set_mapping($this->_old_table, $event_venue_rel['id'], $this->_new_table, $term_relation_id);
43
+			}
44
+			$items_actually_migrated++;
45
+		}
46
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
47
+			$this->set_completed();
48
+		}
49
+		return $items_actually_migrated;
50
+	}
51
+	public function _count_records_to_migrate()
52
+	{
53
+		global $wpdb;
54
+		$count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
55
+		return $count;
56
+	}
57
+	public function __construct()
58
+	{
59
+		global $wpdb;
60
+		$this->_old_table = $wpdb->prefix."events_category_rel";
61
+		$this->_new_table = $wpdb->prefix."term_relationships";
62
+		$this->_pretty_name = __("Event to Category (4.1 Term Relationships)", "event_espresso");
63
+		parent::__construct();
64
+	}
67 65
 
68
-    /**
69
-     * Attempts to insert a new question group inthe new format given an old one
70
-     * @global type $wpdb
71
-     * @param array $old_event_cat_relation
72
-     * @return int
73
-     */
74
-    private function _add_relation_from_event_to_term_taxonomy($old_event_cat_relation)
75
-    {
76
-        global $wpdb;
77
-        $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix."posts");
78
-        $new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix."term_taxonomy");
79
-        if (! $new_event_id) {
80
-            $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id']));
81
-            return 0;
82
-        }
83
-        if (! $new_term_taxonomy_id) {
84
-            $this->add_error(sprintf(__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id']));
85
-            return 0;
86
-        }
87
-        $cols_n_values = array(
88
-            'object_id'=>$new_event_id,
89
-            'term_taxonomy_id'=>$new_term_taxonomy_id,
90
-            'term_order'=>0
91
-        );
92
-        $datatypes = array(
93
-            '%d',// object_id
94
-            '%d',// term_taxonomy_id
95
-            '%d',// term_order
96
-        );
97
-        $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
98
-        if (! $success) {
99
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes));
100
-            return 0;
101
-        } else {
102
-            // increment the term-taxonomie's count
103
-            $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id));
104
-            if (! $success) {
105
-                $this->add_error(sprintf(__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error));
106
-            }
107
-        }
108
-        return $wpdb->insert_id;
109
-    }
66
+	/**
67
+	 * Attempts to insert a new question group inthe new format given an old one
68
+	 * @global type $wpdb
69
+	 * @param array $old_event_cat_relation
70
+	 * @return int
71
+	 */
72
+	private function _add_relation_from_event_to_term_taxonomy($old_event_cat_relation)
73
+	{
74
+		global $wpdb;
75
+		$new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix."posts");
76
+		$new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix."term_taxonomy");
77
+		if (! $new_event_id) {
78
+			$this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id']));
79
+			return 0;
80
+		}
81
+		if (! $new_term_taxonomy_id) {
82
+			$this->add_error(sprintf(__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id']));
83
+			return 0;
84
+		}
85
+		$cols_n_values = array(
86
+			'object_id'=>$new_event_id,
87
+			'term_taxonomy_id'=>$new_term_taxonomy_id,
88
+			'term_order'=>0
89
+		);
90
+		$datatypes = array(
91
+			'%d',// object_id
92
+			'%d',// term_taxonomy_id
93
+			'%d',// term_order
94
+		);
95
+		$success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
96
+		if (! $success) {
97
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes));
98
+			return 0;
99
+		} else {
100
+			// increment the term-taxonomie's count
101
+			$success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id));
102
+			if (! $success) {
103
+				$this->add_error(sprintf(__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error));
104
+			}
105
+		}
106
+		return $wpdb->insert_id;
107
+	}
110 108
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
         global $wpdb;
77 77
         $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix."posts");
78 78
         $new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix."term_taxonomy");
79
-        if (! $new_event_id) {
79
+        if ( ! $new_event_id) {
80 80
             $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id']));
81 81
             return 0;
82 82
         }
83
-        if (! $new_term_taxonomy_id) {
83
+        if ( ! $new_term_taxonomy_id) {
84 84
             $this->add_error(sprintf(__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id']));
85 85
             return 0;
86 86
         }
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
             'term_order'=>0
91 91
         );
92 92
         $datatypes = array(
93
-            '%d',// object_id
94
-            '%d',// term_taxonomy_id
95
-            '%d',// term_order
93
+            '%d', // object_id
94
+            '%d', // term_taxonomy_id
95
+            '%d', // term_order
96 96
         );
97 97
         $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
98
-        if (! $success) {
98
+        if ( ! $success) {
99 99
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes));
100 100
             return 0;
101 101
         } else {
102 102
             // increment the term-taxonomie's count
103 103
             $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id));
104
-            if (! $success) {
104
+            if ( ! $success) {
105 105
                 $this->add_error(sprintf(__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error));
106 106
             }
107 107
         }
Please login to merge, or discard this patch.
4_1_0_stages/EE_DMS_4_1_0_question_groups.dmsstage.php 2 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -40,119 +40,119 @@
 block discarded – undo
40 40
  */
41 41
 class EE_DMS_4_1_0_question_groups extends EE_Data_Migration_Script_Stage
42 42
 {
43
-    private $_old_table;
44
-    private $_new_table;
45
-    /**
46
-     * Keeps track of whether or not we've already added a system question group,
47
-     * in order to avoid adding more than 1 (basically, in 3.1 this would happen
48
-     * with the Roles & Permissions addon, because each user had their own set of
49
-     * question groups and questions),
50
-     * @var boolean
51
-     */
52
-    private $_already_got_system_question_group_1 = false;
53
-    public function _migration_step($num_items = 50)
54
-    {
43
+	private $_old_table;
44
+	private $_new_table;
45
+	/**
46
+	 * Keeps track of whether or not we've already added a system question group,
47
+	 * in order to avoid adding more than 1 (basically, in 3.1 this would happen
48
+	 * with the Roles & Permissions addon, because each user had their own set of
49
+	 * question groups and questions),
50
+	 * @var boolean
51
+	 */
52
+	private $_already_got_system_question_group_1 = false;
53
+	public function _migration_step($num_items = 50)
54
+	{
55 55
         
56
-        global $wpdb;
57
-        $start_at_record = $this->count_records_migrated();
58
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
59
-        $items_actually_migrated = 0;
60
-        foreach ($rows as $question_group) {
61
-            $new_id = $this->_insert_new_question_group($question_group);
56
+		global $wpdb;
57
+		$start_at_record = $this->count_records_migrated();
58
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
59
+		$items_actually_migrated = 0;
60
+		foreach ($rows as $question_group) {
61
+			$new_id = $this->_insert_new_question_group($question_group);
62 62
 
63
-            $this->get_migration_script()->set_mapping($this->_old_table, $question_group['id'], $this->_new_table, $new_id);
64
-            $items_actually_migrated++;
65
-        }
66
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
67
-            $this->set_completed();
68
-        }
69
-        return $items_actually_migrated;
70
-    }
71
-    public function _count_records_to_migrate()
72
-    {
73
-        global $wpdb;
74
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
75
-        return $count;
76
-    }
77
-    public function __construct()
78
-    {
79
-        global $wpdb;
80
-        $this->_old_table = $wpdb->prefix."events_qst_group";
81
-        $this->_new_table = $wpdb->prefix."esp_question_group";
82
-        $this->_pretty_name = __("Question Groups", "event_espresso");
83
-        parent::__construct();
84
-    }
63
+			$this->get_migration_script()->set_mapping($this->_old_table, $question_group['id'], $this->_new_table, $new_id);
64
+			$items_actually_migrated++;
65
+		}
66
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
67
+			$this->set_completed();
68
+		}
69
+		return $items_actually_migrated;
70
+	}
71
+	public function _count_records_to_migrate()
72
+	{
73
+		global $wpdb;
74
+		$count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
75
+		return $count;
76
+	}
77
+	public function __construct()
78
+	{
79
+		global $wpdb;
80
+		$this->_old_table = $wpdb->prefix."events_qst_group";
81
+		$this->_new_table = $wpdb->prefix."esp_question_group";
82
+		$this->_pretty_name = __("Question Groups", "event_espresso");
83
+		parent::__construct();
84
+	}
85 85
     
86
-    /**
87
-     * Attempts to insert a new question group inthe new format given an old one
88
-     * @global type $wpdb
89
-     * @param array $old_question_group
90
-     * @return int
91
-     */
92
-    private function _insert_new_question_group($old_question_group)
93
-    {
94
-        global $wpdb;
95
-        // try to guess what the QST_system int should be... finding the Personal info system
96
-        // question group is quite easy. But in 3.1 address info WASN'T a system group, it just exitsed by default but
97
-        // could be easily removed.
98
-        if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) {
99
-            $guess_at_system_number = 1;
100
-        } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) {
101
-            $guess_at_system_number = 2;
102
-        } else {
103
-            $guess_at_system_number = 0;
104
-        }
105
-        // if the question group wasn't made by the normal admin,
106
-        // we'd like to keep track of who made it
107
-        if (intval($old_question_group['wp_user'])!=1) {
108
-            $username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user']));
109
-            $identifier = $old_question_group['group_identifier']."-by-".$username;
110
-        } else {
111
-            $identifier = $old_question_group['group_identifier'];
112
-        }
113
-        $cols_n_values = array(
114
-            'QSG_name'=>stripslashes($old_question_group['group_name']),
115
-            'QSG_identifier'=>$identifier,
116
-            'QSG_desc'=>stripslashes($old_question_group['group_description']),
117
-            'QSG_order'=>$old_question_group['group_order'],
118
-            'QSG_show_group_name'=>$old_question_group['show_group_name'],
119
-            'QSG_show_group_desc'=>$old_question_group['show_group_description'],
120
-            'QSG_system'=>$guess_at_system_number,
121
-            'QSG_deleted'=>false
122
-        );
123
-        $datatypes = array(
124
-            '%s',// QSG_name
125
-            '%s',// QSG_identifier
126
-            '%s',// QSG_desc
127
-            '%d',// QSG_order
128
-            '%d',// QSG_show_group_name
129
-            '%d',// QSG_show_group_desc
130
-            '%d',// QSG_system
131
-            '%d',// QSG_deleted
132
-        );
133
-        $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
134
-        if (! $success) {
135
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes));
136
-            return 0;
137
-        }
138
-        return $wpdb->insert_id;
139
-    }
86
+	/**
87
+	 * Attempts to insert a new question group inthe new format given an old one
88
+	 * @global type $wpdb
89
+	 * @param array $old_question_group
90
+	 * @return int
91
+	 */
92
+	private function _insert_new_question_group($old_question_group)
93
+	{
94
+		global $wpdb;
95
+		// try to guess what the QST_system int should be... finding the Personal info system
96
+		// question group is quite easy. But in 3.1 address info WASN'T a system group, it just exitsed by default but
97
+		// could be easily removed.
98
+		if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) {
99
+			$guess_at_system_number = 1;
100
+		} elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) {
101
+			$guess_at_system_number = 2;
102
+		} else {
103
+			$guess_at_system_number = 0;
104
+		}
105
+		// if the question group wasn't made by the normal admin,
106
+		// we'd like to keep track of who made it
107
+		if (intval($old_question_group['wp_user'])!=1) {
108
+			$username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user']));
109
+			$identifier = $old_question_group['group_identifier']."-by-".$username;
110
+		} else {
111
+			$identifier = $old_question_group['group_identifier'];
112
+		}
113
+		$cols_n_values = array(
114
+			'QSG_name'=>stripslashes($old_question_group['group_name']),
115
+			'QSG_identifier'=>$identifier,
116
+			'QSG_desc'=>stripslashes($old_question_group['group_description']),
117
+			'QSG_order'=>$old_question_group['group_order'],
118
+			'QSG_show_group_name'=>$old_question_group['show_group_name'],
119
+			'QSG_show_group_desc'=>$old_question_group['show_group_description'],
120
+			'QSG_system'=>$guess_at_system_number,
121
+			'QSG_deleted'=>false
122
+		);
123
+		$datatypes = array(
124
+			'%s',// QSG_name
125
+			'%s',// QSG_identifier
126
+			'%s',// QSG_desc
127
+			'%d',// QSG_order
128
+			'%d',// QSG_show_group_name
129
+			'%d',// QSG_show_group_desc
130
+			'%d',// QSG_system
131
+			'%d',// QSG_deleted
132
+		);
133
+		$success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
134
+		if (! $success) {
135
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes));
136
+			return 0;
137
+		}
138
+		return $wpdb->insert_id;
139
+	}
140 140
     
141
-    /**
142
-     * Checks if we've already added a system question 1 to the new question groups table
143
-     * @global type $wpdb
144
-     * @return boolean
145
-     */
146
-    private function _already_got_system_question_group_1()
147
-    {
148
-        if (! $this->_already_got_system_question_group_1) {
149
-            // check the db
150
-            global $wpdb;
151
-            $exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1");
152
-            if (intval($exists)>0) {
153
-                $this->_already_got_system_question_group_1 = true;
154
-            }
155
-        }
156
-        return $this->_already_got_system_question_group_1;
157
-    }
141
+	/**
142
+	 * Checks if we've already added a system question 1 to the new question groups table
143
+	 * @global type $wpdb
144
+	 * @return boolean
145
+	 */
146
+	private function _already_got_system_question_group_1()
147
+	{
148
+		if (! $this->_already_got_system_question_group_1) {
149
+			// check the db
150
+			global $wpdb;
151
+			$exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1");
152
+			if (intval($exists)>0) {
153
+				$this->_already_got_system_question_group_1 = true;
154
+			}
155
+		}
156
+		return $this->_already_got_system_question_group_1;
157
+	}
158 158
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
         // could be easily removed.
98 98
         if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) {
99 99
             $guess_at_system_number = 1;
100
-        } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) {
100
+        } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address') !== false) {
101 101
             $guess_at_system_number = 2;
102 102
         } else {
103 103
             $guess_at_system_number = 0;
104 104
         }
105 105
         // if the question group wasn't made by the normal admin,
106 106
         // we'd like to keep track of who made it
107
-        if (intval($old_question_group['wp_user'])!=1) {
107
+        if (intval($old_question_group['wp_user']) != 1) {
108 108
             $username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user']));
109 109
             $identifier = $old_question_group['group_identifier']."-by-".$username;
110 110
         } else {
@@ -121,17 +121,17 @@  discard block
 block discarded – undo
121 121
             'QSG_deleted'=>false
122 122
         );
123 123
         $datatypes = array(
124
-            '%s',// QSG_name
125
-            '%s',// QSG_identifier
126
-            '%s',// QSG_desc
127
-            '%d',// QSG_order
128
-            '%d',// QSG_show_group_name
129
-            '%d',// QSG_show_group_desc
130
-            '%d',// QSG_system
131
-            '%d',// QSG_deleted
124
+            '%s', // QSG_name
125
+            '%s', // QSG_identifier
126
+            '%s', // QSG_desc
127
+            '%d', // QSG_order
128
+            '%d', // QSG_show_group_name
129
+            '%d', // QSG_show_group_desc
130
+            '%d', // QSG_system
131
+            '%d', // QSG_deleted
132 132
         );
133 133
         $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
134
-        if (! $success) {
134
+        if ( ! $success) {
135 135
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes));
136 136
             return 0;
137 137
         }
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
      */
146 146
     private function _already_got_system_question_group_1()
147 147
     {
148
-        if (! $this->_already_got_system_question_group_1) {
148
+        if ( ! $this->_already_got_system_question_group_1) {
149 149
             // check the db
150 150
             global $wpdb;
151 151
             $exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1");
152
-            if (intval($exists)>0) {
152
+            if (intval($exists) > 0) {
153 153
                 $this->_already_got_system_question_group_1 = true;
154 154
             }
155 155
         }
Please login to merge, or discard this patch.