Completed
Branch EE5Update (bc64e6)
by
unknown
09:36 queued 05:38
created
core/db_models/EEM_Line_Item.model.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
         );
325 325
         $query = $wpdb->prepare(
326 326
             'DELETE li
327
-				FROM ' . $this->table() . ' li
328
-				LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON li.TXN_ID = t.TXN_ID
327
+				FROM ' . $this->table().' li
328
+				LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID
329 329
 				WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s',
330 330
             // use GMT time because that's what TXN_timestamps are in
331 331
             date('Y-m-d H:i:s', time() - $time_to_leave_alone)
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
      */
599 599
     public function getTicketLineItemsForExpiredCarts($timestamp = 0)
600 600
     {
601
-        if (! absint($timestamp)) {
601
+        if ( ! absint($timestamp)) {
602 602
             /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
603 603
             $session_lifespan = LoaderFactory::getLoader()->getShared(
604 604
                 'EventEspresso\core\domain\values\session\SessionLifespan'
Please login to merge, or discard this patch.
Indentation   +609 added lines, -609 removed lines patch added patch discarded remove patch
@@ -27,616 +27,616 @@
 block discarded – undo
27 27
  */
28 28
 class EEM_Line_Item extends EEM_Base
29 29
 {
30
-    /**
31
-     * Tax sub-total is just the total of all the taxes, which should be children
32
-     * of this line item. There should only ever be one tax sub-total, and it should
33
-     * be a direct child of. Its quantity and LIN_unit_price = 1.
34
-     */
35
-    const type_tax_sub_total = 'tax-sub-total';
36
-
37
-    /**
38
-     * Tax line items indicate a tax applied to all the taxable line items.
39
-     * Should not have any children line items. Its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal
40
-     * (eg 10% tax = 10, not 0.1). Its LIN_total = LIN_unit_price * pre-tax-total. Quantity = 1.
41
-     */
42
-    const type_tax = 'tax';
43
-
44
-    /**
45
-     * Indicating individual items purchased, or discounts or surcharges.
46
-     * The sum of all the regular line items  plus the tax items should equal the grand total.
47
-     * Possible children are sub-line-items and cancellations.
48
-     * For flat items, LIN_unit_price * LIN_quantity = LIN_total. Its LIN_total is the sum of all the children
49
-     * LIN_totals. Its LIN_percent = 0.
50
-     * For percent items, its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal (eg 10% = 10, not 0.1).
51
-     * Its LIN_total is LIN_percent / 100 * sum of lower-priority sibling line items. Quantity = 1.
52
-     */
53
-    const type_line_item = 'line-item';
54
-
55
-    /**
56
-     * Line item indicating all the factors that make a single line item.
57
-     * Sub-line items should have NO children line items.
58
-     * For flat sub-items, their quantity should match their parent item, their LIN_unit_price should be this sub-item's
59
-     * contribution towards the price of ONE of their parent items, and its LIN_total should be
60
-     *  = LIN_quantity * LIN_unit_price. Its LIN_percent = 0.
61
-     * For percent sub-items, the quantity should be 1, LIN_unit_price should be 0, and its LIN_total should
62
-     * = LIN_percent / 100 * sum of lower-priority sibling line items..
63
-     */
64
-    const type_sub_line_item = 'sub-item';
65
-
66
-    /**
67
-     * SubTax line items indicate a tax that is only applied to the pre-tax total of their parent line item.
68
-     * Should not have any children line items. Its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal
69
-     * (eg 10% tax = 10, not 0.1). Its LIN_total = LIN_unit_price * pre-tax-total. Quantity = 1.
70
-     */
71
-    const type_sub_tax = 'sub-tax';
72
-
73
-    /**
74
-     * Line item indicating a sub-total (eg total for an event, or pre-tax subtotal).
75
-     * Direct children should be event subtotals.
76
-     * Should have quantity of 1, and a LIN_total and LIN_unit_price of the sum of all its sub-items' LIN_totals.
77
-     */
78
-    const type_sub_total = 'sub-total';
79
-
80
-    /**
81
-     * Line item for the grand total of an order.
82
-     * Its direct children should be tax subtotals and (pre-tax) subtotals,
83
-     * and possibly a regular line item indicating a transaction-wide discount/surcharge.
84
-     * Should have a quantity of 1, a LIN_total and LIN_unit_price of the entire order's amount.
85
-     */
86
-    const type_total = 'total';
87
-
88
-    /**
89
-     * When a line item is cancelled, a sub-line-item of type 'cancellation'
90
-     * should be created, indicating the quantity that were cancelled
91
-     * (because a line item could have a quantity of 1, and its cancellation item
92
-     * could be for 3, indicating that originally 4 were purchased, but 3 have been
93
-     * cancelled, and only one remains).
94
-     * When items are refunded, a cancellation line item should be made, which points
95
-     * to teh payment model object which actually refunded the payment.
96
-     * Cancellations should NOT have any children line items; the should NOT affect
97
-     * any calculations, and are only meant as a record that cancellations have occurred.
98
-     * Their LIN_percent should be 0.
99
-     */
100
-    const type_cancellation = 'cancellation';
101
-
102
-    // various line item object types
103
-    const OBJ_TYPE_EVENT = 'Event';
104
-
105
-    const OBJ_TYPE_PRICE = 'Price';
106
-
107
-    const OBJ_TYPE_PROMOTION = 'Promotion';
108
-
109
-    const OBJ_TYPE_TICKET = 'Ticket';
110
-
111
-    const OBJ_TYPE_TRANSACTION = 'Transaction';
112
-
113
-    /**
114
-     * @var EEM_Line_Item $_instance
115
-     */
116
-    protected static $_instance;
117
-
118
-
119
-    /**
120
-     * private constructor to prevent direct creation
121
-     *
122
-     * @Constructor
123
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
124
-     *                         (and any incoming timezone data that gets saved).
125
-     *                         Note this just sends the timezone info to the date time model field objects.
126
-     *                         Default is NULL
127
-     *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
128
-     * @throws EE_Error
129
-     * @throws InvalidArgumentException
130
-     */
131
-    protected function __construct($timezone)
132
-    {
133
-        $this->singular_item = esc_html__('Line Item', 'event_espresso');
134
-        $this->plural_item = esc_html__('Line Items', 'event_espresso');
135
-
136
-        $this->_tables = array(
137
-            'Line_Item' => new EE_Primary_Table('esp_line_item', 'LIN_ID'),
138
-        );
139
-        $line_items_can_be_for = apply_filters(
140
-            'FHEE__EEM_Line_Item__line_items_can_be_for',
141
-            array('Ticket', 'Price', 'Event')
142
-        );
143
-        $this->_fields = array(
144
-            'Line_Item' => array(
145
-                'LIN_ID'         => new EE_Primary_Key_Int_Field(
146
-                    'LIN_ID',
147
-                    esc_html__('ID', 'event_espresso')
148
-                ),
149
-                'LIN_code'       => new EE_Slug_Field(
150
-                    'LIN_code',
151
-                    esc_html__('Code for index into Cart', 'event_espresso'),
152
-                    true
153
-                ),
154
-                'TXN_ID'         => new EE_Foreign_Key_Int_Field(
155
-                    'TXN_ID',
156
-                    esc_html__('Transaction ID', 'event_espresso'),
157
-                    true,
158
-                    null,
159
-                    'Transaction'
160
-                ),
161
-                'LIN_name'       => new EE_Full_HTML_Field(
162
-                    'LIN_name',
163
-                    esc_html__('Line Item Name', 'event_espresso'),
164
-                    false,
165
-                    ''
166
-                ),
167
-                'LIN_desc'       => new EE_Full_HTML_Field(
168
-                    'LIN_desc',
169
-                    esc_html__('Line Item Description', 'event_espresso'),
170
-                    true
171
-                ),
172
-                'LIN_unit_price' => new EE_Money_Field(
173
-                    'LIN_unit_price',
174
-                    esc_html__('Unit Price', 'event_espresso'),
175
-                    false,
176
-                    0
177
-                ),
178
-                'LIN_percent'    => new EE_Float_Field(
179
-                    'LIN_percent',
180
-                    esc_html__('Percent', 'event_espresso'),
181
-                    false,
182
-                    0
183
-                ),
184
-                'LIN_is_taxable' => new EE_Boolean_Field(
185
-                    'LIN_is_taxable',
186
-                    esc_html__('Taxable', 'event_espresso'),
187
-                    false,
188
-                    false
189
-                ),
190
-                'LIN_order'      => new EE_Integer_Field(
191
-                    'LIN_order',
192
-                    esc_html__('Order of Application towards total of parent', 'event_espresso'),
193
-                    false,
194
-                    1
195
-                ),
196
-                'LIN_total'      => new EE_Money_Field(
197
-                    'LIN_total',
198
-                    esc_html__('Total (unit price x quantity) after taxes', 'event_espresso'),
199
-                    false,
200
-                    0
201
-                ),
202
-                'LIN_pretax'      => new EE_Money_Field(
203
-                    'LIN_pretax',
204
-                    esc_html__('Total (unit price x quantity) before taxes', 'event_espresso'),
205
-                    false,
206
-                    0
207
-                ),
208
-                'LIN_quantity'   => new EE_Integer_Field(
209
-                    'LIN_quantity',
210
-                    esc_html__('Quantity', 'event_espresso'),
211
-                    true,
212
-                    1
213
-                ),
214
-                'LIN_parent'     => new EE_Integer_Field(
215
-                    'LIN_parent',
216
-                    esc_html__("Parent ID (this item goes towards that Line Item's total)", 'event_espresso'),
217
-                    true,
218
-                    null
219
-                ),
220
-                'LIN_type'       => new EE_Enum_Text_Field(
221
-                    'LIN_type',
222
-                    esc_html__('Type', 'event_espresso'),
223
-                    false,
224
-                    'line-item',
225
-                    array(
226
-                        self::type_line_item     => esc_html__('Line Item', 'event_espresso'),
227
-                        self::type_sub_line_item => esc_html__('Sub-Item', 'event_espresso'),
228
-                        self::type_sub_tax       => esc_html__('Sub-Tax', 'event_espresso'),
229
-                        self::type_sub_total     => esc_html__('Subtotal', 'event_espresso'),
230
-                        self::type_tax_sub_total => esc_html__('Tax Subtotal', 'event_espresso'),
231
-                        self::type_tax           => esc_html__('Tax', 'event_espresso'),
232
-                        self::type_total         => esc_html__('Total', 'event_espresso'),
233
-                        self::type_cancellation  => esc_html__('Cancellation', 'event_espresso'),
234
-                    )
235
-                ),
236
-                'OBJ_ID'         => new EE_Foreign_Key_Int_Field(
237
-                    'OBJ_ID',
238
-                    esc_html__('ID of Item purchased.', 'event_espresso'),
239
-                    true,
240
-                    null,
241
-                    $line_items_can_be_for
242
-                ),
243
-                'OBJ_type'       => new EE_Any_Foreign_Model_Name_Field(
244
-                    'OBJ_type',
245
-                    esc_html__('Model Name this Line Item is for', 'event_espresso'),
246
-                    true,
247
-                    null,
248
-                    $line_items_can_be_for
249
-                ),
250
-                'LIN_timestamp'  => new EE_Datetime_Field(
251
-                    'LIN_timestamp',
252
-                    esc_html__('When the line item was created', 'event_espresso'),
253
-                    false,
254
-                    EE_Datetime_Field::now,
255
-                    $timezone
256
-                ),
257
-            ),
258
-        );
259
-        $this->_model_relations = array(
260
-            'Transaction' => new EE_Belongs_To_Relation(),
261
-            'Ticket'      => new EE_Belongs_To_Any_Relation(),
262
-            'Price'       => new EE_Belongs_To_Any_Relation(),
263
-            'Event'       => new EE_Belongs_To_Any_Relation(),
264
-        );
265
-        $this->_model_chain_to_wp_user = 'Transaction.Registration.Event';
266
-        $this->_caps_slug = 'transactions';
267
-        parent::__construct($timezone);
268
-    }
269
-
270
-
271
-    /**
272
-     * Gets all the line items for this transaction of the given type
273
-     *
274
-     * @param string             $line_item_type like one of EEM_Line_Item::type_*
275
-     * @param EE_Transaction|int $transaction
276
-     * @return EE_Base_Class[]|EE_Line_Item[]
277
-     * @throws EE_Error
278
-     * @throws InvalidArgumentException
279
-     * @throws InvalidDataTypeException
280
-     * @throws InvalidInterfaceException
281
-     */
282
-    public function get_all_of_type_for_transaction($line_item_type, $transaction)
283
-    {
284
-        $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
285
-        return $this->get_all(array(
286
-            array(
287
-                'LIN_type' => $line_item_type,
288
-                'TXN_ID'   => $transaction,
289
-            ),
290
-        ));
291
-    }
292
-
293
-
294
-    /**
295
-     * Gets all line items unrelated to tickets that are normal line items
296
-     * (eg shipping, promotions, and miscellaneous other stuff should probably fit in this category)
297
-     *
298
-     * @param EE_Transaction|int $transaction
299
-     * @return EE_Base_Class[]|EE_Line_Item[]
300
-     * @throws EE_Error
301
-     * @throws InvalidArgumentException
302
-     * @throws InvalidDataTypeException
303
-     * @throws InvalidInterfaceException
304
-     */
305
-    public function get_all_non_ticket_line_items_for_transaction($transaction)
306
-    {
307
-        $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
308
-        return $this->get_all(array(
309
-            array(
310
-                'LIN_type' => self::type_line_item,
311
-                'TXN_ID'   => $transaction,
312
-                'OR'       => array(
313
-                    'OBJ_type*notticket' => array('!=', EEM_Line_Item::OBJ_TYPE_TICKET),
314
-                    'OBJ_type*null'      => array('IS_NULL'),
315
-                ),
316
-            ),
317
-        ));
318
-    }
319
-
320
-
321
-    /**
322
-     * Deletes line items with no transaction who have passed the transaction cutoff time.
323
-     * This needs to be very efficient
324
-     * because if there are spam bots afoot there will be LOTS of line items. Also MySQL doesn't allow a limit when
325
-     * deleting and joining tables like this.
326
-     *
327
-     * @return int count of how many deleted
328
-     * @throws EE_Error
329
-     * @throws InvalidArgumentException
330
-     * @throws InvalidDataTypeException
331
-     * @throws InvalidInterfaceException
332
-     */
333
-    public function delete_line_items_with_no_transaction()
334
-    {
335
-        /** @type WPDB $wpdb */
336
-        global $wpdb;
337
-        $time_to_leave_alone = apply_filters(
338
-            'FHEE__EEM_Line_Item__delete_line_items_with_no_transaction__time_to_leave_alone',
339
-            WEEK_IN_SECONDS
340
-        );
341
-        $query = $wpdb->prepare(
342
-            'DELETE li
30
+	/**
31
+	 * Tax sub-total is just the total of all the taxes, which should be children
32
+	 * of this line item. There should only ever be one tax sub-total, and it should
33
+	 * be a direct child of. Its quantity and LIN_unit_price = 1.
34
+	 */
35
+	const type_tax_sub_total = 'tax-sub-total';
36
+
37
+	/**
38
+	 * Tax line items indicate a tax applied to all the taxable line items.
39
+	 * Should not have any children line items. Its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal
40
+	 * (eg 10% tax = 10, not 0.1). Its LIN_total = LIN_unit_price * pre-tax-total. Quantity = 1.
41
+	 */
42
+	const type_tax = 'tax';
43
+
44
+	/**
45
+	 * Indicating individual items purchased, or discounts or surcharges.
46
+	 * The sum of all the regular line items  plus the tax items should equal the grand total.
47
+	 * Possible children are sub-line-items and cancellations.
48
+	 * For flat items, LIN_unit_price * LIN_quantity = LIN_total. Its LIN_total is the sum of all the children
49
+	 * LIN_totals. Its LIN_percent = 0.
50
+	 * For percent items, its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal (eg 10% = 10, not 0.1).
51
+	 * Its LIN_total is LIN_percent / 100 * sum of lower-priority sibling line items. Quantity = 1.
52
+	 */
53
+	const type_line_item = 'line-item';
54
+
55
+	/**
56
+	 * Line item indicating all the factors that make a single line item.
57
+	 * Sub-line items should have NO children line items.
58
+	 * For flat sub-items, their quantity should match their parent item, their LIN_unit_price should be this sub-item's
59
+	 * contribution towards the price of ONE of their parent items, and its LIN_total should be
60
+	 *  = LIN_quantity * LIN_unit_price. Its LIN_percent = 0.
61
+	 * For percent sub-items, the quantity should be 1, LIN_unit_price should be 0, and its LIN_total should
62
+	 * = LIN_percent / 100 * sum of lower-priority sibling line items..
63
+	 */
64
+	const type_sub_line_item = 'sub-item';
65
+
66
+	/**
67
+	 * SubTax line items indicate a tax that is only applied to the pre-tax total of their parent line item.
68
+	 * Should not have any children line items. Its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal
69
+	 * (eg 10% tax = 10, not 0.1). Its LIN_total = LIN_unit_price * pre-tax-total. Quantity = 1.
70
+	 */
71
+	const type_sub_tax = 'sub-tax';
72
+
73
+	/**
74
+	 * Line item indicating a sub-total (eg total for an event, or pre-tax subtotal).
75
+	 * Direct children should be event subtotals.
76
+	 * Should have quantity of 1, and a LIN_total and LIN_unit_price of the sum of all its sub-items' LIN_totals.
77
+	 */
78
+	const type_sub_total = 'sub-total';
79
+
80
+	/**
81
+	 * Line item for the grand total of an order.
82
+	 * Its direct children should be tax subtotals and (pre-tax) subtotals,
83
+	 * and possibly a regular line item indicating a transaction-wide discount/surcharge.
84
+	 * Should have a quantity of 1, a LIN_total and LIN_unit_price of the entire order's amount.
85
+	 */
86
+	const type_total = 'total';
87
+
88
+	/**
89
+	 * When a line item is cancelled, a sub-line-item of type 'cancellation'
90
+	 * should be created, indicating the quantity that were cancelled
91
+	 * (because a line item could have a quantity of 1, and its cancellation item
92
+	 * could be for 3, indicating that originally 4 were purchased, but 3 have been
93
+	 * cancelled, and only one remains).
94
+	 * When items are refunded, a cancellation line item should be made, which points
95
+	 * to teh payment model object which actually refunded the payment.
96
+	 * Cancellations should NOT have any children line items; the should NOT affect
97
+	 * any calculations, and are only meant as a record that cancellations have occurred.
98
+	 * Their LIN_percent should be 0.
99
+	 */
100
+	const type_cancellation = 'cancellation';
101
+
102
+	// various line item object types
103
+	const OBJ_TYPE_EVENT = 'Event';
104
+
105
+	const OBJ_TYPE_PRICE = 'Price';
106
+
107
+	const OBJ_TYPE_PROMOTION = 'Promotion';
108
+
109
+	const OBJ_TYPE_TICKET = 'Ticket';
110
+
111
+	const OBJ_TYPE_TRANSACTION = 'Transaction';
112
+
113
+	/**
114
+	 * @var EEM_Line_Item $_instance
115
+	 */
116
+	protected static $_instance;
117
+
118
+
119
+	/**
120
+	 * private constructor to prevent direct creation
121
+	 *
122
+	 * @Constructor
123
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
124
+	 *                         (and any incoming timezone data that gets saved).
125
+	 *                         Note this just sends the timezone info to the date time model field objects.
126
+	 *                         Default is NULL
127
+	 *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
128
+	 * @throws EE_Error
129
+	 * @throws InvalidArgumentException
130
+	 */
131
+	protected function __construct($timezone)
132
+	{
133
+		$this->singular_item = esc_html__('Line Item', 'event_espresso');
134
+		$this->plural_item = esc_html__('Line Items', 'event_espresso');
135
+
136
+		$this->_tables = array(
137
+			'Line_Item' => new EE_Primary_Table('esp_line_item', 'LIN_ID'),
138
+		);
139
+		$line_items_can_be_for = apply_filters(
140
+			'FHEE__EEM_Line_Item__line_items_can_be_for',
141
+			array('Ticket', 'Price', 'Event')
142
+		);
143
+		$this->_fields = array(
144
+			'Line_Item' => array(
145
+				'LIN_ID'         => new EE_Primary_Key_Int_Field(
146
+					'LIN_ID',
147
+					esc_html__('ID', 'event_espresso')
148
+				),
149
+				'LIN_code'       => new EE_Slug_Field(
150
+					'LIN_code',
151
+					esc_html__('Code for index into Cart', 'event_espresso'),
152
+					true
153
+				),
154
+				'TXN_ID'         => new EE_Foreign_Key_Int_Field(
155
+					'TXN_ID',
156
+					esc_html__('Transaction ID', 'event_espresso'),
157
+					true,
158
+					null,
159
+					'Transaction'
160
+				),
161
+				'LIN_name'       => new EE_Full_HTML_Field(
162
+					'LIN_name',
163
+					esc_html__('Line Item Name', 'event_espresso'),
164
+					false,
165
+					''
166
+				),
167
+				'LIN_desc'       => new EE_Full_HTML_Field(
168
+					'LIN_desc',
169
+					esc_html__('Line Item Description', 'event_espresso'),
170
+					true
171
+				),
172
+				'LIN_unit_price' => new EE_Money_Field(
173
+					'LIN_unit_price',
174
+					esc_html__('Unit Price', 'event_espresso'),
175
+					false,
176
+					0
177
+				),
178
+				'LIN_percent'    => new EE_Float_Field(
179
+					'LIN_percent',
180
+					esc_html__('Percent', 'event_espresso'),
181
+					false,
182
+					0
183
+				),
184
+				'LIN_is_taxable' => new EE_Boolean_Field(
185
+					'LIN_is_taxable',
186
+					esc_html__('Taxable', 'event_espresso'),
187
+					false,
188
+					false
189
+				),
190
+				'LIN_order'      => new EE_Integer_Field(
191
+					'LIN_order',
192
+					esc_html__('Order of Application towards total of parent', 'event_espresso'),
193
+					false,
194
+					1
195
+				),
196
+				'LIN_total'      => new EE_Money_Field(
197
+					'LIN_total',
198
+					esc_html__('Total (unit price x quantity) after taxes', 'event_espresso'),
199
+					false,
200
+					0
201
+				),
202
+				'LIN_pretax'      => new EE_Money_Field(
203
+					'LIN_pretax',
204
+					esc_html__('Total (unit price x quantity) before taxes', 'event_espresso'),
205
+					false,
206
+					0
207
+				),
208
+				'LIN_quantity'   => new EE_Integer_Field(
209
+					'LIN_quantity',
210
+					esc_html__('Quantity', 'event_espresso'),
211
+					true,
212
+					1
213
+				),
214
+				'LIN_parent'     => new EE_Integer_Field(
215
+					'LIN_parent',
216
+					esc_html__("Parent ID (this item goes towards that Line Item's total)", 'event_espresso'),
217
+					true,
218
+					null
219
+				),
220
+				'LIN_type'       => new EE_Enum_Text_Field(
221
+					'LIN_type',
222
+					esc_html__('Type', 'event_espresso'),
223
+					false,
224
+					'line-item',
225
+					array(
226
+						self::type_line_item     => esc_html__('Line Item', 'event_espresso'),
227
+						self::type_sub_line_item => esc_html__('Sub-Item', 'event_espresso'),
228
+						self::type_sub_tax       => esc_html__('Sub-Tax', 'event_espresso'),
229
+						self::type_sub_total     => esc_html__('Subtotal', 'event_espresso'),
230
+						self::type_tax_sub_total => esc_html__('Tax Subtotal', 'event_espresso'),
231
+						self::type_tax           => esc_html__('Tax', 'event_espresso'),
232
+						self::type_total         => esc_html__('Total', 'event_espresso'),
233
+						self::type_cancellation  => esc_html__('Cancellation', 'event_espresso'),
234
+					)
235
+				),
236
+				'OBJ_ID'         => new EE_Foreign_Key_Int_Field(
237
+					'OBJ_ID',
238
+					esc_html__('ID of Item purchased.', 'event_espresso'),
239
+					true,
240
+					null,
241
+					$line_items_can_be_for
242
+				),
243
+				'OBJ_type'       => new EE_Any_Foreign_Model_Name_Field(
244
+					'OBJ_type',
245
+					esc_html__('Model Name this Line Item is for', 'event_espresso'),
246
+					true,
247
+					null,
248
+					$line_items_can_be_for
249
+				),
250
+				'LIN_timestamp'  => new EE_Datetime_Field(
251
+					'LIN_timestamp',
252
+					esc_html__('When the line item was created', 'event_espresso'),
253
+					false,
254
+					EE_Datetime_Field::now,
255
+					$timezone
256
+				),
257
+			),
258
+		);
259
+		$this->_model_relations = array(
260
+			'Transaction' => new EE_Belongs_To_Relation(),
261
+			'Ticket'      => new EE_Belongs_To_Any_Relation(),
262
+			'Price'       => new EE_Belongs_To_Any_Relation(),
263
+			'Event'       => new EE_Belongs_To_Any_Relation(),
264
+		);
265
+		$this->_model_chain_to_wp_user = 'Transaction.Registration.Event';
266
+		$this->_caps_slug = 'transactions';
267
+		parent::__construct($timezone);
268
+	}
269
+
270
+
271
+	/**
272
+	 * Gets all the line items for this transaction of the given type
273
+	 *
274
+	 * @param string             $line_item_type like one of EEM_Line_Item::type_*
275
+	 * @param EE_Transaction|int $transaction
276
+	 * @return EE_Base_Class[]|EE_Line_Item[]
277
+	 * @throws EE_Error
278
+	 * @throws InvalidArgumentException
279
+	 * @throws InvalidDataTypeException
280
+	 * @throws InvalidInterfaceException
281
+	 */
282
+	public function get_all_of_type_for_transaction($line_item_type, $transaction)
283
+	{
284
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
285
+		return $this->get_all(array(
286
+			array(
287
+				'LIN_type' => $line_item_type,
288
+				'TXN_ID'   => $transaction,
289
+			),
290
+		));
291
+	}
292
+
293
+
294
+	/**
295
+	 * Gets all line items unrelated to tickets that are normal line items
296
+	 * (eg shipping, promotions, and miscellaneous other stuff should probably fit in this category)
297
+	 *
298
+	 * @param EE_Transaction|int $transaction
299
+	 * @return EE_Base_Class[]|EE_Line_Item[]
300
+	 * @throws EE_Error
301
+	 * @throws InvalidArgumentException
302
+	 * @throws InvalidDataTypeException
303
+	 * @throws InvalidInterfaceException
304
+	 */
305
+	public function get_all_non_ticket_line_items_for_transaction($transaction)
306
+	{
307
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
308
+		return $this->get_all(array(
309
+			array(
310
+				'LIN_type' => self::type_line_item,
311
+				'TXN_ID'   => $transaction,
312
+				'OR'       => array(
313
+					'OBJ_type*notticket' => array('!=', EEM_Line_Item::OBJ_TYPE_TICKET),
314
+					'OBJ_type*null'      => array('IS_NULL'),
315
+				),
316
+			),
317
+		));
318
+	}
319
+
320
+
321
+	/**
322
+	 * Deletes line items with no transaction who have passed the transaction cutoff time.
323
+	 * This needs to be very efficient
324
+	 * because if there are spam bots afoot there will be LOTS of line items. Also MySQL doesn't allow a limit when
325
+	 * deleting and joining tables like this.
326
+	 *
327
+	 * @return int count of how many deleted
328
+	 * @throws EE_Error
329
+	 * @throws InvalidArgumentException
330
+	 * @throws InvalidDataTypeException
331
+	 * @throws InvalidInterfaceException
332
+	 */
333
+	public function delete_line_items_with_no_transaction()
334
+	{
335
+		/** @type WPDB $wpdb */
336
+		global $wpdb;
337
+		$time_to_leave_alone = apply_filters(
338
+			'FHEE__EEM_Line_Item__delete_line_items_with_no_transaction__time_to_leave_alone',
339
+			WEEK_IN_SECONDS
340
+		);
341
+		$query = $wpdb->prepare(
342
+			'DELETE li
343 343
 				FROM ' . $this->table() . ' li
344 344
 				LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON li.TXN_ID = t.TXN_ID
345 345
 				WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s',
346
-            // use GMT time because that's what TXN_timestamps are in
347
-            date('Y-m-d H:i:s', time() - $time_to_leave_alone)
348
-        );
349
-        return $wpdb->query($query);
350
-    }
351
-
352
-
353
-    /**
354
-     * get_line_item_for_transaction_object
355
-     * Gets a transaction's line item record for a specific object such as a EE_Event or EE_Ticket
356
-     *
357
-     * @param int           $TXN_ID
358
-     * @param EE_Base_Class $object
359
-     * @return EE_Base_Class[]|EE_Line_Item[]
360
-     * @throws EE_Error
361
-     * @throws InvalidArgumentException
362
-     * @throws InvalidDataTypeException
363
-     * @throws InvalidInterfaceException
364
-     * @throws ReflectionException
365
-     */
366
-    public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object)
367
-    {
368
-        return $this->get_all(array(
369
-            array(
370
-                'TXN_ID'   => $TXN_ID,
371
-                'OBJ_type' => str_replace('EE_', '', get_class($object)),
372
-                'OBJ_ID'   => $object->ID(),
373
-            ),
374
-        ));
375
-    }
376
-
377
-
378
-    /**
379
-     * get_object_line_items_for_transaction
380
-     * Gets all of the the object line items for a transaction, based on an object type plus an array of object IDs
381
-     *
382
-     * @param int    $TXN_ID
383
-     * @param string $OBJ_type
384
-     * @param array  $OBJ_IDs
385
-     * @return EE_Base_Class[]|EE_Line_Item[]
386
-     * @throws EE_Error
387
-     */
388
-    public function get_object_line_items_for_transaction(
389
-        $TXN_ID,
390
-        $OBJ_type = EEM_Line_Item::OBJ_TYPE_EVENT,
391
-        $OBJ_IDs = array()
392
-    ) {
393
-        $query_params = array(
394
-            'OBJ_type' => $OBJ_type,
395
-            // if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query
396
-            'OBJ_ID'   => is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs,
397
-        );
398
-        if ($TXN_ID) {
399
-            $query_params['TXN_ID'] = $TXN_ID;
400
-        }
401
-        return $this->get_all(array($query_params));
402
-    }
403
-
404
-
405
-    /**
406
-     * get_all_ticket_line_items_for_transaction
407
-     *
408
-     * @param EE_Transaction $transaction
409
-     * @return EE_Base_Class[]|EE_Line_Item[]
410
-     * @throws EE_Error
411
-     * @throws InvalidArgumentException
412
-     * @throws InvalidDataTypeException
413
-     * @throws InvalidInterfaceException
414
-     * @throws ReflectionException
415
-     */
416
-    public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction)
417
-    {
418
-        return $this->get_all(array(
419
-            array(
420
-                'TXN_ID'   => $transaction->ID(),
421
-                'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
422
-            ),
423
-        ));
424
-    }
425
-
426
-
427
-    /**
428
-     * get_ticket_line_item_for_transaction
429
-     *
430
-     * @param int $TXN_ID
431
-     * @param int $TKT_ID
432
-     * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL
433
-     * @throws EE_Error
434
-     * @throws InvalidArgumentException
435
-     * @throws InvalidDataTypeException
436
-     * @throws InvalidInterfaceException
437
-     */
438
-    public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID)
439
-    {
440
-        return $this->get_one(array(
441
-            array(
442
-                'TXN_ID'   => EEM_Transaction::instance()->ensure_is_ID($TXN_ID),
443
-                'OBJ_ID'   => $TKT_ID,
444
-                'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
445
-            ),
446
-        ));
447
-    }
448
-
449
-
450
-    /**
451
-     * get_existing_promotion_line_item
452
-     * searches the cart for existing line items for the specified promotion
453
-     *
454
-     * @since 1.0.0
455
-     * @param EE_Line_Item $parent_line_item
456
-     * @param EE_Promotion $promotion
457
-     * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL
458
-     * @throws EE_Error
459
-     * @throws InvalidArgumentException
460
-     * @throws InvalidDataTypeException
461
-     * @throws InvalidInterfaceException
462
-     * @throws ReflectionException
463
-     */
464
-    public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion)
465
-    {
466
-        return $this->get_one(array(
467
-            array(
468
-                'TXN_ID'     => $parent_line_item->TXN_ID(),
469
-                'LIN_parent' => $parent_line_item->ID(),
470
-                'OBJ_type'   => EEM_Line_Item::OBJ_TYPE_PROMOTION,
471
-                'OBJ_ID'     => $promotion->ID(),
472
-            ),
473
-        ));
474
-    }
475
-
476
-
477
-    /**
478
-     * get_all_promotion_line_items
479
-     * searches the cart for any and all existing promotion line items
480
-     *
481
-     * @since   1.0.0
482
-     * @param EE_Line_Item $parent_line_item
483
-     * @return EE_Base_Class[]|EE_Line_Item[]
484
-     * @throws EE_Error
485
-     * @throws InvalidArgumentException
486
-     * @throws InvalidDataTypeException
487
-     * @throws InvalidInterfaceException
488
-     * @throws ReflectionException
489
-     */
490
-    public function get_all_promotion_line_items(EE_Line_Item $parent_line_item)
491
-    {
492
-        return $this->get_all(array(
493
-            array(
494
-                'TXN_ID'     => $parent_line_item->TXN_ID(),
495
-                'LIN_parent' => $parent_line_item->ID(),
496
-                'OBJ_type'   => EEM_Line_Item::OBJ_TYPE_PROMOTION,
497
-            ),
498
-        ));
499
-    }
500
-
501
-
502
-    /**
503
-     * Gets the registration's corresponding line item.
504
-     * Note: basically does NOT support having multiple line items for a single ticket,
505
-     * which would happen if some of the registrations had a price modifier while others didn't.
506
-     * In order to support that, we'd probably need a LIN_ID on registrations or something.
507
-     *
508
-     * @param EE_Registration $registration
509
-     * @return EE_Base_Class|EE_Line_ITem|EE_Soft_Delete_Base_Class|NULL
510
-     * @throws EE_Error
511
-     */
512
-    public function get_line_item_for_registration(EE_Registration $registration)
513
-    {
514
-        return $this->get_one($this->line_item_for_registration_query_params($registration));
515
-    }
516
-
517
-
518
-    /**
519
-     * Gets the query params used to retrieve a specific line item for the given registration
520
-     *
521
-     * @param EE_Registration $registration
522
-     * @param array           $original_query_params any extra query params you'd like to be merged with
523
-     * @return array @see
524
-     *      https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
525
-     * @throws EE_Error
526
-     */
527
-    public function line_item_for_registration_query_params(
528
-        EE_Registration $registration,
529
-        $original_query_params = array()
530
-    ) {
531
-        return array_replace_recursive($original_query_params, array(
532
-            array(
533
-                'OBJ_ID'   => $registration->ticket_ID(),
534
-                'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
535
-                'TXN_ID'   => $registration->transaction_ID(),
536
-            ),
537
-        ));
538
-    }
539
-
540
-
541
-    /**
542
-     * @return EE_Base_Class[]|EE_Line_Item[]
543
-     * @throws InvalidInterfaceException
544
-     * @throws InvalidDataTypeException
545
-     * @throws EE_Error
546
-     * @throws InvalidArgumentException
547
-     */
548
-    public function get_total_line_items_with_no_transaction()
549
-    {
550
-        return $this->get_total_line_items_for_carts();
551
-    }
552
-
553
-
554
-    /**
555
-     * @return EE_Base_Class[]|EE_Line_Item[]
556
-     * @throws InvalidInterfaceException
557
-     * @throws InvalidDataTypeException
558
-     * @throws EE_Error
559
-     * @throws InvalidArgumentException
560
-     */
561
-    public function get_total_line_items_for_active_carts()
562
-    {
563
-        return $this->get_total_line_items_for_carts(false);
564
-    }
565
-
566
-
567
-    /**
568
-     * @return EE_Base_Class[]|EE_Line_Item[]
569
-     * @throws InvalidInterfaceException
570
-     * @throws InvalidDataTypeException
571
-     * @throws EE_Error
572
-     * @throws InvalidArgumentException
573
-     */
574
-    public function get_total_line_items_for_expired_carts()
575
-    {
576
-        return $this->get_total_line_items_for_carts(true);
577
-    }
578
-
579
-
580
-    /**
581
-     * Returns an array of grand total line items where the TXN_ID is 0.
582
-     * If $expired is set to true, then only line items for expired sessions will be returned.
583
-     * If $expired is set to false, then only line items for active sessions will be returned.
584
-     *
585
-     * @param null $expired
586
-     * @return EE_Base_Class[]|EE_Line_Item[]
587
-     * @throws EE_Error
588
-     * @throws InvalidArgumentException
589
-     * @throws InvalidDataTypeException
590
-     * @throws InvalidInterfaceException
591
-     */
592
-    private function get_total_line_items_for_carts($expired = null)
593
-    {
594
-        $where_params = array(
595
-            'TXN_ID'   => 0,
596
-            'LIN_type' => 'total',
597
-        );
598
-        if ($expired !== null) {
599
-            /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
600
-            $session_lifespan = LoaderFactory::getLoader()->getShared(
601
-                'EventEspresso\core\domain\values\session\SessionLifespan'
602
-            );
603
-            $where_params['LIN_timestamp'] = array(
604
-                $expired ? '<=' : '>',
605
-                $session_lifespan->expiration(),
606
-            );
607
-        }
608
-        return $this->get_all(array($where_params));
609
-    }
610
-
611
-
612
-    /**
613
-     * Returns an array of ticket total line items where the TXN_ID is 0
614
-     * AND the timestamp is older than the session lifespan.
615
-     *
616
-     * @param int $timestamp
617
-     * @return EE_Base_Class[]|EE_Line_Item[]
618
-     * @throws EE_Error
619
-     * @throws InvalidArgumentException
620
-     * @throws InvalidDataTypeException
621
-     * @throws InvalidInterfaceException
622
-     */
623
-    public function getTicketLineItemsForExpiredCarts($timestamp = 0)
624
-    {
625
-        if (! absint($timestamp)) {
626
-            /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
627
-            $session_lifespan = LoaderFactory::getLoader()->getShared(
628
-                'EventEspresso\core\domain\values\session\SessionLifespan'
629
-            );
630
-            $timestamp = $session_lifespan->expiration();
631
-        }
632
-        return $this->get_all(
633
-            array(
634
-                array(
635
-                    'TXN_ID'        => 0,
636
-                    'OBJ_type'      => EEM_Line_Item::OBJ_TYPE_TICKET,
637
-                    'LIN_timestamp' => array('<=', $timestamp),
638
-                ),
639
-            )
640
-        );
641
-    }
346
+			// use GMT time because that's what TXN_timestamps are in
347
+			date('Y-m-d H:i:s', time() - $time_to_leave_alone)
348
+		);
349
+		return $wpdb->query($query);
350
+	}
351
+
352
+
353
+	/**
354
+	 * get_line_item_for_transaction_object
355
+	 * Gets a transaction's line item record for a specific object such as a EE_Event or EE_Ticket
356
+	 *
357
+	 * @param int           $TXN_ID
358
+	 * @param EE_Base_Class $object
359
+	 * @return EE_Base_Class[]|EE_Line_Item[]
360
+	 * @throws EE_Error
361
+	 * @throws InvalidArgumentException
362
+	 * @throws InvalidDataTypeException
363
+	 * @throws InvalidInterfaceException
364
+	 * @throws ReflectionException
365
+	 */
366
+	public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object)
367
+	{
368
+		return $this->get_all(array(
369
+			array(
370
+				'TXN_ID'   => $TXN_ID,
371
+				'OBJ_type' => str_replace('EE_', '', get_class($object)),
372
+				'OBJ_ID'   => $object->ID(),
373
+			),
374
+		));
375
+	}
376
+
377
+
378
+	/**
379
+	 * get_object_line_items_for_transaction
380
+	 * Gets all of the the object line items for a transaction, based on an object type plus an array of object IDs
381
+	 *
382
+	 * @param int    $TXN_ID
383
+	 * @param string $OBJ_type
384
+	 * @param array  $OBJ_IDs
385
+	 * @return EE_Base_Class[]|EE_Line_Item[]
386
+	 * @throws EE_Error
387
+	 */
388
+	public function get_object_line_items_for_transaction(
389
+		$TXN_ID,
390
+		$OBJ_type = EEM_Line_Item::OBJ_TYPE_EVENT,
391
+		$OBJ_IDs = array()
392
+	) {
393
+		$query_params = array(
394
+			'OBJ_type' => $OBJ_type,
395
+			// if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query
396
+			'OBJ_ID'   => is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs,
397
+		);
398
+		if ($TXN_ID) {
399
+			$query_params['TXN_ID'] = $TXN_ID;
400
+		}
401
+		return $this->get_all(array($query_params));
402
+	}
403
+
404
+
405
+	/**
406
+	 * get_all_ticket_line_items_for_transaction
407
+	 *
408
+	 * @param EE_Transaction $transaction
409
+	 * @return EE_Base_Class[]|EE_Line_Item[]
410
+	 * @throws EE_Error
411
+	 * @throws InvalidArgumentException
412
+	 * @throws InvalidDataTypeException
413
+	 * @throws InvalidInterfaceException
414
+	 * @throws ReflectionException
415
+	 */
416
+	public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction)
417
+	{
418
+		return $this->get_all(array(
419
+			array(
420
+				'TXN_ID'   => $transaction->ID(),
421
+				'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
422
+			),
423
+		));
424
+	}
425
+
426
+
427
+	/**
428
+	 * get_ticket_line_item_for_transaction
429
+	 *
430
+	 * @param int $TXN_ID
431
+	 * @param int $TKT_ID
432
+	 * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL
433
+	 * @throws EE_Error
434
+	 * @throws InvalidArgumentException
435
+	 * @throws InvalidDataTypeException
436
+	 * @throws InvalidInterfaceException
437
+	 */
438
+	public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID)
439
+	{
440
+		return $this->get_one(array(
441
+			array(
442
+				'TXN_ID'   => EEM_Transaction::instance()->ensure_is_ID($TXN_ID),
443
+				'OBJ_ID'   => $TKT_ID,
444
+				'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
445
+			),
446
+		));
447
+	}
448
+
449
+
450
+	/**
451
+	 * get_existing_promotion_line_item
452
+	 * searches the cart for existing line items for the specified promotion
453
+	 *
454
+	 * @since 1.0.0
455
+	 * @param EE_Line_Item $parent_line_item
456
+	 * @param EE_Promotion $promotion
457
+	 * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL
458
+	 * @throws EE_Error
459
+	 * @throws InvalidArgumentException
460
+	 * @throws InvalidDataTypeException
461
+	 * @throws InvalidInterfaceException
462
+	 * @throws ReflectionException
463
+	 */
464
+	public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion)
465
+	{
466
+		return $this->get_one(array(
467
+			array(
468
+				'TXN_ID'     => $parent_line_item->TXN_ID(),
469
+				'LIN_parent' => $parent_line_item->ID(),
470
+				'OBJ_type'   => EEM_Line_Item::OBJ_TYPE_PROMOTION,
471
+				'OBJ_ID'     => $promotion->ID(),
472
+			),
473
+		));
474
+	}
475
+
476
+
477
+	/**
478
+	 * get_all_promotion_line_items
479
+	 * searches the cart for any and all existing promotion line items
480
+	 *
481
+	 * @since   1.0.0
482
+	 * @param EE_Line_Item $parent_line_item
483
+	 * @return EE_Base_Class[]|EE_Line_Item[]
484
+	 * @throws EE_Error
485
+	 * @throws InvalidArgumentException
486
+	 * @throws InvalidDataTypeException
487
+	 * @throws InvalidInterfaceException
488
+	 * @throws ReflectionException
489
+	 */
490
+	public function get_all_promotion_line_items(EE_Line_Item $parent_line_item)
491
+	{
492
+		return $this->get_all(array(
493
+			array(
494
+				'TXN_ID'     => $parent_line_item->TXN_ID(),
495
+				'LIN_parent' => $parent_line_item->ID(),
496
+				'OBJ_type'   => EEM_Line_Item::OBJ_TYPE_PROMOTION,
497
+			),
498
+		));
499
+	}
500
+
501
+
502
+	/**
503
+	 * Gets the registration's corresponding line item.
504
+	 * Note: basically does NOT support having multiple line items for a single ticket,
505
+	 * which would happen if some of the registrations had a price modifier while others didn't.
506
+	 * In order to support that, we'd probably need a LIN_ID on registrations or something.
507
+	 *
508
+	 * @param EE_Registration $registration
509
+	 * @return EE_Base_Class|EE_Line_ITem|EE_Soft_Delete_Base_Class|NULL
510
+	 * @throws EE_Error
511
+	 */
512
+	public function get_line_item_for_registration(EE_Registration $registration)
513
+	{
514
+		return $this->get_one($this->line_item_for_registration_query_params($registration));
515
+	}
516
+
517
+
518
+	/**
519
+	 * Gets the query params used to retrieve a specific line item for the given registration
520
+	 *
521
+	 * @param EE_Registration $registration
522
+	 * @param array           $original_query_params any extra query params you'd like to be merged with
523
+	 * @return array @see
524
+	 *      https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
525
+	 * @throws EE_Error
526
+	 */
527
+	public function line_item_for_registration_query_params(
528
+		EE_Registration $registration,
529
+		$original_query_params = array()
530
+	) {
531
+		return array_replace_recursive($original_query_params, array(
532
+			array(
533
+				'OBJ_ID'   => $registration->ticket_ID(),
534
+				'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
535
+				'TXN_ID'   => $registration->transaction_ID(),
536
+			),
537
+		));
538
+	}
539
+
540
+
541
+	/**
542
+	 * @return EE_Base_Class[]|EE_Line_Item[]
543
+	 * @throws InvalidInterfaceException
544
+	 * @throws InvalidDataTypeException
545
+	 * @throws EE_Error
546
+	 * @throws InvalidArgumentException
547
+	 */
548
+	public function get_total_line_items_with_no_transaction()
549
+	{
550
+		return $this->get_total_line_items_for_carts();
551
+	}
552
+
553
+
554
+	/**
555
+	 * @return EE_Base_Class[]|EE_Line_Item[]
556
+	 * @throws InvalidInterfaceException
557
+	 * @throws InvalidDataTypeException
558
+	 * @throws EE_Error
559
+	 * @throws InvalidArgumentException
560
+	 */
561
+	public function get_total_line_items_for_active_carts()
562
+	{
563
+		return $this->get_total_line_items_for_carts(false);
564
+	}
565
+
566
+
567
+	/**
568
+	 * @return EE_Base_Class[]|EE_Line_Item[]
569
+	 * @throws InvalidInterfaceException
570
+	 * @throws InvalidDataTypeException
571
+	 * @throws EE_Error
572
+	 * @throws InvalidArgumentException
573
+	 */
574
+	public function get_total_line_items_for_expired_carts()
575
+	{
576
+		return $this->get_total_line_items_for_carts(true);
577
+	}
578
+
579
+
580
+	/**
581
+	 * Returns an array of grand total line items where the TXN_ID is 0.
582
+	 * If $expired is set to true, then only line items for expired sessions will be returned.
583
+	 * If $expired is set to false, then only line items for active sessions will be returned.
584
+	 *
585
+	 * @param null $expired
586
+	 * @return EE_Base_Class[]|EE_Line_Item[]
587
+	 * @throws EE_Error
588
+	 * @throws InvalidArgumentException
589
+	 * @throws InvalidDataTypeException
590
+	 * @throws InvalidInterfaceException
591
+	 */
592
+	private function get_total_line_items_for_carts($expired = null)
593
+	{
594
+		$where_params = array(
595
+			'TXN_ID'   => 0,
596
+			'LIN_type' => 'total',
597
+		);
598
+		if ($expired !== null) {
599
+			/** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
600
+			$session_lifespan = LoaderFactory::getLoader()->getShared(
601
+				'EventEspresso\core\domain\values\session\SessionLifespan'
602
+			);
603
+			$where_params['LIN_timestamp'] = array(
604
+				$expired ? '<=' : '>',
605
+				$session_lifespan->expiration(),
606
+			);
607
+		}
608
+		return $this->get_all(array($where_params));
609
+	}
610
+
611
+
612
+	/**
613
+	 * Returns an array of ticket total line items where the TXN_ID is 0
614
+	 * AND the timestamp is older than the session lifespan.
615
+	 *
616
+	 * @param int $timestamp
617
+	 * @return EE_Base_Class[]|EE_Line_Item[]
618
+	 * @throws EE_Error
619
+	 * @throws InvalidArgumentException
620
+	 * @throws InvalidDataTypeException
621
+	 * @throws InvalidInterfaceException
622
+	 */
623
+	public function getTicketLineItemsForExpiredCarts($timestamp = 0)
624
+	{
625
+		if (! absint($timestamp)) {
626
+			/** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
627
+			$session_lifespan = LoaderFactory::getLoader()->getShared(
628
+				'EventEspresso\core\domain\values\session\SessionLifespan'
629
+			);
630
+			$timestamp = $session_lifespan->expiration();
631
+		}
632
+		return $this->get_all(
633
+			array(
634
+				array(
635
+					'TXN_ID'        => 0,
636
+					'OBJ_type'      => EEM_Line_Item::OBJ_TYPE_TICKET,
637
+					'LIN_timestamp' => array('<=', $timestamp),
638
+				),
639
+			)
640
+		);
641
+	}
642 642
 }
Please login to merge, or discard this patch.
support/templates/support_admin_details_additional_information.template.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <div class="padding">
2 2
     <p><?php
3
-        printf(
4
-            esc_html__('Check out the %1$sroadmap for Event Espresso%2$s.', 'event_espresso'),
5
-            '<a href="https://trello.com/b/zg9DCIpe/event-espresso-public-roadmap" target="_blank" rel="noopener noreferrer">',
6
-            '</a>'
7
-        ); ?></p>
3
+		printf(
4
+			esc_html__('Check out the %1$sroadmap for Event Espresso%2$s.', 'event_espresso'),
5
+			'<a href="https://trello.com/b/zg9DCIpe/event-espresso-public-roadmap" target="_blank" rel="noopener noreferrer">',
6
+			'</a>'
7
+		); ?></p>
8 8
 </div>
9 9
\ No newline at end of file
Please login to merge, or discard this patch.
admin_pages/support/templates/developers_admin_details.template.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,93 +1,93 @@
 block discarded – undo
1 1
 <div class="padding">
2 2
     <?php esc_html_e(
3
-        'If you want to integrate with Event Espresso or participate in building code, then you are in the right place. The following resources can help you get started.',
4
-        'event_espresso'
5
-    ); ?>
3
+		'If you want to integrate with Event Espresso or participate in building code, then you are in the right place. The following resources can help you get started.',
4
+		'event_espresso'
5
+	); ?>
6 6
     <h2><?php esc_html_e('Developer Resources', 'event_espresso'); ?></h2>
7 7
     <ul>
8 8
         <li>
9 9
             <?php printf(
10
-                esc_html__('%1$sEvent Espresso 4 Developer Documentation%2$s', 'event_espresso'),
11
-                '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs#getting-started-with-the-ee-developer-docs" target="_blank" rel="noopener noreferrer">',
12
-                '</a>'
13
-            ); ?></li>
10
+				esc_html__('%1$sEvent Espresso 4 Developer Documentation%2$s', 'event_espresso'),
11
+				'<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs#getting-started-with-the-ee-developer-docs" target="_blank" rel="noopener noreferrer">',
12
+				'</a>'
13
+			); ?></li>
14 14
         <li>
15 15
             <?php printf(
16
-                esc_html__('%1$sEvent Espresso 4 Developer News%2$s', 'event_espresso'),
17
-                '<a href="http://developer.eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
18
-                '</a>'
19
-            ); ?></li>
16
+				esc_html__('%1$sEvent Espresso 4 Developer News%2$s', 'event_espresso'),
17
+				'<a href="http://developer.eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
18
+				'</a>'
19
+			); ?></li>
20 20
         <li>
21 21
             <?php printf(
22
-                esc_html__('%1$sApply%2$s to be listed as an %3$sEvent Espresso Professional%2$s', 'event_espresso'),
23
-                '<a href="https://eventespresso.com/developers/event-espresso-pros-application/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
24
-                '</a>',
25
-                '<a href="https://eventespresso.com/developers/event-espresso-pros/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">'
26
-            ); ?></li>
22
+				esc_html__('%1$sApply%2$s to be listed as an %3$sEvent Espresso Professional%2$s', 'event_espresso'),
23
+				'<a href="https://eventespresso.com/developers/event-espresso-pros-application/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
24
+				'</a>',
25
+				'<a href="https://eventespresso.com/developers/event-espresso-pros/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">'
26
+			); ?></li>
27 27
     </ul>
28 28
 
29 29
     <h2><?php esc_html_e('Event Espresso 4 Articles for Developers', 'event_espresso'); ?></h2>
30 30
     <ul>
31 31
         <li>
32 32
             <?php printf(
33
-                esc_html__('%1$sCustom Post Types Usage%2$s', 'event_espresso'),
34
-                '<a href="https://eventespresso.com/2014/02/epsresso-brewery-custom-post-types-event-espresso/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
35
-                '</a>'
36
-            ); ?></li>
33
+				esc_html__('%1$sCustom Post Types Usage%2$s', 'event_espresso'),
34
+				'<a href="https://eventespresso.com/2014/02/epsresso-brewery-custom-post-types-event-espresso/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
35
+				'</a>'
36
+			); ?></li>
37 37
         <li>
38 38
             <?php printf(
39
-                esc_html__('%1$sTheme Development%2$s', 'event_espresso'),
40
-                '<a href="https://eventespresso.com/2014/02/developers-corner-theming-event-espresso-4/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
41
-                '</a>'
42
-            ); ?></li>
39
+				esc_html__('%1$sTheme Development%2$s', 'event_espresso'),
40
+				'<a href="https://eventespresso.com/2014/02/developers-corner-theming-event-espresso-4/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
41
+				'</a>'
42
+			); ?></li>
43 43
         <li>
44 44
             <?php printf(
45
-                esc_html__('%1$sCapability System%2$s', 'event_espresso'),
46
-                '<a href="http://developer.eventespresso.com/docs/ee-capability-system-overview/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
47
-                '</a>'
48
-            ); ?></li>
45
+				esc_html__('%1$sCapability System%2$s', 'event_espresso'),
46
+				'<a href="http://developer.eventespresso.com/docs/ee-capability-system-overview/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
47
+				'</a>'
48
+			); ?></li>
49 49
         <li>
50 50
             <?php printf(
51
-                esc_html__('%1$sPayment Method Development%2$s', 'event_espresso'),
52
-                '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/L--Payment-Methods-and-Gateways/creating-a-payment-method.md" target="_blank" rel="noopener noreferrer">',
53
-                '</a>'
54
-            ); ?></li>
51
+				esc_html__('%1$sPayment Method Development%2$s', 'event_espresso'),
52
+				'<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/L--Payment-Methods-and-Gateways/creating-a-payment-method.md" target="_blank" rel="noopener noreferrer">',
53
+				'</a>'
54
+			); ?></li>
55 55
         <li>
56 56
             <?php printf(
57
-                esc_html__('%1$sMessages System in Event Espresso 4%2$s', 'event_espresso'),
58
-                '<a href="https://eventespresso.com/2014/03/messages-systemyour-tool-getting-word/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
59
-                '</a>'
60
-            ); ?></li>
57
+				esc_html__('%1$sMessages System in Event Espresso 4%2$s', 'event_espresso'),
58
+				'<a href="https://eventespresso.com/2014/03/messages-systemyour-tool-getting-word/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
59
+				'</a>'
60
+			); ?></li>
61 61
         <li>
62 62
             <?php printf(
63
-                esc_html__(
64
-                    '%1$sDatabase Model System%2$s (used for interfacing with EE4 data via WordPress plugins and server side querying)',
65
-                    'event_espresso'
66
-                ),
67
-                '<a href="http://developer.eventespresso.com/docs/using-ee4-model-objects/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
68
-                '</a>'
69
-            ); ?></li>
63
+				esc_html__(
64
+					'%1$sDatabase Model System%2$s (used for interfacing with EE4 data via WordPress plugins and server side querying)',
65
+					'event_espresso'
66
+				),
67
+				'<a href="http://developer.eventespresso.com/docs/using-ee4-model-objects/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">',
68
+				'</a>'
69
+			); ?></li>
70 70
     </ul>
71 71
 
72 72
     <h2><?php esc_html_e('REST API Resources', 'event_espresso'); ?></h2>
73 73
     <ul>
74 74
         <li>
75 75
             <?php printf(
76
-                esc_html__('%1$sREST API: Introduction%2$s', 'event_espresso'),
77
-                '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-introduction.md" target="_blank" rel="noopener noreferrer">',
78
-                '</a>'
79
-            ); ?></li>
76
+				esc_html__('%1$sREST API: Introduction%2$s', 'event_espresso'),
77
+				'<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-introduction.md" target="_blank" rel="noopener noreferrer">',
78
+				'</a>'
79
+			); ?></li>
80 80
         <li>
81 81
             <?php printf(
82
-                esc_html__('%1$sREST API: Reading Data%2$s', 'event_espresso'),
83
-                '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-reading-data.md" target="_blank" rel="noopener noreferrer">',
84
-                '</a>'
85
-            ); ?></li>
82
+				esc_html__('%1$sREST API: Reading Data%2$s', 'event_espresso'),
83
+				'<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-reading-data.md" target="_blank" rel="noopener noreferrer">',
84
+				'</a>'
85
+			); ?></li>
86 86
         <li>
87 87
             <?php printf(
88
-                esc_html__('%1$sBuilding an EE4 Add-on Using the REST API%2$s', 'event_espresso'),
89
-                '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/T--Tutorials/building-an-ee4-addon-that-uses-angular-js-and-the-ee4-json-rest-api.md" target="_blank" rel="noopener noreferrer">',
90
-                '</a>'
91
-            ); ?></li>
88
+				esc_html__('%1$sBuilding an EE4 Add-on Using the REST API%2$s', 'event_espresso'),
89
+				'<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/T--Tutorials/building-an-ee4-addon-that-uses-angular-js-and-the-ee4-json-rest-api.md" target="_blank" rel="noopener noreferrer">',
90
+				'</a>'
91
+			); ?></li>
92 92
     </ul>
93 93
 </div>
94 94
\ No newline at end of file
Please login to merge, or discard this patch.
core/services/request/files/FileSubmission.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function getType()
95 95
     {
96
-        if (!$this->type) {
96
+        if ( ! $this->type) {
97 97
             $this->type = $this->determineType();
98 98
         }
99 99
         return $this->type;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     protected function determineType()
107 107
     {
108
-        if (!$this->getTmpFile()) {
108
+        if ( ! $this->getTmpFile()) {
109 109
             return '';
110 110
         }
111 111
         $finfo = new finfo(FILEINFO_MIME_TYPE);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function getExtension()
121 121
     {
122
-        if (!$this->extension) {
122
+        if ( ! $this->extension) {
123 123
             $this->extension = $this->determineExtension();
124 124
         }
125 125
         return $this->extension;
Please login to merge, or discard this patch.
Indentation   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -19,164 +19,164 @@
 block discarded – undo
19 19
  */
20 20
 class FileSubmission implements FileSubmissionInterface
21 21
 {
22
-    /**
23
-     * @var string original name on the client machine
24
-     */
25
-    protected $name;
26
-
27
-    /**
28
-     * @var string mime type
29
-     */
30
-    protected $type;
31
-
32
-    /**
33
-     * @var string file extension
34
-     */
35
-    protected $extension;
36
-
37
-    /**
38
-     * @var int in bytes
39
-     */
40
-    protected $size;
41
-
42
-    /**
43
-     * @var string local filepath to the temporary file
44
-     */
45
-    protected $tmp_file;
46
-
47
-    /**
48
-     * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values
49
-     * although those aren't expected.
50
-     */
51
-    protected $error_code;
52
-
53
-    /**
54
-     * FileSubmission constructor.
55
-     * @param $name
56
-     * @param $tmp_file
57
-     * @param $size
58
-     * @param null $error_code
59
-     * @throws InvalidArgumentException
60
-     */
61
-    public function __construct($name, $tmp_file, $size, $error_code = null)
62
-    {
63
-        $this->name = basename($name);
64
-        $scheme = parse_url($tmp_file, PHP_URL_SCHEME);
65
-        if (in_array($scheme, ['http', 'https'])) {
66
-            // Wait a minute- just local filepaths please, no URL schemes allowed!
67
-            throw new InvalidArgumentException(
68
-                sprintf(
69
-                    // @codingStandardsIgnoreStart
70
-                    esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'),
71
-                    // @codingStandardsIgnoreEnd
72
-                    $scheme,
73
-                    $tmp_file
74
-                )
75
-            );
76
-        }
77
-        $this->tmp_file = (string) $tmp_file;
78
-        $this->size = (int) $size;
79
-        $this->error_code = (int) $error_code;
80
-    }
81
-
82
-    /**
83
-     * @return string
84
-     */
85
-    public function getName()
86
-    {
87
-        return $this->name;
88
-    }
89
-
90
-    /**
91
-     * Gets the file's mime type
92
-     * @return string
93
-     */
94
-    public function getType()
95
-    {
96
-        if (!$this->type) {
97
-            $this->type = $this->determineType();
98
-        }
99
-        return $this->type;
100
-    }
101
-
102
-    /**
103
-     * @since 4.9.80.p
104
-     * @return string
105
-     */
106
-    protected function determineType()
107
-    {
108
-        if (!$this->getTmpFile()) {
109
-            return '';
110
-        }
111
-        $finfo = new finfo(FILEINFO_MIME_TYPE);
112
-        return $finfo->file($this->getTmpFile());
113
-    }
114
-
115
-    /**
116
-     * Gets the file's extension.
117
-     * @since 4.9.80.p
118
-     * @return string
119
-     */
120
-    public function getExtension()
121
-    {
122
-        if (!$this->extension) {
123
-            $this->extension = $this->determineExtension();
124
-        }
125
-        return $this->extension;
126
-    }
127
-
128
-    /**
129
-     * Determine's the file's extension given the temporary file.
130
-     * @since 4.9.80.p
131
-     * @return string
132
-     */
133
-    protected function determineExtension()
134
-    {
135
-        $position_of_period = strrpos($this->getName(), '.');
136
-        if ($position_of_period === false) {
137
-            return '';
138
-        }
139
-        return mb_substr(
140
-            $this->getName(),
141
-            $position_of_period + 1
142
-        );
143
-    }
144
-
145
-    /**
146
-     * Gets the size of the file
147
-     * @return int
148
-     */
149
-    public function getSize()
150
-    {
151
-        return $this->size;
152
-    }
153
-
154
-    /**
155
-     * Gets the path to the temporary file which was uploaded.
156
-     * @return string
157
-     */
158
-    public function getTmpFile()
159
-    {
160
-        return $this->tmp_file;
161
-    }
162
-
163
-    /**
164
-     * @since 4.9.80.p
165
-     * @return string
166
-     */
167
-    public function __toString()
168
-    {
169
-        return $this->getName();
170
-    }
171
-
172
-    /**
173
-     * Gets the error code PHP reported for the file upload.
174
-     * @return string
175
-     */
176
-    public function getErrorCode()
177
-    {
178
-        return $this->error_code;
179
-    }
22
+	/**
23
+	 * @var string original name on the client machine
24
+	 */
25
+	protected $name;
26
+
27
+	/**
28
+	 * @var string mime type
29
+	 */
30
+	protected $type;
31
+
32
+	/**
33
+	 * @var string file extension
34
+	 */
35
+	protected $extension;
36
+
37
+	/**
38
+	 * @var int in bytes
39
+	 */
40
+	protected $size;
41
+
42
+	/**
43
+	 * @var string local filepath to the temporary file
44
+	 */
45
+	protected $tmp_file;
46
+
47
+	/**
48
+	 * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values
49
+	 * although those aren't expected.
50
+	 */
51
+	protected $error_code;
52
+
53
+	/**
54
+	 * FileSubmission constructor.
55
+	 * @param $name
56
+	 * @param $tmp_file
57
+	 * @param $size
58
+	 * @param null $error_code
59
+	 * @throws InvalidArgumentException
60
+	 */
61
+	public function __construct($name, $tmp_file, $size, $error_code = null)
62
+	{
63
+		$this->name = basename($name);
64
+		$scheme = parse_url($tmp_file, PHP_URL_SCHEME);
65
+		if (in_array($scheme, ['http', 'https'])) {
66
+			// Wait a minute- just local filepaths please, no URL schemes allowed!
67
+			throw new InvalidArgumentException(
68
+				sprintf(
69
+					// @codingStandardsIgnoreStart
70
+					esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'),
71
+					// @codingStandardsIgnoreEnd
72
+					$scheme,
73
+					$tmp_file
74
+				)
75
+			);
76
+		}
77
+		$this->tmp_file = (string) $tmp_file;
78
+		$this->size = (int) $size;
79
+		$this->error_code = (int) $error_code;
80
+	}
81
+
82
+	/**
83
+	 * @return string
84
+	 */
85
+	public function getName()
86
+	{
87
+		return $this->name;
88
+	}
89
+
90
+	/**
91
+	 * Gets the file's mime type
92
+	 * @return string
93
+	 */
94
+	public function getType()
95
+	{
96
+		if (!$this->type) {
97
+			$this->type = $this->determineType();
98
+		}
99
+		return $this->type;
100
+	}
101
+
102
+	/**
103
+	 * @since 4.9.80.p
104
+	 * @return string
105
+	 */
106
+	protected function determineType()
107
+	{
108
+		if (!$this->getTmpFile()) {
109
+			return '';
110
+		}
111
+		$finfo = new finfo(FILEINFO_MIME_TYPE);
112
+		return $finfo->file($this->getTmpFile());
113
+	}
114
+
115
+	/**
116
+	 * Gets the file's extension.
117
+	 * @since 4.9.80.p
118
+	 * @return string
119
+	 */
120
+	public function getExtension()
121
+	{
122
+		if (!$this->extension) {
123
+			$this->extension = $this->determineExtension();
124
+		}
125
+		return $this->extension;
126
+	}
127
+
128
+	/**
129
+	 * Determine's the file's extension given the temporary file.
130
+	 * @since 4.9.80.p
131
+	 * @return string
132
+	 */
133
+	protected function determineExtension()
134
+	{
135
+		$position_of_period = strrpos($this->getName(), '.');
136
+		if ($position_of_period === false) {
137
+			return '';
138
+		}
139
+		return mb_substr(
140
+			$this->getName(),
141
+			$position_of_period + 1
142
+		);
143
+	}
144
+
145
+	/**
146
+	 * Gets the size of the file
147
+	 * @return int
148
+	 */
149
+	public function getSize()
150
+	{
151
+		return $this->size;
152
+	}
153
+
154
+	/**
155
+	 * Gets the path to the temporary file which was uploaded.
156
+	 * @return string
157
+	 */
158
+	public function getTmpFile()
159
+	{
160
+		return $this->tmp_file;
161
+	}
162
+
163
+	/**
164
+	 * @since 4.9.80.p
165
+	 * @return string
166
+	 */
167
+	public function __toString()
168
+	{
169
+		return $this->getName();
170
+	}
171
+
172
+	/**
173
+	 * Gets the error code PHP reported for the file upload.
174
+	 * @return string
175
+	 */
176
+	public function getErrorCode()
177
+	{
178
+		return $this->error_code;
179
+	}
180 180
 }
181 181
 // End of file FileSubmission.php
182 182
 // Location: EventEspresso\core\services\request\files/FileSubmission.php
Please login to merge, or discard this patch.
strategies/display/EE_File_Input_Display_Strategy.strategy.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@
 block discarded – undo
10 10
  */
11 11
 class EE_File_Input_Display_Strategy extends EE_Text_Input_Display_Strategy
12 12
 {
13
-    /**
14
-     * Override's parent to just set the type. May someday support other arguments.
15
-     */
16
-    public function __construct()
17
-    {
18
-        parent::__construct('file');
19
-    }
13
+	/**
14
+	 * Override's parent to just set the type. May someday support other arguments.
15
+	 */
16
+	public function __construct()
17
+	{
18
+		parent::__construct('file');
19
+	}
20 20
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_File_Input.input.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
                     esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'),
56 56
                     implode(', ', $this->allowed_file_extensions)
57 57
                 ),
58
-                '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~'
58
+                '~.*\.('.implode('|', $this->allowed_file_extensions).')$~'
59 59
             )
60 60
         );
61 61
         parent::__construct($options);
Please login to merge, or discard this patch.
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -19,86 +19,86 @@
 block discarded – undo
19 19
  */
20 20
 class EE_File_Input extends EE_Form_Input_Base
21 21
 {
22
-    /**
23
-     * @var array
24
-     */
25
-    protected $allowed_file_extensions;
22
+	/**
23
+	 * @var array
24
+	 */
25
+	protected $allowed_file_extensions;
26 26
 
27
-    /**
28
-     * @var array
29
-     */
30
-    protected $allowed_mime_types;
27
+	/**
28
+	 * @var array
29
+	 */
30
+	protected $allowed_mime_types;
31 31
 
32
-    /**
33
-     * @param array $options
34
-     * @throws InvalidArgumentException
35
-     */
36
-    public function __construct($options = array())
37
-    {
38
-        if (isset($options['allowed_file_extensions'])) {
39
-            $this->allowed_file_extensions = (array) $options['allowed_file_extensions'];
40
-        } else {
41
-            $this->allowed_file_extensions = ['csv'];
42
-        }
43
-        if (isset($options['allowed_mime_types'])) {
44
-            $this->allowed_mime_types = (array) $options['allowed_file_extensions'];
45
-        } else {
46
-            $this->allowed_mime_types = ['text/csv'];
47
-        }
32
+	/**
33
+	 * @param array $options
34
+	 * @throws InvalidArgumentException
35
+	 */
36
+	public function __construct($options = array())
37
+	{
38
+		if (isset($options['allowed_file_extensions'])) {
39
+			$this->allowed_file_extensions = (array) $options['allowed_file_extensions'];
40
+		} else {
41
+			$this->allowed_file_extensions = ['csv'];
42
+		}
43
+		if (isset($options['allowed_mime_types'])) {
44
+			$this->allowed_mime_types = (array) $options['allowed_file_extensions'];
45
+		} else {
46
+			$this->allowed_mime_types = ['text/csv'];
47
+		}
48 48
 
49
-        $this->_set_display_strategy(new EE_File_Input_Display_Strategy());
50
-        $this->_set_normalization_strategy(new EE_File_Normalization());
51
-        $this->add_validation_strategy(
52
-            new EE_Text_Validation_Strategy(
53
-                sprintf(
54
-                    // translators: %1$s is a list of allowed file extensions.
55
-                    esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'),
56
-                    implode(', ', $this->allowed_file_extensions)
57
-                ),
58
-                '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~'
59
-            )
60
-        );
61
-        parent::__construct($options);
49
+		$this->_set_display_strategy(new EE_File_Input_Display_Strategy());
50
+		$this->_set_normalization_strategy(new EE_File_Normalization());
51
+		$this->add_validation_strategy(
52
+			new EE_Text_Validation_Strategy(
53
+				sprintf(
54
+					// translators: %1$s is a list of allowed file extensions.
55
+					esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'),
56
+					implode(', ', $this->allowed_file_extensions)
57
+				),
58
+				'~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~'
59
+			)
60
+		);
61
+		parent::__construct($options);
62 62
 
63 63
 //        It would be great to add this HTML attribute, but jQuery validate chokes on it.
64
-        $this->set_other_html_attributes(
65
-            $this->other_html_attributes()
66
-            . ' extension="'
67
-            . implode(
68
-                ',',
69
-                $this->allowed_file_extensions
70
-            )
71
-            . '"'
72
-        );
73
-    }
64
+		$this->set_other_html_attributes(
65
+			$this->other_html_attributes()
66
+			. ' extension="'
67
+			. implode(
68
+				',',
69
+				$this->allowed_file_extensions
70
+			)
71
+			. '"'
72
+		);
73
+	}
74 74
 
75
-    /**
76
-     * $_FILES has a really weird structure. So we let `FilesDataHandler` take care of finding the file info for
77
-     * this input.
78
-     * @since 4.9.80.p
79
-     * @param array $req_data
80
-     * @return FileSubmissionInterface
81
-     * @throws InvalidArgumentException
82
-     * @throws InvalidDataTypeException
83
-     * @throws InvalidInterfaceException
84
-     */
85
-    public function find_form_data_for_this_section($req_data)
86
-    {
87
-        // ignore $req_data. Files are in the files data handler.
88
-        $fileDataHandler = LoaderFactory::getLoader()->getShared(
89
-            'EventEspresso\core\services\request\files\FilesDataHandler'
90
-        );
91
-        return $fileDataHandler->getFileObject($this->html_name());
92
-    }
75
+	/**
76
+	 * $_FILES has a really weird structure. So we let `FilesDataHandler` take care of finding the file info for
77
+	 * this input.
78
+	 * @since 4.9.80.p
79
+	 * @param array $req_data
80
+	 * @return FileSubmissionInterface
81
+	 * @throws InvalidArgumentException
82
+	 * @throws InvalidDataTypeException
83
+	 * @throws InvalidInterfaceException
84
+	 */
85
+	public function find_form_data_for_this_section($req_data)
86
+	{
87
+		// ignore $req_data. Files are in the files data handler.
88
+		$fileDataHandler = LoaderFactory::getLoader()->getShared(
89
+			'EventEspresso\core\services\request\files\FilesDataHandler'
90
+		);
91
+		return $fileDataHandler->getFileObject($this->html_name());
92
+	}
93 93
 
94
-    /**
95
-     * Don't transform the file submission object into a string, thanks.
96
-     *
97
-     * @param string $value
98
-     * @return null|string
99
-     */
100
-    protected function _sanitize($value)
101
-    {
102
-        return $value;
103
-    }
94
+	/**
95
+	 * Don't transform the file submission object into a string, thanks.
96
+	 *
97
+	 * @param string $value
98
+	 * @return null|string
99
+	 */
100
+	protected function _sanitize($value)
101
+	{
102
+		return $value;
103
+	}
104 104
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Script_Stage_Table.core.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
     {
71 71
         global $wpdb;
72 72
         $start_at_record = $this->count_records_migrated();
73
-        $query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
73
+        $query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} ".$wpdb->prepare(
74 74
             "LIMIT %d, %d",
75 75
             $start_at_record,
76 76
             $limit
Please login to merge, or discard this patch.
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -15,89 +15,89 @@
 block discarded – undo
15 15
  */
16 16
 abstract class EE_Data_Migration_Script_Stage_Table extends EE_Data_Migration_Script_Stage
17 17
 {
18
-    protected $_old_table;
18
+	protected $_old_table;
19 19
 
20
-    /**
21
-     * @var string The columns to select. May be overridden for children.
22
-     */
23
-    protected $select_expression = '*';
20
+	/**
21
+	 * @var string The columns to select. May be overridden for children.
22
+	 */
23
+	protected $select_expression = '*';
24 24
 
25
-    /**
26
-     * Set in the constructor to add this sql to both the counting query in
27
-     * EE_Data_Migration_Script_Stage_Table::_count_records_to_migrate() and
28
-     * EE_Data_Migration_Script_Stage_Table::_get_rows().
29
-     * Eg "where column_name like '%some_value%'"
30
-     *
31
-     * @var string
32
-     */
33
-    protected $_extra_where_sql;
25
+	/**
26
+	 * Set in the constructor to add this sql to both the counting query in
27
+	 * EE_Data_Migration_Script_Stage_Table::_count_records_to_migrate() and
28
+	 * EE_Data_Migration_Script_Stage_Table::_get_rows().
29
+	 * Eg "where column_name like '%some_value%'"
30
+	 *
31
+	 * @var string
32
+	 */
33
+	protected $_extra_where_sql;
34 34
 
35 35
 
36
-    /**
37
-     * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property
38
-     * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that
39
-     * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the
40
-     * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees
41
-     * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at
42
-     * very least we MUST report/return 50 items migrated)
43
-     *
44
-     * @param int $num_items
45
-     * @return int number of items ACTUALLY migrated
46
-     */
47
-    public function _migration_step($num_items = 50)
48
-    {
49
-        $rows = $this->_get_rows($num_items);
50
-        $items_actually_migrated = 0;
51
-        foreach ($rows as $old_row) {
52
-            $this->_migrate_old_row($old_row);
53
-            $items_actually_migrated++;
54
-        }
55
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
56
-            $this->set_completed();
57
-        }
58
-        return $items_actually_migrated;
59
-    }
36
+	/**
37
+	 * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property
38
+	 * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that
39
+	 * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the
40
+	 * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees
41
+	 * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at
42
+	 * very least we MUST report/return 50 items migrated)
43
+	 *
44
+	 * @param int $num_items
45
+	 * @return int number of items ACTUALLY migrated
46
+	 */
47
+	public function _migration_step($num_items = 50)
48
+	{
49
+		$rows = $this->_get_rows($num_items);
50
+		$items_actually_migrated = 0;
51
+		foreach ($rows as $old_row) {
52
+			$this->_migrate_old_row($old_row);
53
+			$items_actually_migrated++;
54
+		}
55
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
56
+			$this->set_completed();
57
+		}
58
+		return $items_actually_migrated;
59
+	}
60 60
 
61
-    /**
62
-     * Gets the rows for each migration stage from the old table
63
-     *
64
-     * @global wpdb $wpdb
65
-     * @param int   $limit
66
-     * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
67
-     */
68
-    protected function _get_rows($limit)
69
-    {
70
-        global $wpdb;
71
-        $start_at_record = $this->count_records_migrated();
72
-        $query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
73
-            "LIMIT %d, %d",
74
-            $start_at_record,
75
-            $limit
76
-        );
77
-        return $wpdb->get_results($query, ARRAY_A);
78
-    }
61
+	/**
62
+	 * Gets the rows for each migration stage from the old table
63
+	 *
64
+	 * @global wpdb $wpdb
65
+	 * @param int   $limit
66
+	 * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
67
+	 */
68
+	protected function _get_rows($limit)
69
+	{
70
+		global $wpdb;
71
+		$start_at_record = $this->count_records_migrated();
72
+		$query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
73
+			"LIMIT %d, %d",
74
+			$start_at_record,
75
+			$limit
76
+		);
77
+		return $wpdb->get_results($query, ARRAY_A);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * Counts the records to migrate; the public version may cache it
83
-     *
84
-     * @return int
85
-     */
86
-    public function _count_records_to_migrate()
87
-    {
88
-        global $wpdb;
89
-        $query = "SELECT COUNT(*) FROM {$this->_old_table} {$this->_extra_where_sql}";
90
-        $count = $wpdb->get_var($query);
91
-        return $count;
92
-    }
81
+	/**
82
+	 * Counts the records to migrate; the public version may cache it
83
+	 *
84
+	 * @return int
85
+	 */
86
+	public function _count_records_to_migrate()
87
+	{
88
+		global $wpdb;
89
+		$query = "SELECT COUNT(*) FROM {$this->_old_table} {$this->_extra_where_sql}";
90
+		$count = $wpdb->get_var($query);
91
+		return $count;
92
+	}
93 93
 
94
-    /**
95
-     * takes care of migrating this particular row from the OLD table to whatever its
96
-     * representation is in the new database. If there are errors, use $this->add_error to log them. If there is a
97
-     * fatal error which prevents all future migrations, throw an exception describing it
98
-     *
99
-     * @param array $old_row an associative array where keys are column names and values are their values.
100
-     * @return null
101
-     */
102
-    abstract protected function _migrate_old_row($old_row);
94
+	/**
95
+	 * takes care of migrating this particular row from the OLD table to whatever its
96
+	 * representation is in the new database. If there are errors, use $this->add_error to log them. If there is a
97
+	 * fatal error which prevents all future migrations, throw an exception describing it
98
+	 *
99
+	 * @param array $old_row an associative array where keys are column names and values are their values.
100
+	 * @return null
101
+	 */
102
+	abstract protected function _migrate_old_row($old_row);
103 103
 }
Please login to merge, or discard this patch.
form_sections/strategies/layout/EE_Form_Section_Layout_Base.strategy.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
         $html = '';
68 68
         // layout_form_begin
69 69
         $html .= apply_filters(
70
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
70
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_'.$this->_form_section->name(),
71 71
             $this->layout_form_begin(),
72 72
             $this->_form_section
73 73
         );
74 74
         // layout_form_loop
75 75
         $html .= apply_filters(
76
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
76
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_'.$this->_form_section->name(),
77 77
             $this->layout_form_loop(),
78 78
             $this->_form_section
79 79
         );
80 80
         // layout_form_end
81 81
         $html .= apply_filters(
82
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
82
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_'.$this->_form_section->name(),
83 83
             $this->layout_form_end(),
84 84
             $this->_form_section
85 85
         );
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             if ($subsection instanceof EE_Form_Input_Base) {
101 101
                 $html .= apply_filters(
102 102
                     'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
103
-                    . $name . '__in_' . $this->_form_section->name(),
103
+                    . $name.'__in_'.$this->_form_section->name(),
104 104
                     $this->layout_input($subsection),
105 105
                     $this->_form_section,
106 106
                     $subsection
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             } elseif ($subsection instanceof EE_Form_Section_Base) {
109 109
                 $html .= apply_filters(
110 110
                     'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
111
-                    . $name . '__in_' . $this->_form_section->name(),
111
+                    . $name.'__in_'.$this->_form_section->name(),
112 112
                     $this->layout_subsection($subsection),
113 113
                     $this->_form_section,
114 114
                     $subsection
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
             return '';
178 178
         }
179 179
         $class = $input->required()
180
-            ? 'ee-required-label ' . $input->html_label_class()
180
+            ? 'ee-required-label '.$input->html_label_class()
181 181
             : $input->html_label_class();
182 182
         $label_text = $input->required()
183
-            ? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
183
+            ? $input->html_label_text().'<span class="ee-asterisk">*</span>'
184 184
             : $input->html_label_text();
185 185
         return '<label id="'
186 186
                . $input->html_label_id()
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                . $class
189 189
                . '" style="'
190 190
                . $input->html_label_style()
191
-               . '" for="' . $input->html_id()
191
+               . '" for="'.$input->html_id()
192 192
                . '">'
193 193
                . $label_text
194 194
                . '</label>';
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
             // get all the errors on THIS form section (errors which aren't
211 211
             // for specific inputs, but instead for the entire form section)
212 212
             foreach ($this->_form_section->get_validation_errors() as $error) {
213
-                $html .= $error->getMessage() . '<br>';
213
+                $html .= $error->getMessage().'<br>';
214 214
             }
215 215
             $html .= '</div>';
216 216
         }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function display_help_text($input)
256 256
     {
257
-        $help_text  = $input->html_help_text();
257
+        $help_text = $input->html_help_text();
258 258
         if ($help_text !== '' && $help_text !== null) {
259 259
             $tag = is_admin() ? 'p' : 'span';
260 260
             return '<'
@@ -286,14 +286,14 @@  discard block
 block discarded – undo
286 286
     {
287 287
         // replace dashes and spaces with underscores
288 288
         $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
289
-        do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
289
+        do_action('AHEE__Form_Section_Layout__'.$hook_name, $this->_form_section);
290 290
         $html = (string) apply_filters(
291
-            'AFEE__Form_Section_Layout__' . $hook_name . '__html',
291
+            'AFEE__Form_Section_Layout__'.$hook_name.'__html',
292 292
             $html,
293 293
             $this->_form_section
294 294
         );
295
-        $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
296
-        $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
295
+        $html .= EEH_HTML::nl().'<!-- AHEE__Form_Section_Layout__'.$hook_name.'__html -->';
296
+        $html .= EEH_HTML::nl().'<!-- AFEE__Form_Section_Layout__'.$hook_name.' -->';
297 297
         return $html;
298 298
     }
299 299
 }
Please login to merge, or discard this patch.
Indentation   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -11,287 +11,287 @@
 block discarded – undo
11 11
  */
12 12
 abstract class EE_Form_Section_Layout_Base
13 13
 {
14
-    /**
15
-     * Form section to lay out
16
-     *
17
-     * @var EE_Form_Section_Proper
18
-     */
19
-    protected $_form_section;
20
-
21
-
22
-
23
-    /**
24
-     *  __construct
25
-     */
26
-    public function __construct()
27
-    {
28
-    }
29
-
30
-
31
-
32
-    /**
33
-     * The form section on which this strategy is to perform
34
-     *
35
-     * @param EE_Form_Section_Proper $form
36
-     */
37
-    public function _construct_finalize(EE_Form_Section_Proper $form)
38
-    {
39
-        $this->_form_section = $form;
40
-    }
41
-
42
-
43
-
44
-    /**
45
-     * @return EE_Form_Section_Proper
46
-     */
47
-    public function form_section()
48
-    {
49
-        return $this->_form_section;
50
-    }
51
-
52
-
53
-
54
-    /**
55
-     * Also has teh side effect of enqueuing any needed JS and CSS for
56
-     * this form.
57
-     * Creates all the HTML necessary for displaying this form, its inputs, and
58
-     * proper subsections.
59
-     * Returns the HTML
60
-     *
61
-     * @return string HTML for displaying
62
-     * @throws EE_Error
63
-     */
64
-    public function layout_form()
65
-    {
66
-        $html = '';
67
-        // layout_form_begin
68
-        $html .= apply_filters(
69
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
70
-            $this->layout_form_begin(),
71
-            $this->_form_section
72
-        );
73
-        // layout_form_loop
74
-        $html .= apply_filters(
75
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
76
-            $this->layout_form_loop(),
77
-            $this->_form_section
78
-        );
79
-        // layout_form_end
80
-        $html .= apply_filters(
81
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
82
-            $this->layout_form_end(),
83
-            $this->_form_section
84
-        );
85
-        return $this->add_form_section_hooks_and_filters($html);
86
-    }
87
-
88
-
89
-
90
-    /**
91
-     * @return string
92
-     * @throws EE_Error
93
-     */
94
-    public function layout_form_loop()
95
-    {
96
-        $html = '';
97
-        foreach ($this->_form_section->subsections() as $name => $subsection) {
98
-            if ($subsection instanceof EE_Form_Input_Base) {
99
-                $html .= apply_filters(
100
-                    'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
101
-                    . $name . '__in_' . $this->_form_section->name(),
102
-                    $this->layout_input($subsection),
103
-                    $this->_form_section,
104
-                    $subsection
105
-                );
106
-            } elseif ($subsection instanceof EE_Form_Section_Base) {
107
-                $html .= apply_filters(
108
-                    'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
109
-                    . $name . '__in_' . $this->_form_section->name(),
110
-                    $this->layout_subsection($subsection),
111
-                    $this->_form_section,
112
-                    $subsection
113
-                );
114
-            }
115
-        }
116
-        return $html;
117
-    }
118
-
119
-
120
-
121
-    /**
122
-     * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
123
-     *
124
-     * @return string
125
-     */
126
-    abstract public function layout_form_begin();
127
-
128
-
129
-
130
-    /**
131
-     * Should be used to end the form section (eg a /table tag, or a /div tag, etc.)
132
-     *
133
-     * @return string
134
-     */
135
-    abstract public function layout_form_end();
136
-
137
-
138
-
139
-    /**
140
-     * Should be used internally by layout_form() to lay out each input (eg, if this layout
141
-     * is putting each input in a row of its own, this should probably be called by a
142
-     *  foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop.
143
-     * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely
144
-     * customize the form's layout, but would like to make use of it for laying out
145
-     * 'easy-to-layout' inputs
146
-     *
147
-     * @param EE_Form_Input_Base $input
148
-     * @return string html
149
-     */
150
-    abstract public function layout_input($input);
151
-
152
-
153
-
154
-    /**
155
-     * Similar to layout_input(), should be used internally by layout_form() within a
156
-     * loop to lay out each proper subsection. Unlike layout_input(), however, it is assumed
157
-     * that the proper subsection will lay out its container, label, etc on its own.
158
-     *
159
-     * @param EE_Form_Section_Base $subsection
160
-     * @return string html
161
-     */
162
-    abstract public function layout_subsection($subsection);
163
-
164
-
165
-    /**
166
-     * Gets the HTML for the label tag and its contents for the input
167
-     *
168
-     * @param EE_Form_Input_Base $input
169
-     * @return string
170
-     * @throws EE_Error
171
-     */
172
-    public function display_label($input)
173
-    {
174
-        if ($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
175
-            return '';
176
-        }
177
-        $class = $input->required()
178
-            ? 'ee-required-label ' . $input->html_label_class()
179
-            : $input->html_label_class();
180
-        $label_text = $input->required()
181
-            ? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
182
-            : $input->html_label_text();
183
-        return '<label id="'
184
-               . $input->html_label_id()
185
-               . '" class="'
186
-               . $class
187
-               . '" style="'
188
-               . $input->html_label_style()
189
-               . '" for="' . $input->html_id()
190
-               . '">'
191
-               . $label_text
192
-               . '</label>';
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     * Gets the HTML for all the form's form-wide errors (ie, errors which
199
-     * are not for specific inputs. E.g., if two inputs somehow disagree,
200
-     * those errors would probably be on the form section, not one of its inputs)
201
-     * @return string
202
-     */
203
-    public function display_form_wide_errors()
204
-    {
205
-        $html = '';
206
-        if ($this->_form_section->get_validation_errors()) {
207
-            $html .= "<div class='ee-form-wide-errors'>";
208
-            // get all the errors on THIS form section (errors which aren't
209
-            // for specific inputs, but instead for the entire form section)
210
-            foreach ($this->_form_section->get_validation_errors() as $error) {
211
-                $html .= $error->getMessage() . '<br>';
212
-            }
213
-            $html .= '</div>';
214
-        }
215
-        return apply_filters(
216
-            'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors',
217
-            $html,
218
-            $this
219
-        );
220
-    }
221
-
222
-
223
-    /**
224
-     * returns the HTML for the server-side validation errors for the specified input
225
-     * Note that if JS is enabled, it should remove these and instead
226
-     * populate the form's errors in the jquery validate fashion
227
-     * using the localized data provided to the JS
228
-     *
229
-     * @param EE_Form_Input_Base $input
230
-     * @return string
231
-     * @throws EE_Error
232
-     */
233
-    public function display_errors($input)
234
-    {
235
-        if ($input->get_validation_errors()) {
236
-            return "<label  id='"
237
-                   . $input->html_id()
238
-                   . "-error' class='error' for='{$input->html_name()}'>"
239
-                   . $input->get_validation_error_string()
240
-                   . '</label>';
241
-        }
242
-        return '';
243
-    }
244
-
245
-
246
-    /**
247
-     * Displays the help span for the specified input
248
-     *
249
-     * @param EE_Form_Input_Base $input
250
-     * @return string
251
-     * @throws EE_Error
252
-     */
253
-    public function display_help_text($input)
254
-    {
255
-        $help_text  = $input->html_help_text();
256
-        if ($help_text !== '' && $help_text !== null) {
257
-            $tag = is_admin() ? 'p' : 'span';
258
-            return '<'
259
-                   . $tag
260
-                   . ' id="'
261
-                   . $input->html_id()
262
-                   . '-help" class="'
263
-                   . $input->html_help_class()
264
-                   . '" style="'
265
-                   . $input->html_help_style()
266
-                   . '">'
267
-                   . $help_text
268
-                   . '</'
269
-                   . $tag
270
-                   . '>';
271
-        }
272
-        return '';
273
-    }
274
-
275
-
276
-    /**
277
-     * Does an action and hook onto the end of teh form
278
-     *
279
-     * @param string $html
280
-     * @return string
281
-     * @throws EE_Error
282
-     */
283
-    public function add_form_section_hooks_and_filters($html)
284
-    {
285
-        // replace dashes and spaces with underscores
286
-        $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
287
-        do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
288
-        $html = (string) apply_filters(
289
-            'AFEE__Form_Section_Layout__' . $hook_name . '__html',
290
-            $html,
291
-            $this->_form_section
292
-        );
293
-        $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
294
-        $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
295
-        return $html;
296
-    }
14
+	/**
15
+	 * Form section to lay out
16
+	 *
17
+	 * @var EE_Form_Section_Proper
18
+	 */
19
+	protected $_form_section;
20
+
21
+
22
+
23
+	/**
24
+	 *  __construct
25
+	 */
26
+	public function __construct()
27
+	{
28
+	}
29
+
30
+
31
+
32
+	/**
33
+	 * The form section on which this strategy is to perform
34
+	 *
35
+	 * @param EE_Form_Section_Proper $form
36
+	 */
37
+	public function _construct_finalize(EE_Form_Section_Proper $form)
38
+	{
39
+		$this->_form_section = $form;
40
+	}
41
+
42
+
43
+
44
+	/**
45
+	 * @return EE_Form_Section_Proper
46
+	 */
47
+	public function form_section()
48
+	{
49
+		return $this->_form_section;
50
+	}
51
+
52
+
53
+
54
+	/**
55
+	 * Also has teh side effect of enqueuing any needed JS and CSS for
56
+	 * this form.
57
+	 * Creates all the HTML necessary for displaying this form, its inputs, and
58
+	 * proper subsections.
59
+	 * Returns the HTML
60
+	 *
61
+	 * @return string HTML for displaying
62
+	 * @throws EE_Error
63
+	 */
64
+	public function layout_form()
65
+	{
66
+		$html = '';
67
+		// layout_form_begin
68
+		$html .= apply_filters(
69
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
70
+			$this->layout_form_begin(),
71
+			$this->_form_section
72
+		);
73
+		// layout_form_loop
74
+		$html .= apply_filters(
75
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
76
+			$this->layout_form_loop(),
77
+			$this->_form_section
78
+		);
79
+		// layout_form_end
80
+		$html .= apply_filters(
81
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
82
+			$this->layout_form_end(),
83
+			$this->_form_section
84
+		);
85
+		return $this->add_form_section_hooks_and_filters($html);
86
+	}
87
+
88
+
89
+
90
+	/**
91
+	 * @return string
92
+	 * @throws EE_Error
93
+	 */
94
+	public function layout_form_loop()
95
+	{
96
+		$html = '';
97
+		foreach ($this->_form_section->subsections() as $name => $subsection) {
98
+			if ($subsection instanceof EE_Form_Input_Base) {
99
+				$html .= apply_filters(
100
+					'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
101
+					. $name . '__in_' . $this->_form_section->name(),
102
+					$this->layout_input($subsection),
103
+					$this->_form_section,
104
+					$subsection
105
+				);
106
+			} elseif ($subsection instanceof EE_Form_Section_Base) {
107
+				$html .= apply_filters(
108
+					'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
109
+					. $name . '__in_' . $this->_form_section->name(),
110
+					$this->layout_subsection($subsection),
111
+					$this->_form_section,
112
+					$subsection
113
+				);
114
+			}
115
+		}
116
+		return $html;
117
+	}
118
+
119
+
120
+
121
+	/**
122
+	 * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
123
+	 *
124
+	 * @return string
125
+	 */
126
+	abstract public function layout_form_begin();
127
+
128
+
129
+
130
+	/**
131
+	 * Should be used to end the form section (eg a /table tag, or a /div tag, etc.)
132
+	 *
133
+	 * @return string
134
+	 */
135
+	abstract public function layout_form_end();
136
+
137
+
138
+
139
+	/**
140
+	 * Should be used internally by layout_form() to lay out each input (eg, if this layout
141
+	 * is putting each input in a row of its own, this should probably be called by a
142
+	 *  foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop.
143
+	 * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely
144
+	 * customize the form's layout, but would like to make use of it for laying out
145
+	 * 'easy-to-layout' inputs
146
+	 *
147
+	 * @param EE_Form_Input_Base $input
148
+	 * @return string html
149
+	 */
150
+	abstract public function layout_input($input);
151
+
152
+
153
+
154
+	/**
155
+	 * Similar to layout_input(), should be used internally by layout_form() within a
156
+	 * loop to lay out each proper subsection. Unlike layout_input(), however, it is assumed
157
+	 * that the proper subsection will lay out its container, label, etc on its own.
158
+	 *
159
+	 * @param EE_Form_Section_Base $subsection
160
+	 * @return string html
161
+	 */
162
+	abstract public function layout_subsection($subsection);
163
+
164
+
165
+	/**
166
+	 * Gets the HTML for the label tag and its contents for the input
167
+	 *
168
+	 * @param EE_Form_Input_Base $input
169
+	 * @return string
170
+	 * @throws EE_Error
171
+	 */
172
+	public function display_label($input)
173
+	{
174
+		if ($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
175
+			return '';
176
+		}
177
+		$class = $input->required()
178
+			? 'ee-required-label ' . $input->html_label_class()
179
+			: $input->html_label_class();
180
+		$label_text = $input->required()
181
+			? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
182
+			: $input->html_label_text();
183
+		return '<label id="'
184
+			   . $input->html_label_id()
185
+			   . '" class="'
186
+			   . $class
187
+			   . '" style="'
188
+			   . $input->html_label_style()
189
+			   . '" for="' . $input->html_id()
190
+			   . '">'
191
+			   . $label_text
192
+			   . '</label>';
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 * Gets the HTML for all the form's form-wide errors (ie, errors which
199
+	 * are not for specific inputs. E.g., if two inputs somehow disagree,
200
+	 * those errors would probably be on the form section, not one of its inputs)
201
+	 * @return string
202
+	 */
203
+	public function display_form_wide_errors()
204
+	{
205
+		$html = '';
206
+		if ($this->_form_section->get_validation_errors()) {
207
+			$html .= "<div class='ee-form-wide-errors'>";
208
+			// get all the errors on THIS form section (errors which aren't
209
+			// for specific inputs, but instead for the entire form section)
210
+			foreach ($this->_form_section->get_validation_errors() as $error) {
211
+				$html .= $error->getMessage() . '<br>';
212
+			}
213
+			$html .= '</div>';
214
+		}
215
+		return apply_filters(
216
+			'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors',
217
+			$html,
218
+			$this
219
+		);
220
+	}
221
+
222
+
223
+	/**
224
+	 * returns the HTML for the server-side validation errors for the specified input
225
+	 * Note that if JS is enabled, it should remove these and instead
226
+	 * populate the form's errors in the jquery validate fashion
227
+	 * using the localized data provided to the JS
228
+	 *
229
+	 * @param EE_Form_Input_Base $input
230
+	 * @return string
231
+	 * @throws EE_Error
232
+	 */
233
+	public function display_errors($input)
234
+	{
235
+		if ($input->get_validation_errors()) {
236
+			return "<label  id='"
237
+				   . $input->html_id()
238
+				   . "-error' class='error' for='{$input->html_name()}'>"
239
+				   . $input->get_validation_error_string()
240
+				   . '</label>';
241
+		}
242
+		return '';
243
+	}
244
+
245
+
246
+	/**
247
+	 * Displays the help span for the specified input
248
+	 *
249
+	 * @param EE_Form_Input_Base $input
250
+	 * @return string
251
+	 * @throws EE_Error
252
+	 */
253
+	public function display_help_text($input)
254
+	{
255
+		$help_text  = $input->html_help_text();
256
+		if ($help_text !== '' && $help_text !== null) {
257
+			$tag = is_admin() ? 'p' : 'span';
258
+			return '<'
259
+				   . $tag
260
+				   . ' id="'
261
+				   . $input->html_id()
262
+				   . '-help" class="'
263
+				   . $input->html_help_class()
264
+				   . '" style="'
265
+				   . $input->html_help_style()
266
+				   . '">'
267
+				   . $help_text
268
+				   . '</'
269
+				   . $tag
270
+				   . '>';
271
+		}
272
+		return '';
273
+	}
274
+
275
+
276
+	/**
277
+	 * Does an action and hook onto the end of teh form
278
+	 *
279
+	 * @param string $html
280
+	 * @return string
281
+	 * @throws EE_Error
282
+	 */
283
+	public function add_form_section_hooks_and_filters($html)
284
+	{
285
+		// replace dashes and spaces with underscores
286
+		$hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
287
+		do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
288
+		$html = (string) apply_filters(
289
+			'AFEE__Form_Section_Layout__' . $hook_name . '__html',
290
+			$html,
291
+			$this->_form_section
292
+		);
293
+		$html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
294
+		$html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
295
+		return $html;
296
+	}
297 297
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 // unfortunately, this needs to be done upon INCLUSION of this file,
16 16
 // instead of construction, because it only gets constructed on first page load
17 17
 // (all other times it gets resurrected from a wordpress option)
18
-$stages = glob(EE_CORE . 'data_migration_scripts/4_7_0_stages/*');
18
+$stages = glob(EE_CORE.'data_migration_scripts/4_7_0_stages/*');
19 19
 $class_to_filepath = array();
20 20
 foreach ($stages as $filepath) {
21 21
     $matches = array();
22 22
     preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches);
23
-    $class_to_filepath[ $matches[1] ] = $filepath;
23
+    $class_to_filepath[$matches[1]] = $filepath;
24 24
 }
25 25
 // give addons a chance to autoload their stages too
26 26
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath);
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
             )
77 77
         ) {
78 78
             return true;
79
-        } elseif (! $version_string) {
79
+        } elseif ( ! $version_string) {
80 80
             // no version string provided... this must be pre 4.3
81
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
81
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
82 82
         } else {
83 83
             return false;
84 84
         }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     public function schema_changes_before_migration()
93 93
     {
94 94
         // relies on 4.1's EEH_Activation::create_table
95
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
96 96
         $table_name = 'esp_answer';
97 97
         $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
98 98
 					REG_ID int(10) unsigned NOT NULL,
Please login to merge, or discard this patch.
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
 $stages = glob(EE_CORE . 'data_migration_scripts/4_7_0_stages/*');
11 11
 $class_to_filepath = array();
12 12
 foreach ($stages as $filepath) {
13
-    $matches = array();
14
-    preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches);
15
-    $class_to_filepath[ $matches[1] ] = $filepath;
13
+	$matches = array();
14
+	preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches);
15
+	$class_to_filepath[ $matches[1] ] = $filepath;
16 16
 }
17 17
 // give addons a chance to autoload their stages too
18 18
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath);
@@ -34,72 +34,72 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base
36 36
 {
37
-    /**
38
-     * return EE_DMS_Core_4_7_0
39
-     *
40
-     * @param TableManager  $table_manager
41
-     * @param TableAnalysis $table_analysis
42
-     */
43
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
44
-    {
45
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.7.0", "event_espresso");
46
-        $this->_priority = 10;
47
-        $this->_migration_stages = array(
48
-            new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(),
49
-            new EE_DMS_4_7_0_Registration_Payments(),
50
-        );
51
-        parent::__construct($table_manager, $table_analysis);
52
-    }
37
+	/**
38
+	 * return EE_DMS_Core_4_7_0
39
+	 *
40
+	 * @param TableManager  $table_manager
41
+	 * @param TableAnalysis $table_analysis
42
+	 */
43
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
44
+	{
45
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.7.0", "event_espresso");
46
+		$this->_priority = 10;
47
+		$this->_migration_stages = array(
48
+			new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(),
49
+			new EE_DMS_4_7_0_Registration_Payments(),
50
+		);
51
+		parent::__construct($table_manager, $table_analysis);
52
+	}
53 53
 
54 54
 
55 55
 
56
-    /**
57
-     * @param array $version_array
58
-     * @return bool
59
-     */
60
-    public function can_migrate_from_version($version_array)
61
-    {
62
-        $version_string = $version_array['Core'];
63
-        if (
64
-            (
65
-                version_compare($version_string, '4.7.0.decaf', '<')
66
-                && version_compare($version_string, '4.6.0.decaf', '>=')
67
-            )
68
-            || (
69
-                version_compare($version_string, '4.7.0.decaf', '>=')
70
-                && ! $this->_get_table_analysis()->tableExists('esp_registration_payment')
71
-                && $this->_get_table_analysis()->tableExists('esp_registration')
72
-            )
73
-        ) {
74
-            return true;
75
-        } elseif (! $version_string) {
76
-            // no version string provided... this must be pre 4.3
77
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
78
-        } else {
79
-            return false;
80
-        }
81
-    }
56
+	/**
57
+	 * @param array $version_array
58
+	 * @return bool
59
+	 */
60
+	public function can_migrate_from_version($version_array)
61
+	{
62
+		$version_string = $version_array['Core'];
63
+		if (
64
+			(
65
+				version_compare($version_string, '4.7.0.decaf', '<')
66
+				&& version_compare($version_string, '4.6.0.decaf', '>=')
67
+			)
68
+			|| (
69
+				version_compare($version_string, '4.7.0.decaf', '>=')
70
+				&& ! $this->_get_table_analysis()->tableExists('esp_registration_payment')
71
+				&& $this->_get_table_analysis()->tableExists('esp_registration')
72
+			)
73
+		) {
74
+			return true;
75
+		} elseif (! $version_string) {
76
+			// no version string provided... this must be pre 4.3
77
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
78
+		} else {
79
+			return false;
80
+		}
81
+	}
82 82
 
83 83
 
84 84
 
85
-    /**
86
-     * @return bool
87
-     */
88
-    public function schema_changes_before_migration()
89
-    {
90
-        // relies on 4.1's EEH_Activation::create_table
91
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
-        $table_name = 'esp_answer';
93
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
85
+	/**
86
+	 * @return bool
87
+	 */
88
+	public function schema_changes_before_migration()
89
+	{
90
+		// relies on 4.1's EEH_Activation::create_table
91
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
+		$table_name = 'esp_answer';
93
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
94 94
 					REG_ID int(10) unsigned NOT NULL,
95 95
 					QST_ID int(10) unsigned NOT NULL,
96 96
 					ANS_value text NOT NULL,
97 97
 					PRIMARY KEY  (ANS_ID),
98 98
 					KEY REG_ID (REG_ID),
99 99
 					KEY QST_ID (QST_ID)";
100
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
101
-        $table_name = 'esp_attendee_meta';
102
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
100
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
101
+		$table_name = 'esp_attendee_meta';
102
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
103 103
 						ATT_ID bigint(20) unsigned NOT NULL,
104 104
 						ATT_fname varchar(45) NOT NULL,
105 105
 						ATT_lname varchar(45) NOT	NULL,
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 								KEY ATT_email (ATT_email(191)),
117 117
 								KEY ATT_lname (ATT_lname),
118 118
 								KEY ATT_fname (ATT_fname)";
119
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
120
-        $table_name = 'esp_country';
121
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
119
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
120
+		$table_name = 'esp_country';
121
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
122 122
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
123 123
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
124 124
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
 					  CNT_is_EU tinyint(1) DEFAULT '0',
135 135
 					  CNT_active tinyint(1) DEFAULT '0',
136 136
 					  PRIMARY KEY  (CNT_ISO)";
137
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
138
-        $table_name = 'esp_currency';
139
-        $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
137
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
138
+		$table_name = 'esp_currency';
139
+		$sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
140 140
 				CUR_single varchar(45) COLLATE utf8_bin DEFAULT 'dollar',
141 141
 				CUR_plural varchar(45) COLLATE utf8_bin DEFAULT 'dollars',
142 142
 				CUR_sign varchar(45) COLLATE utf8_bin DEFAULT '$',
143 143
 				CUR_dec_plc varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
144 144
 				CUR_active tinyint(1) DEFAULT '0',
145 145
 				PRIMARY KEY  (CUR_code)";
146
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
147
-        $table_name = 'esp_datetime';
148
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
146
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
147
+		$table_name = 'esp_datetime';
148
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
149 149
 				  EVT_ID bigint(20) unsigned NOT NULL,
150 150
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
151 151
 				  DTT_description text NOT NULL,
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 						KEY DTT_EVT_start (DTT_EVT_start),
162 162
 						KEY EVT_ID (EVT_ID),
163 163
 						KEY DTT_is_primary (DTT_is_primary)";
164
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
165
-        $table_name = 'esp_event_meta';
166
-        $sql = "
164
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
165
+		$table_name = 'esp_event_meta';
166
+		$sql = "
167 167
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
168 168
 			EVT_ID bigint(20) unsigned NOT NULL,
169 169
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -179,34 +179,34 @@  discard block
 block discarded – undo
179 179
 			EVT_donations tinyint(1) NULL,
180 180
 			PRIMARY KEY  (EVTM_ID),
181 181
 			KEY EVT_ID (EVT_ID)";
182
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
183
-        $table_name = 'esp_event_question_group';
184
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
182
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
183
+		$table_name = 'esp_event_question_group';
184
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
185 185
 					EVT_ID bigint(20) unsigned NOT NULL,
186 186
 					QSG_ID int(10) unsigned NOT NULL,
187 187
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
188 188
 					PRIMARY KEY  (EQG_ID),
189 189
 					KEY EVT_ID (EVT_ID),
190 190
 					KEY QSG_ID (QSG_ID)";
191
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
192
-        $table_name = 'esp_event_venue';
193
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
191
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
192
+		$table_name = 'esp_event_venue';
193
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
194 194
 				EVT_ID bigint(20) unsigned NOT NULL,
195 195
 				VNU_ID bigint(20) unsigned NOT NULL,
196 196
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
197 197
 				PRIMARY KEY  (EVV_ID)";
198
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
199
-        $table_name = 'esp_extra_meta';
200
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
198
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
199
+		$table_name = 'esp_extra_meta';
200
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
201 201
 				OBJ_ID int(11) DEFAULT NULL,
202 202
 				EXM_type varchar(45) DEFAULT NULL,
203 203
 				EXM_key varchar(45) DEFAULT NULL,
204 204
 				EXM_value text,
205 205
 				PRIMARY KEY  (EXM_ID),
206 206
 				KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))";
207
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
208
-        $table_name = 'esp_line_item';
209
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
207
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
208
+		$table_name = 'esp_line_item';
209
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
210 210
 				LIN_code varchar(245) NOT NULL DEFAULT '',
211 211
 				TXN_ID int(11) DEFAULT NULL,
212 212
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 				PRIMARY KEY  (LIN_ID),
225 225
 				KEY LIN_code (LIN_code(191)),
226 226
 				KEY TXN_ID (TXN_ID)";
227
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
228
-        $table_name = 'esp_log';
229
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
227
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
228
+		$table_name = 'esp_log';
229
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
230 230
 				LOG_time datetime DEFAULT NULL,
231 231
 				OBJ_ID varchar(45) DEFAULT NULL,
232 232
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -237,18 +237,18 @@  discard block
 block discarded – undo
237 237
 				KEY LOG_time (LOG_time),
238 238
 				KEY OBJ (OBJ_type,OBJ_ID),
239 239
 				KEY LOG_type (LOG_type)";
240
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
241
-        $table_name = 'esp_message_template';
242
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
240
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
241
+		$table_name = 'esp_message_template';
242
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
243 243
 					GRP_ID int(10) unsigned NOT NULL,
244 244
 					MTP_context varchar(50) NOT NULL,
245 245
 					MTP_template_field varchar(30) NOT NULL,
246 246
 					MTP_content text NOT NULL,
247 247
 					PRIMARY KEY  (MTP_ID),
248 248
 					KEY GRP_ID (GRP_ID)";
249
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
250
-        $table_name = 'esp_message_template_group';
251
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
249
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
250
+		$table_name = 'esp_message_template_group';
251
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
252 252
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
253 253
 					MTP_name varchar(245) NOT NULL DEFAULT '',
254 254
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -260,17 +260,17 @@  discard block
 block discarded – undo
260 260
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
261 261
 					PRIMARY KEY  (GRP_ID),
262 262
 					KEY MTP_user_id (MTP_user_id)";
263
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
264
-        $table_name = 'esp_event_message_template';
265
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
263
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
264
+		$table_name = 'esp_event_message_template';
265
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
266 266
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
267 267
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
268 268
 					PRIMARY KEY  (EMT_ID),
269 269
 					KEY EVT_ID (EVT_ID),
270 270
 					KEY GRP_ID (GRP_ID)";
271
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
272
-        $table_name = 'esp_payment';
273
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
271
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
272
+		$table_name = 'esp_payment';
273
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
274 274
 					TXN_ID int(10) unsigned DEFAULT NULL,
275 275
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
276 276
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 					PRIMARY KEY  (PAY_ID),
288 288
 					KEY PAY_timestamp (PAY_timestamp),
289 289
 					KEY TXN_ID (TXN_ID)";
290
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
291
-        $table_name = 'esp_payment_method';
292
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
290
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
291
+		$table_name = 'esp_payment_method';
292
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
293 293
 				PMD_type varchar(124) DEFAULT NULL,
294 294
 				PMD_name varchar(255) DEFAULT NULL,
295 295
 				PMD_desc text,
@@ -305,32 +305,32 @@  discard block
 block discarded – undo
305 305
 				PRIMARY KEY  (PMD_ID),
306 306
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
307 307
 				KEY PMD_type (PMD_type)";
308
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
309
-        $table_name = "esp_ticket_price";
310
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
308
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
309
+		$table_name = "esp_ticket_price";
310
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
311 311
 					  TKT_ID int(10) unsigned NOT NULL,
312 312
 					  PRC_ID int(10) unsigned NOT NULL,
313 313
 					  PRIMARY KEY  (TKP_ID),
314 314
 					  KEY TKT_ID (TKT_ID),
315 315
 					  KEY PRC_ID (PRC_ID)";
316
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
317
-        $table_name = "esp_datetime_ticket";
318
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
316
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
317
+		$table_name = "esp_datetime_ticket";
318
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
319 319
 					  DTT_ID int(10) unsigned NOT NULL,
320 320
 					  TKT_ID int(10) unsigned NOT NULL,
321 321
 					  PRIMARY KEY  (DTK_ID),
322 322
 					  KEY DTT_ID (DTT_ID),
323 323
 					  KEY TKT_ID (TKT_ID)";
324
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
325
-        $table_name = "esp_ticket_template";
326
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
324
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
325
+		$table_name = "esp_ticket_template";
326
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
327 327
 					  TTM_name varchar(45) NOT NULL,
328 328
 					  TTM_description text,
329 329
 					  TTM_file varchar(45),
330 330
 					  PRIMARY KEY  (TTM_ID)";
331
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
332
-        $table_name = 'esp_question';
333
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
331
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
332
+		$table_name = 'esp_question';
333
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
334 334
 					QST_display_text text NOT NULL,
335 335
 					QST_admin_label varchar(255) NOT NULL,
336 336
 					QST_system varchar(25) DEFAULT NULL,
@@ -343,18 +343,18 @@  discard block
 block discarded – undo
343 343
 					QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
344 344
 					PRIMARY KEY  (QST_ID),
345 345
 					KEY QST_order (QST_order)';
346
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
347
-        $table_name = 'esp_question_group_question';
348
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
346
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
347
+		$table_name = 'esp_question_group_question';
348
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
349 349
 					QSG_ID int(10) unsigned NOT NULL,
350 350
 					QST_ID int(10) unsigned NOT NULL,
351 351
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
352 352
 					PRIMARY KEY  (QGQ_ID),
353 353
 					KEY QST_ID (QST_ID),
354 354
 					KEY QSG_ID_order (QSG_ID, QGQ_order)";
355
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
356
-        $table_name = 'esp_question_option';
357
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
355
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
356
+		$table_name = 'esp_question_option';
357
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
358 358
 					QSO_value varchar(255) NOT NULL,
359 359
 					QSO_desc text NOT NULL,
360 360
 					QST_ID int(10) unsigned NOT NULL,
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
 					PRIMARY KEY  (QSO_ID),
364 364
 					KEY QST_ID (QST_ID),
365 365
 					KEY QSO_order (QSO_order)";
366
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
367
-        $table_name = 'esp_registration';
368
-        $sql = "REG_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_registration';
368
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
369 369
 					  EVT_ID bigint(20) unsigned NOT NULL,
370 370
 					  ATT_ID bigint(20) unsigned NOT NULL,
371 371
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -389,18 +389,18 @@  discard block
 block discarded – undo
389 389
 					  KEY TKT_ID (TKT_ID),
390 390
 					  KEY EVT_ID (EVT_ID),
391 391
 					  KEY STS_ID (STS_ID)";
392
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
393
-        $table_name = 'esp_registration_payment';
394
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
392
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
393
+		$table_name = 'esp_registration_payment';
394
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
395 395
 					  REG_ID int(10) unsigned NOT NULL,
396 396
 					  PAY_ID int(10) unsigned NULL,
397 397
 					  RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00',
398 398
 					  PRIMARY KEY  (RPY_ID),
399 399
 					  KEY REG_ID (REG_ID),
400 400
 					  KEY PAY_ID (PAY_ID)";
401
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
402
-        $table_name = 'esp_checkin';
403
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
401
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
402
+		$table_name = 'esp_checkin';
403
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
404 404
 					REG_ID int(10) unsigned NOT NULL,
405 405
 					DTT_ID int(10) unsigned NOT NULL,
406 406
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -408,9 +408,9 @@  discard block
 block discarded – undo
408 408
 					PRIMARY KEY  (CHK_ID),
409 409
 					KEY REG_ID (REG_ID),
410 410
 					KEY DTT_ID (DTT_ID)";
411
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
412
-        $table_name = 'esp_state';
413
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
411
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
412
+		$table_name = 'esp_state';
413
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
414 414
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
415 415
 					  STA_abbrev varchar(24) COLLATE utf8_bin NOT NULL,
416 416
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 					  PRIMARY KEY  (STA_ID),
419 419
 					  KEY STA_abbrev (STA_abbrev),
420 420
 					  KEY CNT_ISO (CNT_ISO)";
421
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
422
-        $table_name = 'esp_status';
423
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
421
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
422
+		$table_name = 'esp_status';
423
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
424 424
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
425 425
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
426 426
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
429 429
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
430 430
 					  KEY STS_type (STS_type)";
431
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
432
-        $table_name = 'esp_transaction';
433
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
431
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
432
+		$table_name = 'esp_transaction';
433
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
434 434
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
435 435
 					  TXN_total decimal(10,3) DEFAULT '0.00',
436 436
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 					  PRIMARY KEY  (TXN_ID),
443 443
 					  KEY TXN_timestamp (TXN_timestamp),
444 444
 					  KEY STS_ID (STS_ID)";
445
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
446
-        $table_name = 'esp_venue_meta';
447
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
445
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
446
+		$table_name = 'esp_venue_meta';
447
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
448 448
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
449 449
 			VNU_address varchar(255) DEFAULT NULL,
450 450
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
 			KEY VNU_ID (VNU_ID),
464 464
 			KEY STA_ID (STA_ID),
465 465
 			KEY CNT_ISO (CNT_ISO)";
466
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
467
-        // modified tables
468
-        $table_name = "esp_price";
469
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
466
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
467
+		// modified tables
468
+		$table_name = "esp_price";
469
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
470 470
 					  PRT_ID tinyint(3) unsigned NOT NULL,
471 471
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
472 472
 					  PRC_name varchar(245) NOT NULL,
@@ -479,9 +479,9 @@  discard block
 block discarded – undo
479 479
 					  PRC_parent int(10) unsigned DEFAULT 0,
480 480
 					  PRIMARY KEY  (PRC_ID),
481 481
 					  KEY PRT_ID (PRT_ID)";
482
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
483
-        $table_name = "esp_price_type";
484
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
482
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
483
+		$table_name = "esp_price_type";
484
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
485 485
 				  PRT_name varchar(45) NOT NULL,
486 486
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
487 487
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
491 491
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
492 492
 				  PRIMARY KEY  (PRT_ID)";
493
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
494
-        $table_name = "esp_ticket";
495
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
493
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
494
+		$table_name = "esp_ticket";
495
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
496 496
 					  TTM_ID int(10) unsigned NOT NULL,
497 497
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
498 498
 					  TKT_description text NOT NULL,
@@ -514,9 +514,9 @@  discard block
 block discarded – undo
514 514
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
515 515
 					  PRIMARY KEY  (TKT_ID),
516 516
 					  KEY TKT_start_date (TKT_start_date)";
517
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
518
-        $table_name = 'esp_question_group';
519
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
517
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
518
+		$table_name = 'esp_question_group';
519
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
520 520
 					QSG_name varchar(255) NOT NULL,
521 521
 					QSG_identifier varchar(100) NOT NULL,
522 522
 					QSG_desc text NULL,
@@ -529,38 +529,38 @@  discard block
 block discarded – undo
529 529
 					PRIMARY KEY  (QSG_ID),
530 530
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
531 531
 					KEY QSG_order (QSG_order)';
532
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
533
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
534
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
535
-        // (because many need to convert old string states to foreign keys into the states table)
536
-        $script_4_1_defaults->insert_default_states();
537
-        $script_4_1_defaults->insert_default_countries();
538
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
539
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
540
-        $script_4_5_defaults->insert_default_price_types();
541
-        $script_4_5_defaults->insert_default_prices();
542
-        $script_4_5_defaults->insert_default_tickets();
543
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
544
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
545
-        $script_4_6_defaults->add_default_admin_only_payments();
546
-        $script_4_6_defaults->insert_default_currencies();
547
-        return true;
548
-    }
532
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
533
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
534
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
535
+		// (because many need to convert old string states to foreign keys into the states table)
536
+		$script_4_1_defaults->insert_default_states();
537
+		$script_4_1_defaults->insert_default_countries();
538
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
539
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
540
+		$script_4_5_defaults->insert_default_price_types();
541
+		$script_4_5_defaults->insert_default_prices();
542
+		$script_4_5_defaults->insert_default_tickets();
543
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
544
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
545
+		$script_4_6_defaults->add_default_admin_only_payments();
546
+		$script_4_6_defaults->insert_default_currencies();
547
+		return true;
548
+	}
549 549
 
550 550
 
551 551
 
552
-    /**
553
-     * @return boolean
554
-     */
555
-    public function schema_changes_after_migration()
556
-    {
557
-        return true;
558
-    }
552
+	/**
553
+	 * @return boolean
554
+	 */
555
+	public function schema_changes_after_migration()
556
+	{
557
+		return true;
558
+	}
559 559
 
560 560
 
561 561
 
562
-    public function migration_page_hooks()
563
-    {
564
-    }
562
+	public function migration_page_hooks()
563
+	{
564
+	}
565 565
 }
566 566
 // end of file: /core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php
Please login to merge, or discard this patch.