Completed
Branch dev (02312e)
by
unknown
11:42 queued 04:50
created
core/db_models/EEM_Event.model.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
             'WP_User'                => new EE_Belongs_To_Relation(),
279 279
         );
280 280
         // this model is generally available for reading
281
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
281
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
282 282
         $this->model_chain_to_password = '';
283 283
         parent::__construct($timezone);
284 284
     }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
      */
372 372
     public function get_all_event_question_groups($EVT_ID = 0)
373 373
     {
374
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
374
+        if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
375 375
             EE_Error::add_error(
376 376
                 esc_html__(
377 377
                     'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      */
406 406
     public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true)
407 407
     {
408
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
408
+        if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
409 409
             EE_Error::add_error(
410 410
                 esc_html__(
411 411
                     // @codingStandardsIgnoreStart
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
      */
449 449
     public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration)
450 450
     {
451
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
451
+        if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
452 452
             EE_Error::add_error(
453 453
                 esc_html__(
454 454
                     'An error occurred. No Question Groups could be retrieved because an Event ID was not received.',
@@ -861,11 +861,11 @@  discard block
 block discarded – undo
861 861
         $questions = array();
862 862
         // get all question groups for event
863 863
         $qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
864
-        if (! empty($qgs)) {
864
+        if ( ! empty($qgs)) {
865 865
             foreach ($qgs as $qg) {
866 866
                 $qsts = $qg->questions();
867
-                $questions[ $qg->ID() ] = $qg->model_field_array();
868
-                $questions[ $qg->ID() ]['QSG_questions'] = array();
867
+                $questions[$qg->ID()] = $qg->model_field_array();
868
+                $questions[$qg->ID()]['QSG_questions'] = array();
869 869
                 foreach ($qsts as $qst) {
870 870
                     if ($qst->is_system_question()) {
871 871
                         continue;
@@ -879,26 +879,26 @@  discard block
 block discarded – undo
879 879
                     $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
880 880
                     $qst_name = $qstn_id = $qst->ID();
881 881
                     $ans_id = $answer->ID();
882
-                    $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
882
+                    $qst_name = ! empty($ans_id) ? '['.$qst_name.']['.$ans_id.']' : '['.$qst_name.']';
883 883
                     $input_name = '';
884 884
                     $input_id = sanitize_key($qst->display_text());
885 885
                     $input_class = '';
886
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ] = $qst->model_field_array();
887
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn'
886
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array();
887
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'
888 888
                                                                                            . $input_name
889 889
                                                                                            . $qst_name;
890
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
891
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
892
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
893
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
894
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
890
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id.'-'.$qstn_id;
891
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class;
892
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array();
893
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst;
894
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer;
895 895
                     // leave responses as-is, don't convert stuff into html entities please!
896
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['htmlentities'] = false;
896
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['htmlentities'] = false;
897 897
                     if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
898 898
                         $QSOs = $qst->options(true, $answer->value());
899 899
                         if (is_array($QSOs)) {
900 900
                             foreach ($QSOs as $QSO_ID => $QSO) {
901
-                                $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
901
+                                $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array();
902 902
                             }
903 903
                         }
904 904
                     }
Please login to merge, or discard this patch.
Indentation   +963 added lines, -963 removed lines patch added patch discarded remove patch
@@ -13,967 +13,967 @@
 block discarded – undo
13 13
  */
14 14
 class EEM_Event extends EEM_CPT_Base
15 15
 {
16
-    /**
17
-     * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the
18
-     * event
19
-     */
20
-    const sold_out = 'sold_out';
21
-
22
-    /**
23
-     * constant used by status(), indicating that upcoming event dates have been postponed (may be pushed to a later
24
-     * date)
25
-     */
26
-    const postponed = 'postponed';
27
-
28
-    /**
29
-     * constant used by status(), indicating that the event will no longer occur
30
-     */
31
-    const cancelled = 'cancelled';
32
-
33
-
34
-    /**
35
-     * @var string
36
-     */
37
-    protected static $_default_reg_status;
38
-
39
-
40
-    /**
41
-     * This is the default for the additional limit field.
42
-     * @var int
43
-     */
44
-    protected static $_default_additional_limit = 10;
45
-
46
-
47
-    /**
48
-     * private instance of the Event object
49
-     *
50
-     * @var EEM_Event
51
-     */
52
-    protected static $_instance;
53
-
54
-
55
-    /**
56
-     * Adds a relationship to Term_Taxonomy for each CPT_Base
57
-     *
58
-     * @param string $timezone
59
-     * @throws EE_Error
60
-     * @throws ReflectionException
61
-     */
62
-    protected function __construct($timezone = null)
63
-    {
64
-        EE_Registry::instance()->load_model('Registration');
65
-        $this->singular_item = esc_html__('Event', 'event_espresso');
66
-        $this->plural_item = esc_html__('Events', 'event_espresso');
67
-        // to remove Cancelled events from the frontend, copy the following filter to your functions.php file
68
-        // add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
69
-        // to remove Postponed events from the frontend, copy the following filter to your functions.php file
70
-        // add_filter( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', '__return_false' );
71
-        // to remove Sold Out events from the frontend, copy the following filter to your functions.php file
72
-        //  add_filter( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', '__return_false' );
73
-        $this->_custom_stati = apply_filters(
74
-            'AFEE__EEM_Event__construct___custom_stati',
75
-            array(
76
-                EEM_Event::cancelled => array(
77
-                    'label'  => esc_html__('Cancelled', 'event_espresso'),
78
-                    'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', true),
79
-                ),
80
-                EEM_Event::postponed => array(
81
-                    'label'  => esc_html__('Postponed', 'event_espresso'),
82
-                    'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', true),
83
-                ),
84
-                EEM_Event::sold_out  => array(
85
-                    'label'  => esc_html__('Sold Out', 'event_espresso'),
86
-                    'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', true),
87
-                ),
88
-            )
89
-        );
90
-        self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment
91
-            : self::$_default_reg_status;
92
-        $this->_tables = array(
93
-            'Event_CPT'  => new EE_Primary_Table('posts', 'ID'),
94
-            'Event_Meta' => new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID'),
95
-        );
96
-        $this->_fields = array(
97
-            'Event_CPT'  => array(
98
-                'EVT_ID'         => new EE_Primary_Key_Int_Field(
99
-                    'ID',
100
-                    esc_html__('Post ID for Event', 'event_espresso')
101
-                ),
102
-                'EVT_name'       => new EE_Plain_Text_Field(
103
-                    'post_title',
104
-                    esc_html__('Event Name', 'event_espresso'),
105
-                    false,
106
-                    ''
107
-                ),
108
-                'EVT_desc'       => new EE_Post_Content_Field(
109
-                    'post_content',
110
-                    esc_html__('Event Description', 'event_espresso'),
111
-                    false,
112
-                    ''
113
-                ),
114
-                'EVT_slug'       => new EE_Slug_Field(
115
-                    'post_name',
116
-                    esc_html__('Event Slug', 'event_espresso'),
117
-                    false,
118
-                    ''
119
-                ),
120
-                'EVT_created'    => new EE_Datetime_Field(
121
-                    'post_date',
122
-                    esc_html__('Date/Time Event Created', 'event_espresso'),
123
-                    false,
124
-                    EE_Datetime_Field::now
125
-                ),
126
-                'EVT_short_desc' => new EE_Simple_HTML_Field(
127
-                    'post_excerpt',
128
-                    esc_html__('Event Short Description', 'event_espresso'),
129
-                    false,
130
-                    ''
131
-                ),
132
-                'EVT_modified'   => new EE_Datetime_Field(
133
-                    'post_modified',
134
-                    esc_html__('Date/Time Event Modified', 'event_espresso'),
135
-                    false,
136
-                    EE_Datetime_Field::now
137
-                ),
138
-                'EVT_wp_user'    => new EE_WP_User_Field(
139
-                    'post_author',
140
-                    esc_html__('Event Creator ID', 'event_espresso'),
141
-                    false
142
-                ),
143
-                'parent'         => new EE_Integer_Field(
144
-                    'post_parent',
145
-                    esc_html__('Event Parent ID', 'event_espresso'),
146
-                    false,
147
-                    0
148
-                ),
149
-                'EVT_order'      => new EE_Integer_Field(
150
-                    'menu_order',
151
-                    esc_html__('Event Menu Order', 'event_espresso'),
152
-                    false,
153
-                    1
154
-                ),
155
-                'post_type'      => new EE_WP_Post_Type_Field('espresso_events'),
156
-                // EE_Plain_Text_Field( 'post_type', esc_html__( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
157
-                'status'         => new EE_WP_Post_Status_Field(
158
-                    'post_status',
159
-                    esc_html__('Event Status', 'event_espresso'),
160
-                    false,
161
-                    'draft',
162
-                    $this->_custom_stati
163
-                ),
164
-                'password' => new EE_Password_Field(
165
-                    'post_password',
166
-                    esc_html__('Password', 'event_espresso'),
167
-                    false,
168
-                    '',
169
-                    array(
170
-                        'EVT_desc',
171
-                        'EVT_short_desc',
172
-                        'EVT_display_desc',
173
-                        'EVT_display_ticket_selector',
174
-                        'EVT_visible_on',
175
-                        'EVT_additional_limit',
176
-                        'EVT_default_registration_status',
177
-                        'EVT_member_only',
178
-                        'EVT_phone',
179
-                        'EVT_allow_overflow',
180
-                        'EVT_timezone_string',
181
-                        'EVT_external_URL',
182
-                        'EVT_donations'
183
-                    )
184
-                )
185
-            ),
186
-            'Event_Meta' => array(
187
-                'EVTM_ID'                         => new EE_DB_Only_Float_Field(
188
-                    'EVTM_ID',
189
-                    esc_html__('Event Meta Row ID', 'event_espresso'),
190
-                    false
191
-                ),
192
-                'EVT_ID_fk'                       => new EE_DB_Only_Int_Field(
193
-                    'EVT_ID',
194
-                    esc_html__('Foreign key to Event ID from Event Meta table', 'event_espresso'),
195
-                    false
196
-                ),
197
-                'VNU_ID' => new EE_Foreign_Key_Int_Field(
198
-                    'VNU_ID',
199
-                    __('Venue ID', 'event_espresso'),
200
-                    false,
201
-                    0,
202
-                    'Venue'
203
-                ),
204
-                'EVT_display_desc'                => new EE_Boolean_Field(
205
-                    'EVT_display_desc',
206
-                    esc_html__('Display Description Flag', 'event_espresso'),
207
-                    false,
208
-                    true
209
-                ),
210
-                'EVT_display_ticket_selector'     => new EE_Boolean_Field(
211
-                    'EVT_display_ticket_selector',
212
-                    esc_html__('Display Ticket Selector Flag', 'event_espresso'),
213
-                    false,
214
-                    true
215
-                ),
216
-                'EVT_visible_on'                  => new EE_Datetime_Field(
217
-                    'EVT_visible_on',
218
-                    esc_html__('Event Visible Date', 'event_espresso'),
219
-                    true,
220
-                    EE_Datetime_Field::now
221
-                ),
222
-                'EVT_additional_limit'            => new EE_Integer_Field(
223
-                    'EVT_additional_limit',
224
-                    esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
225
-                    true,
226
-                    self::$_default_additional_limit
227
-                ),
228
-                'EVT_default_registration_status' => new EE_Enum_Text_Field(
229
-                    'EVT_default_registration_status',
230
-                    esc_html__('Default Registration Status on this Event', 'event_espresso'),
231
-                    false,
232
-                    EEM_Event::$_default_reg_status,
233
-                    EEM_Registration::reg_status_array()
234
-                ),
235
-                'EVT_member_only'                 => new EE_Boolean_Field(
236
-                    'EVT_member_only',
237
-                    esc_html__('Member-Only Event Flag', 'event_espresso'),
238
-                    false,
239
-                    false
240
-                ),
241
-                'EVT_phone'                       => new EE_Plain_Text_Field(
242
-                    'EVT_phone',
243
-                    esc_html__('Event Phone Number', 'event_espresso'),
244
-                    false,
245
-                    ''
246
-                ),
247
-                'EVT_allow_overflow'              => new EE_Boolean_Field(
248
-                    'EVT_allow_overflow',
249
-                    esc_html__('Allow Overflow on Event', 'event_espresso'),
250
-                    false,
251
-                    false
252
-                ),
253
-                'EVT_timezone_string'             => new EE_Plain_Text_Field(
254
-                    'EVT_timezone_string',
255
-                    esc_html__('Timezone (name) for Event times', 'event_espresso'),
256
-                    false,
257
-                    ''
258
-                ),
259
-                'EVT_external_URL'                => new EE_Plain_Text_Field(
260
-                    'EVT_external_URL',
261
-                    esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso'),
262
-                    true
263
-                ),
264
-                'EVT_donations'                   => new EE_Boolean_Field(
265
-                    'EVT_donations',
266
-                    esc_html__('Accept Donations?', 'event_espresso'),
267
-                    false,
268
-                    false
269
-                ),
270
-                'FSC_UUID'                        => new EE_Foreign_Key_String_Field(
271
-                    'FSC_UUID',
272
-                    esc_html__('Registration Form UUID (universally unique identifier)', 'event_espresso'),
273
-                    true,
274
-                    null,
275
-                    'Form_Section',
276
-                    false
277
-                ),
278
-            ),
279
-        );
280
-        $this->_model_relations = array(
281
-            'Attendee'               => new EE_HABTM_Relation('Registration'),
282
-            'Datetime'               => new EE_Has_Many_Relation(),
283
-            'Event_Question_Group'   => new EE_Has_Many_Relation(),
284
-            'Form_Section'           => new EE_Belongs_To_Relation(),
285
-            'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'),
286
-            'Question_Group'         => new EE_HABTM_Relation('Event_Question_Group'),
287
-            'Registration'           => new EE_Has_Many_Relation(),
288
-            'Term_Relationship'      => new EE_Has_Many_Relation(),
289
-            'Term_Taxonomy'          => new EE_HABTM_Relation('Term_Relationship'),
290
-            'Venue'                  => new EE_Belongs_To_Relation(),
291
-            'WP_User'                => new EE_Belongs_To_Relation(),
292
-        );
293
-        // this model is generally available for reading
294
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
295
-        $this->model_chain_to_password = '';
296
-        parent::__construct($timezone);
297
-    }
298
-
299
-
300
-    /**
301
-     * @param string $default_reg_status
302
-     * @throws EE_Error
303
-     * @throws EE_Error
304
-     */
305
-    public static function set_default_reg_status($default_reg_status)
306
-    {
307
-        self::$_default_reg_status = $default_reg_status;
308
-        // if EEM_Event has already been instantiated,
309
-        // then we need to reset the `EVT_default_reg_status` field to use the new default.
310
-        if (self::$_instance instanceof EEM_Event) {
311
-            $default_reg_status = new EE_Enum_Text_Field(
312
-                'EVT_default_registration_status',
313
-                esc_html__('Default Registration Status on this Event', 'event_espresso'),
314
-                false,
315
-                $default_reg_status,
316
-                EEM_Registration::reg_status_array()
317
-            );
318
-            $default_reg_status->_construct_finalize(
319
-                'Event_Meta',
320
-                'EVT_default_registration_status',
321
-                'EEM_Event'
322
-            );
323
-            self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = $default_reg_status;
324
-        }
325
-    }
326
-
327
-
328
-    /**
329
-     * Used to override the default for the additional limit field.
330
-     * @param $additional_limit
331
-     */
332
-    public static function set_default_additional_limit($additional_limit)
333
-    {
334
-        self::$_default_additional_limit = (int) $additional_limit;
335
-        if (self::$_instance instanceof EEM_Event) {
336
-            self::$_instance->_fields['Event_Meta']['EVT_additional_limit'] = new EE_Integer_Field(
337
-                'EVT_additional_limit',
338
-                esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
339
-                true,
340
-                self::$_default_additional_limit
341
-            );
342
-            self::$_instance->_fields['Event_Meta']['EVT_additional_limit']->_construct_finalize(
343
-                'Event_Meta',
344
-                'EVT_additional_limit',
345
-                'EEM_Event'
346
-            );
347
-        }
348
-    }
349
-
350
-
351
-    /**
352
-     * Return what is currently set as the default additional limit for the event.
353
-     * @return int
354
-     */
355
-    public static function get_default_additional_limit()
356
-    {
357
-        return apply_filters('FHEE__EEM_Event__get_default_additional_limit', self::$_default_additional_limit);
358
-    }
359
-
360
-
361
-    /**
362
-     * get_question_groups
363
-     *
364
-     * @return array
365
-     * @throws EE_Error
366
-     * @throws ReflectionException
367
-     */
368
-    public function get_all_question_groups()
369
-    {
370
-        return EE_Registry::instance()->load_model('Question_Group')->get_all(
371
-            array(
372
-                array('QSG_deleted' => false),
373
-                'order_by' => array('QSG_order' => 'ASC'),
374
-            )
375
-        );
376
-    }
377
-
378
-
379
-    /**
380
-     * get_question_groups
381
-     *
382
-     * @param int $EVT_ID
383
-     * @return array|bool
384
-     * @throws EE_Error
385
-     * @throws ReflectionException
386
-     */
387
-    public function get_all_event_question_groups($EVT_ID = 0)
388
-    {
389
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
390
-            EE_Error::add_error(
391
-                esc_html__(
392
-                    'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
393
-                    'event_espresso'
394
-                ),
395
-                __FILE__,
396
-                __FUNCTION__,
397
-                __LINE__
398
-            );
399
-            return false;
400
-        }
401
-        return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(
402
-            array(
403
-                array('EVT_ID' => $EVT_ID),
404
-            )
405
-        );
406
-    }
407
-
408
-
409
-    /**
410
-     * get_question_groups
411
-     *
412
-     * @param int $EVT_ID
413
-     * @param boolean $for_primary_attendee
414
-     * @return array|bool
415
-     * @throws EE_Error
416
-     * @throws InvalidArgumentException
417
-     * @throws ReflectionException
418
-     * @throws InvalidDataTypeException
419
-     * @throws InvalidInterfaceException
420
-     */
421
-    public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true)
422
-    {
423
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
424
-            EE_Error::add_error(
425
-                esc_html__(
426
-                    // @codingStandardsIgnoreStart
427
-                    'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
428
-                    // @codingStandardsIgnoreEnd
429
-                    'event_espresso'
430
-                ),
431
-                __FILE__,
432
-                __FUNCTION__,
433
-                __LINE__
434
-            );
435
-            return false;
436
-        }
437
-        $query_params = [
438
-            [
439
-                'EVT_ID' => $EVT_ID,
440
-                EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary_attendee) => true
441
-            ]
442
-        ];
443
-        if ($for_primary_attendee) {
444
-            $query_params[0]['EQG_primary'] = true;
445
-        } else {
446
-            $query_params[0]['EQG_additional'] = true;
447
-        }
448
-        return EE_Registry::instance()->load_model('Event_Question_Group')->get_all($query_params);
449
-    }
450
-
451
-
452
-    /**
453
-     * get_question_groups
454
-     *
455
-     * @param int $EVT_ID
456
-     * @param EE_Registration $registration
457
-     * @return array|bool
458
-     * @throws EE_Error
459
-     * @throws InvalidArgumentException
460
-     * @throws InvalidDataTypeException
461
-     * @throws InvalidInterfaceException
462
-     * @throws ReflectionException
463
-     */
464
-    public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration)
465
-    {
466
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
467
-            EE_Error::add_error(
468
-                esc_html__(
469
-                    'An error occurred. No Question Groups could be retrieved because an Event ID was not received.',
470
-                    'event_espresso'
471
-                ),
472
-                __FILE__,
473
-                __FUNCTION__,
474
-                __LINE__
475
-            );
476
-            return false;
477
-        }
478
-        return EE_Registry::instance()->load_model('Question_Group')->get_all(
479
-            [
480
-                [
481
-                    'Event_Question_Group.EVT_ID'      => $EVT_ID,
482
-                    'Event_Question_Group.'
483
-                        . EEM_Event_Question_Group::instance()->fieldNameForContext(
484
-                            $registration->is_primary_registrant()
485
-                        ) => true
486
-                ],
487
-                'order_by' => ['QSG_order' => 'ASC'],
488
-            ]
489
-        );
490
-    }
491
-
492
-
493
-    /**
494
-     * get_question_target_db_column
495
-     *
496
-     * @param string $QSG_IDs csv list of $QSG IDs
497
-     * @return array|bool
498
-     * @throws EE_Error
499
-     * @throws ReflectionException
500
-     */
501
-    public function get_questions_in_groups($QSG_IDs = '')
502
-    {
503
-        if (empty($QSG_IDs)) {
504
-            EE_Error::add_error(
505
-                esc_html__('An error occurred. No Question Group IDs were received.', 'event_espresso'),
506
-                __FILE__,
507
-                __FUNCTION__,
508
-                __LINE__
509
-            );
510
-            return false;
511
-        }
512
-        return EE_Registry::instance()->load_model('Question')->get_all(
513
-            array(
514
-                array(
515
-                    'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
516
-                    'QST_deleted'           => false,
517
-                    'QST_admin_only'        => is_admin(),
518
-                ),
519
-                'order_by' => 'QST_order',
520
-            )
521
-        );
522
-    }
523
-
524
-
525
-    /**
526
-     * get_options_for_question
527
-     *
528
-     * @param string $QST_IDs csv list of $QST IDs
529
-     * @return array|bool
530
-     * @throws EE_Error
531
-     * @throws ReflectionException
532
-     */
533
-    public function get_options_for_question($QST_IDs)
534
-    {
535
-        if (empty($QST_IDs)) {
536
-            EE_Error::add_error(
537
-                esc_html__('An error occurred. No Question IDs were received.', 'event_espresso'),
538
-                __FILE__,
539
-                __FUNCTION__,
540
-                __LINE__
541
-            );
542
-            return false;
543
-        }
544
-        return EE_Registry::instance()->load_model('Question_Option')->get_all(
545
-            array(
546
-                array(
547
-                    'Question.QST_ID' => array('IN', $QST_IDs),
548
-                    'QSO_deleted'     => false,
549
-                ),
550
-                'order_by' => 'QSO_ID',
551
-            )
552
-        );
553
-    }
554
-
555
-
556
-    /**
557
-     * Gets all events that are published
558
-     * and have event start time earlier than now and an event end time later than now
559
-     *
560
-     * @param array $query_params  An array of query params to further filter on
561
-     *                             (note that status and DTT_EVT_start and DTT_EVT_end will be overridden)
562
-     * @param bool  $count         whether to return the count or not (default FALSE)
563
-     * @return EE_Event[]|int
564
-     * @throws EE_Error
565
-     * @throws ReflectionException
566
-     */
567
-    public function get_active_events($query_params, $count = false)
568
-    {
569
-        if (array_key_exists(0, $query_params)) {
570
-            $where_params = $query_params[0];
571
-            unset($query_params[0]);
572
-        } else {
573
-            $where_params = array();
574
-        }
575
-        // if we have count make sure we don't include group by
576
-        if ($count && isset($query_params['group_by'])) {
577
-            unset($query_params['group_by']);
578
-        }
579
-        // let's add specific query_params for active_events
580
-        // keep in mind this will override any sent status in the query AND any date queries.
581
-        $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
582
-        // if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
583
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
584
-            $where_params['Datetime.DTT_EVT_start******'] = array(
585
-                '<',
586
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
587
-            );
588
-        } else {
589
-            $where_params['Datetime.DTT_EVT_start'] = array(
590
-                '<',
591
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
592
-            );
593
-        }
594
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
595
-            $where_params['Datetime.DTT_EVT_end*****'] = array(
596
-                '>',
597
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
598
-            );
599
-        } else {
600
-            $where_params['Datetime.DTT_EVT_end'] = array(
601
-                '>',
602
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
603
-            );
604
-        }
605
-        $query_params[0] = $where_params;
606
-        // don't use $query_params with count()
607
-        // because we don't want to include additional query clauses like "GROUP BY"
608
-        return $count
609
-            ? $this->count(array($where_params), 'EVT_ID', true)
610
-            : $this->get_all($query_params);
611
-    }
612
-
613
-
614
-    /**
615
-     * get all events that are published and have an event start time later than now
616
-     *
617
-     * @param array $query_params  An array of query params to further filter on
618
-     *                             (Note that status and DTT_EVT_start will be overridden)
619
-     * @param bool  $count         whether to return the count or not (default FALSE)
620
-     * @return EE_Event[]|int
621
-     * @throws EE_Error
622
-     * @throws ReflectionException
623
-     */
624
-    public function get_upcoming_events($query_params, $count = false)
625
-    {
626
-        if (array_key_exists(0, $query_params)) {
627
-            $where_params = $query_params[0];
628
-            unset($query_params[0]);
629
-        } else {
630
-            $where_params = array();
631
-        }
632
-        // if we have count make sure we don't include group by
633
-        if ($count && isset($query_params['group_by'])) {
634
-            unset($query_params['group_by']);
635
-        }
636
-        // let's add specific query_params for active_events
637
-        // keep in mind this will override any sent status in the query AND any date queries.
638
-        // we need to pull events with a status of publish and sold_out
639
-        $event_status = array('publish', EEM_Event::sold_out);
640
-        // check if the user can read private events and if so add the 'private status to the were params'
641
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_upcoming_events')) {
642
-            $event_status[] = 'private';
643
-        }
644
-        $where_params['status'] = array('IN', $event_status);
645
-        // if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
646
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
647
-            $where_params['Datetime.DTT_EVT_start*****'] = array(
648
-                '>',
649
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
650
-            );
651
-        } else {
652
-            $where_params['Datetime.DTT_EVT_start'] = array(
653
-                '>',
654
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
655
-            );
656
-        }
657
-        $query_params[0] = $where_params;
658
-        // don't use $query_params with count()
659
-        // because we don't want to include additional query clauses like "GROUP BY"
660
-        return $count
661
-            ? $this->count(array($where_params), 'EVT_ID', true)
662
-            : $this->get_all($query_params);
663
-    }
664
-
665
-
666
-    /**
667
-     * Gets all events that are published
668
-     * and have an event end time later than now
669
-     *
670
-     * @param array $query_params  An array of query params to further filter on
671
-     *                             (note that status and DTT_EVT_end will be overridden)
672
-     * @param bool  $count         whether to return the count or not (default FALSE)
673
-     * @return EE_Event[]|int
674
-     * @throws EE_Error
675
-     * @throws ReflectionException
676
-     */
677
-    public function get_active_and_upcoming_events($query_params, $count = false)
678
-    {
679
-        if (array_key_exists(0, $query_params)) {
680
-            $where_params = $query_params[0];
681
-            unset($query_params[0]);
682
-        } else {
683
-            $where_params = array();
684
-        }
685
-        // if we have count make sure we don't include group by
686
-        if ($count && isset($query_params['group_by'])) {
687
-            unset($query_params['group_by']);
688
-        }
689
-        // let's add specific query_params for active_events
690
-        // keep in mind this will override any sent status in the query AND any date queries.
691
-        $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
692
-        // add where params for DTT_EVT_end
693
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
694
-            $where_params['Datetime.DTT_EVT_end*****'] = array(
695
-                '>',
696
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
697
-            );
698
-        } else {
699
-            $where_params['Datetime.DTT_EVT_end'] = array(
700
-                '>',
701
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
702
-            );
703
-        }
704
-        $query_params[0] = $where_params;
705
-        // don't use $query_params with count()
706
-        // because we don't want to include additional query clauses like "GROUP BY"
707
-        return $count
708
-            ? $this->count(array($where_params), 'EVT_ID', true)
709
-            : $this->get_all($query_params);
710
-    }
711
-
712
-
713
-    /**
714
-     * This only returns events that are expired.
715
-     * They may still be published but all their datetimes have expired.
716
-     *
717
-     * @param array $query_params  An array of query params to further filter on
718
-     *                             (note that status and DTT_EVT_end will be overridden)
719
-     * @param bool  $count         whether to return the count or not (default FALSE)
720
-     * @return EE_Event[]|int
721
-     * @throws EE_Error
722
-     * @throws ReflectionException
723
-     */
724
-    public function get_expired_events($query_params, $count = false)
725
-    {
726
-        $where_params = isset($query_params[0]) ? $query_params[0] : array();
727
-        // if we have count make sure we don't include group by
728
-        if ($count && isset($query_params['group_by'])) {
729
-            unset($query_params['group_by']);
730
-        }
731
-        // let's add specific query_params for active_events
732
-        // keep in mind this will override any sent status in the query AND any date queries.
733
-        if (isset($where_params['status'])) {
734
-            unset($where_params['status']);
735
-        }
736
-        $exclude_query = $query_params;
737
-        if (isset($exclude_query[0])) {
738
-            unset($exclude_query[0]);
739
-        }
740
-        $exclude_query[0] = array(
741
-            'Datetime.DTT_EVT_end' => array(
742
-                '>',
743
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
744
-            ),
745
-        );
746
-        // first get all events that have datetimes where its not expired.
747
-        $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
748
-        $event_ids = array_keys($event_ids);
749
-        // if we have any additional query_params, let's add them to the 'AND' condition
750
-        $and_condition = array(
751
-            'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
752
-            'EVT_ID'               => array('NOT IN', $event_ids),
753
-        );
754
-        if (isset($where_params['OR'])) {
755
-            $and_condition['OR'] = $where_params['OR'];
756
-            unset($where_params['OR']);
757
-        }
758
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
759
-            $and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
760
-            unset($where_params['Datetime.DTT_EVT_end']);
761
-        }
762
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
763
-            $and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
764
-            unset($where_params['Datetime.DTT_EVT_start']);
765
-        }
766
-        // merge remaining $where params with the and conditions.
767
-        $where_params['AND'] = array_merge($and_condition, $where_params);
768
-        $query_params[0] = $where_params;
769
-        // don't use $query_params with count()
770
-        // because we don't want to include additional query clauses like "GROUP BY"
771
-        return $count
772
-            ? $this->count(array($where_params), 'EVT_ID', true)
773
-            : $this->get_all($query_params);
774
-    }
775
-
776
-
777
-
778
-    /**
779
-     * This basically just returns the events that do not have the publish status.
780
-     *
781
-     * @param  array   $query_params An array of query params to further filter on
782
-     *                               (note that status will be overwritten)
783
-     * @param  boolean $count        whether to return the count or not (default FALSE)
784
-     * @return EE_Event[]|int
785
-     * @throws EE_Error
786
-     */
787
-    public function get_inactive_events($query_params, $count = false)
788
-    {
789
-        $where_params = isset($query_params[0]) ? $query_params[0] : array();
790
-        // let's add in specific query_params for inactive events.
791
-        if (isset($where_params['status'])) {
792
-            unset($where_params['status']);
793
-        }
794
-        // if we have count make sure we don't include group by
795
-        if ($count && isset($query_params['group_by'])) {
796
-            unset($query_params['group_by']);
797
-        }
798
-        // if we have any additional query_params, let's add them to the 'AND' condition
799
-        $where_params['AND']['status'] = array('!=', 'publish');
800
-        if (isset($where_params['OR'])) {
801
-            $where_params['AND']['OR'] = $where_params['OR'];
802
-            unset($where_params['OR']);
803
-        }
804
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
805
-            $where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
806
-            unset($where_params['Datetime.DTT_EVT_end']);
807
-        }
808
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
809
-            $where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
810
-            unset($where_params['Datetime.DTT_EVT_start']);
811
-        }
812
-        $query_params[0] = $where_params;
813
-        // don't use $query_params with count()
814
-        // because we don't want to include additional query clauses like "GROUP BY"
815
-        return $count
816
-            ? $this->count(array($where_params), 'EVT_ID', true)
817
-            : $this->get_all($query_params);
818
-    }
819
-
820
-
821
-    /**
822
-     * This is just injecting into the parent add_relationship_to so we do special handling on price relationships
823
-     * because we don't want to override any existing global default prices but instead insert NEW prices that get
824
-     * attached to the event. See parent for param descriptions
825
-     *
826
-     * @param        $id_or_obj
827
-     * @param        $other_model_id_or_obj
828
-     * @param string $relationName
829
-     * @param array  $where_query
830
-     * @return EE_Base_Class
831
-     * @throws EE_Error
832
-     * @throws ReflectionException
833
-     */
834
-    public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array())
835
-    {
836
-        if ($relationName === 'Price') {
837
-            // let's get the PRC object for the given ID to make sure that we aren't dealing with a default
838
-            $prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
839
-            // if EVT_ID = 0, then this is a default
840
-            if ((int) $prc_chk->get('EVT_ID') === 0) {
841
-                // let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
842
-                $prc_chk->set('PRC_ID', 0);
843
-            }
844
-            // run parent
845
-            return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query);
846
-        }
847
-        // otherwise carry on as normal
848
-        return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
849
-    }
850
-
851
-
852
-
853
-    /******************** DEPRECATED METHODS ********************/
854
-
855
-
856
-    /**
857
-     * _get_question_target_db_column
858
-     *
859
-     * @param EE_Registration $registration    (so existing answers for registration are included)
860
-     * @param int             $EVT_ID          so all question groups are included for event (not just answers from
861
-     *                                         registration).
862
-     * @return    array
863
-     * @throws ReflectionException
864
-     * @throws EE_Error*@deprecated as of 4.8.32.rc.001. Instead consider using
865
-     *                                         EE_Registration_Custom_Questions_Form located in
866
-     *                                         admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php
867
-     * @access     public
868
-     */
869
-    public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0)
870
-    {
871
-        if (empty($EVT_ID)) {
872
-            throw new EE_Error(esc_html__(
873
-                'An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.',
874
-                'event_espresso'
875
-            ));
876
-        }
877
-        $questions = array();
878
-        // get all question groups for event
879
-        $qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
880
-        if (! empty($qgs)) {
881
-            foreach ($qgs as $qg) {
882
-                $qsts = $qg->questions();
883
-                $questions[ $qg->ID() ] = $qg->model_field_array();
884
-                $questions[ $qg->ID() ]['QSG_questions'] = array();
885
-                foreach ($qsts as $qst) {
886
-                    if ($qst->is_system_question()) {
887
-                        continue;
888
-                    }
889
-                    $answer = EEM_Answer::instance()->get_one(array(
890
-                        array(
891
-                            'QST_ID' => $qst->ID(),
892
-                            'REG_ID' => $registration->ID(),
893
-                        ),
894
-                    ));
895
-                    $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
896
-                    $qst_name = $qstn_id = $qst->ID();
897
-                    $ans_id = $answer->ID();
898
-                    $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
899
-                    $input_name = '';
900
-                    $input_id = sanitize_key($qst->display_text());
901
-                    $input_class = '';
902
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ] = $qst->model_field_array();
903
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn'
904
-                                                                                           . $input_name
905
-                                                                                           . $qst_name;
906
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
907
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
908
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
909
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
910
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
911
-                    // leave responses as-is, don't convert stuff into html entities please!
912
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['htmlentities'] = false;
913
-                    if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
914
-                        $QSOs = $qst->options(true, $answer->value());
915
-                        if (is_array($QSOs)) {
916
-                            foreach ($QSOs as $QSO_ID => $QSO) {
917
-                                $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
918
-                            }
919
-                        }
920
-                    }
921
-                }
922
-            }
923
-        }
924
-        return $questions;
925
-    }
926
-
927
-
928
-    /**
929
-     * @param mixed $cols_n_values either an array of where each key is the name of a field, and the value is its value
930
-     *                             or an stdClass where each property is the name of a column,
931
-     * @return EE_Base_Class
932
-     * @throws EE_Error
933
-     */
934
-    public function instantiate_class_from_array_or_object($cols_n_values)
935
-    {
936
-        $classInstance = parent::instantiate_class_from_array_or_object($cols_n_values);
937
-        if ($classInstance instanceof EE_Event) {
938
-            // events have their timezone defined in the DB, so use it immediately
939
-            $this->set_timezone($classInstance->get_timezone());
940
-        }
941
-        return $classInstance;
942
-    }
943
-
944
-
945
-    /**
946
-     * Deletes the model objects that meet the query params. Note: this method is overridden
947
-     * in EEM_Soft_Delete_Base so that soft-deleted model objects are instead only flagged
948
-     * as archived, not actually deleted
949
-     *
950
-     * @param array   $query_params   @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
951
-     * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info
952
-     *                                that blocks it (ie, there' sno other data that depends on this data); if false,
953
-     *                                deletes regardless of other objects which may depend on it. Its generally
954
-     *                                advisable to always leave this as TRUE, otherwise you could easily corrupt your
955
-     *                                DB
956
-     * @return int                    number of rows deleted
957
-     * @throws EE_Error
958
-     */
959
-    public function delete_permanently($query_params, $allow_blocking = true)
960
-    {
961
-        $deleted = parent::delete_permanently($query_params, $allow_blocking);
962
-        if ($deleted) {
963
-            // get list of events with no prices
964
-            $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', []);
965
-            $where = isset($query_params[0]) ? $query_params[0] : [];
966
-            $where_event = isset($where['EVT_ID']) ? $where['EVT_ID'] : ['', ''];
967
-            $where_event_ids = isset($where_event[1]) ? $where_event[1] : '';
968
-            $event_ids = is_string($where_event_ids)
969
-                ? explode(',', $where_event_ids)
970
-                : (array) $where_event_ids;
971
-            array_walk($event_ids, 'trim');
972
-            $event_ids = array_filter($event_ids);
973
-            // remove events from list of events with no prices
974
-            $espresso_no_ticket_prices = array_diff($espresso_no_ticket_prices, $event_ids);
975
-            update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
976
-        }
977
-        return $deleted;
978
-    }
16
+	/**
17
+	 * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the
18
+	 * event
19
+	 */
20
+	const sold_out = 'sold_out';
21
+
22
+	/**
23
+	 * constant used by status(), indicating that upcoming event dates have been postponed (may be pushed to a later
24
+	 * date)
25
+	 */
26
+	const postponed = 'postponed';
27
+
28
+	/**
29
+	 * constant used by status(), indicating that the event will no longer occur
30
+	 */
31
+	const cancelled = 'cancelled';
32
+
33
+
34
+	/**
35
+	 * @var string
36
+	 */
37
+	protected static $_default_reg_status;
38
+
39
+
40
+	/**
41
+	 * This is the default for the additional limit field.
42
+	 * @var int
43
+	 */
44
+	protected static $_default_additional_limit = 10;
45
+
46
+
47
+	/**
48
+	 * private instance of the Event object
49
+	 *
50
+	 * @var EEM_Event
51
+	 */
52
+	protected static $_instance;
53
+
54
+
55
+	/**
56
+	 * Adds a relationship to Term_Taxonomy for each CPT_Base
57
+	 *
58
+	 * @param string $timezone
59
+	 * @throws EE_Error
60
+	 * @throws ReflectionException
61
+	 */
62
+	protected function __construct($timezone = null)
63
+	{
64
+		EE_Registry::instance()->load_model('Registration');
65
+		$this->singular_item = esc_html__('Event', 'event_espresso');
66
+		$this->plural_item = esc_html__('Events', 'event_espresso');
67
+		// to remove Cancelled events from the frontend, copy the following filter to your functions.php file
68
+		// add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
69
+		// to remove Postponed events from the frontend, copy the following filter to your functions.php file
70
+		// add_filter( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', '__return_false' );
71
+		// to remove Sold Out events from the frontend, copy the following filter to your functions.php file
72
+		//  add_filter( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', '__return_false' );
73
+		$this->_custom_stati = apply_filters(
74
+			'AFEE__EEM_Event__construct___custom_stati',
75
+			array(
76
+				EEM_Event::cancelled => array(
77
+					'label'  => esc_html__('Cancelled', 'event_espresso'),
78
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', true),
79
+				),
80
+				EEM_Event::postponed => array(
81
+					'label'  => esc_html__('Postponed', 'event_espresso'),
82
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', true),
83
+				),
84
+				EEM_Event::sold_out  => array(
85
+					'label'  => esc_html__('Sold Out', 'event_espresso'),
86
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', true),
87
+				),
88
+			)
89
+		);
90
+		self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment
91
+			: self::$_default_reg_status;
92
+		$this->_tables = array(
93
+			'Event_CPT'  => new EE_Primary_Table('posts', 'ID'),
94
+			'Event_Meta' => new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID'),
95
+		);
96
+		$this->_fields = array(
97
+			'Event_CPT'  => array(
98
+				'EVT_ID'         => new EE_Primary_Key_Int_Field(
99
+					'ID',
100
+					esc_html__('Post ID for Event', 'event_espresso')
101
+				),
102
+				'EVT_name'       => new EE_Plain_Text_Field(
103
+					'post_title',
104
+					esc_html__('Event Name', 'event_espresso'),
105
+					false,
106
+					''
107
+				),
108
+				'EVT_desc'       => new EE_Post_Content_Field(
109
+					'post_content',
110
+					esc_html__('Event Description', 'event_espresso'),
111
+					false,
112
+					''
113
+				),
114
+				'EVT_slug'       => new EE_Slug_Field(
115
+					'post_name',
116
+					esc_html__('Event Slug', 'event_espresso'),
117
+					false,
118
+					''
119
+				),
120
+				'EVT_created'    => new EE_Datetime_Field(
121
+					'post_date',
122
+					esc_html__('Date/Time Event Created', 'event_espresso'),
123
+					false,
124
+					EE_Datetime_Field::now
125
+				),
126
+				'EVT_short_desc' => new EE_Simple_HTML_Field(
127
+					'post_excerpt',
128
+					esc_html__('Event Short Description', 'event_espresso'),
129
+					false,
130
+					''
131
+				),
132
+				'EVT_modified'   => new EE_Datetime_Field(
133
+					'post_modified',
134
+					esc_html__('Date/Time Event Modified', 'event_espresso'),
135
+					false,
136
+					EE_Datetime_Field::now
137
+				),
138
+				'EVT_wp_user'    => new EE_WP_User_Field(
139
+					'post_author',
140
+					esc_html__('Event Creator ID', 'event_espresso'),
141
+					false
142
+				),
143
+				'parent'         => new EE_Integer_Field(
144
+					'post_parent',
145
+					esc_html__('Event Parent ID', 'event_espresso'),
146
+					false,
147
+					0
148
+				),
149
+				'EVT_order'      => new EE_Integer_Field(
150
+					'menu_order',
151
+					esc_html__('Event Menu Order', 'event_espresso'),
152
+					false,
153
+					1
154
+				),
155
+				'post_type'      => new EE_WP_Post_Type_Field('espresso_events'),
156
+				// EE_Plain_Text_Field( 'post_type', esc_html__( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
157
+				'status'         => new EE_WP_Post_Status_Field(
158
+					'post_status',
159
+					esc_html__('Event Status', 'event_espresso'),
160
+					false,
161
+					'draft',
162
+					$this->_custom_stati
163
+				),
164
+				'password' => new EE_Password_Field(
165
+					'post_password',
166
+					esc_html__('Password', 'event_espresso'),
167
+					false,
168
+					'',
169
+					array(
170
+						'EVT_desc',
171
+						'EVT_short_desc',
172
+						'EVT_display_desc',
173
+						'EVT_display_ticket_selector',
174
+						'EVT_visible_on',
175
+						'EVT_additional_limit',
176
+						'EVT_default_registration_status',
177
+						'EVT_member_only',
178
+						'EVT_phone',
179
+						'EVT_allow_overflow',
180
+						'EVT_timezone_string',
181
+						'EVT_external_URL',
182
+						'EVT_donations'
183
+					)
184
+				)
185
+			),
186
+			'Event_Meta' => array(
187
+				'EVTM_ID'                         => new EE_DB_Only_Float_Field(
188
+					'EVTM_ID',
189
+					esc_html__('Event Meta Row ID', 'event_espresso'),
190
+					false
191
+				),
192
+				'EVT_ID_fk'                       => new EE_DB_Only_Int_Field(
193
+					'EVT_ID',
194
+					esc_html__('Foreign key to Event ID from Event Meta table', 'event_espresso'),
195
+					false
196
+				),
197
+				'VNU_ID' => new EE_Foreign_Key_Int_Field(
198
+					'VNU_ID',
199
+					__('Venue ID', 'event_espresso'),
200
+					false,
201
+					0,
202
+					'Venue'
203
+				),
204
+				'EVT_display_desc'                => new EE_Boolean_Field(
205
+					'EVT_display_desc',
206
+					esc_html__('Display Description Flag', 'event_espresso'),
207
+					false,
208
+					true
209
+				),
210
+				'EVT_display_ticket_selector'     => new EE_Boolean_Field(
211
+					'EVT_display_ticket_selector',
212
+					esc_html__('Display Ticket Selector Flag', 'event_espresso'),
213
+					false,
214
+					true
215
+				),
216
+				'EVT_visible_on'                  => new EE_Datetime_Field(
217
+					'EVT_visible_on',
218
+					esc_html__('Event Visible Date', 'event_espresso'),
219
+					true,
220
+					EE_Datetime_Field::now
221
+				),
222
+				'EVT_additional_limit'            => new EE_Integer_Field(
223
+					'EVT_additional_limit',
224
+					esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
225
+					true,
226
+					self::$_default_additional_limit
227
+				),
228
+				'EVT_default_registration_status' => new EE_Enum_Text_Field(
229
+					'EVT_default_registration_status',
230
+					esc_html__('Default Registration Status on this Event', 'event_espresso'),
231
+					false,
232
+					EEM_Event::$_default_reg_status,
233
+					EEM_Registration::reg_status_array()
234
+				),
235
+				'EVT_member_only'                 => new EE_Boolean_Field(
236
+					'EVT_member_only',
237
+					esc_html__('Member-Only Event Flag', 'event_espresso'),
238
+					false,
239
+					false
240
+				),
241
+				'EVT_phone'                       => new EE_Plain_Text_Field(
242
+					'EVT_phone',
243
+					esc_html__('Event Phone Number', 'event_espresso'),
244
+					false,
245
+					''
246
+				),
247
+				'EVT_allow_overflow'              => new EE_Boolean_Field(
248
+					'EVT_allow_overflow',
249
+					esc_html__('Allow Overflow on Event', 'event_espresso'),
250
+					false,
251
+					false
252
+				),
253
+				'EVT_timezone_string'             => new EE_Plain_Text_Field(
254
+					'EVT_timezone_string',
255
+					esc_html__('Timezone (name) for Event times', 'event_espresso'),
256
+					false,
257
+					''
258
+				),
259
+				'EVT_external_URL'                => new EE_Plain_Text_Field(
260
+					'EVT_external_URL',
261
+					esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso'),
262
+					true
263
+				),
264
+				'EVT_donations'                   => new EE_Boolean_Field(
265
+					'EVT_donations',
266
+					esc_html__('Accept Donations?', 'event_espresso'),
267
+					false,
268
+					false
269
+				),
270
+				'FSC_UUID'                        => new EE_Foreign_Key_String_Field(
271
+					'FSC_UUID',
272
+					esc_html__('Registration Form UUID (universally unique identifier)', 'event_espresso'),
273
+					true,
274
+					null,
275
+					'Form_Section',
276
+					false
277
+				),
278
+			),
279
+		);
280
+		$this->_model_relations = array(
281
+			'Attendee'               => new EE_HABTM_Relation('Registration'),
282
+			'Datetime'               => new EE_Has_Many_Relation(),
283
+			'Event_Question_Group'   => new EE_Has_Many_Relation(),
284
+			'Form_Section'           => new EE_Belongs_To_Relation(),
285
+			'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'),
286
+			'Question_Group'         => new EE_HABTM_Relation('Event_Question_Group'),
287
+			'Registration'           => new EE_Has_Many_Relation(),
288
+			'Term_Relationship'      => new EE_Has_Many_Relation(),
289
+			'Term_Taxonomy'          => new EE_HABTM_Relation('Term_Relationship'),
290
+			'Venue'                  => new EE_Belongs_To_Relation(),
291
+			'WP_User'                => new EE_Belongs_To_Relation(),
292
+		);
293
+		// this model is generally available for reading
294
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
295
+		$this->model_chain_to_password = '';
296
+		parent::__construct($timezone);
297
+	}
298
+
299
+
300
+	/**
301
+	 * @param string $default_reg_status
302
+	 * @throws EE_Error
303
+	 * @throws EE_Error
304
+	 */
305
+	public static function set_default_reg_status($default_reg_status)
306
+	{
307
+		self::$_default_reg_status = $default_reg_status;
308
+		// if EEM_Event has already been instantiated,
309
+		// then we need to reset the `EVT_default_reg_status` field to use the new default.
310
+		if (self::$_instance instanceof EEM_Event) {
311
+			$default_reg_status = new EE_Enum_Text_Field(
312
+				'EVT_default_registration_status',
313
+				esc_html__('Default Registration Status on this Event', 'event_espresso'),
314
+				false,
315
+				$default_reg_status,
316
+				EEM_Registration::reg_status_array()
317
+			);
318
+			$default_reg_status->_construct_finalize(
319
+				'Event_Meta',
320
+				'EVT_default_registration_status',
321
+				'EEM_Event'
322
+			);
323
+			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = $default_reg_status;
324
+		}
325
+	}
326
+
327
+
328
+	/**
329
+	 * Used to override the default for the additional limit field.
330
+	 * @param $additional_limit
331
+	 */
332
+	public static function set_default_additional_limit($additional_limit)
333
+	{
334
+		self::$_default_additional_limit = (int) $additional_limit;
335
+		if (self::$_instance instanceof EEM_Event) {
336
+			self::$_instance->_fields['Event_Meta']['EVT_additional_limit'] = new EE_Integer_Field(
337
+				'EVT_additional_limit',
338
+				esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
339
+				true,
340
+				self::$_default_additional_limit
341
+			);
342
+			self::$_instance->_fields['Event_Meta']['EVT_additional_limit']->_construct_finalize(
343
+				'Event_Meta',
344
+				'EVT_additional_limit',
345
+				'EEM_Event'
346
+			);
347
+		}
348
+	}
349
+
350
+
351
+	/**
352
+	 * Return what is currently set as the default additional limit for the event.
353
+	 * @return int
354
+	 */
355
+	public static function get_default_additional_limit()
356
+	{
357
+		return apply_filters('FHEE__EEM_Event__get_default_additional_limit', self::$_default_additional_limit);
358
+	}
359
+
360
+
361
+	/**
362
+	 * get_question_groups
363
+	 *
364
+	 * @return array
365
+	 * @throws EE_Error
366
+	 * @throws ReflectionException
367
+	 */
368
+	public function get_all_question_groups()
369
+	{
370
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(
371
+			array(
372
+				array('QSG_deleted' => false),
373
+				'order_by' => array('QSG_order' => 'ASC'),
374
+			)
375
+		);
376
+	}
377
+
378
+
379
+	/**
380
+	 * get_question_groups
381
+	 *
382
+	 * @param int $EVT_ID
383
+	 * @return array|bool
384
+	 * @throws EE_Error
385
+	 * @throws ReflectionException
386
+	 */
387
+	public function get_all_event_question_groups($EVT_ID = 0)
388
+	{
389
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
390
+			EE_Error::add_error(
391
+				esc_html__(
392
+					'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
393
+					'event_espresso'
394
+				),
395
+				__FILE__,
396
+				__FUNCTION__,
397
+				__LINE__
398
+			);
399
+			return false;
400
+		}
401
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(
402
+			array(
403
+				array('EVT_ID' => $EVT_ID),
404
+			)
405
+		);
406
+	}
407
+
408
+
409
+	/**
410
+	 * get_question_groups
411
+	 *
412
+	 * @param int $EVT_ID
413
+	 * @param boolean $for_primary_attendee
414
+	 * @return array|bool
415
+	 * @throws EE_Error
416
+	 * @throws InvalidArgumentException
417
+	 * @throws ReflectionException
418
+	 * @throws InvalidDataTypeException
419
+	 * @throws InvalidInterfaceException
420
+	 */
421
+	public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true)
422
+	{
423
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
424
+			EE_Error::add_error(
425
+				esc_html__(
426
+					// @codingStandardsIgnoreStart
427
+					'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
428
+					// @codingStandardsIgnoreEnd
429
+					'event_espresso'
430
+				),
431
+				__FILE__,
432
+				__FUNCTION__,
433
+				__LINE__
434
+			);
435
+			return false;
436
+		}
437
+		$query_params = [
438
+			[
439
+				'EVT_ID' => $EVT_ID,
440
+				EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary_attendee) => true
441
+			]
442
+		];
443
+		if ($for_primary_attendee) {
444
+			$query_params[0]['EQG_primary'] = true;
445
+		} else {
446
+			$query_params[0]['EQG_additional'] = true;
447
+		}
448
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all($query_params);
449
+	}
450
+
451
+
452
+	/**
453
+	 * get_question_groups
454
+	 *
455
+	 * @param int $EVT_ID
456
+	 * @param EE_Registration $registration
457
+	 * @return array|bool
458
+	 * @throws EE_Error
459
+	 * @throws InvalidArgumentException
460
+	 * @throws InvalidDataTypeException
461
+	 * @throws InvalidInterfaceException
462
+	 * @throws ReflectionException
463
+	 */
464
+	public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration)
465
+	{
466
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
467
+			EE_Error::add_error(
468
+				esc_html__(
469
+					'An error occurred. No Question Groups could be retrieved because an Event ID was not received.',
470
+					'event_espresso'
471
+				),
472
+				__FILE__,
473
+				__FUNCTION__,
474
+				__LINE__
475
+			);
476
+			return false;
477
+		}
478
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(
479
+			[
480
+				[
481
+					'Event_Question_Group.EVT_ID'      => $EVT_ID,
482
+					'Event_Question_Group.'
483
+						. EEM_Event_Question_Group::instance()->fieldNameForContext(
484
+							$registration->is_primary_registrant()
485
+						) => true
486
+				],
487
+				'order_by' => ['QSG_order' => 'ASC'],
488
+			]
489
+		);
490
+	}
491
+
492
+
493
+	/**
494
+	 * get_question_target_db_column
495
+	 *
496
+	 * @param string $QSG_IDs csv list of $QSG IDs
497
+	 * @return array|bool
498
+	 * @throws EE_Error
499
+	 * @throws ReflectionException
500
+	 */
501
+	public function get_questions_in_groups($QSG_IDs = '')
502
+	{
503
+		if (empty($QSG_IDs)) {
504
+			EE_Error::add_error(
505
+				esc_html__('An error occurred. No Question Group IDs were received.', 'event_espresso'),
506
+				__FILE__,
507
+				__FUNCTION__,
508
+				__LINE__
509
+			);
510
+			return false;
511
+		}
512
+		return EE_Registry::instance()->load_model('Question')->get_all(
513
+			array(
514
+				array(
515
+					'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
516
+					'QST_deleted'           => false,
517
+					'QST_admin_only'        => is_admin(),
518
+				),
519
+				'order_by' => 'QST_order',
520
+			)
521
+		);
522
+	}
523
+
524
+
525
+	/**
526
+	 * get_options_for_question
527
+	 *
528
+	 * @param string $QST_IDs csv list of $QST IDs
529
+	 * @return array|bool
530
+	 * @throws EE_Error
531
+	 * @throws ReflectionException
532
+	 */
533
+	public function get_options_for_question($QST_IDs)
534
+	{
535
+		if (empty($QST_IDs)) {
536
+			EE_Error::add_error(
537
+				esc_html__('An error occurred. No Question IDs were received.', 'event_espresso'),
538
+				__FILE__,
539
+				__FUNCTION__,
540
+				__LINE__
541
+			);
542
+			return false;
543
+		}
544
+		return EE_Registry::instance()->load_model('Question_Option')->get_all(
545
+			array(
546
+				array(
547
+					'Question.QST_ID' => array('IN', $QST_IDs),
548
+					'QSO_deleted'     => false,
549
+				),
550
+				'order_by' => 'QSO_ID',
551
+			)
552
+		);
553
+	}
554
+
555
+
556
+	/**
557
+	 * Gets all events that are published
558
+	 * and have event start time earlier than now and an event end time later than now
559
+	 *
560
+	 * @param array $query_params  An array of query params to further filter on
561
+	 *                             (note that status and DTT_EVT_start and DTT_EVT_end will be overridden)
562
+	 * @param bool  $count         whether to return the count or not (default FALSE)
563
+	 * @return EE_Event[]|int
564
+	 * @throws EE_Error
565
+	 * @throws ReflectionException
566
+	 */
567
+	public function get_active_events($query_params, $count = false)
568
+	{
569
+		if (array_key_exists(0, $query_params)) {
570
+			$where_params = $query_params[0];
571
+			unset($query_params[0]);
572
+		} else {
573
+			$where_params = array();
574
+		}
575
+		// if we have count make sure we don't include group by
576
+		if ($count && isset($query_params['group_by'])) {
577
+			unset($query_params['group_by']);
578
+		}
579
+		// let's add specific query_params for active_events
580
+		// keep in mind this will override any sent status in the query AND any date queries.
581
+		$where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
582
+		// if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
583
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
584
+			$where_params['Datetime.DTT_EVT_start******'] = array(
585
+				'<',
586
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
587
+			);
588
+		} else {
589
+			$where_params['Datetime.DTT_EVT_start'] = array(
590
+				'<',
591
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
592
+			);
593
+		}
594
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
595
+			$where_params['Datetime.DTT_EVT_end*****'] = array(
596
+				'>',
597
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
598
+			);
599
+		} else {
600
+			$where_params['Datetime.DTT_EVT_end'] = array(
601
+				'>',
602
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
603
+			);
604
+		}
605
+		$query_params[0] = $where_params;
606
+		// don't use $query_params with count()
607
+		// because we don't want to include additional query clauses like "GROUP BY"
608
+		return $count
609
+			? $this->count(array($where_params), 'EVT_ID', true)
610
+			: $this->get_all($query_params);
611
+	}
612
+
613
+
614
+	/**
615
+	 * get all events that are published and have an event start time later than now
616
+	 *
617
+	 * @param array $query_params  An array of query params to further filter on
618
+	 *                             (Note that status and DTT_EVT_start will be overridden)
619
+	 * @param bool  $count         whether to return the count or not (default FALSE)
620
+	 * @return EE_Event[]|int
621
+	 * @throws EE_Error
622
+	 * @throws ReflectionException
623
+	 */
624
+	public function get_upcoming_events($query_params, $count = false)
625
+	{
626
+		if (array_key_exists(0, $query_params)) {
627
+			$where_params = $query_params[0];
628
+			unset($query_params[0]);
629
+		} else {
630
+			$where_params = array();
631
+		}
632
+		// if we have count make sure we don't include group by
633
+		if ($count && isset($query_params['group_by'])) {
634
+			unset($query_params['group_by']);
635
+		}
636
+		// let's add specific query_params for active_events
637
+		// keep in mind this will override any sent status in the query AND any date queries.
638
+		// we need to pull events with a status of publish and sold_out
639
+		$event_status = array('publish', EEM_Event::sold_out);
640
+		// check if the user can read private events and if so add the 'private status to the were params'
641
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_upcoming_events')) {
642
+			$event_status[] = 'private';
643
+		}
644
+		$where_params['status'] = array('IN', $event_status);
645
+		// if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
646
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
647
+			$where_params['Datetime.DTT_EVT_start*****'] = array(
648
+				'>',
649
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
650
+			);
651
+		} else {
652
+			$where_params['Datetime.DTT_EVT_start'] = array(
653
+				'>',
654
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
655
+			);
656
+		}
657
+		$query_params[0] = $where_params;
658
+		// don't use $query_params with count()
659
+		// because we don't want to include additional query clauses like "GROUP BY"
660
+		return $count
661
+			? $this->count(array($where_params), 'EVT_ID', true)
662
+			: $this->get_all($query_params);
663
+	}
664
+
665
+
666
+	/**
667
+	 * Gets all events that are published
668
+	 * and have an event end time later than now
669
+	 *
670
+	 * @param array $query_params  An array of query params to further filter on
671
+	 *                             (note that status and DTT_EVT_end will be overridden)
672
+	 * @param bool  $count         whether to return the count or not (default FALSE)
673
+	 * @return EE_Event[]|int
674
+	 * @throws EE_Error
675
+	 * @throws ReflectionException
676
+	 */
677
+	public function get_active_and_upcoming_events($query_params, $count = false)
678
+	{
679
+		if (array_key_exists(0, $query_params)) {
680
+			$where_params = $query_params[0];
681
+			unset($query_params[0]);
682
+		} else {
683
+			$where_params = array();
684
+		}
685
+		// if we have count make sure we don't include group by
686
+		if ($count && isset($query_params['group_by'])) {
687
+			unset($query_params['group_by']);
688
+		}
689
+		// let's add specific query_params for active_events
690
+		// keep in mind this will override any sent status in the query AND any date queries.
691
+		$where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
692
+		// add where params for DTT_EVT_end
693
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
694
+			$where_params['Datetime.DTT_EVT_end*****'] = array(
695
+				'>',
696
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
697
+			);
698
+		} else {
699
+			$where_params['Datetime.DTT_EVT_end'] = array(
700
+				'>',
701
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
702
+			);
703
+		}
704
+		$query_params[0] = $where_params;
705
+		// don't use $query_params with count()
706
+		// because we don't want to include additional query clauses like "GROUP BY"
707
+		return $count
708
+			? $this->count(array($where_params), 'EVT_ID', true)
709
+			: $this->get_all($query_params);
710
+	}
711
+
712
+
713
+	/**
714
+	 * This only returns events that are expired.
715
+	 * They may still be published but all their datetimes have expired.
716
+	 *
717
+	 * @param array $query_params  An array of query params to further filter on
718
+	 *                             (note that status and DTT_EVT_end will be overridden)
719
+	 * @param bool  $count         whether to return the count or not (default FALSE)
720
+	 * @return EE_Event[]|int
721
+	 * @throws EE_Error
722
+	 * @throws ReflectionException
723
+	 */
724
+	public function get_expired_events($query_params, $count = false)
725
+	{
726
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
727
+		// if we have count make sure we don't include group by
728
+		if ($count && isset($query_params['group_by'])) {
729
+			unset($query_params['group_by']);
730
+		}
731
+		// let's add specific query_params for active_events
732
+		// keep in mind this will override any sent status in the query AND any date queries.
733
+		if (isset($where_params['status'])) {
734
+			unset($where_params['status']);
735
+		}
736
+		$exclude_query = $query_params;
737
+		if (isset($exclude_query[0])) {
738
+			unset($exclude_query[0]);
739
+		}
740
+		$exclude_query[0] = array(
741
+			'Datetime.DTT_EVT_end' => array(
742
+				'>',
743
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
744
+			),
745
+		);
746
+		// first get all events that have datetimes where its not expired.
747
+		$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
748
+		$event_ids = array_keys($event_ids);
749
+		// if we have any additional query_params, let's add them to the 'AND' condition
750
+		$and_condition = array(
751
+			'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
752
+			'EVT_ID'               => array('NOT IN', $event_ids),
753
+		);
754
+		if (isset($where_params['OR'])) {
755
+			$and_condition['OR'] = $where_params['OR'];
756
+			unset($where_params['OR']);
757
+		}
758
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
759
+			$and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
760
+			unset($where_params['Datetime.DTT_EVT_end']);
761
+		}
762
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
763
+			$and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
764
+			unset($where_params['Datetime.DTT_EVT_start']);
765
+		}
766
+		// merge remaining $where params with the and conditions.
767
+		$where_params['AND'] = array_merge($and_condition, $where_params);
768
+		$query_params[0] = $where_params;
769
+		// don't use $query_params with count()
770
+		// because we don't want to include additional query clauses like "GROUP BY"
771
+		return $count
772
+			? $this->count(array($where_params), 'EVT_ID', true)
773
+			: $this->get_all($query_params);
774
+	}
775
+
776
+
777
+
778
+	/**
779
+	 * This basically just returns the events that do not have the publish status.
780
+	 *
781
+	 * @param  array   $query_params An array of query params to further filter on
782
+	 *                               (note that status will be overwritten)
783
+	 * @param  boolean $count        whether to return the count or not (default FALSE)
784
+	 * @return EE_Event[]|int
785
+	 * @throws EE_Error
786
+	 */
787
+	public function get_inactive_events($query_params, $count = false)
788
+	{
789
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
790
+		// let's add in specific query_params for inactive events.
791
+		if (isset($where_params['status'])) {
792
+			unset($where_params['status']);
793
+		}
794
+		// if we have count make sure we don't include group by
795
+		if ($count && isset($query_params['group_by'])) {
796
+			unset($query_params['group_by']);
797
+		}
798
+		// if we have any additional query_params, let's add them to the 'AND' condition
799
+		$where_params['AND']['status'] = array('!=', 'publish');
800
+		if (isset($where_params['OR'])) {
801
+			$where_params['AND']['OR'] = $where_params['OR'];
802
+			unset($where_params['OR']);
803
+		}
804
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
805
+			$where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
806
+			unset($where_params['Datetime.DTT_EVT_end']);
807
+		}
808
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
809
+			$where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
810
+			unset($where_params['Datetime.DTT_EVT_start']);
811
+		}
812
+		$query_params[0] = $where_params;
813
+		// don't use $query_params with count()
814
+		// because we don't want to include additional query clauses like "GROUP BY"
815
+		return $count
816
+			? $this->count(array($where_params), 'EVT_ID', true)
817
+			: $this->get_all($query_params);
818
+	}
819
+
820
+
821
+	/**
822
+	 * This is just injecting into the parent add_relationship_to so we do special handling on price relationships
823
+	 * because we don't want to override any existing global default prices but instead insert NEW prices that get
824
+	 * attached to the event. See parent for param descriptions
825
+	 *
826
+	 * @param        $id_or_obj
827
+	 * @param        $other_model_id_or_obj
828
+	 * @param string $relationName
829
+	 * @param array  $where_query
830
+	 * @return EE_Base_Class
831
+	 * @throws EE_Error
832
+	 * @throws ReflectionException
833
+	 */
834
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array())
835
+	{
836
+		if ($relationName === 'Price') {
837
+			// let's get the PRC object for the given ID to make sure that we aren't dealing with a default
838
+			$prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
839
+			// if EVT_ID = 0, then this is a default
840
+			if ((int) $prc_chk->get('EVT_ID') === 0) {
841
+				// let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
842
+				$prc_chk->set('PRC_ID', 0);
843
+			}
844
+			// run parent
845
+			return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query);
846
+		}
847
+		// otherwise carry on as normal
848
+		return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
849
+	}
850
+
851
+
852
+
853
+	/******************** DEPRECATED METHODS ********************/
854
+
855
+
856
+	/**
857
+	 * _get_question_target_db_column
858
+	 *
859
+	 * @param EE_Registration $registration    (so existing answers for registration are included)
860
+	 * @param int             $EVT_ID          so all question groups are included for event (not just answers from
861
+	 *                                         registration).
862
+	 * @return    array
863
+	 * @throws ReflectionException
864
+	 * @throws EE_Error*@deprecated as of 4.8.32.rc.001. Instead consider using
865
+	 *                                         EE_Registration_Custom_Questions_Form located in
866
+	 *                                         admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php
867
+	 * @access     public
868
+	 */
869
+	public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0)
870
+	{
871
+		if (empty($EVT_ID)) {
872
+			throw new EE_Error(esc_html__(
873
+				'An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.',
874
+				'event_espresso'
875
+			));
876
+		}
877
+		$questions = array();
878
+		// get all question groups for event
879
+		$qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
880
+		if (! empty($qgs)) {
881
+			foreach ($qgs as $qg) {
882
+				$qsts = $qg->questions();
883
+				$questions[ $qg->ID() ] = $qg->model_field_array();
884
+				$questions[ $qg->ID() ]['QSG_questions'] = array();
885
+				foreach ($qsts as $qst) {
886
+					if ($qst->is_system_question()) {
887
+						continue;
888
+					}
889
+					$answer = EEM_Answer::instance()->get_one(array(
890
+						array(
891
+							'QST_ID' => $qst->ID(),
892
+							'REG_ID' => $registration->ID(),
893
+						),
894
+					));
895
+					$answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
896
+					$qst_name = $qstn_id = $qst->ID();
897
+					$ans_id = $answer->ID();
898
+					$qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
899
+					$input_name = '';
900
+					$input_id = sanitize_key($qst->display_text());
901
+					$input_class = '';
902
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ] = $qst->model_field_array();
903
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn'
904
+																						   . $input_name
905
+																						   . $qst_name;
906
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
907
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
908
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
909
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
910
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
911
+					// leave responses as-is, don't convert stuff into html entities please!
912
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['htmlentities'] = false;
913
+					if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
914
+						$QSOs = $qst->options(true, $answer->value());
915
+						if (is_array($QSOs)) {
916
+							foreach ($QSOs as $QSO_ID => $QSO) {
917
+								$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
918
+							}
919
+						}
920
+					}
921
+				}
922
+			}
923
+		}
924
+		return $questions;
925
+	}
926
+
927
+
928
+	/**
929
+	 * @param mixed $cols_n_values either an array of where each key is the name of a field, and the value is its value
930
+	 *                             or an stdClass where each property is the name of a column,
931
+	 * @return EE_Base_Class
932
+	 * @throws EE_Error
933
+	 */
934
+	public function instantiate_class_from_array_or_object($cols_n_values)
935
+	{
936
+		$classInstance = parent::instantiate_class_from_array_or_object($cols_n_values);
937
+		if ($classInstance instanceof EE_Event) {
938
+			// events have their timezone defined in the DB, so use it immediately
939
+			$this->set_timezone($classInstance->get_timezone());
940
+		}
941
+		return $classInstance;
942
+	}
943
+
944
+
945
+	/**
946
+	 * Deletes the model objects that meet the query params. Note: this method is overridden
947
+	 * in EEM_Soft_Delete_Base so that soft-deleted model objects are instead only flagged
948
+	 * as archived, not actually deleted
949
+	 *
950
+	 * @param array   $query_params   @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
951
+	 * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info
952
+	 *                                that blocks it (ie, there' sno other data that depends on this data); if false,
953
+	 *                                deletes regardless of other objects which may depend on it. Its generally
954
+	 *                                advisable to always leave this as TRUE, otherwise you could easily corrupt your
955
+	 *                                DB
956
+	 * @return int                    number of rows deleted
957
+	 * @throws EE_Error
958
+	 */
959
+	public function delete_permanently($query_params, $allow_blocking = true)
960
+	{
961
+		$deleted = parent::delete_permanently($query_params, $allow_blocking);
962
+		if ($deleted) {
963
+			// get list of events with no prices
964
+			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', []);
965
+			$where = isset($query_params[0]) ? $query_params[0] : [];
966
+			$where_event = isset($where['EVT_ID']) ? $where['EVT_ID'] : ['', ''];
967
+			$where_event_ids = isset($where_event[1]) ? $where_event[1] : '';
968
+			$event_ids = is_string($where_event_ids)
969
+				? explode(',', $where_event_ids)
970
+				: (array) $where_event_ids;
971
+			array_walk($event_ids, 'trim');
972
+			$event_ids = array_filter($event_ids);
973
+			// remove events from list of events with no prices
974
+			$espresso_no_ticket_prices = array_diff($espresso_no_ticket_prices, $event_ids);
975
+			update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
976
+		}
977
+		return $deleted;
978
+	}
979 979
 }
Please login to merge, or discard this patch.
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.
form_sections/strategies/display/EE_Select2_Display_Strategy.strategy.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
         // is carelessly registering an older version of Select2 on admin pages that don't even belong to them
43 43
         wp_deregister_script('select2');
44 44
         wp_deregister_style('select2');
45
-        wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true);
46
-        wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all');
47
-        wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true);
48
-        wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all');
45
+        wp_register_script('select2', EE_GLOBAL_ASSETS_URL.'scripts/select2.min.js', array(), '4.0.2', true);
46
+        wp_register_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all');
47
+        wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL.'scripts/form_section_select2_init.js', array('select2'), '1.0.0', true);
48
+        wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all');
49 49
     }
50 50
 
51 51
     /**
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
     public function get_other_js_data($other_js_data = array())
75 75
     {
76 76
         $other_js_data = parent::get_other_js_data($other_js_data);
77
-        if (! isset($other_js_data['select2s'])) {
77
+        if ( ! isset($other_js_data['select2s'])) {
78 78
             $other_js_data['select2s'] = array();
79 79
         }
80
-        $other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args();
80
+        $other_js_data['select2s'][$this->_input->html_id()] = $this->get_js_args();
81 81
         return $other_js_data;
82 82
     }
83 83
 
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -15,80 +15,80 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy
17 17
 {
18
-    /**
19
-     * Arguments that will be passed into the select2 javascript constructor
20
-     * @var array
21
-     */
22
-    protected $_select2_js_args = array();
18
+	/**
19
+	 * Arguments that will be passed into the select2 javascript constructor
20
+	 * @var array
21
+	 */
22
+	protected $_select2_js_args = array();
23 23
 
24
-    /**
25
-     *
26
-     * @param array $select2_js_args pass in the EXACT array of JS arguments you want
27
-     * to pass into the select2 js/html input. See https://select2.github.io
28
-     */
29
-    public function __construct($select2_js_args = array())
30
-    {
31
-        $this->_select2_js_args = $select2_js_args;
32
-        parent::__construct();
33
-    }
24
+	/**
25
+	 *
26
+	 * @param array $select2_js_args pass in the EXACT array of JS arguments you want
27
+	 * to pass into the select2 js/html input. See https://select2.github.io
28
+	 */
29
+	public function __construct($select2_js_args = array())
30
+	{
31
+		$this->_select2_js_args = $select2_js_args;
32
+		parent::__construct();
33
+	}
34 34
 
35
-    /**
36
-     * enqueues the select2 initializing js (which depends on the select2 js) and
37
-     * the select2 css
38
-     */
39
-    public function enqueue_js()
40
-    {
41
-        // need to first deregister the select2 script in case some other plugin **cough cough Toolset Types cough**
42
-        // is carelessly registering an older version of Select2 on admin pages that don't even belong to them
43
-        wp_deregister_script('select2');
44
-        wp_deregister_style('select2');
45
-        wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true);
46
-        wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all');
47
-        wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true);
48
-        wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all');
49
-    }
35
+	/**
36
+	 * enqueues the select2 initializing js (which depends on the select2 js) and
37
+	 * the select2 css
38
+	 */
39
+	public function enqueue_js()
40
+	{
41
+		// need to first deregister the select2 script in case some other plugin **cough cough Toolset Types cough**
42
+		// is carelessly registering an older version of Select2 on admin pages that don't even belong to them
43
+		wp_deregister_script('select2');
44
+		wp_deregister_style('select2');
45
+		wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true);
46
+		wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all');
47
+		wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true);
48
+		wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all');
49
+	}
50 50
 
51
-    /**
52
-     * Gets the javascript args which will be localized and passed into the select2 js/html input
53
-     * @return array
54
-     */
55
-    public function get_js_args()
56
-    {
57
-        return $this->_select2_js_args;
58
-    }
51
+	/**
52
+	 * Gets the javascript args which will be localized and passed into the select2 js/html input
53
+	 * @return array
54
+	 */
55
+	public function get_js_args()
56
+	{
57
+		return $this->_select2_js_args;
58
+	}
59 59
 
60
-    /**
61
-     * Sets the exact js args which will be passed into the select2 js/html input
62
-     * @param array $js_args
63
-     */
64
-    public function set_js_args($js_args)
65
-    {
66
-        $this->_select2_js_args = $js_args;
67
-    }
60
+	/**
61
+	 * Sets the exact js args which will be passed into the select2 js/html input
62
+	 * @param array $js_args
63
+	 */
64
+	public function set_js_args($js_args)
65
+	{
66
+		$this->_select2_js_args = $js_args;
67
+	}
68 68
 
69
-    /**
70
-     * Adds select2 data for localization
71
-     * @param array $other_js_data
72
-     * @return array
73
-     */
74
-    public function get_other_js_data($other_js_data = array())
75
-    {
76
-        $other_js_data = parent::get_other_js_data($other_js_data);
77
-        if (! isset($other_js_data['select2s'])) {
78
-            $other_js_data['select2s'] = array();
79
-        }
80
-        $other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args();
81
-        return $other_js_data;
82
-    }
69
+	/**
70
+	 * Adds select2 data for localization
71
+	 * @param array $other_js_data
72
+	 * @return array
73
+	 */
74
+	public function get_other_js_data($other_js_data = array())
75
+	{
76
+		$other_js_data = parent::get_other_js_data($other_js_data);
77
+		if (! isset($other_js_data['select2s'])) {
78
+			$other_js_data['select2s'] = array();
79
+		}
80
+		$other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args();
81
+		return $other_js_data;
82
+	}
83 83
 
84
-    /**
85
-     * Overrides standard attributes array to add the CSS class "ee-select2"
86
-     * @return array
87
-     */
88
-    protected function _standard_attributes_array()
89
-    {
90
-        $standard_attributes = parent::_standard_attributes_array();
91
-        $standard_attributes['class'] .= ' ee-select2';
92
-        return $standard_attributes;
93
-    }
84
+	/**
85
+	 * Overrides standard attributes array to add the CSS class "ee-select2"
86
+	 * @return array
87
+	 */
88
+	protected function _standard_attributes_array()
89
+	{
90
+		$standard_attributes = parent::_standard_attributes_array();
91
+		$standard_attributes['class'] .= ' ee-select2';
92
+		return $standard_attributes;
93
+	}
94 94
 }
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.