Completed
Branch models-cleanup/main (de94a1)
by
unknown
96:57 queued 87:28
created
core/db_models/EEM_Question.model.php 2 patches
Indentation   +575 added lines, -575 removed lines patch added patch discarded remove patch
@@ -10,580 +10,580 @@
 block discarded – undo
10 10
 class EEM_Question extends EEM_Soft_Delete_Base
11 11
 {
12 12
 
13
-    // constant used to indicate that the question type is CHECKBOX
14
-    const QST_type_checkbox = 'CHECKBOX';
13
+	// constant used to indicate that the question type is CHECKBOX
14
+	const QST_type_checkbox = 'CHECKBOX';
15 15
 
16
-    // constant used to indicate that the question type is COUNTRY
17
-    const QST_type_country = 'COUNTRY';
18
-
19
-    // constant used to indicate that the question type is DATE
20
-    const QST_type_date = 'DATE';
21
-
22
-    // constant used to indicate that the question type is a decimal (float)
23
-    const QST_type_decimal = 'DECIMAL';
24
-
25
-    // constant used to indicate that the question type is DROPDOWN
26
-    const QST_type_dropdown = 'DROPDOWN';
27
-
28
-    // constant used to indicate that the question type is an email input
29
-    const QST_type_email = 'EMAIL';
30
-
31
-    // constant used to indicate that the question type is an email input
32
-    const QST_type_email_confirm = 'EMAIL_CONFIRM';
33
-
34
-    // constant used to indicate that the question type is a TEXTAREA that allows simple html
35
-    const QST_type_html_textarea = 'HTML_TEXTAREA';
36
-
37
-    // constant used to indicate that the question type is an integer (whole number)
38
-    const QST_type_int = 'INTEGER';
39
-
40
-    // constant used to indicate that the question type is a multi-select
41
-    const QST_type_multi_select = 'MULTI_SELECT';
42
-
43
-    // constant used to indicate that the question type is RADIO_BTN
44
-    const QST_type_radio = 'RADIO_BTN';
45
-
46
-    // constant used to indicate that the question type is STATE
47
-    const QST_type_state = 'STATE';
48
-
49
-    // constant used to indicate that the question type is TEXT
50
-    const QST_type_text = 'TEXT';
51
-
52
-    // constant used to indicate that the question type is TEXTAREA
53
-    const QST_type_textarea = 'TEXTAREA';
54
-
55
-    // constant used to indicate that the question type is a valid URL
56
-    const QST_type_url = 'URL';
57
-
58
-    // constant used to indicate that the question type is a US-formatted phone number
59
-    const QST_type_us_phone = 'US_PHONE';
60
-
61
-    // constant used to indicate that the question type is a YEAR
62
-    const QST_type_year = 'YEAR';
63
-
64
-    /**
65
-     * lists all the question types which should be allowed. Ideally, this will be extensible.
66
-     *
67
-     * @var array $_allowed_question_types
68
-     */
69
-    protected $_allowed_question_types = [];
70
-
71
-
72
-    // private instance of the Attendee object
73
-    protected static $_instance;
74
-
75
-    /**
76
-     * brief descriptions for all the question types
77
-     *
78
-     * @var EEM_Question $_instance
79
-     */
80
-    protected $_question_descriptions;
81
-
82
-    /**
83
-     * Question types that are interchangeable, even after answers have been provided for them.
84
-     * Top-level keys are category slugs, next level is an array of question types. If question types
85
-     * aren't in this array, it is assumed they AREN'T interchangeable with any other question types.
86
-     *
87
-     * @var array   $_question_type_categories {
88
-     *      @type string $text
89
-     *      @type string $single -answer-enum
90
-     *      @type string $multi -answer-enum
91
-     * }
92
-     */
93
-    protected $_question_type_categories = [];
94
-
95
-
96
-    /**
97
-     * Question types that should have an admin-defined max input length
98
-     *
99
-     * @var array
100
-     */
101
-    protected $question_types_with_max_length;
102
-
103
-
104
-    /**
105
-     * EEM_Question constructor.
106
-     *
107
-     * @param string $timezone
108
-     * @throws EE_Error
109
-     */
110
-    protected function __construct(string $timezone = '')
111
-    {
112
-        $this->singular_item                  = esc_html__('Question', 'event_espresso');
113
-        $this->plural_item                    = esc_html__('Questions', 'event_espresso');
114
-        $this->_allowed_question_types        = apply_filters(
115
-            'FHEE__EEM_Question__construct__allowed_question_types',
116
-            [
117
-                EEM_Question::QST_type_checkbox      => esc_html__('Checkboxes', 'event_espresso'),
118
-                EEM_Question::QST_type_country       => esc_html__('Country Dropdown', 'event_espresso'),
119
-                EEM_Question::QST_type_date          => esc_html__('Date Picker', 'event_espresso'),
120
-                EEM_Question::QST_type_decimal       => esc_html__('Number', 'event_espresso'),
121
-                EEM_Question::QST_type_dropdown      => esc_html__('Dropdown', 'event_espresso'),
122
-                EEM_Question::QST_type_email         => esc_html__('Email', 'event_espresso'),
123
-                EEM_Question::QST_type_email_confirm => esc_html__('Confirm Email', 'event_espresso'),
124
-                EEM_Question::QST_type_html_textarea => esc_html__('HTML Textarea', 'event_espresso'),
125
-                EEM_Question::QST_type_int           => esc_html__('Whole Number', 'event_espresso'),
126
-                EEM_Question::QST_type_multi_select  => esc_html__('Multi Select', 'event_espresso'),
127
-                EEM_Question::QST_type_radio         => esc_html__('Radio Buttons', 'event_espresso'),
128
-                EEM_Question::QST_type_state         => esc_html__('State/Province Dropdown', 'event_espresso'),
129
-                EEM_Question::QST_type_text          => esc_html__('Text', 'event_espresso'),
130
-                EEM_Question::QST_type_textarea      => esc_html__('Textarea', 'event_espresso'),
131
-                EEM_Question::QST_type_url           => esc_html__('URL', 'event_espresso'),
132
-                EEM_Question::QST_type_us_phone      => esc_html__('USA - Format Phone', 'event_espresso'),
133
-                EEM_Question::QST_type_year          => esc_html__('Year', 'event_espresso'),
134
-            ]
135
-        );
136
-        $this->_question_descriptions         = apply_filters(
137
-            'FHEE__EEM_Question__construct__question_descriptions',
138
-            [
139
-                EEM_Question::QST_type_checkbox      => esc_html__(
140
-                    'Allows multiple preset options to be selected',
141
-                    'event_espresso'
142
-                ),
143
-                EEM_Question::QST_type_country       => esc_html__(
144
-                    'A dropdown that lists countries',
145
-                    'event_espresso'
146
-                ),
147
-                EEM_Question::QST_type_date          => esc_html__(
148
-                    'A popup calendar that allows date selections',
149
-                    'event_espresso'
150
-                ),
151
-                EEM_Question::QST_type_decimal       => esc_html__(
152
-                    'A text field that allows number values with decimals',
153
-                    'event_espresso'
154
-                ),
155
-                EEM_Question::QST_type_dropdown      => esc_html__(
156
-                    'A dropdown that allows a single selection',
157
-                    'event_espresso'
158
-                ),
159
-                EEM_Question::QST_type_email         => esc_html__(
160
-                    'A text field that must contain a valid Email address',
161
-                    'event_espresso'
162
-                ),
163
-                EEM_Question::QST_type_email_confirm => esc_html__(
164
-                    'A text field that must contain a valid Email address and be equal to Email field',
165
-                    'event_espresso'
166
-                ),
167
-                EEM_Question::QST_type_html_textarea => esc_html__(
168
-                    'A multi line text input field that allows HTML',
169
-                    'event_espresso'
170
-                ),
171
-                EEM_Question::QST_type_int           => esc_html__(
172
-                    'A text field that only allows whole numbers (no decimals)',
173
-                    'event_espresso'
174
-                ),
175
-                EEM_Question::QST_type_multi_select  => esc_html__(
176
-                    'A dropdown that allows multiple selections',
177
-                    'event_espresso'
178
-                ),
179
-                EEM_Question::QST_type_radio         => esc_html__(
180
-                    'Allows a single preset option to be selected',
181
-                    'event_espresso'
182
-                ),
183
-                EEM_Question::QST_type_state         => esc_html__(
184
-                    'A dropdown that lists states/provinces',
185
-                    'event_espresso'
186
-                ),
187
-                EEM_Question::QST_type_text          => esc_html__(
188
-                    'A single line text input field',
189
-                    'event_espresso'
190
-                ),
191
-                EEM_Question::QST_type_textarea      => esc_html__(
192
-                    'A multi line text input field',
193
-                    'event_espresso'
194
-                ),
195
-                EEM_Question::QST_type_url           => esc_html__(
196
-                    'A text field that must contain a valid URL',
197
-                    'event_espresso'
198
-                ),
199
-                EEM_Question::QST_type_us_phone      => esc_html__(
200
-                    'A text field that must contain a valid US phone number',
201
-                    'event_espresso'
202
-                ),
203
-                EEM_Question::QST_type_year          => esc_html__(
204
-                    'A dropdown that lists the last 100 years',
205
-                    'event_espresso'
206
-                ),
207
-            ]
208
-        );
209
-        $this->_question_type_categories      = (array) apply_filters(
210
-            'FHEE__EEM_Question__construct__question_type_categories',
211
-            [
212
-                'text'               => [
213
-                    EEM_Question::QST_type_date,
214
-                    EEM_Question::QST_type_decimal,
215
-                    EEM_Question::QST_type_email,
216
-                    EEM_Question::QST_type_email_confirm,
217
-                    EEM_Question::QST_type_html_textarea,
218
-                    EEM_Question::QST_type_int,
219
-                    EEM_Question::QST_type_text,
220
-                    EEM_Question::QST_type_textarea,
221
-                    EEM_Question::QST_type_url,
222
-                    EEM_Question::QST_type_us_phone,
223
-                    EEM_Question::QST_type_year,
224
-                ],
225
-                'single-answer-enum' => [
226
-                    EEM_Question::QST_type_dropdown,
227
-                    EEM_Question::QST_type_radio,
228
-                ],
229
-                'multi-answer-enum'  => [
230
-                    EEM_Question::QST_type_multi_select,
231
-                    EEM_Question::QST_type_checkbox,
232
-                ],
233
-            ]
234
-        );
235
-        $this->question_types_with_max_length = apply_filters(
236
-            'FHEE__EEM_Question___construct__question_types_with_max_length',
237
-            [
238
-                EEM_Question::QST_type_html_textarea,
239
-                EEM_Question::QST_type_text,
240
-                EEM_Question::QST_type_textarea,
241
-            ]
242
-        );
243
-
244
-        $this->_tables          = [
245
-            'Question' => new EE_Primary_Table('esp_question', 'QST_ID'),
246
-        ];
247
-        $this->_fields          = [
248
-            'Question' => [
249
-                'QST_ID'            => new EE_Primary_Key_Int_Field(
250
-                    'QST_ID',
251
-                    esc_html__('Question ID', 'event_espresso')
252
-                ),
253
-                'QST_admin_label'   => new EE_Plain_Text_Field(
254
-                    'QST_admin_label',
255
-                    esc_html__('Question Label (admin-only)', 'event_espresso'),
256
-                    true,
257
-                    ''
258
-                ),
259
-                'QST_admin_only'    => new EE_Boolean_Field(
260
-                    'QST_admin_only',
261
-                    esc_html__('Admin-Only Question?', 'event_espresso'),
262
-                    false,
263
-                    false
264
-                ),
265
-                'QST_deleted'       => new EE_Trashed_Flag_Field(
266
-                    'QST_deleted',
267
-                    esc_html__('Flag Indicating question was deleted', 'event_espresso'),
268
-                    false,
269
-                    false
270
-                ),
271
-                'QST_display_text'  => new EE_Post_Content_Field(
272
-                    'QST_display_text',
273
-                    esc_html__('Question Text', 'event_espresso'),
274
-                    true,
275
-                    ''
276
-                ),
277
-                'QST_max'           => new EE_Infinite_Integer_Field(
278
-                    'QST_max',
279
-                    esc_html__('Max Size', 'event_espresso'),
280
-                    false,
281
-                    EE_INF
282
-                ),
283
-                'QST_order'         => new EE_Integer_Field(
284
-                    'QST_order',
285
-                    esc_html__('Question Order', 'event_espresso'),
286
-                    false,
287
-                    0
288
-                ),
289
-                'QST_required'      => new EE_Boolean_Field(
290
-                    'QST_required',
291
-                    esc_html__('Required Question?', 'event_espresso'),
292
-                    false,
293
-                    false
294
-                ),
295
-                'QST_required_text' => new EE_Simple_HTML_Field(
296
-                    'QST_required_text',
297
-                    esc_html__('Text to Display if Not Provided', 'event_espresso'),
298
-                    true,
299
-                    ''
300
-                ),
301
-                'QST_system'        => new EE_Plain_Text_Field(
302
-                    'QST_system',
303
-                    esc_html__('Internal string ID for question', 'event_espresso'),
304
-                    false,
305
-                    ''
306
-                ),
307
-                'QST_type'          => new EE_Enum_Text_Field(
308
-                    'QST_type',
309
-                    esc_html__('Question Type', 'event_espresso'),
310
-                    false,
311
-                    'TEXT',
312
-                    $this->_allowed_question_types
313
-                ),
314
-                'QST_wp_user'       => new EE_WP_User_Field(
315
-                    'QST_wp_user',
316
-                    esc_html__('Question Creator ID', 'event_espresso'),
317
-                    false
318
-                ),
319
-            ],
320
-        ];
321
-        $this->_model_relations = [
322
-            'Answer'                  => new EE_Has_Many_Relation(),
323
-            'Question_Group'          => new EE_HABTM_Relation('Question_Group_Question'),
324
-            // for QST_order column
325
-            'Question_Group_Question' => new EE_Has_Many_Relation(),
326
-            'Question_Option'         => new EE_Has_Many_Relation(),
327
-            'WP_User'                 => new EE_Belongs_To_Relation(),
328
-        ];
329
-        // this model is generally available for reading
330
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
331
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form(
332
-            'QST_system'
333
-        );
334
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form(
335
-                'QST_system'
336
-        );
337
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form(
338
-                'QST_system'
339
-        );
340
-
341
-        parent::__construct($timezone);
342
-    }
343
-
344
-
345
-    /**
346
-     * Returns the list of allowed question types, which are normally:
347
-     * 'TEXT','TEXTAREA','RADIO_BTN','DROPDOWN','CHECKBOX','DATE' but they can be extended
348
-     *
349
-     * @return string[]
350
-     */
351
-    public function allowed_question_types(): array
352
-    {
353
-        return $this->_allowed_question_types;
354
-    }
355
-
356
-
357
-    /**
358
-     * Gets all the question types in the same category
359
-     *
360
-     * @param string $question_type one of EEM_Question::allowed_question_types(
361
-     * @return string[] like EEM_Question::allowed_question_types()
362
-     */
363
-    public function question_types_in_same_category(string $question_type): array
364
-    {
365
-        $question_types = [$question_type];
366
-        foreach ($this->_question_type_categories as $question_types_in_category) {
367
-            if (in_array($question_type, $question_types_in_category)) {
368
-                $question_types = $question_types_in_category;
369
-                break;
370
-            }
371
-        }
372
-
373
-        return array_intersect_key($this->allowed_question_types(), array_flip($question_types));
374
-    }
375
-
376
-
377
-    /**
378
-     * Determines if the given question type is in the given question type category
379
-     *
380
-     * @param string $question_type one of EEM_Question::allowed_question_types()
381
-     * @param string $category      one of the top-level keys of EEM_Question::question_type_categories()
382
-     * @return boolean
383
-     */
384
-    public function question_type_is_in_category(string $question_type, string $category): bool
385
-    {
386
-        if (! isset($this->_question_type_categories[ $category ])) {
387
-            return false;
388
-        }
389
-        return in_array($question_type, $this->_question_type_categories[ $category ]);
390
-    }
391
-
392
-
393
-    /**
394
-     * Returns all the question types in the given category
395
-     *
396
-     * @param string $category
397
-     * @return array|mixed
398
-     */
399
-    public function question_types_in_category(string $category): array
400
-    {
401
-        if (isset($this->_question_type_categories[ $category ])) {
402
-            return $this->_question_type_categories[ $category ];
403
-        }
404
-        return [];
405
-    }
406
-
407
-
408
-    /**
409
-     * Returns all the question types that should have question options
410
-     *
411
-     * @return array
412
-     */
413
-    public function question_types_with_options(): array
414
-    {
415
-        return array_merge(
416
-            $this->question_types_in_category('single-answer-enum'),
417
-            $this->question_types_in_category('multi-answer-enum')
418
-        );
419
-    }
420
-
421
-
422
-    /**
423
-     * Returns the question type categories 2d array
424
-     *
425
-     * @return array see EEM_Question::_question_type_categories
426
-     */
427
-    public function question_type_categories(): array
428
-    {
429
-        return $this->_question_type_categories;
430
-    }
431
-
432
-
433
-    /**
434
-     * Returns an array of all the QST_system values that can be allowed in the system question group
435
-     * identified by $system_question_group_id
436
-     *
437
-     * @param string $system_question_group_id QSG_system
438
-     * @return array of system question names (QST_system)
439
-     */
440
-    public function allowed_system_questions_in_system_question_group(string $system_question_group_id): array
441
-    {
442
-        $question_system_ids = [];
443
-        switch ($system_question_group_id) {
444
-            case EEM_Question_Group::system_personal:
445
-                $question_system_ids = [
446
-                    EEM_Attendee::system_question_fname,
447
-                    EEM_Attendee::system_question_lname,
448
-                    EEM_Attendee::system_question_email,
449
-                    EEM_Attendee::system_question_email_confirm,
450
-                    EEM_Attendee::system_question_phone,
451
-                ];
452
-                break;
453
-            case EEM_Question_Group::system_address:
454
-                $question_system_ids = [
455
-                    EEM_Attendee::system_question_address,
456
-                    EEM_Attendee::system_question_address2,
457
-                    EEM_Attendee::system_question_city,
458
-                    EEM_Attendee::system_question_state,
459
-                    EEM_Attendee::system_question_country,
460
-                    EEM_Attendee::system_question_zip,
461
-                    EEM_Attendee::system_question_phone,
462
-                ];
463
-                break;
464
-        }
465
-        return apply_filters(
466
-            'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return',
467
-            $question_system_ids,
468
-            $system_question_group_id
469
-        );
470
-    }
471
-
472
-
473
-    /**
474
-     * Returns an array of all the QST_system values that are required in the system question group
475
-     * identified by $system_question_group_id
476
-     *
477
-     * @param string $system_question_group_id QSG_system
478
-     * @return array of system question names (QST_system)
479
-     */
480
-    public function required_system_questions_in_system_question_group(string $system_question_group_id): array
481
-    {
482
-        switch ($system_question_group_id) {
483
-            case EEM_Question_Group::system_personal:
484
-                $question_system_ids = [
485
-                    EEM_Attendee::system_question_fname,
486
-                    EEM_Attendee::system_question_email,
487
-                ];
488
-                break;
489
-            default:
490
-                $question_system_ids = [];
491
-        }
492
-        return apply_filters(
493
-            'FHEE__EEM_Question__system_questions_required_in_system_question_group',
494
-            $question_system_ids,
495
-            $system_question_group_id
496
-        );
497
-    }
498
-
499
-
500
-    /**
501
-     * Gets an array for converting between QST_system and QST_IDs for system questions. Eg, if you want to know
502
-     * which system question QST_ID corresponds to the QST_system 'city', use
503
-     * EEM_Question::instance()->get_Question_ID_from_system_string('city');
504
-     *
505
-     * @param $QST_system
506
-     * @return int of QST_ID for the question that corresponds to that QST_system
507
-     * @throws EE_Error
508
-     * @throws ReflectionException
509
-     */
510
-    public function get_Question_ID_from_system_string($QST_system): int
511
-    {
512
-        return $this->get_var([['QST_system' => $QST_system]]);
513
-    }
514
-
515
-
516
-    /**
517
-     * searches the db for the question with the latest question order and returns that value.
518
-     *
519
-     * @return int
520
-     * @throws EE_Error
521
-     * @throws ReflectionException
522
-     */
523
-    public function get_latest_question_order(): int
524
-    {
525
-        $columns_to_select = [
526
-            'max_order' => ["MAX(QST_order)", "%d"],
527
-        ];
528
-        $max               = $this->_get_all_wpdb_results([], ARRAY_A, $columns_to_select);
529
-        return isset($max[0], $max[0]['max_order']) ? $max[0]['max_order'] : 0;
530
-    }
531
-
532
-
533
-    /**
534
-     * Returns an array where keys are system question QST_system values,
535
-     * and values are the highest question max the admin can set on the question
536
-     * (aka the "max max"; eg, a site admin can change the zip question to have a max
537
-     * of 5, but no larger than 12)
538
-     *
539
-     * @return array
540
-     */
541
-    public function system_question_maxes(): array
542
-    {
543
-        return [
544
-            'fname'         => 45,
545
-            'lname'         => 45,
546
-            'address'       => 255,
547
-            'address2'      => 255,
548
-            'city'          => 45,
549
-            'zip'           => 12,
550
-            'email'         => 255,
551
-            'email_confirm' => 255,
552
-            'phone'         => 45,
553
-        ];
554
-    }
555
-
556
-
557
-    /**
558
-     * Given a QST_system value, gets the question's largest allowable max input.
559
-     *
560
-     * @param string $system_question_value
561
-     * @return int|float
562
-     * @see Registration_Form_Admin_Page::system_question_maxes()
563
-     */
564
-    public function absolute_max_for_system_question(string $system_question_value)
565
-    {
566
-        $maxes = $this->system_question_maxes();
567
-        return $maxes[ $system_question_value ] ?? EE_INF;
568
-    }
569
-
570
-
571
-    /**
572
-     * @return array
573
-     */
574
-    public function question_descriptions(): array
575
-    {
576
-        return $this->_question_descriptions;
577
-    }
578
-
579
-
580
-    /**
581
-     * Returns all the question types that should have an admin-defined max input length
582
-     *
583
-     * @return array
584
-     */
585
-    public function questionTypesWithMaxLength(): array
586
-    {
587
-        return (array) $this->question_types_with_max_length;
588
-    }
16
+	// constant used to indicate that the question type is COUNTRY
17
+	const QST_type_country = 'COUNTRY';
18
+
19
+	// constant used to indicate that the question type is DATE
20
+	const QST_type_date = 'DATE';
21
+
22
+	// constant used to indicate that the question type is a decimal (float)
23
+	const QST_type_decimal = 'DECIMAL';
24
+
25
+	// constant used to indicate that the question type is DROPDOWN
26
+	const QST_type_dropdown = 'DROPDOWN';
27
+
28
+	// constant used to indicate that the question type is an email input
29
+	const QST_type_email = 'EMAIL';
30
+
31
+	// constant used to indicate that the question type is an email input
32
+	const QST_type_email_confirm = 'EMAIL_CONFIRM';
33
+
34
+	// constant used to indicate that the question type is a TEXTAREA that allows simple html
35
+	const QST_type_html_textarea = 'HTML_TEXTAREA';
36
+
37
+	// constant used to indicate that the question type is an integer (whole number)
38
+	const QST_type_int = 'INTEGER';
39
+
40
+	// constant used to indicate that the question type is a multi-select
41
+	const QST_type_multi_select = 'MULTI_SELECT';
42
+
43
+	// constant used to indicate that the question type is RADIO_BTN
44
+	const QST_type_radio = 'RADIO_BTN';
45
+
46
+	// constant used to indicate that the question type is STATE
47
+	const QST_type_state = 'STATE';
48
+
49
+	// constant used to indicate that the question type is TEXT
50
+	const QST_type_text = 'TEXT';
51
+
52
+	// constant used to indicate that the question type is TEXTAREA
53
+	const QST_type_textarea = 'TEXTAREA';
54
+
55
+	// constant used to indicate that the question type is a valid URL
56
+	const QST_type_url = 'URL';
57
+
58
+	// constant used to indicate that the question type is a US-formatted phone number
59
+	const QST_type_us_phone = 'US_PHONE';
60
+
61
+	// constant used to indicate that the question type is a YEAR
62
+	const QST_type_year = 'YEAR';
63
+
64
+	/**
65
+	 * lists all the question types which should be allowed. Ideally, this will be extensible.
66
+	 *
67
+	 * @var array $_allowed_question_types
68
+	 */
69
+	protected $_allowed_question_types = [];
70
+
71
+
72
+	// private instance of the Attendee object
73
+	protected static $_instance;
74
+
75
+	/**
76
+	 * brief descriptions for all the question types
77
+	 *
78
+	 * @var EEM_Question $_instance
79
+	 */
80
+	protected $_question_descriptions;
81
+
82
+	/**
83
+	 * Question types that are interchangeable, even after answers have been provided for them.
84
+	 * Top-level keys are category slugs, next level is an array of question types. If question types
85
+	 * aren't in this array, it is assumed they AREN'T interchangeable with any other question types.
86
+	 *
87
+	 * @var array   $_question_type_categories {
88
+	 *      @type string $text
89
+	 *      @type string $single -answer-enum
90
+	 *      @type string $multi -answer-enum
91
+	 * }
92
+	 */
93
+	protected $_question_type_categories = [];
94
+
95
+
96
+	/**
97
+	 * Question types that should have an admin-defined max input length
98
+	 *
99
+	 * @var array
100
+	 */
101
+	protected $question_types_with_max_length;
102
+
103
+
104
+	/**
105
+	 * EEM_Question constructor.
106
+	 *
107
+	 * @param string $timezone
108
+	 * @throws EE_Error
109
+	 */
110
+	protected function __construct(string $timezone = '')
111
+	{
112
+		$this->singular_item                  = esc_html__('Question', 'event_espresso');
113
+		$this->plural_item                    = esc_html__('Questions', 'event_espresso');
114
+		$this->_allowed_question_types        = apply_filters(
115
+			'FHEE__EEM_Question__construct__allowed_question_types',
116
+			[
117
+				EEM_Question::QST_type_checkbox      => esc_html__('Checkboxes', 'event_espresso'),
118
+				EEM_Question::QST_type_country       => esc_html__('Country Dropdown', 'event_espresso'),
119
+				EEM_Question::QST_type_date          => esc_html__('Date Picker', 'event_espresso'),
120
+				EEM_Question::QST_type_decimal       => esc_html__('Number', 'event_espresso'),
121
+				EEM_Question::QST_type_dropdown      => esc_html__('Dropdown', 'event_espresso'),
122
+				EEM_Question::QST_type_email         => esc_html__('Email', 'event_espresso'),
123
+				EEM_Question::QST_type_email_confirm => esc_html__('Confirm Email', 'event_espresso'),
124
+				EEM_Question::QST_type_html_textarea => esc_html__('HTML Textarea', 'event_espresso'),
125
+				EEM_Question::QST_type_int           => esc_html__('Whole Number', 'event_espresso'),
126
+				EEM_Question::QST_type_multi_select  => esc_html__('Multi Select', 'event_espresso'),
127
+				EEM_Question::QST_type_radio         => esc_html__('Radio Buttons', 'event_espresso'),
128
+				EEM_Question::QST_type_state         => esc_html__('State/Province Dropdown', 'event_espresso'),
129
+				EEM_Question::QST_type_text          => esc_html__('Text', 'event_espresso'),
130
+				EEM_Question::QST_type_textarea      => esc_html__('Textarea', 'event_espresso'),
131
+				EEM_Question::QST_type_url           => esc_html__('URL', 'event_espresso'),
132
+				EEM_Question::QST_type_us_phone      => esc_html__('USA - Format Phone', 'event_espresso'),
133
+				EEM_Question::QST_type_year          => esc_html__('Year', 'event_espresso'),
134
+			]
135
+		);
136
+		$this->_question_descriptions         = apply_filters(
137
+			'FHEE__EEM_Question__construct__question_descriptions',
138
+			[
139
+				EEM_Question::QST_type_checkbox      => esc_html__(
140
+					'Allows multiple preset options to be selected',
141
+					'event_espresso'
142
+				),
143
+				EEM_Question::QST_type_country       => esc_html__(
144
+					'A dropdown that lists countries',
145
+					'event_espresso'
146
+				),
147
+				EEM_Question::QST_type_date          => esc_html__(
148
+					'A popup calendar that allows date selections',
149
+					'event_espresso'
150
+				),
151
+				EEM_Question::QST_type_decimal       => esc_html__(
152
+					'A text field that allows number values with decimals',
153
+					'event_espresso'
154
+				),
155
+				EEM_Question::QST_type_dropdown      => esc_html__(
156
+					'A dropdown that allows a single selection',
157
+					'event_espresso'
158
+				),
159
+				EEM_Question::QST_type_email         => esc_html__(
160
+					'A text field that must contain a valid Email address',
161
+					'event_espresso'
162
+				),
163
+				EEM_Question::QST_type_email_confirm => esc_html__(
164
+					'A text field that must contain a valid Email address and be equal to Email field',
165
+					'event_espresso'
166
+				),
167
+				EEM_Question::QST_type_html_textarea => esc_html__(
168
+					'A multi line text input field that allows HTML',
169
+					'event_espresso'
170
+				),
171
+				EEM_Question::QST_type_int           => esc_html__(
172
+					'A text field that only allows whole numbers (no decimals)',
173
+					'event_espresso'
174
+				),
175
+				EEM_Question::QST_type_multi_select  => esc_html__(
176
+					'A dropdown that allows multiple selections',
177
+					'event_espresso'
178
+				),
179
+				EEM_Question::QST_type_radio         => esc_html__(
180
+					'Allows a single preset option to be selected',
181
+					'event_espresso'
182
+				),
183
+				EEM_Question::QST_type_state         => esc_html__(
184
+					'A dropdown that lists states/provinces',
185
+					'event_espresso'
186
+				),
187
+				EEM_Question::QST_type_text          => esc_html__(
188
+					'A single line text input field',
189
+					'event_espresso'
190
+				),
191
+				EEM_Question::QST_type_textarea      => esc_html__(
192
+					'A multi line text input field',
193
+					'event_espresso'
194
+				),
195
+				EEM_Question::QST_type_url           => esc_html__(
196
+					'A text field that must contain a valid URL',
197
+					'event_espresso'
198
+				),
199
+				EEM_Question::QST_type_us_phone      => esc_html__(
200
+					'A text field that must contain a valid US phone number',
201
+					'event_espresso'
202
+				),
203
+				EEM_Question::QST_type_year          => esc_html__(
204
+					'A dropdown that lists the last 100 years',
205
+					'event_espresso'
206
+				),
207
+			]
208
+		);
209
+		$this->_question_type_categories      = (array) apply_filters(
210
+			'FHEE__EEM_Question__construct__question_type_categories',
211
+			[
212
+				'text'               => [
213
+					EEM_Question::QST_type_date,
214
+					EEM_Question::QST_type_decimal,
215
+					EEM_Question::QST_type_email,
216
+					EEM_Question::QST_type_email_confirm,
217
+					EEM_Question::QST_type_html_textarea,
218
+					EEM_Question::QST_type_int,
219
+					EEM_Question::QST_type_text,
220
+					EEM_Question::QST_type_textarea,
221
+					EEM_Question::QST_type_url,
222
+					EEM_Question::QST_type_us_phone,
223
+					EEM_Question::QST_type_year,
224
+				],
225
+				'single-answer-enum' => [
226
+					EEM_Question::QST_type_dropdown,
227
+					EEM_Question::QST_type_radio,
228
+				],
229
+				'multi-answer-enum'  => [
230
+					EEM_Question::QST_type_multi_select,
231
+					EEM_Question::QST_type_checkbox,
232
+				],
233
+			]
234
+		);
235
+		$this->question_types_with_max_length = apply_filters(
236
+			'FHEE__EEM_Question___construct__question_types_with_max_length',
237
+			[
238
+				EEM_Question::QST_type_html_textarea,
239
+				EEM_Question::QST_type_text,
240
+				EEM_Question::QST_type_textarea,
241
+			]
242
+		);
243
+
244
+		$this->_tables          = [
245
+			'Question' => new EE_Primary_Table('esp_question', 'QST_ID'),
246
+		];
247
+		$this->_fields          = [
248
+			'Question' => [
249
+				'QST_ID'            => new EE_Primary_Key_Int_Field(
250
+					'QST_ID',
251
+					esc_html__('Question ID', 'event_espresso')
252
+				),
253
+				'QST_admin_label'   => new EE_Plain_Text_Field(
254
+					'QST_admin_label',
255
+					esc_html__('Question Label (admin-only)', 'event_espresso'),
256
+					true,
257
+					''
258
+				),
259
+				'QST_admin_only'    => new EE_Boolean_Field(
260
+					'QST_admin_only',
261
+					esc_html__('Admin-Only Question?', 'event_espresso'),
262
+					false,
263
+					false
264
+				),
265
+				'QST_deleted'       => new EE_Trashed_Flag_Field(
266
+					'QST_deleted',
267
+					esc_html__('Flag Indicating question was deleted', 'event_espresso'),
268
+					false,
269
+					false
270
+				),
271
+				'QST_display_text'  => new EE_Post_Content_Field(
272
+					'QST_display_text',
273
+					esc_html__('Question Text', 'event_espresso'),
274
+					true,
275
+					''
276
+				),
277
+				'QST_max'           => new EE_Infinite_Integer_Field(
278
+					'QST_max',
279
+					esc_html__('Max Size', 'event_espresso'),
280
+					false,
281
+					EE_INF
282
+				),
283
+				'QST_order'         => new EE_Integer_Field(
284
+					'QST_order',
285
+					esc_html__('Question Order', 'event_espresso'),
286
+					false,
287
+					0
288
+				),
289
+				'QST_required'      => new EE_Boolean_Field(
290
+					'QST_required',
291
+					esc_html__('Required Question?', 'event_espresso'),
292
+					false,
293
+					false
294
+				),
295
+				'QST_required_text' => new EE_Simple_HTML_Field(
296
+					'QST_required_text',
297
+					esc_html__('Text to Display if Not Provided', 'event_espresso'),
298
+					true,
299
+					''
300
+				),
301
+				'QST_system'        => new EE_Plain_Text_Field(
302
+					'QST_system',
303
+					esc_html__('Internal string ID for question', 'event_espresso'),
304
+					false,
305
+					''
306
+				),
307
+				'QST_type'          => new EE_Enum_Text_Field(
308
+					'QST_type',
309
+					esc_html__('Question Type', 'event_espresso'),
310
+					false,
311
+					'TEXT',
312
+					$this->_allowed_question_types
313
+				),
314
+				'QST_wp_user'       => new EE_WP_User_Field(
315
+					'QST_wp_user',
316
+					esc_html__('Question Creator ID', 'event_espresso'),
317
+					false
318
+				),
319
+			],
320
+		];
321
+		$this->_model_relations = [
322
+			'Answer'                  => new EE_Has_Many_Relation(),
323
+			'Question_Group'          => new EE_HABTM_Relation('Question_Group_Question'),
324
+			// for QST_order column
325
+			'Question_Group_Question' => new EE_Has_Many_Relation(),
326
+			'Question_Option'         => new EE_Has_Many_Relation(),
327
+			'WP_User'                 => new EE_Belongs_To_Relation(),
328
+		];
329
+		// this model is generally available for reading
330
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
331
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form(
332
+			'QST_system'
333
+		);
334
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form(
335
+				'QST_system'
336
+		);
337
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form(
338
+				'QST_system'
339
+		);
340
+
341
+		parent::__construct($timezone);
342
+	}
343
+
344
+
345
+	/**
346
+	 * Returns the list of allowed question types, which are normally:
347
+	 * 'TEXT','TEXTAREA','RADIO_BTN','DROPDOWN','CHECKBOX','DATE' but they can be extended
348
+	 *
349
+	 * @return string[]
350
+	 */
351
+	public function allowed_question_types(): array
352
+	{
353
+		return $this->_allowed_question_types;
354
+	}
355
+
356
+
357
+	/**
358
+	 * Gets all the question types in the same category
359
+	 *
360
+	 * @param string $question_type one of EEM_Question::allowed_question_types(
361
+	 * @return string[] like EEM_Question::allowed_question_types()
362
+	 */
363
+	public function question_types_in_same_category(string $question_type): array
364
+	{
365
+		$question_types = [$question_type];
366
+		foreach ($this->_question_type_categories as $question_types_in_category) {
367
+			if (in_array($question_type, $question_types_in_category)) {
368
+				$question_types = $question_types_in_category;
369
+				break;
370
+			}
371
+		}
372
+
373
+		return array_intersect_key($this->allowed_question_types(), array_flip($question_types));
374
+	}
375
+
376
+
377
+	/**
378
+	 * Determines if the given question type is in the given question type category
379
+	 *
380
+	 * @param string $question_type one of EEM_Question::allowed_question_types()
381
+	 * @param string $category      one of the top-level keys of EEM_Question::question_type_categories()
382
+	 * @return boolean
383
+	 */
384
+	public function question_type_is_in_category(string $question_type, string $category): bool
385
+	{
386
+		if (! isset($this->_question_type_categories[ $category ])) {
387
+			return false;
388
+		}
389
+		return in_array($question_type, $this->_question_type_categories[ $category ]);
390
+	}
391
+
392
+
393
+	/**
394
+	 * Returns all the question types in the given category
395
+	 *
396
+	 * @param string $category
397
+	 * @return array|mixed
398
+	 */
399
+	public function question_types_in_category(string $category): array
400
+	{
401
+		if (isset($this->_question_type_categories[ $category ])) {
402
+			return $this->_question_type_categories[ $category ];
403
+		}
404
+		return [];
405
+	}
406
+
407
+
408
+	/**
409
+	 * Returns all the question types that should have question options
410
+	 *
411
+	 * @return array
412
+	 */
413
+	public function question_types_with_options(): array
414
+	{
415
+		return array_merge(
416
+			$this->question_types_in_category('single-answer-enum'),
417
+			$this->question_types_in_category('multi-answer-enum')
418
+		);
419
+	}
420
+
421
+
422
+	/**
423
+	 * Returns the question type categories 2d array
424
+	 *
425
+	 * @return array see EEM_Question::_question_type_categories
426
+	 */
427
+	public function question_type_categories(): array
428
+	{
429
+		return $this->_question_type_categories;
430
+	}
431
+
432
+
433
+	/**
434
+	 * Returns an array of all the QST_system values that can be allowed in the system question group
435
+	 * identified by $system_question_group_id
436
+	 *
437
+	 * @param string $system_question_group_id QSG_system
438
+	 * @return array of system question names (QST_system)
439
+	 */
440
+	public function allowed_system_questions_in_system_question_group(string $system_question_group_id): array
441
+	{
442
+		$question_system_ids = [];
443
+		switch ($system_question_group_id) {
444
+			case EEM_Question_Group::system_personal:
445
+				$question_system_ids = [
446
+					EEM_Attendee::system_question_fname,
447
+					EEM_Attendee::system_question_lname,
448
+					EEM_Attendee::system_question_email,
449
+					EEM_Attendee::system_question_email_confirm,
450
+					EEM_Attendee::system_question_phone,
451
+				];
452
+				break;
453
+			case EEM_Question_Group::system_address:
454
+				$question_system_ids = [
455
+					EEM_Attendee::system_question_address,
456
+					EEM_Attendee::system_question_address2,
457
+					EEM_Attendee::system_question_city,
458
+					EEM_Attendee::system_question_state,
459
+					EEM_Attendee::system_question_country,
460
+					EEM_Attendee::system_question_zip,
461
+					EEM_Attendee::system_question_phone,
462
+				];
463
+				break;
464
+		}
465
+		return apply_filters(
466
+			'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return',
467
+			$question_system_ids,
468
+			$system_question_group_id
469
+		);
470
+	}
471
+
472
+
473
+	/**
474
+	 * Returns an array of all the QST_system values that are required in the system question group
475
+	 * identified by $system_question_group_id
476
+	 *
477
+	 * @param string $system_question_group_id QSG_system
478
+	 * @return array of system question names (QST_system)
479
+	 */
480
+	public function required_system_questions_in_system_question_group(string $system_question_group_id): array
481
+	{
482
+		switch ($system_question_group_id) {
483
+			case EEM_Question_Group::system_personal:
484
+				$question_system_ids = [
485
+					EEM_Attendee::system_question_fname,
486
+					EEM_Attendee::system_question_email,
487
+				];
488
+				break;
489
+			default:
490
+				$question_system_ids = [];
491
+		}
492
+		return apply_filters(
493
+			'FHEE__EEM_Question__system_questions_required_in_system_question_group',
494
+			$question_system_ids,
495
+			$system_question_group_id
496
+		);
497
+	}
498
+
499
+
500
+	/**
501
+	 * Gets an array for converting between QST_system and QST_IDs for system questions. Eg, if you want to know
502
+	 * which system question QST_ID corresponds to the QST_system 'city', use
503
+	 * EEM_Question::instance()->get_Question_ID_from_system_string('city');
504
+	 *
505
+	 * @param $QST_system
506
+	 * @return int of QST_ID for the question that corresponds to that QST_system
507
+	 * @throws EE_Error
508
+	 * @throws ReflectionException
509
+	 */
510
+	public function get_Question_ID_from_system_string($QST_system): int
511
+	{
512
+		return $this->get_var([['QST_system' => $QST_system]]);
513
+	}
514
+
515
+
516
+	/**
517
+	 * searches the db for the question with the latest question order and returns that value.
518
+	 *
519
+	 * @return int
520
+	 * @throws EE_Error
521
+	 * @throws ReflectionException
522
+	 */
523
+	public function get_latest_question_order(): int
524
+	{
525
+		$columns_to_select = [
526
+			'max_order' => ["MAX(QST_order)", "%d"],
527
+		];
528
+		$max               = $this->_get_all_wpdb_results([], ARRAY_A, $columns_to_select);
529
+		return isset($max[0], $max[0]['max_order']) ? $max[0]['max_order'] : 0;
530
+	}
531
+
532
+
533
+	/**
534
+	 * Returns an array where keys are system question QST_system values,
535
+	 * and values are the highest question max the admin can set on the question
536
+	 * (aka the "max max"; eg, a site admin can change the zip question to have a max
537
+	 * of 5, but no larger than 12)
538
+	 *
539
+	 * @return array
540
+	 */
541
+	public function system_question_maxes(): array
542
+	{
543
+		return [
544
+			'fname'         => 45,
545
+			'lname'         => 45,
546
+			'address'       => 255,
547
+			'address2'      => 255,
548
+			'city'          => 45,
549
+			'zip'           => 12,
550
+			'email'         => 255,
551
+			'email_confirm' => 255,
552
+			'phone'         => 45,
553
+		];
554
+	}
555
+
556
+
557
+	/**
558
+	 * Given a QST_system value, gets the question's largest allowable max input.
559
+	 *
560
+	 * @param string $system_question_value
561
+	 * @return int|float
562
+	 * @see Registration_Form_Admin_Page::system_question_maxes()
563
+	 */
564
+	public function absolute_max_for_system_question(string $system_question_value)
565
+	{
566
+		$maxes = $this->system_question_maxes();
567
+		return $maxes[ $system_question_value ] ?? EE_INF;
568
+	}
569
+
570
+
571
+	/**
572
+	 * @return array
573
+	 */
574
+	public function question_descriptions(): array
575
+	{
576
+		return $this->_question_descriptions;
577
+	}
578
+
579
+
580
+	/**
581
+	 * Returns all the question types that should have an admin-defined max input length
582
+	 *
583
+	 * @return array
584
+	 */
585
+	public function questionTypesWithMaxLength(): array
586
+	{
587
+		return (array) $this->question_types_with_max_length;
588
+	}
589 589
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                 EEM_Question::QST_type_year          => esc_html__('Year', 'event_espresso'),
134 134
             ]
135 135
         );
136
-        $this->_question_descriptions         = apply_filters(
136
+        $this->_question_descriptions = apply_filters(
137 137
             'FHEE__EEM_Question__construct__question_descriptions',
138 138
             [
139 139
                 EEM_Question::QST_type_checkbox      => esc_html__(
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                 ),
207 207
             ]
208 208
         );
209
-        $this->_question_type_categories      = (array) apply_filters(
209
+        $this->_question_type_categories = (array) apply_filters(
210 210
             'FHEE__EEM_Question__construct__question_type_categories',
211 211
             [
212 212
                 'text'               => [
@@ -327,14 +327,14 @@  discard block
 block discarded – undo
327 327
             'WP_User'                 => new EE_Belongs_To_Relation(),
328 328
         ];
329 329
         // this model is generally available for reading
330
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
331
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form(
330
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
331
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form(
332 332
             'QST_system'
333 333
         );
334
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form(
334
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form(
335 335
                 'QST_system'
336 336
         );
337
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form(
337
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form(
338 338
                 'QST_system'
339 339
         );
340 340
 
@@ -383,10 +383,10 @@  discard block
 block discarded – undo
383 383
      */
384 384
     public function question_type_is_in_category(string $question_type, string $category): bool
385 385
     {
386
-        if (! isset($this->_question_type_categories[ $category ])) {
386
+        if ( ! isset($this->_question_type_categories[$category])) {
387 387
             return false;
388 388
         }
389
-        return in_array($question_type, $this->_question_type_categories[ $category ]);
389
+        return in_array($question_type, $this->_question_type_categories[$category]);
390 390
     }
391 391
 
392 392
 
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
      */
399 399
     public function question_types_in_category(string $category): array
400 400
     {
401
-        if (isset($this->_question_type_categories[ $category ])) {
402
-            return $this->_question_type_categories[ $category ];
401
+        if (isset($this->_question_type_categories[$category])) {
402
+            return $this->_question_type_categories[$category];
403 403
         }
404 404
         return [];
405 405
     }
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
     public function absolute_max_for_system_question(string $system_question_value)
565 565
     {
566 566
         $maxes = $this->system_question_maxes();
567
-        return $maxes[ $system_question_value ] ?? EE_INF;
567
+        return $maxes[$system_question_value] ?? EE_INF;
568 568
     }
569 569
 
570 570
 
Please login to merge, or discard this patch.
core/db_models/EEM_Currency_Payment_Method.model.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -9,54 +9,54 @@
 block discarded – undo
9 9
  */
10 10
 class EEM_Currency_Payment_Method extends EEM_Base
11 11
 {
12
-    /**
13
-     * @var EEM_Currency_Payment_Method
14
-     */
15
-    protected static $_instance;
12
+	/**
13
+	 * @var EEM_Currency_Payment_Method
14
+	 */
15
+	protected static $_instance;
16 16
 
17 17
 
18
-    /**
19
-     * EEM_Currency_Payment_Method constructor.
20
-     *
21
-     * @param string $timezone
22
-     * @throws EE_Error
23
-     */
24
-    protected function __construct(string $timezone = '')
25
-    {
26
-        $this->singular_item    = esc_html__('Currency Usable by Payment Method', 'event_espresso');
27
-        $this->plural_item      = esc_html__('Currencies Usable by Payment Methods', 'event_espresso');
28
-        $this->_tables          = [
29
-            'Currency_Payment_Method' => new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID'),
30
-        ];
31
-        $this->_fields          = [
32
-            'Currency_Payment_Method' => [
33
-                'CPM_ID'   => new EE_Primary_Key_Int_Field(
34
-                    'CPM_ID',
35
-                    esc_html__('Currency to Payment Method LInk ID', 'event_espresso')
36
-                ),
37
-                'CUR_code' => new EE_Foreign_Key_String_Field(
38
-                    'CUR_code',
39
-                    esc_html__('Currency Code', 'event_espresso'),
40
-                    false,
41
-                    '',
42
-                    'Currency'
43
-                ),
44
-                'PMD_ID'   => new EE_Foreign_Key_Int_Field(
45
-                    'PMD_ID',
46
-                    esc_html__('Payment Method ID', 'event_espresso'),
47
-                    false,
48
-                    0,
49
-                    'Payment_Method'
50
-                ),
51
-            ],
52
-        ];
53
-        $this->_model_relations = [
54
-            'Currency'       => new EE_Belongs_To_Relation(),
55
-            'Payment_Method' => new EE_Belongs_To_Relation(),
56
-        ];
57
-        // this model is generally available for reading
58
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
59
-        $this->_caps_slug                                         = 'payment_methods';
60
-        parent::__construct($timezone);
61
-    }
18
+	/**
19
+	 * EEM_Currency_Payment_Method constructor.
20
+	 *
21
+	 * @param string $timezone
22
+	 * @throws EE_Error
23
+	 */
24
+	protected function __construct(string $timezone = '')
25
+	{
26
+		$this->singular_item    = esc_html__('Currency Usable by Payment Method', 'event_espresso');
27
+		$this->plural_item      = esc_html__('Currencies Usable by Payment Methods', 'event_espresso');
28
+		$this->_tables          = [
29
+			'Currency_Payment_Method' => new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID'),
30
+		];
31
+		$this->_fields          = [
32
+			'Currency_Payment_Method' => [
33
+				'CPM_ID'   => new EE_Primary_Key_Int_Field(
34
+					'CPM_ID',
35
+					esc_html__('Currency to Payment Method LInk ID', 'event_espresso')
36
+				),
37
+				'CUR_code' => new EE_Foreign_Key_String_Field(
38
+					'CUR_code',
39
+					esc_html__('Currency Code', 'event_espresso'),
40
+					false,
41
+					'',
42
+					'Currency'
43
+				),
44
+				'PMD_ID'   => new EE_Foreign_Key_Int_Field(
45
+					'PMD_ID',
46
+					esc_html__('Payment Method ID', 'event_espresso'),
47
+					false,
48
+					0,
49
+					'Payment_Method'
50
+				),
51
+			],
52
+		];
53
+		$this->_model_relations = [
54
+			'Currency'       => new EE_Belongs_To_Relation(),
55
+			'Payment_Method' => new EE_Belongs_To_Relation(),
56
+		];
57
+		// this model is generally available for reading
58
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
59
+		$this->_caps_slug                                         = 'payment_methods';
60
+		parent::__construct($timezone);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
             'Payment_Method' => new EE_Belongs_To_Relation(),
56 56
         ];
57 57
         // this model is generally available for reading
58
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
58
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
59 59
         $this->_caps_slug                                         = 'payment_methods';
60 60
         parent::__construct($timezone);
61 61
     }
Please login to merge, or discard this patch.
core/db_models/EEM_Currency.model.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -9,104 +9,104 @@
 block discarded – undo
9 9
  */
10 10
 class EEM_Currency extends EEM_Base
11 11
 {
12
-    // private instance of the Attendee object
13
-    protected static $_instance;
12
+	// private instance of the Attendee object
13
+	protected static $_instance;
14 14
 
15
-    protected function __construct(string $timezone = '')
16
-    {
17
-        $this->singular_item    = esc_html__('Currency', 'event_espresso');
18
-        $this->plural_item      = esc_html__('Currencies', 'event_espresso');
19
-        $this->_tables          = [
20
-            'Currency' => new EE_Primary_Table('esp_currency', 'CUR_code'),
21
-        ];
22
-        $this->_fields          = [
23
-            'Currency' => [
24
-                'CUR_code'    => new EE_Primary_Key_String_Field(
25
-                    'CUR_code',
26
-                    esc_html__('Currency Code', 'event_espresso')
27
-                ),
28
-                'CUR_single'  => new EE_Plain_Text_Field(
29
-                    'CUR_single',
30
-                    esc_html__('Currency Name Singular', 'event_espresso'),
31
-                    false
32
-                ),
33
-                'CUR_plural'  => new EE_Plain_Text_Field(
34
-                    'CUR_plural',
35
-                    esc_html__('Currency Name Plural', 'event_espresso'),
36
-                    false
37
-                ),
38
-                'CUR_sign'    => new EE_Plain_Text_Field(
39
-                    'CUR_sign',
40
-                    esc_html__('Currency Sign', 'event_espresso'),
41
-                    false
42
-                ),
43
-                'CUR_dec_plc' => new EE_Integer_Field(
44
-                    'CUR_dec_plc',
45
-                    esc_html__('Currency Decimal Places', 'event_espresso'),
46
-                    false,
47
-                    2
48
-                ),
49
-                'CUR_active'  => new EE_Boolean_Field(
50
-                    'CUR_active',
51
-                    esc_html__('Active?', 'event_espresso'),
52
-                    false,
53
-                    true
54
-                ),
55
-            ],
56
-        ];
57
-        $this->_model_relations = [
58
-            'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
59
-        ];
60
-        // this model is generally available for reading
61
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
15
+	protected function __construct(string $timezone = '')
16
+	{
17
+		$this->singular_item    = esc_html__('Currency', 'event_espresso');
18
+		$this->plural_item      = esc_html__('Currencies', 'event_espresso');
19
+		$this->_tables          = [
20
+			'Currency' => new EE_Primary_Table('esp_currency', 'CUR_code'),
21
+		];
22
+		$this->_fields          = [
23
+			'Currency' => [
24
+				'CUR_code'    => new EE_Primary_Key_String_Field(
25
+					'CUR_code',
26
+					esc_html__('Currency Code', 'event_espresso')
27
+				),
28
+				'CUR_single'  => new EE_Plain_Text_Field(
29
+					'CUR_single',
30
+					esc_html__('Currency Name Singular', 'event_espresso'),
31
+					false
32
+				),
33
+				'CUR_plural'  => new EE_Plain_Text_Field(
34
+					'CUR_plural',
35
+					esc_html__('Currency Name Plural', 'event_espresso'),
36
+					false
37
+				),
38
+				'CUR_sign'    => new EE_Plain_Text_Field(
39
+					'CUR_sign',
40
+					esc_html__('Currency Sign', 'event_espresso'),
41
+					false
42
+				),
43
+				'CUR_dec_plc' => new EE_Integer_Field(
44
+					'CUR_dec_plc',
45
+					esc_html__('Currency Decimal Places', 'event_espresso'),
46
+					false,
47
+					2
48
+				),
49
+				'CUR_active'  => new EE_Boolean_Field(
50
+					'CUR_active',
51
+					esc_html__('Active?', 'event_espresso'),
52
+					false,
53
+					true
54
+				),
55
+			],
56
+		];
57
+		$this->_model_relations = [
58
+			'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
59
+		];
60
+		// this model is generally available for reading
61
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
62 62
 
63
-        parent::__construct($timezone);
64
-    }
63
+		parent::__construct($timezone);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * Gets all the active currencies, and orders them by their singular name, and then their code
69
-     * (may be overridden)
70
-     *
71
-     * @param array $query_params @see
72
-     *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
73
-     * @return EE_Currency[]
74
-     * @throws EE_Error
75
-     * @throws ReflectionException
76
-     */
77
-    public function get_all_active(array $query_params = []): array
78
-    {
79
-        $query_params[0]['CUR_active'] = true;
80
-        if (! isset($query_params['order_by'])) {
81
-            $query_params['order_by'] = ['CUR_code' => 'ASC', 'CUR_single' => 'ASC'];
82
-        }
83
-        return $this->get_all($query_params);
84
-    }
67
+	/**
68
+	 * Gets all the active currencies, and orders them by their singular name, and then their code
69
+	 * (may be overridden)
70
+	 *
71
+	 * @param array $query_params @see
72
+	 *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
73
+	 * @return EE_Currency[]
74
+	 * @throws EE_Error
75
+	 * @throws ReflectionException
76
+	 */
77
+	public function get_all_active(array $query_params = []): array
78
+	{
79
+		$query_params[0]['CUR_active'] = true;
80
+		if (! isset($query_params['order_by'])) {
81
+			$query_params['order_by'] = ['CUR_code' => 'ASC', 'CUR_single' => 'ASC'];
82
+		}
83
+		return $this->get_all($query_params);
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * Gets all the currencies which can be used by that payment method type
89
-     *
90
-     * @param EE_PMT_Base $payment_method_type
91
-     * @return EE_Currency[]
92
-     * @throws EE_Error
93
-     * @throws ReflectionException
94
-     */
95
-    public function get_all_currencies_usable_by(EE_PMT_Base $payment_method_type): array
96
-    {
97
-        if (
98
-            $payment_method_type instanceof EE_PMT_Base
99
-            && $payment_method_type->get_gateway()
100
-        ) {
101
-            $currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
102
-        } else {
103
-            $currencies_supported = EE_Gateway::all_currencies_supported;
104
-        }
105
-        if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
106
-            $currencies = $this->get_all_active();
107
-        } else {
108
-            $currencies = $this->get_all_active([['CUR_code' => ['IN', $currencies_supported]]]);
109
-        }
110
-        return $currencies;
111
-    }
87
+	/**
88
+	 * Gets all the currencies which can be used by that payment method type
89
+	 *
90
+	 * @param EE_PMT_Base $payment_method_type
91
+	 * @return EE_Currency[]
92
+	 * @throws EE_Error
93
+	 * @throws ReflectionException
94
+	 */
95
+	public function get_all_currencies_usable_by(EE_PMT_Base $payment_method_type): array
96
+	{
97
+		if (
98
+			$payment_method_type instanceof EE_PMT_Base
99
+			&& $payment_method_type->get_gateway()
100
+		) {
101
+			$currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
102
+		} else {
103
+			$currencies_supported = EE_Gateway::all_currencies_supported;
104
+		}
105
+		if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
106
+			$currencies = $this->get_all_active();
107
+		} else {
108
+			$currencies = $this->get_all_active([['CUR_code' => ['IN', $currencies_supported]]]);
109
+		}
110
+		return $currencies;
111
+	}
112 112
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
59 59
         ];
60 60
         // this model is generally available for reading
61
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
61
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
62 62
 
63 63
         parent::__construct($timezone);
64 64
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     public function get_all_active(array $query_params = []): array
78 78
     {
79 79
         $query_params[0]['CUR_active'] = true;
80
-        if (! isset($query_params['order_by'])) {
80
+        if ( ! isset($query_params['order_by'])) {
81 81
             $query_params['order_by'] = ['CUR_code' => 'ASC', 'CUR_single' => 'ASC'];
82 82
         }
83 83
         return $this->get_all($query_params);
Please login to merge, or discard this patch.
core/db_models/EEM_Ticket_Price.model.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -10,73 +10,73 @@
 block discarded – undo
10 10
 class EEM_Ticket_Price extends EEM_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @var EEM_Ticket_Price
15
-     */
16
-    protected static $_instance;
13
+	/**
14
+	 * @var EEM_Ticket_Price
15
+	 */
16
+	protected static $_instance;
17 17
 
18 18
 
19
-    /**
20
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
21
-     *                         (and any incoming timezone data that gets saved).
22
-     *                         Note this just sends the timezone info to the date time model field objects.
23
-     *                         Will use 'timezone_string' wp option if no value is provided
24
-     * @throws EE_Error
25
-     */
26
-    protected function __construct(string $timezone = '')
27
-    {
28
-        $this->singular_item = esc_html__('Ticket Price', 'event_espresso');
29
-        $this->plural_item = esc_html__('Ticket Prices', 'event_espresso');
19
+	/**
20
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
21
+	 *                         (and any incoming timezone data that gets saved).
22
+	 *                         Note this just sends the timezone info to the date time model field objects.
23
+	 *                         Will use 'timezone_string' wp option if no value is provided
24
+	 * @throws EE_Error
25
+	 */
26
+	protected function __construct(string $timezone = '')
27
+	{
28
+		$this->singular_item = esc_html__('Ticket Price', 'event_espresso');
29
+		$this->plural_item = esc_html__('Ticket Prices', 'event_espresso');
30 30
 
31
-        $this->_tables = array(
32
-            'Ticket_Price' => new EE_Primary_Table('esp_ticket_price', 'TKP_ID')
33
-        );
34
-        $this->_fields = array(
35
-            'Ticket_Price' => array(
36
-                'TKP_ID' => new EE_Primary_Key_Int_Field(
37
-                    'TKP_ID',
38
-                    esc_html__('Ticket Price ID', 'event_espresso')
39
-                ),
40
-                'TKT_ID' => new EE_Foreign_Key_Int_Field(
41
-                    'TKT_ID',
42
-                    esc_html__('Ticket Id', 'event_espresso'),
43
-                    false,
44
-                    0,
45
-                    'Ticket'
46
-                ),
47
-                'PRC_ID' => new EE_Foreign_Key_Int_Field(
48
-                    'PRC_ID',
49
-                    esc_html__('Price ID', 'event_espresso'),
50
-                    false,
51
-                    0,
52
-                    'Price'
53
-                ),
54
-            )
55
-        );
56
-        $this->_model_relations = array(
57
-            'Ticket' => new EE_Belongs_To_Relation(),
58
-            'Price' => new EE_Belongs_To_Relation()
59
-        );
60
-        $this->_model_chain_to_wp_user = 'Ticket';
61
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public(
62
-            'Ticket.TKT_is_default',
63
-            'Ticket.Datetime.Event'
64
-        );
65
-        // account for default tickets in the caps
66
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected(
67
-            'Ticket.TKT_is_default',
68
-            'Ticket.Datetime.Event'
69
-        );
70
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected(
71
-            'Ticket.TKT_is_default',
72
-            'Ticket.Datetime.Event'
73
-        );
74
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected(
75
-            'Ticket.TKT_is_default',
76
-            'Ticket.Datetime.Event'
77
-        );
78
-        // follow the caps of the ticket
79
-        $this->_caps_slug = 'tickets';
80
-        parent::__construct($timezone);
81
-    }
31
+		$this->_tables = array(
32
+			'Ticket_Price' => new EE_Primary_Table('esp_ticket_price', 'TKP_ID')
33
+		);
34
+		$this->_fields = array(
35
+			'Ticket_Price' => array(
36
+				'TKP_ID' => new EE_Primary_Key_Int_Field(
37
+					'TKP_ID',
38
+					esc_html__('Ticket Price ID', 'event_espresso')
39
+				),
40
+				'TKT_ID' => new EE_Foreign_Key_Int_Field(
41
+					'TKT_ID',
42
+					esc_html__('Ticket Id', 'event_espresso'),
43
+					false,
44
+					0,
45
+					'Ticket'
46
+				),
47
+				'PRC_ID' => new EE_Foreign_Key_Int_Field(
48
+					'PRC_ID',
49
+					esc_html__('Price ID', 'event_espresso'),
50
+					false,
51
+					0,
52
+					'Price'
53
+				),
54
+			)
55
+		);
56
+		$this->_model_relations = array(
57
+			'Ticket' => new EE_Belongs_To_Relation(),
58
+			'Price' => new EE_Belongs_To_Relation()
59
+		);
60
+		$this->_model_chain_to_wp_user = 'Ticket';
61
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public(
62
+			'Ticket.TKT_is_default',
63
+			'Ticket.Datetime.Event'
64
+		);
65
+		// account for default tickets in the caps
66
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected(
67
+			'Ticket.TKT_is_default',
68
+			'Ticket.Datetime.Event'
69
+		);
70
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected(
71
+			'Ticket.TKT_is_default',
72
+			'Ticket.Datetime.Event'
73
+		);
74
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected(
75
+			'Ticket.TKT_is_default',
76
+			'Ticket.Datetime.Event'
77
+		);
78
+		// follow the caps of the ticket
79
+		$this->_caps_slug = 'tickets';
80
+		parent::__construct($timezone);
81
+	}
82 82
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,20 +58,20 @@
 block discarded – undo
58 58
             'Price' => new EE_Belongs_To_Relation()
59 59
         );
60 60
         $this->_model_chain_to_wp_user = 'Ticket';
61
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public(
61
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public(
62 62
             'Ticket.TKT_is_default',
63 63
             'Ticket.Datetime.Event'
64 64
         );
65 65
         // account for default tickets in the caps
66
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected(
66
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected(
67 67
             'Ticket.TKT_is_default',
68 68
             'Ticket.Datetime.Event'
69 69
         );
70
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected(
70
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected(
71 71
             'Ticket.TKT_is_default',
72 72
             'Ticket.Datetime.Event'
73 73
         );
74
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected(
74
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected(
75 75
             'Ticket.TKT_is_default',
76 76
             'Ticket.Datetime.Event'
77 77
         );
Please login to merge, or discard this patch.
core/db_models/EEM_Ticket_Template.model.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -10,72 +10,72 @@
 block discarded – undo
10 10
 class EEM_Ticket_Template extends EEM_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @var EEM_Ticket_Template
15
-     */
16
-    protected static $_instance;
13
+	/**
14
+	 * @var EEM_Ticket_Template
15
+	 */
16
+	protected static $_instance;
17 17
 
18
-    /**
19
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
20
-     *                         (and any incoming timezone data that gets saved).
21
-     *                         Note this just sends the timezone info to the date time model field objects.
22
-     *                         Will use 'timezone_string' wp option if no value is provided
23
-     * @throws EE_Error
24
-     */
25
-    protected function __construct(string $timezone = '')
26
-    {
27
-        $this->singular_item = esc_html__('Ticket Template', 'event_espresso');
28
-        $this->plural_item = esc_html__('Ticket Templates', 'event_espresso');
18
+	/**
19
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
20
+	 *                         (and any incoming timezone data that gets saved).
21
+	 *                         Note this just sends the timezone info to the date time model field objects.
22
+	 *                         Will use 'timezone_string' wp option if no value is provided
23
+	 * @throws EE_Error
24
+	 */
25
+	protected function __construct(string $timezone = '')
26
+	{
27
+		$this->singular_item = esc_html__('Ticket Template', 'event_espresso');
28
+		$this->plural_item = esc_html__('Ticket Templates', 'event_espresso');
29 29
 
30
-        $this->_tables = array(
31
-            'Ticket_Template' => new EE_Primary_Table('esp_ticket_template', 'TTM_ID')
32
-        );
33
-        $this->_fields = array(
34
-            'Ticket_Template' => array(
35
-                'TTM_ID' => new EE_Primary_Key_Int_Field(
36
-                    'TTM_ID',
37
-                    esc_html__('Ticket Template ID', 'event_espresso')
38
-                ),
39
-                'TTM_name' => new EE_Plain_Text_Field(
40
-                    'TTM_name',
41
-                    esc_html__('The name of the ticket template', 'event_espresso'),
42
-                    false,
43
-                    ''
44
-                ),
45
-                'TTM_description' => new EE_Plain_Text_Field(
46
-                    'TTM_description',
47
-                    esc_html__('The description for the ticket template', 'event_espresso'),
48
-                    true,
49
-                    ''
50
-                ),
51
-                'TTM_file' => new EE_Plain_Text_Field(
52
-                    'TTM_file',
53
-                    esc_html__('The file name for the actual template file saved on disk', 'event_espresso'),
54
-                    true,
55
-                    ''
56
-                ),
57
-            ));
58
-        $this->_model_relations = array(
59
-            'Ticket' => new EE_Has_Many_Relation()
60
-        );
61
-        $this->_model_chain_to_wp_user = 'Ticket';
62
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public(
63
-            'Ticket.TKT_is_default',
64
-            'Ticket.Datetime.Event'
65
-        );
66
-        // account for default tickets in the caps
67
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected(
68
-            'Ticket.TKT_is_default',
69
-            'Ticket.Datetime.Event'
70
-        );
71
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected(
72
-            'Ticket.TKT_is_default',
73
-            'Ticket.Datetime.Event'
74
-        );
75
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected(
76
-            'Ticket.TKT_is_default',
77
-            'Ticket.Datetime.Event'
78
-        );
79
-        parent::__construct($timezone);
80
-    }
30
+		$this->_tables = array(
31
+			'Ticket_Template' => new EE_Primary_Table('esp_ticket_template', 'TTM_ID')
32
+		);
33
+		$this->_fields = array(
34
+			'Ticket_Template' => array(
35
+				'TTM_ID' => new EE_Primary_Key_Int_Field(
36
+					'TTM_ID',
37
+					esc_html__('Ticket Template ID', 'event_espresso')
38
+				),
39
+				'TTM_name' => new EE_Plain_Text_Field(
40
+					'TTM_name',
41
+					esc_html__('The name of the ticket template', 'event_espresso'),
42
+					false,
43
+					''
44
+				),
45
+				'TTM_description' => new EE_Plain_Text_Field(
46
+					'TTM_description',
47
+					esc_html__('The description for the ticket template', 'event_espresso'),
48
+					true,
49
+					''
50
+				),
51
+				'TTM_file' => new EE_Plain_Text_Field(
52
+					'TTM_file',
53
+					esc_html__('The file name for the actual template file saved on disk', 'event_espresso'),
54
+					true,
55
+					''
56
+				),
57
+			));
58
+		$this->_model_relations = array(
59
+			'Ticket' => new EE_Has_Many_Relation()
60
+		);
61
+		$this->_model_chain_to_wp_user = 'Ticket';
62
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public(
63
+			'Ticket.TKT_is_default',
64
+			'Ticket.Datetime.Event'
65
+		);
66
+		// account for default tickets in the caps
67
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected(
68
+			'Ticket.TKT_is_default',
69
+			'Ticket.Datetime.Event'
70
+		);
71
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected(
72
+			'Ticket.TKT_is_default',
73
+			'Ticket.Datetime.Event'
74
+		);
75
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected(
76
+			'Ticket.TKT_is_default',
77
+			'Ticket.Datetime.Event'
78
+		);
79
+		parent::__construct($timezone);
80
+	}
81 81
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@
 block discarded – undo
59 59
             'Ticket' => new EE_Has_Many_Relation()
60 60
         );
61 61
         $this->_model_chain_to_wp_user = 'Ticket';
62
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public(
62
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public(
63 63
             'Ticket.TKT_is_default',
64 64
             'Ticket.Datetime.Event'
65 65
         );
66 66
         // account for default tickets in the caps
67
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected(
67
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected(
68 68
             'Ticket.TKT_is_default',
69 69
             'Ticket.Datetime.Event'
70 70
         );
71
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected(
71
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected(
72 72
             'Ticket.TKT_is_default',
73 73
             'Ticket.Datetime.Event'
74 74
         );
75
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected(
75
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected(
76 76
             'Ticket.TKT_is_default',
77 77
             'Ticket.Datetime.Event'
78 78
         );
Please login to merge, or discard this patch.
core/db_models/EEM_Message_Template.model.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -9,65 +9,65 @@
 block discarded – undo
9 9
  */
10 10
 class EEM_Message_Template extends EEM_Base
11 11
 {
12
-    /**
13
-     * @var EEM_Message_Template
14
-     */
15
-    protected static $_instance;
12
+	/**
13
+	 * @var EEM_Message_Template
14
+	 */
15
+	protected static $_instance;
16 16
 
17 17
 
18
-    /**
19
-     * private constructor to prevent direct creation
20
-     *
21
-     * @param string $timezone
22
-     * @throws EE_Error
23
-     */
24
-    protected function __construct(string $timezone = '')
25
-    {
26
-        $this->singular_item = esc_html__('Message Template', 'event_espresso');
27
-        $this->plural_item   = esc_html__('Message Templates', 'event_espresso');
18
+	/**
19
+	 * private constructor to prevent direct creation
20
+	 *
21
+	 * @param string $timezone
22
+	 * @throws EE_Error
23
+	 */
24
+	protected function __construct(string $timezone = '')
25
+	{
26
+		$this->singular_item = esc_html__('Message Template', 'event_espresso');
27
+		$this->plural_item   = esc_html__('Message Templates', 'event_espresso');
28 28
 
29
-        $this->_tables = [
30
-            'Message_Template' => new EE_Primary_Table('esp_message_template', 'MTP_ID'),
31
-        ];
32
-        $this->_fields = [
33
-            'Message_Template' => [
34
-                'MTP_ID'             => new EE_Primary_Key_Int_Field(
35
-                    'MTP_ID',
36
-                    esc_html__('Message Template ID', 'event_espresso')),
37
-                'GRP_ID'             => new EE_Foreign_Key_Int_Field(
38
-                    'GRP_ID',
39
-                    esc_html__('Message Template Group ID', 'event_espresso'),
40
-                    false, 0, 'Message_Template_Group'
41
-                ),
42
-                'MTP_template_field' => new EE_Plain_Text_Field(
43
-                    'MTP_template_field',
44
-                    esc_html__('Field Name for this Template', 'event_espresso'),
45
-                    false,
46
-                    'default'
47
-                ),
48
-                'MTP_context'        => new EE_Plain_Text_Field(
49
-                    'MTP_context',
50
-                    esc_html__('Message Type Context for this field', 'event_espresso'),
51
-                    false,
52
-                    'admin'
53
-                ),
54
-                'MTP_content'        => new EE_Serialized_Text_Field(
55
-                    'MTP_content',
56
-                    esc_html__('The field content for the template', 'event_espresso'),
57
-                    false,
58
-                    ''
59
-                ),
60
-            ],
61
-        ];
29
+		$this->_tables = [
30
+			'Message_Template' => new EE_Primary_Table('esp_message_template', 'MTP_ID'),
31
+		];
32
+		$this->_fields = [
33
+			'Message_Template' => [
34
+				'MTP_ID'             => new EE_Primary_Key_Int_Field(
35
+					'MTP_ID',
36
+					esc_html__('Message Template ID', 'event_espresso')),
37
+				'GRP_ID'             => new EE_Foreign_Key_Int_Field(
38
+					'GRP_ID',
39
+					esc_html__('Message Template Group ID', 'event_espresso'),
40
+					false, 0, 'Message_Template_Group'
41
+				),
42
+				'MTP_template_field' => new EE_Plain_Text_Field(
43
+					'MTP_template_field',
44
+					esc_html__('Field Name for this Template', 'event_espresso'),
45
+					false,
46
+					'default'
47
+				),
48
+				'MTP_context'        => new EE_Plain_Text_Field(
49
+					'MTP_context',
50
+					esc_html__('Message Type Context for this field', 'event_espresso'),
51
+					false,
52
+					'admin'
53
+				),
54
+				'MTP_content'        => new EE_Serialized_Text_Field(
55
+					'MTP_content',
56
+					esc_html__('The field content for the template', 'event_espresso'),
57
+					false,
58
+					''
59
+				),
60
+			],
61
+		];
62 62
 
63
-        $this->_model_chain_to_wp_user = 'Message_Template_Group';
64
-        $this->_model_relations        = ['Message_Template_Group' => new EE_Belongs_To_Relation()];
65
-        foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
66
-            $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global(
67
-                'Message_Template_Group.MTP_is_global'
68
-            );
69
-        }
70
-        $this->_caps_slug = 'messages';
71
-        parent::__construct($timezone);
72
-    }
63
+		$this->_model_chain_to_wp_user = 'Message_Template_Group';
64
+		$this->_model_relations        = ['Message_Template_Group' => new EE_Belongs_To_Relation()];
65
+		foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
66
+			$this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global(
67
+				'Message_Template_Group.MTP_is_global'
68
+			);
69
+		}
70
+		$this->_caps_slug = 'messages';
71
+		parent::__construct($timezone);
72
+	}
73 73
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
         $this->_model_chain_to_wp_user = 'Message_Template_Group';
64 64
         $this->_model_relations        = ['Message_Template_Group' => new EE_Belongs_To_Relation()];
65 65
         foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
66
-            $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global(
66
+            $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_Global(
67 67
                 'Message_Template_Group.MTP_is_global'
68 68
             );
69 69
         }
Please login to merge, or discard this patch.
core/EE_Deprecated.core.php 2 patches
Indentation   +1215 added lines, -1215 removed lines patch added patch discarded remove patch
@@ -39,31 +39,31 @@  discard block
 block discarded – undo
39 39
  * @param string $action_or_filter
40 40
  */
41 41
 function deprecated_espresso_action_or_filter_doing_it_wrong(
42
-    $deprecated_filter,
43
-    $replacement,
44
-    $replacement_location,
45
-    $version_deprecated,
46
-    $version_applies,
47
-    $action_or_filter = 'action'
42
+	$deprecated_filter,
43
+	$replacement,
44
+	$replacement_location,
45
+	$version_deprecated,
46
+	$version_applies,
47
+	$action_or_filter = 'action'
48 48
 ) {
49
-    $action_or_filter = $action_or_filter === 'action'
50
-        ? esc_html__('action', 'event_espresso')
51
-        : esc_html__('filter', 'event_espresso');
52
-    EE_Error::doing_it_wrong(
53
-        $deprecated_filter,
54
-        sprintf(
55
-            __(
56
-                'This %1$s is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"',
57
-                'event_espresso'
58
-            ),
59
-            $action_or_filter,
60
-            $replacement,
61
-            $replacement_location,
62
-            '<br />'
63
-        ),
64
-        $version_deprecated,
65
-        $version_applies
66
-    );
49
+	$action_or_filter = $action_or_filter === 'action'
50
+		? esc_html__('action', 'event_espresso')
51
+		: esc_html__('filter', 'event_espresso');
52
+	EE_Error::doing_it_wrong(
53
+		$deprecated_filter,
54
+		sprintf(
55
+			__(
56
+				'This %1$s is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"',
57
+				'event_espresso'
58
+			),
59
+			$action_or_filter,
60
+			$replacement,
61
+			$replacement_location,
62
+			'<br />'
63
+		),
64
+		$version_deprecated,
65
+		$version_applies
66
+	);
67 67
 }
68 68
 
69 69
 /**
@@ -75,90 +75,90 @@  discard block
 block discarded – undo
75 75
  */
76 76
 function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout)
77 77
 {
78
-    // list of old filters
79
-    $deprecated_filters = array(
80
-        'update_registration_details' => true,
81
-        'process_payment'             => true,
82
-        'finalize_registration'       => true,
83
-        'and_proceed_to_payment'      => true,
84
-        'proceed_to'                  => true,
85
-    );
86
-    // loop thru and call doing_it_wrong() or remove any that aren't being used
87
-    foreach ($deprecated_filters as $deprecated_filter => $on) {
88
-        // was this filter called ?
89
-        if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
90
-            // only display doing_it_wrong() notice to Event Admins during non-AJAX requests
91
-            if (EE_Registry::instance()->CAP->current_user_can(
92
-                    'ee_read_ee',
93
-                    'hide_doing_it_wrong_for_deprecated_SPCO_filter'
94
-                ) && ! defined('DOING_AJAX')) {
95
-                EE_Error::doing_it_wrong(
96
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
97
-                    sprintf(
98
-                        __(
99
-                            'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
100
-                            'event_espresso'
101
-                        ),
102
-                        'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
103
-                        '<br />',
104
-                        'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
105
-                        '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
106
-                    ),
107
-                    '4.6.10'
108
-                );
109
-            }
110
-        } else {
111
-            unset($deprecated_filters[ $deprecated_filter ]);
112
-        }
113
-    }
114
-    if (! empty($deprecated_filters)) {
115
-
116
-        if ($checkout->current_step->slug(
117
-            ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
118
-            $submit_button_text = apply_filters(
119
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details',
120
-                $submit_button_text
121
-            );
122
-        } elseif ($checkout->current_step->slug(
123
-            ) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
124
-            $submit_button_text = apply_filters(
125
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment',
126
-                $submit_button_text
127
-            );
128
-        } elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug(
129
-            ) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
130
-            $submit_button_text = apply_filters(
131
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration',
132
-                $submit_button_text
133
-            );
134
-        }
135
-        if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
136
-            if ($checkout->payment_required() && $checkout->next_step->slug(
137
-                ) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
138
-                $submit_button_text .= apply_filters(
139
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment',
140
-                    $submit_button_text
141
-                );
142
-            }
143
-            if ($checkout->next_step->slug(
144
-                ) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
145
-                $submit_button_text = apply_filters(
146
-                                          'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
147
-                                          $submit_button_text
148
-                                      ) . $checkout->next_step->name();
149
-            }
150
-        }
151
-
152
-    }
153
-    return $submit_button_text;
78
+	// list of old filters
79
+	$deprecated_filters = array(
80
+		'update_registration_details' => true,
81
+		'process_payment'             => true,
82
+		'finalize_registration'       => true,
83
+		'and_proceed_to_payment'      => true,
84
+		'proceed_to'                  => true,
85
+	);
86
+	// loop thru and call doing_it_wrong() or remove any that aren't being used
87
+	foreach ($deprecated_filters as $deprecated_filter => $on) {
88
+		// was this filter called ?
89
+		if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
90
+			// only display doing_it_wrong() notice to Event Admins during non-AJAX requests
91
+			if (EE_Registry::instance()->CAP->current_user_can(
92
+					'ee_read_ee',
93
+					'hide_doing_it_wrong_for_deprecated_SPCO_filter'
94
+				) && ! defined('DOING_AJAX')) {
95
+				EE_Error::doing_it_wrong(
96
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
97
+					sprintf(
98
+						__(
99
+							'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
100
+							'event_espresso'
101
+						),
102
+						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
103
+						'<br />',
104
+						'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
105
+						'/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
106
+					),
107
+					'4.6.10'
108
+				);
109
+			}
110
+		} else {
111
+			unset($deprecated_filters[ $deprecated_filter ]);
112
+		}
113
+	}
114
+	if (! empty($deprecated_filters)) {
115
+
116
+		if ($checkout->current_step->slug(
117
+			) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
118
+			$submit_button_text = apply_filters(
119
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details',
120
+				$submit_button_text
121
+			);
122
+		} elseif ($checkout->current_step->slug(
123
+			) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
124
+			$submit_button_text = apply_filters(
125
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment',
126
+				$submit_button_text
127
+			);
128
+		} elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug(
129
+			) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
130
+			$submit_button_text = apply_filters(
131
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration',
132
+				$submit_button_text
133
+			);
134
+		}
135
+		if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
136
+			if ($checkout->payment_required() && $checkout->next_step->slug(
137
+				) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
138
+				$submit_button_text .= apply_filters(
139
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment',
140
+					$submit_button_text
141
+				);
142
+			}
143
+			if ($checkout->next_step->slug(
144
+				) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
145
+				$submit_button_text = apply_filters(
146
+										  'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
147
+										  $submit_button_text
148
+									  ) . $checkout->next_step->name();
149
+			}
150
+		}
151
+
152
+	}
153
+	return $submit_button_text;
154 154
 
155 155
 }
156 156
 
157 157
 add_filter(
158
-    'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
159
-    'ee_deprecated__registration_checkout__button_text',
160
-    10,
161
-    2
158
+	'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
159
+	'ee_deprecated__registration_checkout__button_text',
160
+	10,
161
+	2
162 162
 );
163 163
 
164 164
 
@@ -170,54 +170,54 @@  discard block
 block discarded – undo
170 170
  */
171 171
 function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates)
172 172
 {
173
-    $action_ref = null;
174
-    $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction')
175
-        ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
176
-    $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction')
177
-        ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
178
-    if ($action_ref) {
179
-
180
-        EE_Error::doing_it_wrong(
181
-            $action_ref,
182
-            sprintf(
183
-                __(
184
-                    'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"',
185
-                    'event_espresso'
186
-                ),
187
-                '<br />',
188
-                '/core/business/EE_Transaction_Processor.class.php',
189
-                'AHEE__EE_Transaction_Processor__finalize',
190
-                'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
191
-                'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
192
-                'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing'
193
-            ),
194
-            '4.6.0'
195
-        );
196
-        switch ($action_ref) {
197
-            case 'AHEE__EE_Transaction__finalize__new_transaction' :
198
-                do_action(
199
-                    'AHEE__EE_Transaction__finalize__new_transaction',
200
-                    $checkout->transaction,
201
-                    $checkout->admin_request
202
-                );
203
-                break;
204
-            case 'AHEE__EE_Transaction__finalize__all_transaction' :
205
-                do_action(
206
-                    'AHEE__EE_Transaction__finalize__new_transaction',
207
-                    $checkout->transaction,
208
-                    array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates),
209
-                    $checkout->admin_request
210
-                );
211
-                break;
212
-        }
213
-    }
173
+	$action_ref = null;
174
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction')
175
+		? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
176
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction')
177
+		? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
178
+	if ($action_ref) {
179
+
180
+		EE_Error::doing_it_wrong(
181
+			$action_ref,
182
+			sprintf(
183
+				__(
184
+					'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"',
185
+					'event_espresso'
186
+				),
187
+				'<br />',
188
+				'/core/business/EE_Transaction_Processor.class.php',
189
+				'AHEE__EE_Transaction_Processor__finalize',
190
+				'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
191
+				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
192
+				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing'
193
+			),
194
+			'4.6.0'
195
+		);
196
+		switch ($action_ref) {
197
+			case 'AHEE__EE_Transaction__finalize__new_transaction' :
198
+				do_action(
199
+					'AHEE__EE_Transaction__finalize__new_transaction',
200
+					$checkout->transaction,
201
+					$checkout->admin_request
202
+				);
203
+				break;
204
+			case 'AHEE__EE_Transaction__finalize__all_transaction' :
205
+				do_action(
206
+					'AHEE__EE_Transaction__finalize__new_transaction',
207
+					$checkout->transaction,
208
+					array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates),
209
+					$checkout->admin_request
210
+				);
211
+				break;
212
+		}
213
+	}
214 214
 }
215 215
 
216 216
 add_action(
217
-    'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
218
-    'ee_deprecated_finalize_transaction',
219
-    10,
220
-    2
217
+	'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
218
+	'ee_deprecated_finalize_transaction',
219
+	10,
220
+	2
221 221
 );
222 222
 /**
223 223
  * ee_deprecated_finalize_registration
@@ -226,35 +226,35 @@  discard block
 block discarded – undo
226 226
  */
227 227
 function ee_deprecated_finalize_registration(EE_Registration $registration)
228 228
 {
229
-    $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg')
230
-        ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null;
231
-    if ($action_ref) {
232
-        EE_Error::doing_it_wrong(
233
-            $action_ref,
234
-            sprintf(
235
-                __(
236
-                    'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"',
237
-                    'event_espresso'
238
-                ),
239
-                '<br />',
240
-                '/core/business/EE_Registration_Processor.class.php',
241
-                'AHEE__EE_Registration_Processor__trigger_registration_update_notifications'
242
-            ),
243
-            '4.6.0'
244
-        );
245
-        do_action(
246
-            'AHEE__EE_Registration__finalize__update_and_new_reg',
247
-            $registration,
248
-            (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))
249
-        );
250
-    }
229
+	$action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg')
230
+		? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null;
231
+	if ($action_ref) {
232
+		EE_Error::doing_it_wrong(
233
+			$action_ref,
234
+			sprintf(
235
+				__(
236
+					'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"',
237
+					'event_espresso'
238
+				),
239
+				'<br />',
240
+				'/core/business/EE_Registration_Processor.class.php',
241
+				'AHEE__EE_Registration_Processor__trigger_registration_update_notifications'
242
+			),
243
+			'4.6.0'
244
+		);
245
+		do_action(
246
+			'AHEE__EE_Registration__finalize__update_and_new_reg',
247
+			$registration,
248
+			(is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))
249
+		);
250
+	}
251 251
 }
252 252
 
253 253
 add_action(
254
-    'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
255
-    'ee_deprecated_finalize_registration',
256
-    10,
257
-    1
254
+	'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
255
+	'ee_deprecated_finalize_registration',
256
+	10,
257
+	1
258 258
 );
259 259
 
260 260
 
@@ -264,44 +264,44 @@  discard block
 block discarded – undo
264 264
  */
265 265
 function ee_deprecated_hooks()
266 266
 {
267
-    /**
268
-     * @var          $hooks       array where keys are hook names, and their values are array{
269
-     * @type string  $version     when deprecated
270
-     * @type string  $alternative saying what to use instead
271
-     * @type boolean $still_works whether or not the hook still works
272
-     *        }
273
-     */
274
-    $hooks = array(
275
-        'AHEE__EE_System___do_setup_validations' => array(
276
-            'version'     => '4.6.0',
277
-            'alternative' => __(
278
-                'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)',
279
-                'event_espresso'
280
-            ),
281
-            'still_works' => false,
282
-        ),
283
-    );
284
-    foreach ($hooks as $name => $deprecation_info) {
285
-        if (has_action($name)) {
286
-            EE_Error::doing_it_wrong(
287
-                $name,
288
-                sprintf(
289
-                    __('This filter is deprecated. %1$s%2$s', 'event_espresso'),
290
-                    $deprecation_info['still_works'] ? __(
291
-                        'It *may* work as an attempt to build in backwards compatibility.',
292
-                        'event_espresso'
293
-                    ) : __('It has been completely removed.', 'event_espresso'),
294
-                    isset($deprecation_info['alternative'])
295
-                        ? $deprecation_info['alternative']
296
-                        : __(
297
-                        'Please read the current EE4 documentation further or contact Support.',
298
-                        'event_espresso'
299
-                    )
300
-                ),
301
-                isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso')
302
-            );
303
-        }
304
-    }
267
+	/**
268
+	 * @var          $hooks       array where keys are hook names, and their values are array{
269
+	 * @type string  $version     when deprecated
270
+	 * @type string  $alternative saying what to use instead
271
+	 * @type boolean $still_works whether or not the hook still works
272
+	 *        }
273
+	 */
274
+	$hooks = array(
275
+		'AHEE__EE_System___do_setup_validations' => array(
276
+			'version'     => '4.6.0',
277
+			'alternative' => __(
278
+				'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)',
279
+				'event_espresso'
280
+			),
281
+			'still_works' => false,
282
+		),
283
+	);
284
+	foreach ($hooks as $name => $deprecation_info) {
285
+		if (has_action($name)) {
286
+			EE_Error::doing_it_wrong(
287
+				$name,
288
+				sprintf(
289
+					__('This filter is deprecated. %1$s%2$s', 'event_espresso'),
290
+					$deprecation_info['still_works'] ? __(
291
+						'It *may* work as an attempt to build in backwards compatibility.',
292
+						'event_espresso'
293
+					) : __('It has been completely removed.', 'event_espresso'),
294
+					isset($deprecation_info['alternative'])
295
+						? $deprecation_info['alternative']
296
+						: __(
297
+						'Please read the current EE4 documentation further or contact Support.',
298
+						'event_espresso'
299
+					)
300
+				),
301
+				isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso')
302
+			);
303
+		}
304
+	}
305 305
 }
306 306
 
307 307
 add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks');
@@ -316,34 +316,34 @@  discard block
 block discarded – undo
316 316
  */
317 317
 function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
318 318
 {
319
-    $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
320
-              || has_action(
321
-                  'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'
322
-              );
323
-    if ($in_use) {
324
-        $msg = __(
325
-            'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
326
-            . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
327
-            . 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end '
328
-            . 'to add other actions after a form submission has been received.',
329
-            'event_espresso'
330
-        );
331
-        EE_Error::doing_it_wrong(
332
-            __CLASS__ . '::' . __FUNCTION__,
333
-            $msg,
334
-            '4.8.32.rc.000'
335
-        );
336
-        // it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
337
-        if (is_admin() && ! defined('DOING_AJAX')) {
338
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
339
-        }
340
-    }
341
-    return $in_use;
319
+	$in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
320
+			  || has_action(
321
+				  'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'
322
+			  );
323
+	if ($in_use) {
324
+		$msg = __(
325
+			'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
326
+			. 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
327
+			. 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end '
328
+			. 'to add other actions after a form submission has been received.',
329
+			'event_espresso'
330
+		);
331
+		EE_Error::doing_it_wrong(
332
+			__CLASS__ . '::' . __FUNCTION__,
333
+			$msg,
334
+			'4.8.32.rc.000'
335
+		);
336
+		// it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
337
+		if (is_admin() && ! defined('DOING_AJAX')) {
338
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
339
+		}
340
+	}
341
+	return $in_use;
342 342
 }
343 343
 
344 344
 add_action(
345
-    'AHEE__Registrations_Admin_Page___registration_details_metabox__start',
346
-    'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'
345
+	'AHEE__Registrations_Admin_Page___registration_details_metabox__start',
346
+	'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'
347 347
 );
348 348
 
349 349
 /**
@@ -355,77 +355,77 @@  discard block
 block discarded – undo
355 355
  */
356 356
 function ee_deprecated_update_attendee_registration_form_old($admin_page)
357 357
 {
358
-    // check if the old hooks are in use. If not, do the default
359
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
360
-        || ! $admin_page instanceof EE_Admin_Page) {
361
-        return;
362
-    }
363
-    $req_data = $admin_page->get_request_data();
364
-    $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
365
-    $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
366
-    $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
367
-    if (! $REG_ID || ! $qstns) {
368
-        EE_Error::add_error(
369
-            __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
370
-            __FILE__,
371
-            __FUNCTION__,
372
-            __LINE__
373
-        );
374
-    }
375
-    $success = true;
376
-
377
-    // allow others to get in on this awesome fun   :D
378
-    do_action(
379
-        'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save',
380
-        $REG_ID,
381
-        $qstns
382
-    );
383
-    // loop thru questions... FINALLY!!!
384
-
385
-    foreach ($qstns as $QST_ID => $qstn) {
386
-        // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
387
-        if (! is_array($qstn)) {
388
-            $success = EE_Answer::new_instance([ 'QST_ID' => $QST_ID, 'REG_ID' => $REG_ID ]);
389
-            continue;
390
-        }
391
-
392
-
393
-        foreach ($qstn as $ANS_ID => $ANS_value) {
394
-            // get answer
395
-            $query_params = array(
396
-                0 => array(
397
-                    'ANS_ID' => $ANS_ID,
398
-                    'REG_ID' => $REG_ID,
399
-                    'QST_ID' => $QST_ID,
400
-                ),
401
-            );
402
-            $answer = EEM_Answer::instance()->get_one($query_params);
403
-            // this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
404
-            if (! $answer instanceof EE_Answer) {
405
-                $set_values = array(
406
-                    'QST_ID'    => $QST_ID,
407
-                    'REG_ID'    => $REG_ID,
408
-                    'ANS_value' => $qstn,
409
-                );
410
-                $success = EEM_Answer::instance()->insert($set_values);
411
-                continue 2;
412
-            }
413
-
414
-            $answer->set('ANS_value', $ANS_value);
415
-            $success = $answer->save();
416
-        }
417
-    }
418
-    $what = __('Registration Form', 'event_espresso');
419
-    $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
420
-    $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
421
-    exit;
358
+	// check if the old hooks are in use. If not, do the default
359
+	if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
360
+		|| ! $admin_page instanceof EE_Admin_Page) {
361
+		return;
362
+	}
363
+	$req_data = $admin_page->get_request_data();
364
+	$qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
365
+	$REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
366
+	$qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
367
+	if (! $REG_ID || ! $qstns) {
368
+		EE_Error::add_error(
369
+			__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
370
+			__FILE__,
371
+			__FUNCTION__,
372
+			__LINE__
373
+		);
374
+	}
375
+	$success = true;
376
+
377
+	// allow others to get in on this awesome fun   :D
378
+	do_action(
379
+		'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save',
380
+		$REG_ID,
381
+		$qstns
382
+	);
383
+	// loop thru questions... FINALLY!!!
384
+
385
+	foreach ($qstns as $QST_ID => $qstn) {
386
+		// if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
387
+		if (! is_array($qstn)) {
388
+			$success = EE_Answer::new_instance([ 'QST_ID' => $QST_ID, 'REG_ID' => $REG_ID ]);
389
+			continue;
390
+		}
391
+
392
+
393
+		foreach ($qstn as $ANS_ID => $ANS_value) {
394
+			// get answer
395
+			$query_params = array(
396
+				0 => array(
397
+					'ANS_ID' => $ANS_ID,
398
+					'REG_ID' => $REG_ID,
399
+					'QST_ID' => $QST_ID,
400
+				),
401
+			);
402
+			$answer = EEM_Answer::instance()->get_one($query_params);
403
+			// this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
404
+			if (! $answer instanceof EE_Answer) {
405
+				$set_values = array(
406
+					'QST_ID'    => $QST_ID,
407
+					'REG_ID'    => $REG_ID,
408
+					'ANS_value' => $qstn,
409
+				);
410
+				$success = EEM_Answer::instance()->insert($set_values);
411
+				continue 2;
412
+			}
413
+
414
+			$answer->set('ANS_value', $ANS_value);
415
+			$success = $answer->save();
416
+		}
417
+	}
418
+	$what = __('Registration Form', 'event_espresso');
419
+	$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
420
+	$admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
421
+	exit;
422 422
 }
423 423
 
424 424
 add_action(
425
-    'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start',
426
-    'ee_deprecated_update_attendee_registration_form_old',
427
-    10,
428
-    1
425
+	'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start',
426
+	'ee_deprecated_update_attendee_registration_form_old',
427
+	10,
428
+	1
429 429
 );
430 430
 /**
431 431
  * Render the registration admin page's custom questions area in the old fashion
@@ -441,48 +441,48 @@  discard block
 block discarded – undo
441 441
  */
442 442
 function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration)
443 443
 {
444
-    // check if the old hooks are in use. If not, do the default
445
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
446
-        || ! $admin_page instanceof EE_Admin_Page) {
447
-        return $do_default_action;
448
-    }
449
-    add_filter(
450
-        'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
451
-        array($admin_page, 'form_before_question_group'),
452
-        10,
453
-        1
454
-    );
455
-    add_filter(
456
-        'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
457
-        array($admin_page, 'form_after_question_group'),
458
-        10,
459
-        1
460
-    );
461
-    add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
462
-    add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
463
-
464
-    $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options(
465
-        $registration,
466
-        $registration->get('EVT_ID')
467
-    );
468
-
469
-    EE_Registry::instance()->load_helper('Form_Fields');
470
-    $template_args = array(
471
-        'att_questions'             => EEH_Form_Fields::generate_question_groups_html($question_groups),
472
-        'reg_questions_form_action' => 'edit_registration',
473
-        'REG_ID'                    => $registration->ID(),
474
-    );
475
-    $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
476
-    echo EEH_Template::display_template($template_path, $template_args, true);
477
-    // indicate that we should not do the default admin page code
478
-    return false;
444
+	// check if the old hooks are in use. If not, do the default
445
+	if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
446
+		|| ! $admin_page instanceof EE_Admin_Page) {
447
+		return $do_default_action;
448
+	}
449
+	add_filter(
450
+		'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
451
+		array($admin_page, 'form_before_question_group'),
452
+		10,
453
+		1
454
+	);
455
+	add_filter(
456
+		'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
457
+		array($admin_page, 'form_after_question_group'),
458
+		10,
459
+		1
460
+	);
461
+	add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
462
+	add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
463
+
464
+	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options(
465
+		$registration,
466
+		$registration->get('EVT_ID')
467
+	);
468
+
469
+	EE_Registry::instance()->load_helper('Form_Fields');
470
+	$template_args = array(
471
+		'att_questions'             => EEH_Form_Fields::generate_question_groups_html($question_groups),
472
+		'reg_questions_form_action' => 'edit_registration',
473
+		'REG_ID'                    => $registration->ID(),
474
+	);
475
+	$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
476
+	echo EEH_Template::display_template($template_path, $template_args, true);
477
+	// indicate that we should not do the default admin page code
478
+	return false;
479 479
 }
480 480
 
481 481
 add_action(
482
-    'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
483
-    'ee_deprecated_reg_questions_meta_box_old',
484
-    10,
485
-    3
482
+	'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
483
+	'ee_deprecated_reg_questions_meta_box_old',
484
+	10,
485
+	3
486 486
 );
487 487
 
488 488
 
@@ -499,42 +499,42 @@  discard block
 block discarded – undo
499 499
 class EE_Message_Template_Defaults extends EE_Base
500 500
 {
501 501
 
502
-    /**
503
-     * EE_Message_Template_Defaults constructor.
504
-     *
505
-     * @param EE_messages $messages
506
-     * @param             $messenger_name
507
-     * @param             $message_type_name
508
-     * @param int         $GRP_ID
509
-     * @return EE_Messages_Template_Defaults
510
-     */
511
-    public function __construct(
512
-        EE_messages $messages,
513
-        $messenger_name,
514
-        $message_type_name,
515
-        $GRP_ID = 0
516
-    ) {
517
-        EE_Error::doing_it_wrong(
518
-            __FUNCTION__,
519
-            __(
520
-                'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.',
521
-                'event_espresso'
522
-            ),
523
-            '4.9.0'
524
-        );
525
-        /** @var EE_Message_Resource_Manager $message_resource_manager */
526
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
527
-        $messenger = $message_resource_manager->get_messenger($messenger_name);
528
-        $message_type = $message_resource_manager->get_message_type($message_type_name);
529
-        return EE_Registry::instance()->load_lib(
530
-            'Messages_Template_Defaults',
531
-            array(
532
-                $GRP_ID,
533
-                $messenger,
534
-                $message_type,
535
-            )
536
-        );
537
-    }
502
+	/**
503
+	 * EE_Message_Template_Defaults constructor.
504
+	 *
505
+	 * @param EE_messages $messages
506
+	 * @param             $messenger_name
507
+	 * @param             $message_type_name
508
+	 * @param int         $GRP_ID
509
+	 * @return EE_Messages_Template_Defaults
510
+	 */
511
+	public function __construct(
512
+		EE_messages $messages,
513
+		$messenger_name,
514
+		$message_type_name,
515
+		$GRP_ID = 0
516
+	) {
517
+		EE_Error::doing_it_wrong(
518
+			__FUNCTION__,
519
+			__(
520
+				'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.',
521
+				'event_espresso'
522
+			),
523
+			'4.9.0'
524
+		);
525
+		/** @var EE_Message_Resource_Manager $message_resource_manager */
526
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
527
+		$messenger = $message_resource_manager->get_messenger($messenger_name);
528
+		$message_type = $message_resource_manager->get_message_type($message_type_name);
529
+		return EE_Registry::instance()->load_lib(
530
+			'Messages_Template_Defaults',
531
+			array(
532
+				$GRP_ID,
533
+				$messenger,
534
+				$message_type,
535
+			)
536
+		);
537
+	}
538 538
 }
539 539
 
540 540
 
@@ -552,525 +552,525 @@  discard block
 block discarded – undo
552 552
 class EE_messages
553 553
 {
554 554
 
555
-    /** @type EE_messenger[] */
556
-    protected $_active_messengers = array();
557
-
558
-    /** @type array */
559
-    protected $_active_message_types = array();
560
-
561
-    /** @type EE_message_type[] */
562
-    protected $_installed_message_types = array();
563
-
564
-    /** @type EE_messenger */
565
-    protected $_messenger;
566
-
567
-    /** @type EE_message_type */
568
-    protected $_message_type;
569
-
570
-    /** @type array */
571
-    protected $_contexts = array();
572
-
573
-    /** @type EE_Message_Resource_Manager $_message_resource_manager */
574
-    protected $_message_resource_manager;
575
-
576
-
577
-    /**
578
-     * EE_messages constructor.
579
-     *
580
-     * @deprecated 4.9.0
581
-     */
582
-    public function __construct()
583
-    {
584
-    }
585
-
586
-
587
-    /**
588
-     * @param string $method
589
-     */
590
-    public function _class_is_deprecated($method)
591
-    {
592
-        EE_Error::doing_it_wrong(
593
-            'EE_messages::' . $method,
594
-            __('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
595
-            '4.9.0',
596
-            '4.10.0.p'
597
-        );
598
-        // Please use EE_Message_Resource_Manager instead
599
-        $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
600
-    }
601
-
602
-
603
-    /**
604
-     * @deprecated 4.9.0
605
-     * @param string $messenger_name
606
-     * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
607
-     */
608
-    public function ensure_messenger_is_active($messenger_name)
609
-    {
610
-        // EE_messages has been deprecated
611
-        $this->_class_is_deprecated(__FUNCTION__);
612
-        return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
613
-    }
614
-
615
-
616
-    /**
617
-     * @deprecated 4.9.0
618
-     * @param string $message_type message type name
619
-     * @param        $messenger
620
-     * @return bool true if it got activated (or was active) and false if not.
621
-     * @throws \EE_Error
622
-     */
623
-    public function ensure_message_type_is_active($message_type, $messenger)
624
-    {
625
-        // EE_messages has been deprecated
626
-        $this->_class_is_deprecated(__FUNCTION__);
627
-        return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
628
-    }
629
-
630
-
631
-    /**
632
-     * @deprecated 4.9.0
633
-     * @param string $messenger_name
634
-     * @param array  $mts_to_activate             (optional) An array of message types to activate with this messenger.
635
-     *                                             If included we do NOT setup the default message types (assuming they
636
-     *                                             are already setup.)
637
-     * @return boolean an array of generated templates or false if nothing generated/activated.
638
-     */
639
-    public function activate_messenger($messenger_name, $mts_to_activate = array())
640
-    {
641
-        // EE_messages has been deprecated
642
-        $this->_class_is_deprecated(__FUNCTION__);
643
-        return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
644
-    }
645
-
646
-
647
-    /**
648
-     * @deprecated 4.9.0
649
-     * @param EE_messenger    $messenger    messenger used in trigger
650
-     * @param EE_message_type $message_type message type used in trigger
651
-     *
652
-     * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
653
-     */
654
-    public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type)
655
-    {
656
-        // EE_messages has been deprecated
657
-        $this->_class_is_deprecated(__FUNCTION__);
658
-        return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
659
-    }
660
-
661
-
662
-    /**
663
-     * @deprecated 4.9.0
664
-     * @param string $messenger
665
-     * @return EE_messenger | null
666
-     */
667
-    public function get_messenger_if_active($messenger)
668
-    {
669
-        // EE_messages has been deprecated
670
-        $this->_class_is_deprecated(__FUNCTION__);
671
-        return $this->_message_resource_manager->get_active_messenger($messenger);
672
-    }
673
-
674
-
675
-    /**
676
-     * @deprecated 4.9.0
677
-     * @param EE_Message $message
678
-     * @return array  An array with 'messenger' and 'message_type' as the index and the corresponding valid object if
679
-     *                  available.
680
-     *                  Eg. Valid Messenger and Message Type:
681
-     *                  array(
682
-     *                  'messenger' => new EE_Email_messenger(),
683
-     *                  'message_type' => new EE_Registration_Approved_message_type()
684
-     *                  )
685
-     *                  Valid Messenger and Invalid Message Type:
686
-     *                  array(
687
-     *                  'messenger' => new EE_Email_messenger(),
688
-     *                  'message_type' => null
689
-     *                  )
690
-     */
691
-    public function validate_for_use(EE_Message $message)
692
-    {
693
-        // EE_messages has been deprecated
694
-        $this->_class_is_deprecated(__FUNCTION__);
695
-        return array(
696
-            'messenger'    => $message->messenger_object(),
697
-            'message_type' => $message->message_type_object(),
698
-        );
699
-    }
700
-
701
-
702
-    /**
703
-     * @deprecated 4.9.0
704
-     * @param  string $type                 What type of message are we sending (corresponds to message types)
705
-     * @param  mixed  $vars                 Data being sent for parsing in the message
706
-     * @param  string $sending_messenger    if included then we ONLY use the specified messenger for delivery.
707
-     *                                      Otherwise we cycle through all active messengers.
708
-     * @param string  $generating_messenger if included then this messenger is used for generating the message
709
-     *                                      templates (but not for sending).
710
-     * @param string  $context              If included then only a message type for a specific context will be
711
-     *                                      generated.
712
-     * @param bool    $send                 Default TRUE.  If false, then this will just return the generated
713
-     *                                      EE_messages objects which might be used by the trigger to setup a batch
714
-     *                                      message (typically html messenger uses it).
715
-     * @return bool
716
-     */
717
-    public function send_message(
718
-        $type,
719
-        $vars,
720
-        $sending_messenger = '',
721
-        $generating_messenger = '',
722
-        $context = '',
723
-        $send = true
724
-    ) {
725
-        // EE_messages has been deprecated
726
-        $this->_class_is_deprecated(__FUNCTION__);
727
-        /** @type EE_Messages_Processor $processor */
728
-        $processor = EE_Registry::instance()->load_lib('Messages_Processor');
729
-        $error = false;
730
-        // try to intelligently determine what method we'll call based on the incoming data.
731
-        // if generating and sending are different then generate and send immediately.
732
-        if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
733
-            // in the legacy system, when generating and sending were different, that means all the
734
-            // vars are already in the request object.  So let's just use that.
735
-            try {
736
-                /** @type EE_Message_To_Generate_From_Request $mtg */
737
-                $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
738
-                $processor->generate_and_send_now($mtg);
739
-            } catch (EE_Error $e) {
740
-                $error_msg = __(
741
-                    'Please note that a system message failed to send due to a technical issue.',
742
-                    'event_espresso'
743
-                );
744
-                // add specific message for developers if WP_DEBUG in on
745
-                $error_msg .= '||' . $e->getMessage();
746
-                EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
747
-                $error = true;
748
-            }
749
-        } else {
750
-            $processor->generate_for_all_active_messengers($type, $vars, $send);
751
-            // let's find out if there were any errors and how many successfully were queued.
752
-            $count_errors = $processor->get_queue()->count_STS_in_queue(
753
-                array(EEM_Message::status_failed, EEM_Message::status_debug_only)
754
-            );
755
-            $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
756
-            $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
757
-            $count_errors = $count_errors + $count_retry;
758
-            if ($count_errors > 0) {
759
-                $error = true;
760
-                if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
761
-                    $message = sprintf(
762
-                        __(
763
-                            'There were %d errors and %d messages successfully queued for generation and sending',
764
-                            'event_espresso'
765
-                        ),
766
-                        $count_errors,
767
-                        $count_queued
768
-                    );
769
-                } elseif ($count_errors > 1 && $count_queued === 1) {
770
-                    $message = sprintf(
771
-                        __(
772
-                            'There were %d errors and %d message successfully queued for generation.',
773
-                            'event_espresso'
774
-                        ),
775
-                        $count_errors,
776
-                        $count_queued
777
-                    );
778
-                } elseif ($count_errors === 1 && $count_queued > 1) {
779
-                    $message = sprintf(
780
-                        __(
781
-                            'There was %d error and %d messages successfully queued for generation.',
782
-                            'event_espresso'
783
-                        ),
784
-                        $count_errors,
785
-                        $count_queued
786
-                    );
787
-                } else {
788
-                    $message = sprintf(
789
-                        __(
790
-                            'There was %d message that failed to be queued for generation.',
791
-                            'event_espresso'
792
-                        ),
793
-                        $count_errors
794
-                    );
795
-                }
796
-                EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
797
-            } else {
798
-                if ($count_queued === 1) {
799
-                    $message = sprintf(
800
-                        __(
801
-                            '%d message successfully queued for generation.',
802
-                            'event_espresso'
803
-                        ),
804
-                        $count_queued
805
-                    );
806
-                } else {
807
-                    $message = sprintf(
808
-                        __(
809
-                            '%d messages were successfully queued for generation.',
810
-                            'event_espresso'
811
-                        ),
812
-                        $count_queued
813
-                    );
814
-                }
815
-                EE_Error::add_success($message);
816
-            }
817
-        }
818
-        // if no error then return the generated message(s).
819
-        if (! $error && ! $send) {
820
-            $generated_queue = $processor->generate_queue(false);
821
-            // get message and return.
822
-            $generated_queue->get_message_repository()->rewind();
823
-            $messages = array();
824
-            while ($generated_queue->get_message_repository()->valid()) {
825
-                $message = $generated_queue->get_message_repository()->current();
826
-                if ($message instanceof EE_Message) {
827
-                    // set properties that might be expected by add-ons (backward compat)
828
-                    $message->content = $message->content();
829
-                    $message->template_pack = $message->get_template_pack();
830
-                    $message->template_variation = $message->get_template_pack_variation();
831
-                    $messages[] = $message;
832
-                }
833
-                $generated_queue->get_message_repository()->next();
834
-            }
835
-            return $messages;
836
-        }
837
-        return $error ? false
838
-            : true; // yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
839
-    }
840
-
841
-
842
-    /**
843
-     * @deprecated 4.9.0
844
-     * @param  string $type      This should correspond with a valid message type
845
-     * @param  string $context   This should correspond with a valid context for the message type
846
-     * @param  string $messenger This should correspond with a valid messenger.
847
-     * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
848
-     *                           preview
849
-     * @return string          The body of the message.
850
-     */
851
-    public function preview_message($type, $context, $messenger, $send = false)
852
-    {
853
-        // EE_messages has been deprecated
854
-        $this->_class_is_deprecated(__FUNCTION__);
855
-        return EED_Messages::preview_message($type, $context, $messenger, $send);
856
-    }
857
-
858
-
859
-    /**
860
-     * @since      4.5.0
861
-     * @deprecated 4.9.0   Moved to EED_Messages Module
862
-     * @param string   $messenger    a string matching a valid active messenger in the system
863
-     * @param string   $message_type Although it seems contrary to the name of the method, a message type name is still
864
-     *                               required to send along the message type to the messenger because this is used for
865
-     *                               determining what specific variations might be loaded for the generated message.
866
-     * @param stdClass $message      a stdClass object in the format expected by the messenger.
867
-     *
868
-     * @return bool          success or fail.
869
-     */
870
-    public function send_message_with_messenger_only($messenger, $message_type, $message)
871
-    {
872
-        // EE_messages has been deprecated
873
-        $this->_class_is_deprecated(__FUNCTION__);
874
-        // setup for sending to new method.
875
-        /** @type EE_Messages_Queue $queue */
876
-        $queue = EE_Registry::instance()->load_lib('Messages_Queue');
877
-        // make sure we have a proper message object
878
-        if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
879
-            $msg = EE_Message_Factory::create(
880
-                array(
881
-                    'MSG_messenger'    => $messenger,
882
-                    'MSG_message_type' => $message_type,
883
-                    'MSG_content'      => $message->content,
884
-                    'MSG_subject'      => $message->subject,
885
-                )
886
-            );
887
-        } else {
888
-            $msg = $message;
889
-        }
890
-        if (! $msg instanceof EE_Message) {
891
-            return false;
892
-        }
893
-        // make sure any content in a content property (if not empty) is set on the MSG_content.
894
-        if (! empty($msg->content)) {
895
-            $msg->set('MSG_content', $msg->content);
896
-        }
897
-        $queue->add($msg);
898
-        return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
899
-    }
900
-
901
-
902
-    /**
903
-     * @deprecated 4.9.0
904
-     * @param         $messenger
905
-     * @param  string $message_type message type that the templates are being created for
906
-     * @param int     $GRP_ID
907
-     * @param bool    $is_global
908
-     * @return array|object if creation is successful then we return an array of info, otherwise an error_object is
909
-     *                      returned.
910
-     * @throws \EE_Error
911
-     */
912
-    public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false)
913
-    {
914
-        // EE_messages has been deprecated
915
-        $this->_class_is_deprecated(__FUNCTION__);
916
-        EE_Registry::instance()->load_helper('MSG_Template');
917
-        return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
918
-    }
919
-
920
-
921
-    /**
922
-     * @deprecated 4.9.0
923
-     * @param  string $messenger_name    name of EE_messenger
924
-     * @param  string $message_type_name name of EE_message_type
925
-     * @return array
926
-     */
927
-    public function get_fields($messenger_name, $message_type_name)
928
-    {
929
-        // EE_messages has been deprecated
930
-        $this->_class_is_deprecated(__FUNCTION__);
931
-        EE_Registry::instance()->load_helper('MSG_Template');
932
-        return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
933
-    }
934
-
935
-
936
-    /**
937
-     * @deprecated 4.9.0
938
-     * @access     public
939
-     * @param string $type                we can indicate just returning installed message types
940
-     *                                    or messengers (or both) via this parameter.
941
-     * @param bool   $skip_cache          if true then we skip the cache and retrieve via files.
942
-     * @return array                    multidimensional array of messenger and message_type objects
943
-     *                                    (messengers index, and message_type index);
944
-     */
945
-    public function get_installed($type = 'all', $skip_cache = false)
946
-    {
947
-        // EE_messages has been deprecated
948
-        $this->_class_is_deprecated(__FUNCTION__);
949
-        if ($skip_cache) {
950
-            $this->_message_resource_manager->reset_active_messengers_and_message_types();
951
-        }
952
-        switch ($type) {
953
-            case 'messengers' :
954
-                return array(
955
-                    'messenger' => $this->_message_resource_manager->installed_messengers(),
956
-                );
957
-                break;
958
-            case 'message_types' :
959
-                return array(
960
-                    'message_type' => $this->_message_resource_manager->installed_message_types(),
961
-                );
962
-                break;
963
-            case 'all' :
964
-            default :
965
-                return array(
966
-                    'messenger'    => $this->_message_resource_manager->installed_messengers(),
967
-                    'message_type' => $this->_message_resource_manager->installed_message_types(),
968
-                );
969
-                break;
970
-        }
971
-    }
972
-
973
-
974
-    /**
975
-     * @deprecated 4.9.0
976
-     * @return \EE_messenger[]
977
-     */
978
-    public function get_active_messengers()
979
-    {
980
-        // EE_messages has been deprecated
981
-        $this->_class_is_deprecated(__FUNCTION__);
982
-        return $this->_message_resource_manager->active_messengers();
983
-    }
984
-
985
-
986
-    /**
987
-     * @deprecated 4.9.0
988
-     * @return array array of message_type references (string)
989
-     */
990
-    public function get_active_message_types()
991
-    {
992
-        // EE_messages has been deprecated
993
-        $this->_class_is_deprecated(__FUNCTION__);
994
-        return $this->_message_resource_manager->list_of_active_message_types();
995
-    }
996
-
997
-
998
-    /**
999
-     * @deprecated 4.9.0
1000
-     * @return EE_message_type[]
1001
-     */
1002
-    public function get_active_message_type_objects()
1003
-    {
1004
-        // EE_messages has been deprecated
1005
-        $this->_class_is_deprecated(__FUNCTION__);
1006
-        return $this->_message_resource_manager->get_active_message_type_objects();
1007
-    }
1008
-
1009
-
1010
-    /**
1011
-     * @deprecated 4.9.0
1012
-     * @since      4.5.0
1013
-     * @param string $messenger The messenger being checked
1014
-     * @return EE_message_type[]    (or empty array if none present)
1015
-     */
1016
-    public function get_active_message_types_per_messenger($messenger)
1017
-    {
1018
-        // EE_messages has been deprecated
1019
-        $this->_class_is_deprecated(__FUNCTION__);
1020
-        return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
1021
-    }
1022
-
1023
-
1024
-    /**
1025
-     * @deprecated 4.9.0
1026
-     * @param string $messenger    The string should correspond to the messenger (message types are
1027
-     * @param string $message_type The string should correspond to a message type.
1028
-     * @return EE_message_type|null
1029
-     */
1030
-    public function get_active_message_type($messenger, $message_type)
1031
-    {
1032
-        // EE_messages has been deprecated
1033
-        $this->_class_is_deprecated(__FUNCTION__);
1034
-        return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
1035
-    }
1036
-
1037
-
1038
-    /**
1039
-     * @deprecated 4.9.0
1040
-     * @return array|\EE_message_type[]
1041
-     */
1042
-    public function get_installed_message_types()
1043
-    {
1044
-        // EE_messages has been deprecated
1045
-        $this->_class_is_deprecated(__FUNCTION__);
1046
-        return $this->_message_resource_manager->installed_message_types();
1047
-    }
1048
-
1049
-
1050
-    /**
1051
-     * @deprecated 4.9.0
1052
-     * @return array
1053
-     */
1054
-    public function get_installed_messengers()
1055
-    {
1056
-        // EE_messages has been deprecated
1057
-        $this->_class_is_deprecated(__FUNCTION__);
1058
-        return $this->_message_resource_manager->installed_messengers();
1059
-    }
1060
-
1061
-
1062
-    /**
1063
-     * @deprecated 4.9.0
1064
-     * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by
1065
-     *                           message type.
1066
-     * @return array
1067
-     */
1068
-    public function get_all_contexts($slugs_only = true)
1069
-    {
1070
-        // EE_messages has been deprecated
1071
-        $this->_class_is_deprecated(__FUNCTION__);
1072
-        return $this->_message_resource_manager->get_all_contexts($slugs_only);
1073
-    }
555
+	/** @type EE_messenger[] */
556
+	protected $_active_messengers = array();
557
+
558
+	/** @type array */
559
+	protected $_active_message_types = array();
560
+
561
+	/** @type EE_message_type[] */
562
+	protected $_installed_message_types = array();
563
+
564
+	/** @type EE_messenger */
565
+	protected $_messenger;
566
+
567
+	/** @type EE_message_type */
568
+	protected $_message_type;
569
+
570
+	/** @type array */
571
+	protected $_contexts = array();
572
+
573
+	/** @type EE_Message_Resource_Manager $_message_resource_manager */
574
+	protected $_message_resource_manager;
575
+
576
+
577
+	/**
578
+	 * EE_messages constructor.
579
+	 *
580
+	 * @deprecated 4.9.0
581
+	 */
582
+	public function __construct()
583
+	{
584
+	}
585
+
586
+
587
+	/**
588
+	 * @param string $method
589
+	 */
590
+	public function _class_is_deprecated($method)
591
+	{
592
+		EE_Error::doing_it_wrong(
593
+			'EE_messages::' . $method,
594
+			__('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
595
+			'4.9.0',
596
+			'4.10.0.p'
597
+		);
598
+		// Please use EE_Message_Resource_Manager instead
599
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
600
+	}
601
+
602
+
603
+	/**
604
+	 * @deprecated 4.9.0
605
+	 * @param string $messenger_name
606
+	 * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
607
+	 */
608
+	public function ensure_messenger_is_active($messenger_name)
609
+	{
610
+		// EE_messages has been deprecated
611
+		$this->_class_is_deprecated(__FUNCTION__);
612
+		return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
613
+	}
614
+
615
+
616
+	/**
617
+	 * @deprecated 4.9.0
618
+	 * @param string $message_type message type name
619
+	 * @param        $messenger
620
+	 * @return bool true if it got activated (or was active) and false if not.
621
+	 * @throws \EE_Error
622
+	 */
623
+	public function ensure_message_type_is_active($message_type, $messenger)
624
+	{
625
+		// EE_messages has been deprecated
626
+		$this->_class_is_deprecated(__FUNCTION__);
627
+		return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
628
+	}
629
+
630
+
631
+	/**
632
+	 * @deprecated 4.9.0
633
+	 * @param string $messenger_name
634
+	 * @param array  $mts_to_activate             (optional) An array of message types to activate with this messenger.
635
+	 *                                             If included we do NOT setup the default message types (assuming they
636
+	 *                                             are already setup.)
637
+	 * @return boolean an array of generated templates or false if nothing generated/activated.
638
+	 */
639
+	public function activate_messenger($messenger_name, $mts_to_activate = array())
640
+	{
641
+		// EE_messages has been deprecated
642
+		$this->_class_is_deprecated(__FUNCTION__);
643
+		return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
644
+	}
645
+
646
+
647
+	/**
648
+	 * @deprecated 4.9.0
649
+	 * @param EE_messenger    $messenger    messenger used in trigger
650
+	 * @param EE_message_type $message_type message type used in trigger
651
+	 *
652
+	 * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
653
+	 */
654
+	public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type)
655
+	{
656
+		// EE_messages has been deprecated
657
+		$this->_class_is_deprecated(__FUNCTION__);
658
+		return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
659
+	}
660
+
661
+
662
+	/**
663
+	 * @deprecated 4.9.0
664
+	 * @param string $messenger
665
+	 * @return EE_messenger | null
666
+	 */
667
+	public function get_messenger_if_active($messenger)
668
+	{
669
+		// EE_messages has been deprecated
670
+		$this->_class_is_deprecated(__FUNCTION__);
671
+		return $this->_message_resource_manager->get_active_messenger($messenger);
672
+	}
673
+
674
+
675
+	/**
676
+	 * @deprecated 4.9.0
677
+	 * @param EE_Message $message
678
+	 * @return array  An array with 'messenger' and 'message_type' as the index and the corresponding valid object if
679
+	 *                  available.
680
+	 *                  Eg. Valid Messenger and Message Type:
681
+	 *                  array(
682
+	 *                  'messenger' => new EE_Email_messenger(),
683
+	 *                  'message_type' => new EE_Registration_Approved_message_type()
684
+	 *                  )
685
+	 *                  Valid Messenger and Invalid Message Type:
686
+	 *                  array(
687
+	 *                  'messenger' => new EE_Email_messenger(),
688
+	 *                  'message_type' => null
689
+	 *                  )
690
+	 */
691
+	public function validate_for_use(EE_Message $message)
692
+	{
693
+		// EE_messages has been deprecated
694
+		$this->_class_is_deprecated(__FUNCTION__);
695
+		return array(
696
+			'messenger'    => $message->messenger_object(),
697
+			'message_type' => $message->message_type_object(),
698
+		);
699
+	}
700
+
701
+
702
+	/**
703
+	 * @deprecated 4.9.0
704
+	 * @param  string $type                 What type of message are we sending (corresponds to message types)
705
+	 * @param  mixed  $vars                 Data being sent for parsing in the message
706
+	 * @param  string $sending_messenger    if included then we ONLY use the specified messenger for delivery.
707
+	 *                                      Otherwise we cycle through all active messengers.
708
+	 * @param string  $generating_messenger if included then this messenger is used for generating the message
709
+	 *                                      templates (but not for sending).
710
+	 * @param string  $context              If included then only a message type for a specific context will be
711
+	 *                                      generated.
712
+	 * @param bool    $send                 Default TRUE.  If false, then this will just return the generated
713
+	 *                                      EE_messages objects which might be used by the trigger to setup a batch
714
+	 *                                      message (typically html messenger uses it).
715
+	 * @return bool
716
+	 */
717
+	public function send_message(
718
+		$type,
719
+		$vars,
720
+		$sending_messenger = '',
721
+		$generating_messenger = '',
722
+		$context = '',
723
+		$send = true
724
+	) {
725
+		// EE_messages has been deprecated
726
+		$this->_class_is_deprecated(__FUNCTION__);
727
+		/** @type EE_Messages_Processor $processor */
728
+		$processor = EE_Registry::instance()->load_lib('Messages_Processor');
729
+		$error = false;
730
+		// try to intelligently determine what method we'll call based on the incoming data.
731
+		// if generating and sending are different then generate and send immediately.
732
+		if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
733
+			// in the legacy system, when generating and sending were different, that means all the
734
+			// vars are already in the request object.  So let's just use that.
735
+			try {
736
+				/** @type EE_Message_To_Generate_From_Request $mtg */
737
+				$mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
738
+				$processor->generate_and_send_now($mtg);
739
+			} catch (EE_Error $e) {
740
+				$error_msg = __(
741
+					'Please note that a system message failed to send due to a technical issue.',
742
+					'event_espresso'
743
+				);
744
+				// add specific message for developers if WP_DEBUG in on
745
+				$error_msg .= '||' . $e->getMessage();
746
+				EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
747
+				$error = true;
748
+			}
749
+		} else {
750
+			$processor->generate_for_all_active_messengers($type, $vars, $send);
751
+			// let's find out if there were any errors and how many successfully were queued.
752
+			$count_errors = $processor->get_queue()->count_STS_in_queue(
753
+				array(EEM_Message::status_failed, EEM_Message::status_debug_only)
754
+			);
755
+			$count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
756
+			$count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
757
+			$count_errors = $count_errors + $count_retry;
758
+			if ($count_errors > 0) {
759
+				$error = true;
760
+				if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
761
+					$message = sprintf(
762
+						__(
763
+							'There were %d errors and %d messages successfully queued for generation and sending',
764
+							'event_espresso'
765
+						),
766
+						$count_errors,
767
+						$count_queued
768
+					);
769
+				} elseif ($count_errors > 1 && $count_queued === 1) {
770
+					$message = sprintf(
771
+						__(
772
+							'There were %d errors and %d message successfully queued for generation.',
773
+							'event_espresso'
774
+						),
775
+						$count_errors,
776
+						$count_queued
777
+					);
778
+				} elseif ($count_errors === 1 && $count_queued > 1) {
779
+					$message = sprintf(
780
+						__(
781
+							'There was %d error and %d messages successfully queued for generation.',
782
+							'event_espresso'
783
+						),
784
+						$count_errors,
785
+						$count_queued
786
+					);
787
+				} else {
788
+					$message = sprintf(
789
+						__(
790
+							'There was %d message that failed to be queued for generation.',
791
+							'event_espresso'
792
+						),
793
+						$count_errors
794
+					);
795
+				}
796
+				EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
797
+			} else {
798
+				if ($count_queued === 1) {
799
+					$message = sprintf(
800
+						__(
801
+							'%d message successfully queued for generation.',
802
+							'event_espresso'
803
+						),
804
+						$count_queued
805
+					);
806
+				} else {
807
+					$message = sprintf(
808
+						__(
809
+							'%d messages were successfully queued for generation.',
810
+							'event_espresso'
811
+						),
812
+						$count_queued
813
+					);
814
+				}
815
+				EE_Error::add_success($message);
816
+			}
817
+		}
818
+		// if no error then return the generated message(s).
819
+		if (! $error && ! $send) {
820
+			$generated_queue = $processor->generate_queue(false);
821
+			// get message and return.
822
+			$generated_queue->get_message_repository()->rewind();
823
+			$messages = array();
824
+			while ($generated_queue->get_message_repository()->valid()) {
825
+				$message = $generated_queue->get_message_repository()->current();
826
+				if ($message instanceof EE_Message) {
827
+					// set properties that might be expected by add-ons (backward compat)
828
+					$message->content = $message->content();
829
+					$message->template_pack = $message->get_template_pack();
830
+					$message->template_variation = $message->get_template_pack_variation();
831
+					$messages[] = $message;
832
+				}
833
+				$generated_queue->get_message_repository()->next();
834
+			}
835
+			return $messages;
836
+		}
837
+		return $error ? false
838
+			: true; // yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
839
+	}
840
+
841
+
842
+	/**
843
+	 * @deprecated 4.9.0
844
+	 * @param  string $type      This should correspond with a valid message type
845
+	 * @param  string $context   This should correspond with a valid context for the message type
846
+	 * @param  string $messenger This should correspond with a valid messenger.
847
+	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
848
+	 *                           preview
849
+	 * @return string          The body of the message.
850
+	 */
851
+	public function preview_message($type, $context, $messenger, $send = false)
852
+	{
853
+		// EE_messages has been deprecated
854
+		$this->_class_is_deprecated(__FUNCTION__);
855
+		return EED_Messages::preview_message($type, $context, $messenger, $send);
856
+	}
857
+
858
+
859
+	/**
860
+	 * @since      4.5.0
861
+	 * @deprecated 4.9.0   Moved to EED_Messages Module
862
+	 * @param string   $messenger    a string matching a valid active messenger in the system
863
+	 * @param string   $message_type Although it seems contrary to the name of the method, a message type name is still
864
+	 *                               required to send along the message type to the messenger because this is used for
865
+	 *                               determining what specific variations might be loaded for the generated message.
866
+	 * @param stdClass $message      a stdClass object in the format expected by the messenger.
867
+	 *
868
+	 * @return bool          success or fail.
869
+	 */
870
+	public function send_message_with_messenger_only($messenger, $message_type, $message)
871
+	{
872
+		// EE_messages has been deprecated
873
+		$this->_class_is_deprecated(__FUNCTION__);
874
+		// setup for sending to new method.
875
+		/** @type EE_Messages_Queue $queue */
876
+		$queue = EE_Registry::instance()->load_lib('Messages_Queue');
877
+		// make sure we have a proper message object
878
+		if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
879
+			$msg = EE_Message_Factory::create(
880
+				array(
881
+					'MSG_messenger'    => $messenger,
882
+					'MSG_message_type' => $message_type,
883
+					'MSG_content'      => $message->content,
884
+					'MSG_subject'      => $message->subject,
885
+				)
886
+			);
887
+		} else {
888
+			$msg = $message;
889
+		}
890
+		if (! $msg instanceof EE_Message) {
891
+			return false;
892
+		}
893
+		// make sure any content in a content property (if not empty) is set on the MSG_content.
894
+		if (! empty($msg->content)) {
895
+			$msg->set('MSG_content', $msg->content);
896
+		}
897
+		$queue->add($msg);
898
+		return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
899
+	}
900
+
901
+
902
+	/**
903
+	 * @deprecated 4.9.0
904
+	 * @param         $messenger
905
+	 * @param  string $message_type message type that the templates are being created for
906
+	 * @param int     $GRP_ID
907
+	 * @param bool    $is_global
908
+	 * @return array|object if creation is successful then we return an array of info, otherwise an error_object is
909
+	 *                      returned.
910
+	 * @throws \EE_Error
911
+	 */
912
+	public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false)
913
+	{
914
+		// EE_messages has been deprecated
915
+		$this->_class_is_deprecated(__FUNCTION__);
916
+		EE_Registry::instance()->load_helper('MSG_Template');
917
+		return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
918
+	}
919
+
920
+
921
+	/**
922
+	 * @deprecated 4.9.0
923
+	 * @param  string $messenger_name    name of EE_messenger
924
+	 * @param  string $message_type_name name of EE_message_type
925
+	 * @return array
926
+	 */
927
+	public function get_fields($messenger_name, $message_type_name)
928
+	{
929
+		// EE_messages has been deprecated
930
+		$this->_class_is_deprecated(__FUNCTION__);
931
+		EE_Registry::instance()->load_helper('MSG_Template');
932
+		return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
933
+	}
934
+
935
+
936
+	/**
937
+	 * @deprecated 4.9.0
938
+	 * @access     public
939
+	 * @param string $type                we can indicate just returning installed message types
940
+	 *                                    or messengers (or both) via this parameter.
941
+	 * @param bool   $skip_cache          if true then we skip the cache and retrieve via files.
942
+	 * @return array                    multidimensional array of messenger and message_type objects
943
+	 *                                    (messengers index, and message_type index);
944
+	 */
945
+	public function get_installed($type = 'all', $skip_cache = false)
946
+	{
947
+		// EE_messages has been deprecated
948
+		$this->_class_is_deprecated(__FUNCTION__);
949
+		if ($skip_cache) {
950
+			$this->_message_resource_manager->reset_active_messengers_and_message_types();
951
+		}
952
+		switch ($type) {
953
+			case 'messengers' :
954
+				return array(
955
+					'messenger' => $this->_message_resource_manager->installed_messengers(),
956
+				);
957
+				break;
958
+			case 'message_types' :
959
+				return array(
960
+					'message_type' => $this->_message_resource_manager->installed_message_types(),
961
+				);
962
+				break;
963
+			case 'all' :
964
+			default :
965
+				return array(
966
+					'messenger'    => $this->_message_resource_manager->installed_messengers(),
967
+					'message_type' => $this->_message_resource_manager->installed_message_types(),
968
+				);
969
+				break;
970
+		}
971
+	}
972
+
973
+
974
+	/**
975
+	 * @deprecated 4.9.0
976
+	 * @return \EE_messenger[]
977
+	 */
978
+	public function get_active_messengers()
979
+	{
980
+		// EE_messages has been deprecated
981
+		$this->_class_is_deprecated(__FUNCTION__);
982
+		return $this->_message_resource_manager->active_messengers();
983
+	}
984
+
985
+
986
+	/**
987
+	 * @deprecated 4.9.0
988
+	 * @return array array of message_type references (string)
989
+	 */
990
+	public function get_active_message_types()
991
+	{
992
+		// EE_messages has been deprecated
993
+		$this->_class_is_deprecated(__FUNCTION__);
994
+		return $this->_message_resource_manager->list_of_active_message_types();
995
+	}
996
+
997
+
998
+	/**
999
+	 * @deprecated 4.9.0
1000
+	 * @return EE_message_type[]
1001
+	 */
1002
+	public function get_active_message_type_objects()
1003
+	{
1004
+		// EE_messages has been deprecated
1005
+		$this->_class_is_deprecated(__FUNCTION__);
1006
+		return $this->_message_resource_manager->get_active_message_type_objects();
1007
+	}
1008
+
1009
+
1010
+	/**
1011
+	 * @deprecated 4.9.0
1012
+	 * @since      4.5.0
1013
+	 * @param string $messenger The messenger being checked
1014
+	 * @return EE_message_type[]    (or empty array if none present)
1015
+	 */
1016
+	public function get_active_message_types_per_messenger($messenger)
1017
+	{
1018
+		// EE_messages has been deprecated
1019
+		$this->_class_is_deprecated(__FUNCTION__);
1020
+		return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
1021
+	}
1022
+
1023
+
1024
+	/**
1025
+	 * @deprecated 4.9.0
1026
+	 * @param string $messenger    The string should correspond to the messenger (message types are
1027
+	 * @param string $message_type The string should correspond to a message type.
1028
+	 * @return EE_message_type|null
1029
+	 */
1030
+	public function get_active_message_type($messenger, $message_type)
1031
+	{
1032
+		// EE_messages has been deprecated
1033
+		$this->_class_is_deprecated(__FUNCTION__);
1034
+		return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
1035
+	}
1036
+
1037
+
1038
+	/**
1039
+	 * @deprecated 4.9.0
1040
+	 * @return array|\EE_message_type[]
1041
+	 */
1042
+	public function get_installed_message_types()
1043
+	{
1044
+		// EE_messages has been deprecated
1045
+		$this->_class_is_deprecated(__FUNCTION__);
1046
+		return $this->_message_resource_manager->installed_message_types();
1047
+	}
1048
+
1049
+
1050
+	/**
1051
+	 * @deprecated 4.9.0
1052
+	 * @return array
1053
+	 */
1054
+	public function get_installed_messengers()
1055
+	{
1056
+		// EE_messages has been deprecated
1057
+		$this->_class_is_deprecated(__FUNCTION__);
1058
+		return $this->_message_resource_manager->installed_messengers();
1059
+	}
1060
+
1061
+
1062
+	/**
1063
+	 * @deprecated 4.9.0
1064
+	 * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by
1065
+	 *                           message type.
1066
+	 * @return array
1067
+	 */
1068
+	public function get_all_contexts($slugs_only = true)
1069
+	{
1070
+		// EE_messages has been deprecated
1071
+		$this->_class_is_deprecated(__FUNCTION__);
1072
+		return $this->_message_resource_manager->get_all_contexts($slugs_only);
1073
+	}
1074 1074
 
1075 1075
 
1076 1076
 }
@@ -1129,88 +1129,88 @@  discard block
 block discarded – undo
1129 1129
 
1130 1130
 
1131 1131
 add_filter(
1132
-    'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1133
-    function ($event_list_iframe_css) {
1134
-        if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1135
-            return $event_list_iframe_css;
1136
-        }
1137
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1138
-            'FHEE__EventsArchiveIframe__event_list_iframe__css',
1139
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1140
-            '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1141
-            '4.9.14',
1142
-            '5.0.0',
1143
-            'filter'
1144
-        );
1145
-        return apply_filters(
1146
-            'FHEE__EventsArchiveIframe__event_list_iframe__css',
1147
-            $event_list_iframe_css
1148
-        );
1149
-    }
1132
+	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1133
+	function ($event_list_iframe_css) {
1134
+		if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1135
+			return $event_list_iframe_css;
1136
+		}
1137
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1138
+			'FHEE__EventsArchiveIframe__event_list_iframe__css',
1139
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1140
+			'\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1141
+			'4.9.14',
1142
+			'5.0.0',
1143
+			'filter'
1144
+		);
1145
+		return apply_filters(
1146
+			'FHEE__EventsArchiveIframe__event_list_iframe__css',
1147
+			$event_list_iframe_css
1148
+		);
1149
+	}
1150 1150
 );
1151 1151
 add_filter(
1152
-    'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1153
-    function ($event_list_iframe_js) {
1154
-        if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1155
-            return $event_list_iframe_js;
1156
-        }
1157
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1158
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1159
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1160
-            '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1161
-            '4.9.14',
1162
-            '5.0.0',
1163
-            'filter'
1164
-        );
1165
-        return apply_filters(
1166
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1167
-            $event_list_iframe_js
1168
-        );
1169
-    }
1152
+	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1153
+	function ($event_list_iframe_js) {
1154
+		if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1155
+			return $event_list_iframe_js;
1156
+		}
1157
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1158
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1159
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1160
+			'\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1161
+			'4.9.14',
1162
+			'5.0.0',
1163
+			'filter'
1164
+		);
1165
+		return apply_filters(
1166
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1167
+			$event_list_iframe_js
1168
+		);
1169
+	}
1170 1170
 );
1171 1171
 add_action(
1172
-    'AHEE__EE_Capabilities__addCaps__complete',
1173
-    function ($capabilities_map) {
1174
-        if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1175
-            return;
1176
-        }
1177
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1178
-            'AHEE__EE_Capabilities__init_role_caps__complete',
1179
-            'AHEE__EE_Capabilities__addCaps__complete',
1180
-            '\EE_Capabilities::addCaps()',
1181
-            '4.9.42',
1182
-            '5.0.0'
1183
-        );
1184
-        do_action(
1185
-            'AHEE__EE_Capabilities__init_role_caps__complete',
1186
-            $capabilities_map
1187
-        );
1188
-    }
1172
+	'AHEE__EE_Capabilities__addCaps__complete',
1173
+	function ($capabilities_map) {
1174
+		if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1175
+			return;
1176
+		}
1177
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1178
+			'AHEE__EE_Capabilities__init_role_caps__complete',
1179
+			'AHEE__EE_Capabilities__addCaps__complete',
1180
+			'\EE_Capabilities::addCaps()',
1181
+			'4.9.42',
1182
+			'5.0.0'
1183
+		);
1184
+		do_action(
1185
+			'AHEE__EE_Capabilities__init_role_caps__complete',
1186
+			$capabilities_map
1187
+		);
1188
+	}
1189 1189
 );
1190 1190
 
1191 1191
 add_filter(
1192
-    'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1193
-    function ($existing_attendee, $registration, $attendee_data) {
1194
-        if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1195
-            return $existing_attendee;
1196
-        }
1197
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1198
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1199
-            'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1200
-            '\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()',
1201
-            '4.9.34',
1202
-            '5.0.0',
1203
-            'filter'
1204
-        );
1205
-        return apply_filters(
1206
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1207
-            $existing_attendee,
1208
-            $registration,
1209
-            $attendee_data
1210
-        );
1211
-    },
1212
-    10,
1213
-    3
1192
+	'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1193
+	function ($existing_attendee, $registration, $attendee_data) {
1194
+		if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1195
+			return $existing_attendee;
1196
+		}
1197
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1198
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1199
+			'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1200
+			'\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()',
1201
+			'4.9.34',
1202
+			'5.0.0',
1203
+			'filter'
1204
+		);
1205
+		return apply_filters(
1206
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1207
+			$existing_attendee,
1208
+			$registration,
1209
+			$attendee_data
1210
+		);
1211
+	},
1212
+	10,
1213
+	3
1214 1214
 );
1215 1215
 
1216 1216
 /**
@@ -1221,88 +1221,88 @@  discard block
 block discarded – undo
1221 1221
 class EE_Event_List_Query extends WP_Query
1222 1222
 {
1223 1223
 
1224
-    private $title;
1225
-
1226
-    private $css_class;
1227
-
1228
-    private $category_slug;
1229
-
1230
-    /**
1231
-     * EE_Event_List_Query constructor.
1232
-     *
1233
-     * @param array $args
1234
-     */
1235
-    public function __construct($args = array())
1236
-    {
1237
-        \EE_Error::doing_it_wrong(
1238
-            __METHOD__,
1239
-            __(
1240
-                'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1241
-                'event_espresso'
1242
-            ),
1243
-            '4.9.27',
1244
-            '5.0.0'
1245
-        );
1246
-        $this->title = isset($args['title']) ? $args['title'] : '';
1247
-        $this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1248
-        $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1249
-        $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1250
-        // the current "page" we are viewing
1251
-        $paged = max(1, get_query_var('paged'));
1252
-        // Force these args
1253
-        $args = array_merge(
1254
-            $args,
1255
-            array(
1256
-                'post_type'              => 'espresso_events',
1257
-                'posts_per_page'         => $limit,
1258
-                'update_post_term_cache' => false,
1259
-                'update_post_meta_cache' => false,
1260
-                'paged'                  => $paged,
1261
-                'offset'                 => ($paged - 1) * $limit,
1262
-            )
1263
-        );
1264
-        // run the query
1265
-        parent::__construct($args);
1266
-    }
1267
-
1268
-
1269
-    /**
1270
-     * event_list_title
1271
-     *
1272
-     * @param string $event_list_title
1273
-     * @return string
1274
-     */
1275
-    public function event_list_title($event_list_title = '')
1276
-    {
1277
-        if (! empty($this->title)) {
1278
-            return $this->title;
1279
-        }
1280
-        return $event_list_title;
1281
-    }
1282
-
1283
-
1284
-    /**
1285
-     * event_list_css
1286
-     *
1287
-     * @param string $event_list_css
1288
-     * @return string
1289
-     */
1290
-    public function event_list_css($event_list_css = '')
1291
-    {
1292
-        $event_list_css .= ! empty($event_list_css)
1293
-            ? ' '
1294
-            : '';
1295
-        $event_list_css .= ! empty($this->css_class)
1296
-            ? $this->css_class
1297
-            : '';
1298
-        $event_list_css .= ! empty($event_list_css)
1299
-            ? ' '
1300
-            : '';
1301
-        $event_list_css .= ! empty($this->category_slug)
1302
-            ? $this->category_slug
1303
-            : '';
1304
-        return $event_list_css;
1305
-    }
1224
+	private $title;
1225
+
1226
+	private $css_class;
1227
+
1228
+	private $category_slug;
1229
+
1230
+	/**
1231
+	 * EE_Event_List_Query constructor.
1232
+	 *
1233
+	 * @param array $args
1234
+	 */
1235
+	public function __construct($args = array())
1236
+	{
1237
+		\EE_Error::doing_it_wrong(
1238
+			__METHOD__,
1239
+			__(
1240
+				'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1241
+				'event_espresso'
1242
+			),
1243
+			'4.9.27',
1244
+			'5.0.0'
1245
+		);
1246
+		$this->title = isset($args['title']) ? $args['title'] : '';
1247
+		$this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1248
+		$this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1249
+		$limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1250
+		// the current "page" we are viewing
1251
+		$paged = max(1, get_query_var('paged'));
1252
+		// Force these args
1253
+		$args = array_merge(
1254
+			$args,
1255
+			array(
1256
+				'post_type'              => 'espresso_events',
1257
+				'posts_per_page'         => $limit,
1258
+				'update_post_term_cache' => false,
1259
+				'update_post_meta_cache' => false,
1260
+				'paged'                  => $paged,
1261
+				'offset'                 => ($paged - 1) * $limit,
1262
+			)
1263
+		);
1264
+		// run the query
1265
+		parent::__construct($args);
1266
+	}
1267
+
1268
+
1269
+	/**
1270
+	 * event_list_title
1271
+	 *
1272
+	 * @param string $event_list_title
1273
+	 * @return string
1274
+	 */
1275
+	public function event_list_title($event_list_title = '')
1276
+	{
1277
+		if (! empty($this->title)) {
1278
+			return $this->title;
1279
+		}
1280
+		return $event_list_title;
1281
+	}
1282
+
1283
+
1284
+	/**
1285
+	 * event_list_css
1286
+	 *
1287
+	 * @param string $event_list_css
1288
+	 * @return string
1289
+	 */
1290
+	public function event_list_css($event_list_css = '')
1291
+	{
1292
+		$event_list_css .= ! empty($event_list_css)
1293
+			? ' '
1294
+			: '';
1295
+		$event_list_css .= ! empty($this->css_class)
1296
+			? $this->css_class
1297
+			: '';
1298
+		$event_list_css .= ! empty($event_list_css)
1299
+			? ' '
1300
+			: '';
1301
+		$event_list_css .= ! empty($this->category_slug)
1302
+			? $this->category_slug
1303
+			: '';
1304
+		return $event_list_css;
1305
+	}
1306 1306
 
1307 1307
 }
1308 1308
 
@@ -1319,75 +1319,75 @@  discard block
 block discarded – undo
1319 1319
 {
1320 1320
 
1321 1321
 
1322
-    /**
1323
-     *    class constructor
1324
-     *
1325
-     * @deprecated 4.9.59.p
1326
-     */
1327
-    public function __construct()
1328
-    {
1329
-        EE_Error::doing_it_wrong(
1330
-            __METHOD__,
1331
-            sprintf(
1332
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1333
-                __CLASS__,
1334
-                'EventEspresso\core\services\licensing\LicenseServices'
1335
-            ),
1336
-            '4.9.59.p'
1337
-        );
1338
-    }
1339
-
1340
-
1341
-    /**
1342
-     * The purpose of this function is to display information about Event Espresso data collection
1343
-     * and a optin selection for extra data collecting by users.
1344
-     *
1345
-     * @param bool $extra
1346
-     * @return string html.
1347
-     * @deprecated 4.9.59.p
1348
-     */
1349
-    public static function espresso_data_collection_optin_text($extra = true)
1350
-    {
1351
-        EE_Error::doing_it_wrong(
1352
-            __METHOD__,
1353
-            sprintf(
1354
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1355
-                __METHOD__,
1356
-                'EventEspresso\core\domain\services\Stats::optinText'
1357
-            ),
1358
-            '4.9.59.p'
1359
-        );
1360
-        Stats::optinText($extra);
1361
-    }
1362
-
1363
-    /**
1364
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1365
-     *
1366
-     * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1367
-     *                          identify plugins. Defaults to core update
1368
-     * @return boolean           True if update available, false if not.
1369
-     * @deprecated 4.9.59.p
1370
-     */
1371
-    public static function is_update_available($basename = '')
1372
-    {
1373
-        EE_Error::doing_it_wrong(
1374
-            __METHOD__,
1375
-            sprintf(
1376
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1377
-                __METHOD__,
1378
-                'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable'
1379
-            ),
1380
-            '4.9.59.p'
1381
-        );
1382
-        return LicenseService::isUpdateAvailable($basename);
1383
-    }
1322
+	/**
1323
+	 *    class constructor
1324
+	 *
1325
+	 * @deprecated 4.9.59.p
1326
+	 */
1327
+	public function __construct()
1328
+	{
1329
+		EE_Error::doing_it_wrong(
1330
+			__METHOD__,
1331
+			sprintf(
1332
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1333
+				__CLASS__,
1334
+				'EventEspresso\core\services\licensing\LicenseServices'
1335
+			),
1336
+			'4.9.59.p'
1337
+		);
1338
+	}
1339
+
1340
+
1341
+	/**
1342
+	 * The purpose of this function is to display information about Event Espresso data collection
1343
+	 * and a optin selection for extra data collecting by users.
1344
+	 *
1345
+	 * @param bool $extra
1346
+	 * @return string html.
1347
+	 * @deprecated 4.9.59.p
1348
+	 */
1349
+	public static function espresso_data_collection_optin_text($extra = true)
1350
+	{
1351
+		EE_Error::doing_it_wrong(
1352
+			__METHOD__,
1353
+			sprintf(
1354
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1355
+				__METHOD__,
1356
+				'EventEspresso\core\domain\services\Stats::optinText'
1357
+			),
1358
+			'4.9.59.p'
1359
+		);
1360
+		Stats::optinText($extra);
1361
+	}
1362
+
1363
+	/**
1364
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1365
+	 *
1366
+	 * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1367
+	 *                          identify plugins. Defaults to core update
1368
+	 * @return boolean           True if update available, false if not.
1369
+	 * @deprecated 4.9.59.p
1370
+	 */
1371
+	public static function is_update_available($basename = '')
1372
+	{
1373
+		EE_Error::doing_it_wrong(
1374
+			__METHOD__,
1375
+			sprintf(
1376
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1377
+				__METHOD__,
1378
+				'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable'
1379
+			),
1380
+			'4.9.59.p'
1381
+		);
1382
+		return LicenseService::isUpdateAvailable($basename);
1383
+	}
1384 1384
 }
1385 1385
 
1386 1386
 add_filter(
1387
-    'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
1388
-    'ee_deprecated_registrations_report_csv_legacy_fields',
1389
-    10,
1390
-    2
1387
+	'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
1388
+	'ee_deprecated_registrations_report_csv_legacy_fields',
1389
+	10,
1390
+	2
1391 1391
 );
1392 1392
 /**
1393 1393
  * Filters the CSV row to make it appear like the old labels (which were "$pretty_name[$field_name]").
@@ -1404,96 +1404,96 @@  discard block
 block discarded – undo
1404 1404
  */
1405 1405
 function ee_deprecated_registrations_report_csv_legacy_fields($csv_row_data, $reg_row)
1406 1406
 {
1407
-    // no need for all this if nobody is using the deprecated filter
1408
-    if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) {
1409
-        EE_Error::doing_it_wrong(
1410
-            __FUNCTION__,
1411
-            sprintf(
1412
-                // EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too.
1413
-                _x(
1414
-                    'The filter "%1$s" has been deprecated. Please use "%2$s" instead.',
1415
-                    'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.',
1416
-                    'event_espresso'
1417
-                ),
1418
-                'FHEE__EE_Export__report_registrations__reg_csv_array',
1419
-                'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array'
1420
-            ),
1421
-            '4.9.69.p',
1422
-            '4.9.75.p'
1423
-        );
1424
-        // there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format!
1425
-        // first: what model fields might be used as column headers? (whose format we need to change)
1426
-        $model_fields = array_merge(
1427
-            EEM_Registration::instance()->field_settings(),
1428
-            EEM_Attendee::instance()->field_settings()
1429
-        );
1430
-        // create an array that uses the legacy column headers/labels.
1431
-        $new_csv_row = array();
1432
-        foreach ($csv_row_data as $label => $value) {
1433
-            $new_label = $label;
1434
-            foreach ($model_fields as $field) {
1435
-                if ($label === EEH_Export::get_column_name_for_field($field)) {
1436
-                    // re-add the old field name
1437
-                    $new_label = $label . '[' . $field->get_name() . ']';
1438
-                    break;
1439
-                }
1440
-            }
1441
-            $new_csv_row[$new_label] = $value;
1442
-        }
1443
-        // before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()`
1444
-        // to create the old column names, because that's what's in the row temporarily
1445
-        add_filter(
1446
-            'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1447
-            '__return_true',
1448
-            777
1449
-        );
1450
-        // now, those old filters can be run on this data. Have fun!
1451
-        /**
1452
-         * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead.
1453
-         *
1454
-         * Filter to change the contents of each row of the registrations report CSV file.
1455
-         * This can be used to add or remote columns from the CSV file, or change their values.                 *
1456
-         * Note: it has this name because originally that's where this filter resided,
1457
-         * and we've left its name as-is for backward compatibility.
1458
-         * Note when using: all rows in the CSV should have the same columns.
1459
-         *
1460
-         * @param array $reg_csv_array keys are column-header names, and values are that columns' value
1461
-         *                             in this row
1462
-         * @param array $reg_row is the row from the database's wp_esp_registration table
1463
-         */
1464
-        $updated_row = apply_filters(
1465
-            'FHEE__EE_Export__report_registrations__reg_csv_array',
1466
-            $new_csv_row,
1467
-            $reg_row
1468
-        );
1469
-
1470
-        // ok now we can revert to normal for EEH_Export::get_column_name_for_field().
1471
-        remove_filter(
1472
-            'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1473
-            '__return_true',
1474
-            777
1475
-        );
1476
-
1477
-        // great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels.
1478
-        $updated_and_restored_row = array();
1479
-        foreach ($updated_row as $label => $value) {
1480
-            $matches = array();
1481
-            if (preg_match(
1482
-                    '~([^\[]*)\[(.*)\]~',
1483
-                    $label,
1484
-                    $matches
1485
-                )
1486
-                && isset(
1487
-                    $matches[0],
1488
-                    $matches[1],
1489
-                    $matches[2]
1490
-                )
1491
-            ) {
1492
-                $label = $matches[1];
1493
-            }
1494
-            $updated_and_restored_row[$label] = $value;
1495
-        }
1496
-        $csv_row_data = $updated_and_restored_row;
1497
-    }
1498
-    return $csv_row_data;
1407
+	// no need for all this if nobody is using the deprecated filter
1408
+	if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) {
1409
+		EE_Error::doing_it_wrong(
1410
+			__FUNCTION__,
1411
+			sprintf(
1412
+				// EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too.
1413
+				_x(
1414
+					'The filter "%1$s" has been deprecated. Please use "%2$s" instead.',
1415
+					'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.',
1416
+					'event_espresso'
1417
+				),
1418
+				'FHEE__EE_Export__report_registrations__reg_csv_array',
1419
+				'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array'
1420
+			),
1421
+			'4.9.69.p',
1422
+			'4.9.75.p'
1423
+		);
1424
+		// there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format!
1425
+		// first: what model fields might be used as column headers? (whose format we need to change)
1426
+		$model_fields = array_merge(
1427
+			EEM_Registration::instance()->field_settings(),
1428
+			EEM_Attendee::instance()->field_settings()
1429
+		);
1430
+		// create an array that uses the legacy column headers/labels.
1431
+		$new_csv_row = array();
1432
+		foreach ($csv_row_data as $label => $value) {
1433
+			$new_label = $label;
1434
+			foreach ($model_fields as $field) {
1435
+				if ($label === EEH_Export::get_column_name_for_field($field)) {
1436
+					// re-add the old field name
1437
+					$new_label = $label . '[' . $field->get_name() . ']';
1438
+					break;
1439
+				}
1440
+			}
1441
+			$new_csv_row[$new_label] = $value;
1442
+		}
1443
+		// before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()`
1444
+		// to create the old column names, because that's what's in the row temporarily
1445
+		add_filter(
1446
+			'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1447
+			'__return_true',
1448
+			777
1449
+		);
1450
+		// now, those old filters can be run on this data. Have fun!
1451
+		/**
1452
+		 * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead.
1453
+		 *
1454
+		 * Filter to change the contents of each row of the registrations report CSV file.
1455
+		 * This can be used to add or remote columns from the CSV file, or change their values.                 *
1456
+		 * Note: it has this name because originally that's where this filter resided,
1457
+		 * and we've left its name as-is for backward compatibility.
1458
+		 * Note when using: all rows in the CSV should have the same columns.
1459
+		 *
1460
+		 * @param array $reg_csv_array keys are column-header names, and values are that columns' value
1461
+		 *                             in this row
1462
+		 * @param array $reg_row is the row from the database's wp_esp_registration table
1463
+		 */
1464
+		$updated_row = apply_filters(
1465
+			'FHEE__EE_Export__report_registrations__reg_csv_array',
1466
+			$new_csv_row,
1467
+			$reg_row
1468
+		);
1469
+
1470
+		// ok now we can revert to normal for EEH_Export::get_column_name_for_field().
1471
+		remove_filter(
1472
+			'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1473
+			'__return_true',
1474
+			777
1475
+		);
1476
+
1477
+		// great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels.
1478
+		$updated_and_restored_row = array();
1479
+		foreach ($updated_row as $label => $value) {
1480
+			$matches = array();
1481
+			if (preg_match(
1482
+					'~([^\[]*)\[(.*)\]~',
1483
+					$label,
1484
+					$matches
1485
+				)
1486
+				&& isset(
1487
+					$matches[0],
1488
+					$matches[1],
1489
+					$matches[2]
1490
+				)
1491
+			) {
1492
+				$label = $matches[1];
1493
+			}
1494
+			$updated_and_restored_row[$label] = $value;
1495
+		}
1496
+		$csv_row_data = $updated_and_restored_row;
1497
+	}
1498
+	return $csv_row_data;
1499 1499
 }
1500 1500
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -86,20 +86,20 @@  discard block
 block discarded – undo
86 86
     // loop thru and call doing_it_wrong() or remove any that aren't being used
87 87
     foreach ($deprecated_filters as $deprecated_filter => $on) {
88 88
         // was this filter called ?
89
-        if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
89
+        if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) {
90 90
             // only display doing_it_wrong() notice to Event Admins during non-AJAX requests
91 91
             if (EE_Registry::instance()->CAP->current_user_can(
92 92
                     'ee_read_ee',
93 93
                     'hide_doing_it_wrong_for_deprecated_SPCO_filter'
94 94
                 ) && ! defined('DOING_AJAX')) {
95 95
                 EE_Error::doing_it_wrong(
96
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
96
+                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter,
97 97
                     sprintf(
98 98
                         __(
99 99
                             'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
100 100
                             'event_espresso'
101 101
                         ),
102
-                        'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
102
+                        'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter,
103 103
                         '<br />',
104 104
                         'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
105 105
                         '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
                 );
109 109
             }
110 110
         } else {
111
-            unset($deprecated_filters[ $deprecated_filter ]);
111
+            unset($deprecated_filters[$deprecated_filter]);
112 112
         }
113 113
     }
114
-    if (! empty($deprecated_filters)) {
114
+    if ( ! empty($deprecated_filters)) {
115 115
 
116 116
         if ($checkout->current_step->slug(
117 117
             ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                 $submit_button_text = apply_filters(
146 146
                                           'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
147 147
                                           $submit_button_text
148
-                                      ) . $checkout->next_step->name();
148
+                                      ).$checkout->next_step->name();
149 149
             }
150 150
         }
151 151
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
             'event_espresso'
330 330
         );
331 331
         EE_Error::doing_it_wrong(
332
-            __CLASS__ . '::' . __FUNCTION__,
332
+            __CLASS__.'::'.__FUNCTION__,
333 333
             $msg,
334 334
             '4.8.32.rc.000'
335 335
         );
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 function ee_deprecated_update_attendee_registration_form_old($admin_page)
357 357
 {
358 358
     // check if the old hooks are in use. If not, do the default
359
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
359
+    if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
360 360
         || ! $admin_page instanceof EE_Admin_Page) {
361 361
         return;
362 362
     }
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
     $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
365 365
     $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
366 366
     $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
367
-    if (! $REG_ID || ! $qstns) {
367
+    if ( ! $REG_ID || ! $qstns) {
368 368
         EE_Error::add_error(
369 369
             __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
370 370
             __FILE__,
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
 
385 385
     foreach ($qstns as $QST_ID => $qstn) {
386 386
         // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
387
-        if (! is_array($qstn)) {
388
-            $success = EE_Answer::new_instance([ 'QST_ID' => $QST_ID, 'REG_ID' => $REG_ID ]);
387
+        if ( ! is_array($qstn)) {
388
+            $success = EE_Answer::new_instance(['QST_ID' => $QST_ID, 'REG_ID' => $REG_ID]);
389 389
             continue;
390 390
         }
391 391
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
             );
402 402
             $answer = EEM_Answer::instance()->get_one($query_params);
403 403
             // this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
404
-            if (! $answer instanceof EE_Answer) {
404
+            if ( ! $answer instanceof EE_Answer) {
405 405
                 $set_values = array(
406 406
                     'QST_ID'    => $QST_ID,
407 407
                     'REG_ID'    => $REG_ID,
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration)
443 443
 {
444 444
     // check if the old hooks are in use. If not, do the default
445
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
445
+    if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
446 446
         || ! $admin_page instanceof EE_Admin_Page) {
447 447
         return $do_default_action;
448 448
     }
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
         'reg_questions_form_action' => 'edit_registration',
473 473
         'REG_ID'                    => $registration->ID(),
474 474
     );
475
-    $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
475
+    $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
476 476
     echo EEH_Template::display_template($template_path, $template_args, true);
477 477
     // indicate that we should not do the default admin page code
478 478
     return false;
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
     public function _class_is_deprecated($method)
591 591
     {
592 592
         EE_Error::doing_it_wrong(
593
-            'EE_messages::' . $method,
593
+            'EE_messages::'.$method,
594 594
             __('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
595 595
             '4.9.0',
596 596
             '4.10.0.p'
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
         $error = false;
730 730
         // try to intelligently determine what method we'll call based on the incoming data.
731 731
         // if generating and sending are different then generate and send immediately.
732
-        if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
732
+        if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
733 733
             // in the legacy system, when generating and sending were different, that means all the
734 734
             // vars are already in the request object.  So let's just use that.
735 735
             try {
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
                     'event_espresso'
743 743
                 );
744 744
                 // add specific message for developers if WP_DEBUG in on
745
-                $error_msg .= '||' . $e->getMessage();
745
+                $error_msg .= '||'.$e->getMessage();
746 746
                 EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
747 747
                 $error = true;
748 748
             }
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
             }
817 817
         }
818 818
         // if no error then return the generated message(s).
819
-        if (! $error && ! $send) {
819
+        if ( ! $error && ! $send) {
820 820
             $generated_queue = $processor->generate_queue(false);
821 821
             // get message and return.
822 822
             $generated_queue->get_message_repository()->rewind();
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
         /** @type EE_Messages_Queue $queue */
876 876
         $queue = EE_Registry::instance()->load_lib('Messages_Queue');
877 877
         // make sure we have a proper message object
878
-        if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
878
+        if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
879 879
             $msg = EE_Message_Factory::create(
880 880
                 array(
881 881
                     'MSG_messenger'    => $messenger,
@@ -887,11 +887,11 @@  discard block
 block discarded – undo
887 887
         } else {
888 888
             $msg = $message;
889 889
         }
890
-        if (! $msg instanceof EE_Message) {
890
+        if ( ! $msg instanceof EE_Message) {
891 891
             return false;
892 892
         }
893 893
         // make sure any content in a content property (if not empty) is set on the MSG_content.
894
-        if (! empty($msg->content)) {
894
+        if ( ! empty($msg->content)) {
895 895
             $msg->set('MSG_content', $msg->content);
896 896
         }
897 897
         $queue->add($msg);
@@ -1130,8 +1130,8 @@  discard block
 block discarded – undo
1130 1130
 
1131 1131
 add_filter(
1132 1132
     'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1133
-    function ($event_list_iframe_css) {
1134
-        if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1133
+    function($event_list_iframe_css) {
1134
+        if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1135 1135
             return $event_list_iframe_css;
1136 1136
         }
1137 1137
         deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1150,8 +1150,8 @@  discard block
 block discarded – undo
1150 1150
 );
1151 1151
 add_filter(
1152 1152
     'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1153
-    function ($event_list_iframe_js) {
1154
-        if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1153
+    function($event_list_iframe_js) {
1154
+        if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1155 1155
             return $event_list_iframe_js;
1156 1156
         }
1157 1157
         deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1170,8 +1170,8 @@  discard block
 block discarded – undo
1170 1170
 );
1171 1171
 add_action(
1172 1172
     'AHEE__EE_Capabilities__addCaps__complete',
1173
-    function ($capabilities_map) {
1174
-        if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1173
+    function($capabilities_map) {
1174
+        if ( ! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1175 1175
             return;
1176 1176
         }
1177 1177
         deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 
1191 1191
 add_filter(
1192 1192
     'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1193
-    function ($existing_attendee, $registration, $attendee_data) {
1194
-        if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1193
+    function($existing_attendee, $registration, $attendee_data) {
1194
+        if ( ! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1195 1195
             return $existing_attendee;
1196 1196
         }
1197 1197
         deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
      */
1275 1275
     public function event_list_title($event_list_title = '')
1276 1276
     {
1277
-        if (! empty($this->title)) {
1277
+        if ( ! empty($this->title)) {
1278 1278
             return $this->title;
1279 1279
         }
1280 1280
         return $event_list_title;
@@ -1434,7 +1434,7 @@  discard block
 block discarded – undo
1434 1434
             foreach ($model_fields as $field) {
1435 1435
                 if ($label === EEH_Export::get_column_name_for_field($field)) {
1436 1436
                     // re-add the old field name
1437
-                    $new_label = $label . '[' . $field->get_name() . ']';
1437
+                    $new_label = $label.'['.$field->get_name().']';
1438 1438
                     break;
1439 1439
                 }
1440 1440
             }
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 1 patch
Indentation   +1414 added lines, -1414 removed lines patch added patch discarded remove patch
@@ -17,1418 +17,1418 @@
 block discarded – undo
17 17
 class Extend_Events_Admin_Page extends Events_Admin_Page
18 18
 {
19 19
 
20
-    /**
21
-     * @var EE_Admin_Config
22
-     */
23
-    protected $admin_config;
24
-
25
-    /**
26
-     * @var AdvancedEditorAdminFormSection
27
-     */
28
-    protected $advanced_editor_admin_form;
29
-
30
-
31
-    /**
32
-     * Extend_Events_Admin_Page constructor.
33
-     *
34
-     * @param bool $routing
35
-     * @throws ReflectionException
36
-     */
37
-    public function __construct($routing = true)
38
-    {
39
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
40
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
41
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
42
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
43
-        }
44
-        parent::__construct($routing);
45
-        $this->admin_config = $this->loader->getShared('EE_Admin_Config');
46
-    }
47
-
48
-
49
-    /**
50
-     * Sets routes.
51
-     *
52
-     * @throws EE_Error
53
-     * @throws InvalidArgumentException
54
-     * @throws InvalidDataTypeException
55
-     * @throws InvalidInterfaceException
56
-     * @throws Exception
57
-     */
58
-    protected function _extend_page_config()
59
-    {
60
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
61
-        // is there a evt_id in the request?
62
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
63
-            ? $this->_req_data['EVT_ID']
64
-            : 0;
65
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
66
-        // tkt_id?
67
-        $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
68
-            ? $this->_req_data['TKT_ID']
69
-            : 0;
70
-        $new_page_routes = [
71
-            'duplicate_event'          => [
72
-                'func'       => '_duplicate_event',
73
-                'capability' => 'ee_edit_event',
74
-                'obj_id'     => $evt_id,
75
-                'noheader'   => true,
76
-            ],
77
-            'import_page'              => [
78
-                'func'       => '_import_page',
79
-                'capability' => 'import',
80
-            ],
81
-            'import'                   => [
82
-                'func'       => '_import_events',
83
-                'capability' => 'import',
84
-                'noheader'   => true,
85
-            ],
86
-            'import_events'            => [
87
-                'func'       => '_import_events',
88
-                'capability' => 'import',
89
-                'noheader'   => true,
90
-            ],
91
-            'export_events'            => [
92
-                'func'       => '_events_export',
93
-                'capability' => 'export',
94
-                'noheader'   => true,
95
-            ],
96
-            'export_categories'        => [
97
-                'func'       => '_categories_export',
98
-                'capability' => 'export',
99
-                'noheader'   => true,
100
-            ],
101
-            'sample_export_file'       => [
102
-                'func'       => '_sample_export_file',
103
-                'capability' => 'export',
104
-                'noheader'   => true,
105
-            ],
106
-            'update_template_settings' => [
107
-                'func'       => '_update_template_settings',
108
-                'capability' => 'manage_options',
109
-                'noheader'   => true,
110
-            ],
111
-        ];        // don't load these meta boxes if using the advanced editor
112
-        $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
113
-        $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes';
114
-        if (! $this->admin_config->useAdvancedEditor()) {
115
-            $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
116
-            $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips';
117
-
118
-            $legacy_editor_page_routes = [
119
-                'ticket_list_table' => [
120
-                    'func'       => '_tickets_overview_list_table',
121
-                    'capability' => 'ee_read_default_tickets',
122
-                ],
123
-                'trash_ticket'      => [
124
-                    'func'       => '_trash_or_restore_ticket',
125
-                    'capability' => 'ee_delete_default_ticket',
126
-                    'obj_id'     => $tkt_id,
127
-                    'noheader'   => true,
128
-                    'args'       => ['trash' => true],
129
-                ],
130
-                'trash_tickets'     => [
131
-                    'func'       => '_trash_or_restore_ticket',
132
-                    'capability' => 'ee_delete_default_tickets',
133
-                    'noheader'   => true,
134
-                    'args'       => ['trash' => true],
135
-                ],
136
-                'restore_ticket'    => [
137
-                    'func'       => '_trash_or_restore_ticket',
138
-                    'capability' => 'ee_delete_default_ticket',
139
-                    'obj_id'     => $tkt_id,
140
-                    'noheader'   => true,
141
-                ],
142
-                'restore_tickets'   => [
143
-                    'func'       => '_trash_or_restore_ticket',
144
-                    'capability' => 'ee_delete_default_tickets',
145
-                    'noheader'   => true,
146
-                ],
147
-                'delete_ticket'     => [
148
-                    'func'       => '_delete_ticket',
149
-                    'capability' => 'ee_delete_default_ticket',
150
-                    'obj_id'     => $tkt_id,
151
-                    'noheader'   => true,
152
-                ],
153
-                'delete_tickets'    => [
154
-                    'func'       => '_delete_ticket',
155
-                    'capability' => 'ee_delete_default_tickets',
156
-                    'noheader'   => true,
157
-                ],
158
-            ];
159
-            $new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes);
160
-        }
161
-
162
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
163
-        // partial route/config override
164
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
165
-        $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table';
166
-        // add tickets tab but only if there are more than one default ticket!
167
-        $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
168
-            [['TKT_is_default' => 1]],
169
-            'TKT_ID',
170
-            true
171
-        );
172
-        if ($tkt_count > 1) {
173
-            $new_page_config = [
174
-                'ticket_list_table' => [
175
-                    'nav'           => [
176
-                        'label' => esc_html__('Default Tickets', 'event_espresso'),
177
-                        'order' => 60,
178
-                    ],
179
-                    'list_table'    => 'Tickets_List_Table',
180
-                    'require_nonce' => false,
181
-                ],
182
-            ];
183
-        }
184
-        // template settings
185
-        $new_page_config['template_settings'] = [
186
-            'nav'           => [
187
-                'label' => esc_html__('Templates', 'event_espresso'),
188
-                'order' => 30,
189
-            ],
190
-            'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
191
-            'help_tabs'     => [
192
-                'general_settings_templates_help_tab' => [
193
-                    'title'    => esc_html__('Templates', 'event_espresso'),
194
-                    'filename' => 'general_settings_templates',
195
-                ],
196
-            ],
197
-           // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
198
-            // 'help_tour'     => ['Templates_Help_Tour'],
199
-            'require_nonce' => false,
200
-        ];
201
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
202
-        // add filters and actions
203
-        // modifying _views
204
-        add_filter(
205
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
206
-            [$this, 'add_additional_datetime_button'],
207
-            10,
208
-            2
209
-        );
210
-        add_filter(
211
-            'FHEE_event_datetime_metabox_clone_button_template',
212
-            [$this, 'add_datetime_clone_button'],
213
-            10,
214
-            2
215
-        );
216
-        add_filter(
217
-            'FHEE_event_datetime_metabox_timezones_template',
218
-            [$this, 'datetime_timezones_template'],
219
-            10,
220
-            2
221
-        );
222
-        // filters for event list table
223
-        add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2);
224
-        add_filter(
225
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
226
-            [$this, 'extra_list_table_actions'],
227
-            10,
228
-            2
229
-        );
230
-        // legend item
231
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
232
-        add_action('admin_init', [$this, 'admin_init']);
233
-        // load additional handlers
234
-        $this->handleActionRequest();
235
-    }
236
-
237
-
238
-    private function getRequestAction()
239
-    {
240
-        return isset($this->_req_data['action']) ? sanitize_key($this->_req_data['action']) : null;
241
-    }
242
-
243
-
244
-    /**
245
-     * @throws Exception
246
-     */
247
-    private function handleActionRequest()
248
-    {
249
-        $action = $this->getRequestAction();
250
-        if ($action) {
251
-            // setup Advanced Editor ???
252
-            if ($action === 'default_event_settings' || $action === 'update_default_event_settings') {
253
-                $this->advanced_editor_admin_form = $this->loader->getShared(
254
-                    'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'
255
-                );
256
-            }
257
-        }
258
-    }
259
-
260
-
261
-    /**
262
-     * admin_init
263
-     */
264
-    public function admin_init()
265
-    {
266
-        EE_Registry::$i18n_js_strings = array_merge(
267
-            EE_Registry::$i18n_js_strings,
268
-            [
269
-                'image_confirm'          => esc_html__(
270
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
271
-                    'event_espresso'
272
-                ),
273
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
274
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
275
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
276
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
277
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
278
-            ]
279
-        );
280
-    }
281
-
282
-
283
-    /**
284
-     * Add per page screen options to the default ticket list table view.
285
-     *
286
-     * @throws InvalidArgumentException
287
-     * @throws InvalidDataTypeException
288
-     * @throws InvalidInterfaceException
289
-     */
290
-    protected function _add_screen_options_ticket_list_table()
291
-    {
292
-        $this->_per_page_screen_option();
293
-    }
294
-
295
-
296
-    /**
297
-     * @param string $return
298
-     * @param int    $id
299
-     * @param string $new_title
300
-     * @param string $new_slug
301
-     * @return string
302
-     */
303
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
304
-    {
305
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
306
-        // make sure this is only when editing
307
-        if (! empty($id)) {
308
-            $href = EE_Admin_Page::add_query_args_and_nonce(
309
-                ['action' => 'duplicate_event', 'EVT_ID' => $id],
310
-                $this->_admin_base_url
311
-            );
312
-            $title = esc_attr__('Duplicate Event', 'event_espresso');
313
-            $return .= '<a href="'
314
-                       . $href
315
-                       . '" title="'
316
-                       . $title
317
-                       . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
318
-                       . $title
319
-                       . '</a>';
320
-        }
321
-        return $return;
322
-    }
323
-
324
-
325
-    /**
326
-     * Set the list table views for the default ticket list table view.
327
-     */
328
-    public function _set_list_table_views_ticket_list_table()
329
-    {
330
-        $this->_views = [
331
-            'all'     => [
332
-                'slug'        => 'all',
333
-                'label'       => esc_html__('All', 'event_espresso'),
334
-                'count'       => 0,
335
-                'bulk_action' => [
336
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
337
-                ],
338
-            ],
339
-            'trashed' => [
340
-                'slug'        => 'trashed',
341
-                'label'       => esc_html__('Trash', 'event_espresso'),
342
-                'count'       => 0,
343
-                'bulk_action' => [
344
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
345
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
346
-                ],
347
-            ],
348
-        ];
349
-    }
350
-
351
-
352
-    /**
353
-     * Enqueue scripts and styles for the event editor.
354
-     */
355
-    public function load_scripts_styles_edit()
356
-    {
357
-        if (! $this->admin_config->useAdvancedEditor()) {
358
-            wp_register_script(
359
-                'ee-event-editor-heartbeat',
360
-                EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
361
-                ['ee_admin_js', 'heartbeat'],
362
-                EVENT_ESPRESSO_VERSION,
363
-                true
364
-            );
365
-            wp_enqueue_script('ee-accounting');
366
-            wp_enqueue_script('ee-event-editor-heartbeat');
367
-        }
368
-        wp_enqueue_script('event_editor_js');
369
-        // styles
370
-        wp_enqueue_style('espresso-ui-theme');
371
-    }
372
-
373
-
374
-    /**
375
-     * Returns template for the additional datetime.
376
-     *
377
-     * @param $template
378
-     * @param $template_args
379
-     * @return mixed
380
-     * @throws DomainException
381
-     */
382
-    public function add_additional_datetime_button($template, $template_args)
383
-    {
384
-        return EEH_Template::display_template(
385
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
386
-            $template_args,
387
-            true
388
-        );
389
-    }
390
-
391
-
392
-    /**
393
-     * Returns the template for cloning a datetime.
394
-     *
395
-     * @param $template
396
-     * @param $template_args
397
-     * @return mixed
398
-     * @throws DomainException
399
-     */
400
-    public function add_datetime_clone_button($template, $template_args)
401
-    {
402
-        return EEH_Template::display_template(
403
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
404
-            $template_args,
405
-            true
406
-        );
407
-    }
408
-
409
-
410
-    /**
411
-     * Returns the template for datetime timezones.
412
-     *
413
-     * @param $template
414
-     * @param $template_args
415
-     * @return mixed
416
-     * @throws DomainException
417
-     */
418
-    public function datetime_timezones_template($template, $template_args)
419
-    {
420
-        return EEH_Template::display_template(
421
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
422
-            $template_args,
423
-            true
424
-        );
425
-    }
426
-
427
-
428
-    /**
429
-     * Sets the views for the default list table view.
430
-     *
431
-     * @throws EE_Error
432
-     */
433
-    protected function _set_list_table_views_default()
434
-    {
435
-        parent::_set_list_table_views_default();
436
-        $new_views = [
437
-            'today' => [
438
-                'slug'        => 'today',
439
-                'label'       => esc_html__('Today', 'event_espresso'),
440
-                'count'       => $this->total_events_today(),
441
-                'bulk_action' => [
442
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
443
-                ],
444
-            ],
445
-            'month' => [
446
-                'slug'        => 'month',
447
-                'label'       => esc_html__('This Month', 'event_espresso'),
448
-                'count'       => $this->total_events_this_month(),
449
-                'bulk_action' => [
450
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
451
-                ],
452
-            ],
453
-        ];
454
-        $this->_views = array_merge($this->_views, $new_views);
455
-    }
456
-
457
-
458
-    /**
459
-     * Returns the extra action links for the default list table view.
460
-     *
461
-     * @param array    $action_links
462
-     * @param EE_Event $event
463
-     * @return array
464
-     * @throws EE_Error
465
-     * @throws InvalidArgumentException
466
-     * @throws InvalidDataTypeException
467
-     * @throws InvalidInterfaceException
468
-     * @throws ReflectionException
469
-     */
470
-    public function extra_list_table_actions(array $action_links, EE_Event $event)
471
-    {
472
-        if (
473
-            EE_Registry::instance()->CAP->current_user_can(
474
-                'ee_read_registrations',
475
-                'espresso_registrations_reports',
476
-                $event->ID()
477
-            )
478
-        ) {
479
-            $reports_query_args = [
480
-                'action' => 'reports',
481
-                'EVT_ID' => $event->ID(),
482
-            ];
483
-            $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
484
-            $action_links[] = '<a href="'
485
-                              . $reports_link
486
-                              . '" title="'
487
-                              . esc_attr__('View Report', 'event_espresso')
488
-                              . '"><div class="dashicons dashicons-chart-bar"></div></a>'
489
-                              . "\n\t";
490
-        }
491
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
492
-            EE_Registry::instance()->load_helper('MSG_Template');
493
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
494
-                'see_notifications_for',
495
-                null,
496
-                ['EVT_ID' => $event->ID()]
497
-            );
498
-        }
499
-        return $action_links;
500
-    }
501
-
502
-
503
-    /**
504
-     * @param $items
505
-     * @return mixed
506
-     */
507
-    public function additional_legend_items($items)
508
-    {
509
-        if (
510
-            EE_Registry::instance()->CAP->current_user_can(
511
-                'ee_read_registrations',
512
-                'espresso_registrations_reports'
513
-            )
514
-        ) {
515
-            $items['reports'] = [
516
-                'class' => 'dashicons dashicons-chart-bar',
517
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
518
-            ];
519
-        }
520
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
521
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
522
-            // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
523
-            // (can only use numeric offsets when treating strings as arrays)
524
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
525
-                $items['view_related_messages'] = [
526
-                    'class' => $related_for_icon['css_class'],
527
-                    'desc'  => $related_for_icon['label'],
528
-                ];
529
-            }
530
-        }
531
-        return $items;
532
-    }
533
-
534
-
535
-    /**
536
-     * This is the callback method for the duplicate event route
537
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
538
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
539
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
540
-     * After duplication the redirect is to the new event edit page.
541
-     *
542
-     * @return void
543
-     * @throws EE_Error If EE_Event is not available with given ID
544
-     * @throws InvalidArgumentException
545
-     * @throws InvalidDataTypeException
546
-     * @throws InvalidInterfaceException
547
-     * @throws ReflectionException
548
-     * @access protected
549
-     */
550
-    protected function _duplicate_event()
551
-    {
552
-        // first make sure the ID for the event is in the request.
553
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
554
-        if (! isset($this->_req_data['EVT_ID'])) {
555
-            EE_Error::add_error(
556
-                esc_html__(
557
-                    'In order to duplicate an event an Event ID is required.  None was given.',
558
-                    'event_espresso'
559
-                ),
560
-                __FILE__,
561
-                __FUNCTION__,
562
-                __LINE__
563
-            );
564
-            $this->_redirect_after_action(false, '', '', [], true);
565
-            return;
566
-        }
567
-        // k we've got EVT_ID so let's use that to get the event we'll duplicate
568
-        $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
569
-        if (! $orig_event instanceof EE_Event) {
570
-            throw new EE_Error(
571
-                sprintf(
572
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
573
-                    $this->_req_data['EVT_ID']
574
-                )
575
-            );
576
-        }
577
-        // k now let's clone the $orig_event before getting relations
578
-        $new_event = clone $orig_event;
579
-        // original datetimes
580
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
581
-        // other original relations
582
-        $orig_ven = $orig_event->get_many_related('Venue');
583
-        // reset the ID and modify other details to make it clear this is a dupe
584
-        $new_event->set('EVT_ID', 0);
585
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
586
-        $new_event->set('EVT_name', $new_name);
587
-        $new_event->set(
588
-            'EVT_slug',
589
-            wp_unique_post_slug(
590
-                sanitize_title($orig_event->name()),
591
-                0,
592
-                'publish',
593
-                'espresso_events',
594
-                0
595
-            )
596
-        );
597
-        $new_event->set('status', 'draft');
598
-        // duplicate discussion settings
599
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
600
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
601
-        // save the new event
602
-        $new_event->save();
603
-        // venues
604
-        foreach ($orig_ven as $ven) {
605
-            $new_event->_add_relation_to($ven, 'Venue');
606
-        }
607
-        $new_event->save();
608
-        // now we need to get the question group relations and handle that
609
-        // first primary question groups
610
-        $orig_primary_qgs = $orig_event->get_many_related(
611
-            'Question_Group',
612
-            [['Event_Question_Group.EQG_primary' => true]]
613
-        );
614
-        if (! empty($orig_primary_qgs)) {
615
-            foreach ($orig_primary_qgs as $id => $obj) {
616
-                if ($obj instanceof EE_Question_Group) {
617
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
618
-                }
619
-            }
620
-        }
621
-        // next additional attendee question groups
622
-        $orig_additional_qgs = $orig_event->get_many_related(
623
-            'Question_Group',
624
-            [['Event_Question_Group.EQG_additional' => true]]
625
-        );
626
-        if (! empty($orig_additional_qgs)) {
627
-            foreach ($orig_additional_qgs as $id => $obj) {
628
-                if ($obj instanceof EE_Question_Group) {
629
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
630
-                }
631
-            }
632
-        }
633
-
634
-        $new_event->save();
635
-
636
-        // k now that we have the new event saved we can loop through the datetimes and start adding relations.
637
-        $cloned_tickets = [];
638
-        foreach ($orig_datetimes as $orig_dtt) {
639
-            if (! $orig_dtt instanceof EE_Datetime) {
640
-                continue;
641
-            }
642
-            $new_dtt = clone $orig_dtt;
643
-            $orig_tkts = $orig_dtt->tickets();
644
-            // save new dtt then add to event
645
-            $new_dtt->set('DTT_ID', 0);
646
-            $new_dtt->set('DTT_sold', 0);
647
-            $new_dtt->set_reserved(0);
648
-            $new_dtt->save();
649
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
650
-            $new_event->save();
651
-            // now let's get the ticket relations setup.
652
-            foreach ((array) $orig_tkts as $orig_tkt) {
653
-                // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
654
-                if (! $orig_tkt instanceof EE_Ticket) {
655
-                    continue;
656
-                }
657
-                // is this ticket archived?  If it is then let's skip
658
-                if ($orig_tkt->get('TKT_deleted')) {
659
-                    continue;
660
-                }
661
-                // does this original ticket already exist in the clone_tickets cache?
662
-                //  If so we'll just use the new ticket from it.
663
-                if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
664
-                    $new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
665
-                } else {
666
-                    $new_tkt = clone $orig_tkt;
667
-                    // get relations on the $orig_tkt that we need to setup.
668
-                    $orig_prices = $orig_tkt->prices();
669
-                    $new_tkt->set('TKT_ID', 0);
670
-                    $new_tkt->set('TKT_sold', 0);
671
-                    $new_tkt->set('TKT_reserved', 0);
672
-                    $new_tkt->save(); // make sure new ticket has ID.
673
-                    // price relations on new ticket need to be setup.
674
-                    foreach ($orig_prices as $orig_price) {
675
-                        $new_price = clone $orig_price;
676
-                        $new_price->set('PRC_ID', 0);
677
-                        $new_price->save();
678
-                        $new_tkt->_add_relation_to($new_price, 'Price');
679
-                        $new_tkt->save();
680
-                    }
681
-
682
-                    do_action(
683
-                        'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
684
-                        $orig_tkt,
685
-                        $new_tkt,
686
-                        $orig_prices,
687
-                        $orig_event,
688
-                        $orig_dtt,
689
-                        $new_dtt
690
-                    );
691
-                }
692
-                // k now we can add the new ticket as a relation to the new datetime
693
-                // and make sure its added to our cached $cloned_tickets array
694
-                // for use with later datetimes that have the same ticket.
695
-                $new_dtt->_add_relation_to($new_tkt, 'Ticket');
696
-                $new_dtt->save();
697
-                $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
698
-            }
699
-        }
700
-        // clone taxonomy information
701
-        $taxonomies_to_clone_with = apply_filters(
702
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
703
-            ['espresso_event_categories', 'espresso_event_type', 'post_tag']
704
-        );
705
-        // get terms for original event (notice)
706
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
707
-        // loop through terms and add them to new event.
708
-        foreach ($orig_terms as $term) {
709
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
710
-        }
711
-
712
-        // duplicate other core WP_Post items for this event.
713
-        // post thumbnail (feature image).
714
-        $feature_image_id = get_post_thumbnail_id($orig_event->ID());
715
-        if ($feature_image_id) {
716
-            update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
717
-        }
718
-
719
-        // duplicate page_template setting
720
-        $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
721
-        if ($page_template) {
722
-            update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
723
-        }
724
-
725
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
726
-        // now let's redirect to the edit page for this duplicated event if we have a new event id.
727
-        if ($new_event->ID()) {
728
-            $redirect_args = [
729
-                'post'   => $new_event->ID(),
730
-                'action' => 'edit',
731
-            ];
732
-            EE_Error::add_success(
733
-                esc_html__(
734
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
735
-                    'event_espresso'
736
-                )
737
-            );
738
-        } else {
739
-            $redirect_args = [
740
-                'action' => 'default',
741
-            ];
742
-            EE_Error::add_error(
743
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
744
-                __FILE__,
745
-                __FUNCTION__,
746
-                __LINE__
747
-            );
748
-        }
749
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
750
-    }
751
-
752
-
753
-    /**
754
-     * Generates output for the import page.
755
-     *
756
-     * @throws DomainException
757
-     * @throws EE_Error
758
-     * @throws InvalidArgumentException
759
-     * @throws InvalidDataTypeException
760
-     * @throws InvalidInterfaceException
761
-     */
762
-    protected function _import_page()
763
-    {
764
-        $title = esc_html__('Import', 'event_espresso');
765
-        $intro = esc_html__(
766
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
767
-            'event_espresso'
768
-        );
769
-        $form_url = EVENTS_ADMIN_URL;
770
-        $action = 'import_events';
771
-        $type = 'csv';
772
-        $this->_template_args['form'] = EE_Import::instance()->upload_form(
773
-            $title,
774
-            $intro,
775
-            $form_url,
776
-            $action,
777
-            $type
778
-        );
779
-        $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(
780
-            ['action' => 'sample_export_file'],
781
-            $this->_admin_base_url
782
-        );
783
-        $content = EEH_Template::display_template(
784
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
785
-            $this->_template_args,
786
-            true
787
-        );
788
-        $this->_template_args['admin_page_content'] = $content;
789
-        $this->display_admin_page_with_sidebar();
790
-    }
791
-
792
-
793
-    /**
794
-     * _import_events
795
-     * This handles displaying the screen and running imports for importing events.
796
-     *
797
-     * @return void
798
-     * @throws EE_Error
799
-     * @throws InvalidArgumentException
800
-     * @throws InvalidDataTypeException
801
-     * @throws InvalidInterfaceException
802
-     */
803
-    protected function _import_events()
804
-    {
805
-        require_once(EE_CLASSES . 'EE_Import.class.php');
806
-        $success = EE_Import::instance()->import();
807
-        $this->_redirect_after_action($success, 'Import File', 'ran', ['action' => 'import_page'], true);
808
-    }
809
-
810
-
811
-    /**
812
-     * _events_export
813
-     * Will export all (or just the given event) to a Excel compatible file.
814
-     *
815
-     * @access protected
816
-     * @return void
817
-     */
818
-    protected function _events_export()
819
-    {
820
-        if (isset($this->_req_data['EVT_ID'])) {
821
-            $event_ids = $this->_req_data['EVT_ID'];
822
-        } elseif (isset($this->_req_data['EVT_IDs'])) {
823
-            $event_ids = $this->_req_data['EVT_IDs'];
824
-        } else {
825
-            $event_ids = null;
826
-        }
827
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
828
-        $new_request_args = [
829
-            'export' => 'report',
830
-            'action' => 'all_event_data',
831
-            'EVT_ID' => $event_ids,
832
-        ];
833
-        $this->_req_data = array_merge($this->_req_data, $new_request_args);
834
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
835
-            require_once(EE_CLASSES . 'EE_Export.class.php');
836
-            $EE_Export = EE_Export::instance($this->_req_data);
837
-            if ($EE_Export instanceof EE_Export) {
838
-                $EE_Export->export();
839
-            }
840
-        }
841
-    }
842
-
843
-
844
-    /**
845
-     * handle category exports()
846
-     *
847
-     * @return void
848
-     */
849
-    protected function _categories_export()
850
-    {
851
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
852
-        $new_request_args = [
853
-            'export'       => 'report',
854
-            'action'       => 'categories',
855
-            'category_ids' => $this->_req_data['EVT_CAT_ID'],
856
-        ];
857
-        $this->_req_data = array_merge($this->_req_data, $new_request_args);
858
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
859
-            require_once(EE_CLASSES . 'EE_Export.class.php');
860
-            $EE_Export = EE_Export::instance($this->_req_data);
861
-            if ($EE_Export instanceof EE_Export) {
862
-                $EE_Export->export();
863
-            }
864
-        }
865
-    }
866
-
867
-
868
-    /**
869
-     * Creates a sample CSV file for importing
870
-     */
871
-    protected function _sample_export_file()
872
-    {
873
-        $EE_Export = EE_Export::instance();
874
-        if ($EE_Export instanceof EE_Export) {
875
-            $EE_Export->export();
876
-        }
877
-    }
878
-
879
-
880
-    /*************        Template Settings        *************/
881
-    /**
882
-     * Generates template settings page output
883
-     *
884
-     * @throws DomainException
885
-     * @throws EE_Error
886
-     * @throws InvalidArgumentException
887
-     * @throws InvalidDataTypeException
888
-     * @throws InvalidInterfaceException
889
-     */
890
-    protected function _template_settings()
891
-    {
892
-        $this->_template_args['values'] = $this->_yes_no_values;
893
-        /**
894
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
895
-         * from General_Settings_Admin_Page to here.
896
-         */
897
-        $this->_template_args = apply_filters(
898
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
899
-            $this->_template_args
900
-        );
901
-        $this->_set_add_edit_form_tags('update_template_settings');
902
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
903
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
904
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
905
-            $this->_template_args,
906
-            true
907
-        );
908
-        $this->display_admin_page_with_sidebar();
909
-    }
910
-
911
-
912
-    /**
913
-     * Handler for updating template settings.
914
-     *
915
-     * @throws EE_Error
916
-     * @throws InvalidArgumentException
917
-     * @throws InvalidDataTypeException
918
-     * @throws InvalidInterfaceException
919
-     */
920
-    protected function _update_template_settings()
921
-    {
922
-        /**
923
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
924
-         * from General_Settings_Admin_Page to here.
925
-         */
926
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
927
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
928
-            EE_Registry::instance()->CFG->template_settings,
929
-            $this->_req_data
930
-        );
931
-        // update custom post type slugs and detect if we need to flush rewrite rules
932
-        $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
933
-        EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
934
-            ? EE_Registry::instance()->CFG->core->event_cpt_slug
935
-            : EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
936
-        $what = 'Template Settings';
937
-        $success = $this->_update_espresso_configuration(
938
-            $what,
939
-            EE_Registry::instance()->CFG->template_settings,
940
-            __FILE__,
941
-            __FUNCTION__,
942
-            __LINE__
943
-        );
944
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
945
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
946
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
947
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
948
-            );
949
-            $rewrite_rules->flush();
950
-        }
951
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
952
-    }
953
-
954
-
955
-    /**
956
-     * _premium_event_editor_meta_boxes
957
-     * add all metaboxes related to the event_editor
958
-     *
959
-     * @access protected
960
-     * @return void
961
-     * @throws EE_Error
962
-     * @throws InvalidArgumentException
963
-     * @throws InvalidDataTypeException
964
-     * @throws InvalidInterfaceException
965
-     * @throws ReflectionException
966
-     */
967
-    protected function _premium_event_editor_meta_boxes()
968
-    {
969
-        $this->verify_cpt_object();
970
-        /** @var FeatureFlags $flags */
971
-        $flags = $this->loader->getShared('EventEspresso\core\domain\services\capabilities\FeatureFlags');
972
-        // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
973
-        if (! $this->admin_config->useAdvancedEditor() || ! $flags->featureAllowed('use_reg_options_meta_box')) {
974
-            add_meta_box(
975
-                'espresso_event_editor_event_options',
976
-                esc_html__('Event Registration Options', 'event_espresso'),
977
-                [$this, 'registration_options_meta_box'],
978
-                $this->page_slug,
979
-                'side',
980
-                'core'
981
-            );
982
-        }
983
-    }
984
-
985
-
986
-    /**
987
-     * override caf metabox
988
-     *
989
-     * @return void
990
-     * @throws DomainException
991
-     * @throws EE_Error
992
-     */
993
-    public function registration_options_meta_box()
994
-    {
995
-        $yes_no_values = [
996
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
997
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
998
-        ];
999
-        $default_reg_status_values = EEM_Registration::reg_status_array(
1000
-            [
1001
-                EEM_Registration::status_id_cancelled,
1002
-                EEM_Registration::status_id_declined,
1003
-                EEM_Registration::status_id_incomplete,
1004
-                EEM_Registration::status_id_wait_list,
1005
-            ],
1006
-            true
1007
-        );
1008
-        $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1009
-        $template_args['_event'] = $this->_cpt_model_obj;
1010
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1011
-        $template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1012
-            'default_reg_status',
1013
-            $default_reg_status_values,
1014
-            $this->_cpt_model_obj->default_registration_status()
1015
-        );
1016
-        $template_args['display_description'] = EEH_Form_Fields::select_input(
1017
-            'display_desc',
1018
-            $yes_no_values,
1019
-            $this->_cpt_model_obj->display_description()
1020
-        );
1021
-        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1022
-            'display_ticket_selector',
1023
-            $yes_no_values,
1024
-            $this->_cpt_model_obj->display_ticket_selector(),
1025
-            '',
1026
-            '',
1027
-            false
1028
-        );
1029
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
1030
-            'EVT_default_registration_status',
1031
-            $default_reg_status_values,
1032
-            $this->_cpt_model_obj->default_registration_status()
1033
-        );
1034
-        $template_args['additional_registration_options'] = apply_filters(
1035
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1036
-            '',
1037
-            $template_args,
1038
-            $yes_no_values,
1039
-            $default_reg_status_values
1040
-        );
1041
-        EEH_Template::display_template(
1042
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1043
-            $template_args
1044
-        );
1045
-    }
1046
-
1047
-
1048
-
1049
-    /**
1050
-     * wp_list_table_mods for caf
1051
-     * ============================
1052
-     */
1053
-    /**
1054
-     * hook into list table filters and provide filters for caffeinated list table
1055
-     *
1056
-     * @param array $old_filters    any existing filters present
1057
-     * @param array $list_table_obj the list table object
1058
-     * @return array                  new filters
1059
-     * @throws EE_Error
1060
-     * @throws InvalidArgumentException
1061
-     * @throws InvalidDataTypeException
1062
-     * @throws InvalidInterfaceException
1063
-     * @throws ReflectionException
1064
-     */
1065
-    public function list_table_filters($old_filters, $list_table_obj)
1066
-    {
1067
-        $filters = [];
1068
-        // first month/year filters
1069
-        $filters[] = $this->espresso_event_months_dropdown();
1070
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1071
-        // active status dropdown
1072
-        if ($status !== 'draft') {
1073
-            $filters[] = $this->active_status_dropdown(
1074
-                isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
1075
-            );
1076
-            $filters[] = $this->venuesDropdown(
1077
-                isset($this->_req_data['venue']) ? $this->_req_data['venue'] : ''
1078
-            );
1079
-        }
1080
-        // category filter
1081
-        $filters[] = $this->category_dropdown();
1082
-        return array_merge($old_filters, $filters);
1083
-    }
1084
-
1085
-
1086
-    /**
1087
-     * espresso_event_months_dropdown
1088
-     *
1089
-     * @access public
1090
-     * @return string                dropdown listing month/year selections for events.
1091
-     */
1092
-    public function espresso_event_months_dropdown()
1093
-    {
1094
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
1095
-        // Note we need to include any other filters that are set!
1096
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : '';
1097
-        // categories?
1098
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1099
-            ? $this->_req_data['EVT_CAT']
1100
-            : '';
1101
-        // active status?
1102
-        $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '';
1103
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1104
-        return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1105
-    }
1106
-
1107
-
1108
-    /**
1109
-     * returns a list of "active" statuses on the event
1110
-     *
1111
-     * @param string $current_value whatever the current active status is
1112
-     * @return string
1113
-     */
1114
-    public function active_status_dropdown($current_value = '')
1115
-    {
1116
-        $select_name = 'active_status';
1117
-        $values = [
1118
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1119
-            'active'   => esc_html__('Active', 'event_espresso'),
1120
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1121
-            'expired'  => esc_html__('Expired', 'event_espresso'),
1122
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
1123
-        ];
1124
-
1125
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1126
-    }
1127
-
1128
-
1129
-
1130
-    /**
1131
-     * returns a list of "venues"
1132
-     *
1133
-     * @param string $current_value whatever the current active status is
1134
-     * @return string
1135
-     * @throws EE_Error
1136
-     * @throws InvalidArgumentException
1137
-     * @throws InvalidDataTypeException
1138
-     * @throws InvalidInterfaceException
1139
-     * @throws ReflectionException
1140
-     */
1141
-    protected function venuesDropdown($current_value = '')
1142
-    {
1143
-        $select_name = 'venue';
1144
-        $values = [
1145
-            '' => esc_html__('All Venues', 'event_espresso'),
1146
-        ];
1147
-        // populate the list of venues.
1148
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1149
-        $venues = $venue_model->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1150
-
1151
-        foreach ($venues as $venue) {
1152
-            $values[ $venue->ID() ] = $venue->name();
1153
-        }
1154
-
1155
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1156
-    }
1157
-
1158
-
1159
-    /**
1160
-     * output a dropdown of the categories for the category filter on the event admin list table
1161
-     *
1162
-     * @access  public
1163
-     * @return string html
1164
-     */
1165
-    public function category_dropdown()
1166
-    {
1167
-        $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1168
-        return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1169
-    }
1170
-
1171
-
1172
-    /**
1173
-     * get total number of events today
1174
-     *
1175
-     * @access public
1176
-     * @return int
1177
-     * @throws EE_Error
1178
-     * @throws InvalidArgumentException
1179
-     * @throws InvalidDataTypeException
1180
-     * @throws InvalidInterfaceException
1181
-     */
1182
-    public function total_events_today()
1183
-    {
1184
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1185
-            'DTT_EVT_start',
1186
-            date('Y-m-d') . ' 00:00:00',
1187
-            'Y-m-d H:i:s',
1188
-            'UTC'
1189
-        );
1190
-        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1191
-            'DTT_EVT_start',
1192
-            date('Y-m-d') . ' 23:59:59',
1193
-            'Y-m-d H:i:s',
1194
-            'UTC'
1195
-        );
1196
-        $where = [
1197
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1198
-        ];
1199
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1200
-    }
1201
-
1202
-
1203
-    /**
1204
-     * get total number of events this month
1205
-     *
1206
-     * @access public
1207
-     * @return int
1208
-     * @throws EE_Error
1209
-     * @throws InvalidArgumentException
1210
-     * @throws InvalidDataTypeException
1211
-     * @throws InvalidInterfaceException
1212
-     */
1213
-    public function total_events_this_month()
1214
-    {
1215
-        // Dates
1216
-        $this_year_r = date('Y');
1217
-        $this_month_r = date('m');
1218
-        $days_this_month = date('t');
1219
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1220
-            'DTT_EVT_start',
1221
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1222
-            'Y-m-d H:i:s',
1223
-            'UTC'
1224
-        );
1225
-        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1226
-            'DTT_EVT_start',
1227
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1228
-            'Y-m-d H:i:s',
1229
-            'UTC'
1230
-        );
1231
-        $where = [
1232
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1233
-        ];
1234
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1235
-    }
1236
-
1237
-
1238
-    /** DEFAULT TICKETS STUFF **/
1239
-
1240
-    /**
1241
-     * Output default tickets list table view.
1242
-     *
1243
-     * @throws DomainException
1244
-     * @throws EE_Error
1245
-     * @throws InvalidArgumentException
1246
-     * @throws InvalidDataTypeException
1247
-     * @throws InvalidInterfaceException
1248
-     */
1249
-    public function _tickets_overview_list_table()
1250
-    {
1251
-        $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1252
-        $this->display_admin_list_table_page_with_no_sidebar();
1253
-    }
1254
-
1255
-
1256
-    /**
1257
-     * @param int  $per_page
1258
-     * @param bool $count
1259
-     * @param bool $trashed
1260
-     * @return EE_Soft_Delete_Base_Class[]|int
1261
-     * @throws EE_Error
1262
-     * @throws InvalidArgumentException
1263
-     * @throws InvalidDataTypeException
1264
-     * @throws InvalidInterfaceException
1265
-     */
1266
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1267
-    {
1268
-        $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1269
-        $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1270
-        switch ($orderby) {
1271
-            case 'TKT_name':
1272
-                $orderby = ['TKT_name' => $order];
1273
-                break;
1274
-            case 'TKT_price':
1275
-                $orderby = ['TKT_price' => $order];
1276
-                break;
1277
-            case 'TKT_uses':
1278
-                $orderby = ['TKT_uses' => $order];
1279
-                break;
1280
-            case 'TKT_min':
1281
-                $orderby = ['TKT_min' => $order];
1282
-                break;
1283
-            case 'TKT_max':
1284
-                $orderby = ['TKT_max' => $order];
1285
-                break;
1286
-            case 'TKT_qty':
1287
-                $orderby = ['TKT_qty' => $order];
1288
-                break;
1289
-        }
1290
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1291
-            ? $this->_req_data['paged']
1292
-            : 1;
1293
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1294
-            ? $this->_req_data['perpage']
1295
-            : $per_page;
1296
-        $_where = [
1297
-            'TKT_is_default' => 1,
1298
-            'TKT_deleted'    => $trashed,
1299
-        ];
1300
-        $offset = ($current_page - 1) * $per_page;
1301
-        $limit = [$offset, $per_page];
1302
-        if (isset($this->_req_data['s'])) {
1303
-            $sstr = '%' . $this->_req_data['s'] . '%';
1304
-            $_where['OR'] = [
1305
-                'TKT_name'        => ['LIKE', $sstr],
1306
-                'TKT_description' => ['LIKE', $sstr],
1307
-            ];
1308
-        }
1309
-        $query_params = [
1310
-            $_where,
1311
-            'order_by' => $orderby,
1312
-            'limit'    => $limit,
1313
-            'group_by' => 'TKT_ID',
1314
-        ];
1315
-        if ($count) {
1316
-            return EEM_Ticket::instance()->count_deleted_and_undeleted([$_where]);
1317
-        }
1318
-        return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1319
-    }
1320
-
1321
-
1322
-    /**
1323
-     * @param bool $trash
1324
-     * @throws EE_Error
1325
-     * @throws InvalidArgumentException
1326
-     * @throws InvalidDataTypeException
1327
-     * @throws InvalidInterfaceException
1328
-     */
1329
-    protected function _trash_or_restore_ticket($trash = false)
1330
-    {
1331
-        $success = 1;
1332
-        $TKT = EEM_Ticket::instance();
1333
-        // checkboxes?
1334
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1335
-            // if array has more than one element then success message should be plural
1336
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1337
-            // cycle thru the boxes
1338
-            foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1339
-                if ($trash) {
1340
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1341
-                        $success = 0;
1342
-                    }
1343
-                } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1344
-                    $success = 0;
1345
-                }
1346
-            }
1347
-        } else {
1348
-            // grab single id and trash
1349
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1350
-            if ($trash) {
1351
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1352
-                    $success = 0;
1353
-                }
1354
-            } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1355
-                $success = 0;
1356
-            }
1357
-        }
1358
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1359
-        $query_args = [
1360
-            'action' => 'ticket_list_table',
1361
-            'status' => $trash ? '' : 'trashed',
1362
-        ];
1363
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1364
-    }
1365
-
1366
-
1367
-    /**
1368
-     * Handles trashing default ticket.
1369
-     *
1370
-     * @throws EE_Error
1371
-     * @throws InvalidArgumentException
1372
-     * @throws InvalidDataTypeException
1373
-     * @throws InvalidInterfaceException
1374
-     * @throws ReflectionException
1375
-     */
1376
-    protected function _delete_ticket()
1377
-    {
1378
-        $success = 1;
1379
-        // checkboxes?
1380
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1381
-            // if array has more than one element then success message should be plural
1382
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1383
-            // cycle thru the boxes
1384
-            foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1385
-                // delete
1386
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1387
-                    $success = 0;
1388
-                }
1389
-            }
1390
-        } else {
1391
-            // grab single id and trash
1392
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1393
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1394
-                $success = 0;
1395
-            }
1396
-        }
1397
-        $action_desc = 'deleted';
1398
-        // fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1399
-        $ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
1400
-            [['TKT_is_default' => 1]],
1401
-            'TKT_ID',
1402
-            true
1403
-        );
1404
-        $query_args = $ticket_count
1405
-            ? []
1406
-            : [
1407
-                'action' => 'ticket_list_table',
1408
-                'status' => 'trashed',
1409
-            ];
1410
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1411
-    }
1412
-
1413
-
1414
-    /**
1415
-     * @param int $TKT_ID
1416
-     * @return bool|int
1417
-     * @throws EE_Error
1418
-     * @throws InvalidArgumentException
1419
-     * @throws InvalidDataTypeException
1420
-     * @throws InvalidInterfaceException
1421
-     * @throws ReflectionException
1422
-     */
1423
-    protected function _delete_the_ticket($TKT_ID)
1424
-    {
1425
-        $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1426
-        if (! $ticket instanceof EE_Ticket) {
1427
-            return false;
1428
-        }
1429
-        $ticket->_remove_relations('Datetime');
1430
-        // delete all related prices first
1431
-        $ticket->delete_related_permanently('Price');
1432
-        return $ticket->delete_permanently();
1433
-    }
20
+	/**
21
+	 * @var EE_Admin_Config
22
+	 */
23
+	protected $admin_config;
24
+
25
+	/**
26
+	 * @var AdvancedEditorAdminFormSection
27
+	 */
28
+	protected $advanced_editor_admin_form;
29
+
30
+
31
+	/**
32
+	 * Extend_Events_Admin_Page constructor.
33
+	 *
34
+	 * @param bool $routing
35
+	 * @throws ReflectionException
36
+	 */
37
+	public function __construct($routing = true)
38
+	{
39
+		if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
40
+			define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
41
+			define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
42
+			define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
43
+		}
44
+		parent::__construct($routing);
45
+		$this->admin_config = $this->loader->getShared('EE_Admin_Config');
46
+	}
47
+
48
+
49
+	/**
50
+	 * Sets routes.
51
+	 *
52
+	 * @throws EE_Error
53
+	 * @throws InvalidArgumentException
54
+	 * @throws InvalidDataTypeException
55
+	 * @throws InvalidInterfaceException
56
+	 * @throws Exception
57
+	 */
58
+	protected function _extend_page_config()
59
+	{
60
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
61
+		// is there a evt_id in the request?
62
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
63
+			? $this->_req_data['EVT_ID']
64
+			: 0;
65
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
66
+		// tkt_id?
67
+		$tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
68
+			? $this->_req_data['TKT_ID']
69
+			: 0;
70
+		$new_page_routes = [
71
+			'duplicate_event'          => [
72
+				'func'       => '_duplicate_event',
73
+				'capability' => 'ee_edit_event',
74
+				'obj_id'     => $evt_id,
75
+				'noheader'   => true,
76
+			],
77
+			'import_page'              => [
78
+				'func'       => '_import_page',
79
+				'capability' => 'import',
80
+			],
81
+			'import'                   => [
82
+				'func'       => '_import_events',
83
+				'capability' => 'import',
84
+				'noheader'   => true,
85
+			],
86
+			'import_events'            => [
87
+				'func'       => '_import_events',
88
+				'capability' => 'import',
89
+				'noheader'   => true,
90
+			],
91
+			'export_events'            => [
92
+				'func'       => '_events_export',
93
+				'capability' => 'export',
94
+				'noheader'   => true,
95
+			],
96
+			'export_categories'        => [
97
+				'func'       => '_categories_export',
98
+				'capability' => 'export',
99
+				'noheader'   => true,
100
+			],
101
+			'sample_export_file'       => [
102
+				'func'       => '_sample_export_file',
103
+				'capability' => 'export',
104
+				'noheader'   => true,
105
+			],
106
+			'update_template_settings' => [
107
+				'func'       => '_update_template_settings',
108
+				'capability' => 'manage_options',
109
+				'noheader'   => true,
110
+			],
111
+		];        // don't load these meta boxes if using the advanced editor
112
+		$this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
113
+		$this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes';
114
+		if (! $this->admin_config->useAdvancedEditor()) {
115
+			$this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
116
+			$this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips';
117
+
118
+			$legacy_editor_page_routes = [
119
+				'ticket_list_table' => [
120
+					'func'       => '_tickets_overview_list_table',
121
+					'capability' => 'ee_read_default_tickets',
122
+				],
123
+				'trash_ticket'      => [
124
+					'func'       => '_trash_or_restore_ticket',
125
+					'capability' => 'ee_delete_default_ticket',
126
+					'obj_id'     => $tkt_id,
127
+					'noheader'   => true,
128
+					'args'       => ['trash' => true],
129
+				],
130
+				'trash_tickets'     => [
131
+					'func'       => '_trash_or_restore_ticket',
132
+					'capability' => 'ee_delete_default_tickets',
133
+					'noheader'   => true,
134
+					'args'       => ['trash' => true],
135
+				],
136
+				'restore_ticket'    => [
137
+					'func'       => '_trash_or_restore_ticket',
138
+					'capability' => 'ee_delete_default_ticket',
139
+					'obj_id'     => $tkt_id,
140
+					'noheader'   => true,
141
+				],
142
+				'restore_tickets'   => [
143
+					'func'       => '_trash_or_restore_ticket',
144
+					'capability' => 'ee_delete_default_tickets',
145
+					'noheader'   => true,
146
+				],
147
+				'delete_ticket'     => [
148
+					'func'       => '_delete_ticket',
149
+					'capability' => 'ee_delete_default_ticket',
150
+					'obj_id'     => $tkt_id,
151
+					'noheader'   => true,
152
+				],
153
+				'delete_tickets'    => [
154
+					'func'       => '_delete_ticket',
155
+					'capability' => 'ee_delete_default_tickets',
156
+					'noheader'   => true,
157
+				],
158
+			];
159
+			$new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes);
160
+		}
161
+
162
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
163
+		// partial route/config override
164
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
165
+		$this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table';
166
+		// add tickets tab but only if there are more than one default ticket!
167
+		$tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
168
+			[['TKT_is_default' => 1]],
169
+			'TKT_ID',
170
+			true
171
+		);
172
+		if ($tkt_count > 1) {
173
+			$new_page_config = [
174
+				'ticket_list_table' => [
175
+					'nav'           => [
176
+						'label' => esc_html__('Default Tickets', 'event_espresso'),
177
+						'order' => 60,
178
+					],
179
+					'list_table'    => 'Tickets_List_Table',
180
+					'require_nonce' => false,
181
+				],
182
+			];
183
+		}
184
+		// template settings
185
+		$new_page_config['template_settings'] = [
186
+			'nav'           => [
187
+				'label' => esc_html__('Templates', 'event_espresso'),
188
+				'order' => 30,
189
+			],
190
+			'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
191
+			'help_tabs'     => [
192
+				'general_settings_templates_help_tab' => [
193
+					'title'    => esc_html__('Templates', 'event_espresso'),
194
+					'filename' => 'general_settings_templates',
195
+				],
196
+			],
197
+		   // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
198
+			// 'help_tour'     => ['Templates_Help_Tour'],
199
+			'require_nonce' => false,
200
+		];
201
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
202
+		// add filters and actions
203
+		// modifying _views
204
+		add_filter(
205
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
206
+			[$this, 'add_additional_datetime_button'],
207
+			10,
208
+			2
209
+		);
210
+		add_filter(
211
+			'FHEE_event_datetime_metabox_clone_button_template',
212
+			[$this, 'add_datetime_clone_button'],
213
+			10,
214
+			2
215
+		);
216
+		add_filter(
217
+			'FHEE_event_datetime_metabox_timezones_template',
218
+			[$this, 'datetime_timezones_template'],
219
+			10,
220
+			2
221
+		);
222
+		// filters for event list table
223
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2);
224
+		add_filter(
225
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
226
+			[$this, 'extra_list_table_actions'],
227
+			10,
228
+			2
229
+		);
230
+		// legend item
231
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
232
+		add_action('admin_init', [$this, 'admin_init']);
233
+		// load additional handlers
234
+		$this->handleActionRequest();
235
+	}
236
+
237
+
238
+	private function getRequestAction()
239
+	{
240
+		return isset($this->_req_data['action']) ? sanitize_key($this->_req_data['action']) : null;
241
+	}
242
+
243
+
244
+	/**
245
+	 * @throws Exception
246
+	 */
247
+	private function handleActionRequest()
248
+	{
249
+		$action = $this->getRequestAction();
250
+		if ($action) {
251
+			// setup Advanced Editor ???
252
+			if ($action === 'default_event_settings' || $action === 'update_default_event_settings') {
253
+				$this->advanced_editor_admin_form = $this->loader->getShared(
254
+					'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'
255
+				);
256
+			}
257
+		}
258
+	}
259
+
260
+
261
+	/**
262
+	 * admin_init
263
+	 */
264
+	public function admin_init()
265
+	{
266
+		EE_Registry::$i18n_js_strings = array_merge(
267
+			EE_Registry::$i18n_js_strings,
268
+			[
269
+				'image_confirm'          => esc_html__(
270
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
271
+					'event_espresso'
272
+				),
273
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
274
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
275
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
276
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
277
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
278
+			]
279
+		);
280
+	}
281
+
282
+
283
+	/**
284
+	 * Add per page screen options to the default ticket list table view.
285
+	 *
286
+	 * @throws InvalidArgumentException
287
+	 * @throws InvalidDataTypeException
288
+	 * @throws InvalidInterfaceException
289
+	 */
290
+	protected function _add_screen_options_ticket_list_table()
291
+	{
292
+		$this->_per_page_screen_option();
293
+	}
294
+
295
+
296
+	/**
297
+	 * @param string $return
298
+	 * @param int    $id
299
+	 * @param string $new_title
300
+	 * @param string $new_slug
301
+	 * @return string
302
+	 */
303
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
304
+	{
305
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
306
+		// make sure this is only when editing
307
+		if (! empty($id)) {
308
+			$href = EE_Admin_Page::add_query_args_and_nonce(
309
+				['action' => 'duplicate_event', 'EVT_ID' => $id],
310
+				$this->_admin_base_url
311
+			);
312
+			$title = esc_attr__('Duplicate Event', 'event_espresso');
313
+			$return .= '<a href="'
314
+					   . $href
315
+					   . '" title="'
316
+					   . $title
317
+					   . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
318
+					   . $title
319
+					   . '</a>';
320
+		}
321
+		return $return;
322
+	}
323
+
324
+
325
+	/**
326
+	 * Set the list table views for the default ticket list table view.
327
+	 */
328
+	public function _set_list_table_views_ticket_list_table()
329
+	{
330
+		$this->_views = [
331
+			'all'     => [
332
+				'slug'        => 'all',
333
+				'label'       => esc_html__('All', 'event_espresso'),
334
+				'count'       => 0,
335
+				'bulk_action' => [
336
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
337
+				],
338
+			],
339
+			'trashed' => [
340
+				'slug'        => 'trashed',
341
+				'label'       => esc_html__('Trash', 'event_espresso'),
342
+				'count'       => 0,
343
+				'bulk_action' => [
344
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
345
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
346
+				],
347
+			],
348
+		];
349
+	}
350
+
351
+
352
+	/**
353
+	 * Enqueue scripts and styles for the event editor.
354
+	 */
355
+	public function load_scripts_styles_edit()
356
+	{
357
+		if (! $this->admin_config->useAdvancedEditor()) {
358
+			wp_register_script(
359
+				'ee-event-editor-heartbeat',
360
+				EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
361
+				['ee_admin_js', 'heartbeat'],
362
+				EVENT_ESPRESSO_VERSION,
363
+				true
364
+			);
365
+			wp_enqueue_script('ee-accounting');
366
+			wp_enqueue_script('ee-event-editor-heartbeat');
367
+		}
368
+		wp_enqueue_script('event_editor_js');
369
+		// styles
370
+		wp_enqueue_style('espresso-ui-theme');
371
+	}
372
+
373
+
374
+	/**
375
+	 * Returns template for the additional datetime.
376
+	 *
377
+	 * @param $template
378
+	 * @param $template_args
379
+	 * @return mixed
380
+	 * @throws DomainException
381
+	 */
382
+	public function add_additional_datetime_button($template, $template_args)
383
+	{
384
+		return EEH_Template::display_template(
385
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
386
+			$template_args,
387
+			true
388
+		);
389
+	}
390
+
391
+
392
+	/**
393
+	 * Returns the template for cloning a datetime.
394
+	 *
395
+	 * @param $template
396
+	 * @param $template_args
397
+	 * @return mixed
398
+	 * @throws DomainException
399
+	 */
400
+	public function add_datetime_clone_button($template, $template_args)
401
+	{
402
+		return EEH_Template::display_template(
403
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
404
+			$template_args,
405
+			true
406
+		);
407
+	}
408
+
409
+
410
+	/**
411
+	 * Returns the template for datetime timezones.
412
+	 *
413
+	 * @param $template
414
+	 * @param $template_args
415
+	 * @return mixed
416
+	 * @throws DomainException
417
+	 */
418
+	public function datetime_timezones_template($template, $template_args)
419
+	{
420
+		return EEH_Template::display_template(
421
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
422
+			$template_args,
423
+			true
424
+		);
425
+	}
426
+
427
+
428
+	/**
429
+	 * Sets the views for the default list table view.
430
+	 *
431
+	 * @throws EE_Error
432
+	 */
433
+	protected function _set_list_table_views_default()
434
+	{
435
+		parent::_set_list_table_views_default();
436
+		$new_views = [
437
+			'today' => [
438
+				'slug'        => 'today',
439
+				'label'       => esc_html__('Today', 'event_espresso'),
440
+				'count'       => $this->total_events_today(),
441
+				'bulk_action' => [
442
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
443
+				],
444
+			],
445
+			'month' => [
446
+				'slug'        => 'month',
447
+				'label'       => esc_html__('This Month', 'event_espresso'),
448
+				'count'       => $this->total_events_this_month(),
449
+				'bulk_action' => [
450
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
451
+				],
452
+			],
453
+		];
454
+		$this->_views = array_merge($this->_views, $new_views);
455
+	}
456
+
457
+
458
+	/**
459
+	 * Returns the extra action links for the default list table view.
460
+	 *
461
+	 * @param array    $action_links
462
+	 * @param EE_Event $event
463
+	 * @return array
464
+	 * @throws EE_Error
465
+	 * @throws InvalidArgumentException
466
+	 * @throws InvalidDataTypeException
467
+	 * @throws InvalidInterfaceException
468
+	 * @throws ReflectionException
469
+	 */
470
+	public function extra_list_table_actions(array $action_links, EE_Event $event)
471
+	{
472
+		if (
473
+			EE_Registry::instance()->CAP->current_user_can(
474
+				'ee_read_registrations',
475
+				'espresso_registrations_reports',
476
+				$event->ID()
477
+			)
478
+		) {
479
+			$reports_query_args = [
480
+				'action' => 'reports',
481
+				'EVT_ID' => $event->ID(),
482
+			];
483
+			$reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
484
+			$action_links[] = '<a href="'
485
+							  . $reports_link
486
+							  . '" title="'
487
+							  . esc_attr__('View Report', 'event_espresso')
488
+							  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
489
+							  . "\n\t";
490
+		}
491
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
492
+			EE_Registry::instance()->load_helper('MSG_Template');
493
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
494
+				'see_notifications_for',
495
+				null,
496
+				['EVT_ID' => $event->ID()]
497
+			);
498
+		}
499
+		return $action_links;
500
+	}
501
+
502
+
503
+	/**
504
+	 * @param $items
505
+	 * @return mixed
506
+	 */
507
+	public function additional_legend_items($items)
508
+	{
509
+		if (
510
+			EE_Registry::instance()->CAP->current_user_can(
511
+				'ee_read_registrations',
512
+				'espresso_registrations_reports'
513
+			)
514
+		) {
515
+			$items['reports'] = [
516
+				'class' => 'dashicons dashicons-chart-bar',
517
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
518
+			];
519
+		}
520
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
521
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
522
+			// $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
523
+			// (can only use numeric offsets when treating strings as arrays)
524
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
525
+				$items['view_related_messages'] = [
526
+					'class' => $related_for_icon['css_class'],
527
+					'desc'  => $related_for_icon['label'],
528
+				];
529
+			}
530
+		}
531
+		return $items;
532
+	}
533
+
534
+
535
+	/**
536
+	 * This is the callback method for the duplicate event route
537
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
538
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
539
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
540
+	 * After duplication the redirect is to the new event edit page.
541
+	 *
542
+	 * @return void
543
+	 * @throws EE_Error If EE_Event is not available with given ID
544
+	 * @throws InvalidArgumentException
545
+	 * @throws InvalidDataTypeException
546
+	 * @throws InvalidInterfaceException
547
+	 * @throws ReflectionException
548
+	 * @access protected
549
+	 */
550
+	protected function _duplicate_event()
551
+	{
552
+		// first make sure the ID for the event is in the request.
553
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
554
+		if (! isset($this->_req_data['EVT_ID'])) {
555
+			EE_Error::add_error(
556
+				esc_html__(
557
+					'In order to duplicate an event an Event ID is required.  None was given.',
558
+					'event_espresso'
559
+				),
560
+				__FILE__,
561
+				__FUNCTION__,
562
+				__LINE__
563
+			);
564
+			$this->_redirect_after_action(false, '', '', [], true);
565
+			return;
566
+		}
567
+		// k we've got EVT_ID so let's use that to get the event we'll duplicate
568
+		$orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
569
+		if (! $orig_event instanceof EE_Event) {
570
+			throw new EE_Error(
571
+				sprintf(
572
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
573
+					$this->_req_data['EVT_ID']
574
+				)
575
+			);
576
+		}
577
+		// k now let's clone the $orig_event before getting relations
578
+		$new_event = clone $orig_event;
579
+		// original datetimes
580
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
581
+		// other original relations
582
+		$orig_ven = $orig_event->get_many_related('Venue');
583
+		// reset the ID and modify other details to make it clear this is a dupe
584
+		$new_event->set('EVT_ID', 0);
585
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
586
+		$new_event->set('EVT_name', $new_name);
587
+		$new_event->set(
588
+			'EVT_slug',
589
+			wp_unique_post_slug(
590
+				sanitize_title($orig_event->name()),
591
+				0,
592
+				'publish',
593
+				'espresso_events',
594
+				0
595
+			)
596
+		);
597
+		$new_event->set('status', 'draft');
598
+		// duplicate discussion settings
599
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
600
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
601
+		// save the new event
602
+		$new_event->save();
603
+		// venues
604
+		foreach ($orig_ven as $ven) {
605
+			$new_event->_add_relation_to($ven, 'Venue');
606
+		}
607
+		$new_event->save();
608
+		// now we need to get the question group relations and handle that
609
+		// first primary question groups
610
+		$orig_primary_qgs = $orig_event->get_many_related(
611
+			'Question_Group',
612
+			[['Event_Question_Group.EQG_primary' => true]]
613
+		);
614
+		if (! empty($orig_primary_qgs)) {
615
+			foreach ($orig_primary_qgs as $id => $obj) {
616
+				if ($obj instanceof EE_Question_Group) {
617
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
618
+				}
619
+			}
620
+		}
621
+		// next additional attendee question groups
622
+		$orig_additional_qgs = $orig_event->get_many_related(
623
+			'Question_Group',
624
+			[['Event_Question_Group.EQG_additional' => true]]
625
+		);
626
+		if (! empty($orig_additional_qgs)) {
627
+			foreach ($orig_additional_qgs as $id => $obj) {
628
+				if ($obj instanceof EE_Question_Group) {
629
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
630
+				}
631
+			}
632
+		}
633
+
634
+		$new_event->save();
635
+
636
+		// k now that we have the new event saved we can loop through the datetimes and start adding relations.
637
+		$cloned_tickets = [];
638
+		foreach ($orig_datetimes as $orig_dtt) {
639
+			if (! $orig_dtt instanceof EE_Datetime) {
640
+				continue;
641
+			}
642
+			$new_dtt = clone $orig_dtt;
643
+			$orig_tkts = $orig_dtt->tickets();
644
+			// save new dtt then add to event
645
+			$new_dtt->set('DTT_ID', 0);
646
+			$new_dtt->set('DTT_sold', 0);
647
+			$new_dtt->set_reserved(0);
648
+			$new_dtt->save();
649
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
650
+			$new_event->save();
651
+			// now let's get the ticket relations setup.
652
+			foreach ((array) $orig_tkts as $orig_tkt) {
653
+				// it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
654
+				if (! $orig_tkt instanceof EE_Ticket) {
655
+					continue;
656
+				}
657
+				// is this ticket archived?  If it is then let's skip
658
+				if ($orig_tkt->get('TKT_deleted')) {
659
+					continue;
660
+				}
661
+				// does this original ticket already exist in the clone_tickets cache?
662
+				//  If so we'll just use the new ticket from it.
663
+				if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
664
+					$new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
665
+				} else {
666
+					$new_tkt = clone $orig_tkt;
667
+					// get relations on the $orig_tkt that we need to setup.
668
+					$orig_prices = $orig_tkt->prices();
669
+					$new_tkt->set('TKT_ID', 0);
670
+					$new_tkt->set('TKT_sold', 0);
671
+					$new_tkt->set('TKT_reserved', 0);
672
+					$new_tkt->save(); // make sure new ticket has ID.
673
+					// price relations on new ticket need to be setup.
674
+					foreach ($orig_prices as $orig_price) {
675
+						$new_price = clone $orig_price;
676
+						$new_price->set('PRC_ID', 0);
677
+						$new_price->save();
678
+						$new_tkt->_add_relation_to($new_price, 'Price');
679
+						$new_tkt->save();
680
+					}
681
+
682
+					do_action(
683
+						'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
684
+						$orig_tkt,
685
+						$new_tkt,
686
+						$orig_prices,
687
+						$orig_event,
688
+						$orig_dtt,
689
+						$new_dtt
690
+					);
691
+				}
692
+				// k now we can add the new ticket as a relation to the new datetime
693
+				// and make sure its added to our cached $cloned_tickets array
694
+				// for use with later datetimes that have the same ticket.
695
+				$new_dtt->_add_relation_to($new_tkt, 'Ticket');
696
+				$new_dtt->save();
697
+				$cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
698
+			}
699
+		}
700
+		// clone taxonomy information
701
+		$taxonomies_to_clone_with = apply_filters(
702
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
703
+			['espresso_event_categories', 'espresso_event_type', 'post_tag']
704
+		);
705
+		// get terms for original event (notice)
706
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
707
+		// loop through terms and add them to new event.
708
+		foreach ($orig_terms as $term) {
709
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
710
+		}
711
+
712
+		// duplicate other core WP_Post items for this event.
713
+		// post thumbnail (feature image).
714
+		$feature_image_id = get_post_thumbnail_id($orig_event->ID());
715
+		if ($feature_image_id) {
716
+			update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
717
+		}
718
+
719
+		// duplicate page_template setting
720
+		$page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
721
+		if ($page_template) {
722
+			update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
723
+		}
724
+
725
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
726
+		// now let's redirect to the edit page for this duplicated event if we have a new event id.
727
+		if ($new_event->ID()) {
728
+			$redirect_args = [
729
+				'post'   => $new_event->ID(),
730
+				'action' => 'edit',
731
+			];
732
+			EE_Error::add_success(
733
+				esc_html__(
734
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
735
+					'event_espresso'
736
+				)
737
+			);
738
+		} else {
739
+			$redirect_args = [
740
+				'action' => 'default',
741
+			];
742
+			EE_Error::add_error(
743
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
744
+				__FILE__,
745
+				__FUNCTION__,
746
+				__LINE__
747
+			);
748
+		}
749
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
750
+	}
751
+
752
+
753
+	/**
754
+	 * Generates output for the import page.
755
+	 *
756
+	 * @throws DomainException
757
+	 * @throws EE_Error
758
+	 * @throws InvalidArgumentException
759
+	 * @throws InvalidDataTypeException
760
+	 * @throws InvalidInterfaceException
761
+	 */
762
+	protected function _import_page()
763
+	{
764
+		$title = esc_html__('Import', 'event_espresso');
765
+		$intro = esc_html__(
766
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
767
+			'event_espresso'
768
+		);
769
+		$form_url = EVENTS_ADMIN_URL;
770
+		$action = 'import_events';
771
+		$type = 'csv';
772
+		$this->_template_args['form'] = EE_Import::instance()->upload_form(
773
+			$title,
774
+			$intro,
775
+			$form_url,
776
+			$action,
777
+			$type
778
+		);
779
+		$this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(
780
+			['action' => 'sample_export_file'],
781
+			$this->_admin_base_url
782
+		);
783
+		$content = EEH_Template::display_template(
784
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
785
+			$this->_template_args,
786
+			true
787
+		);
788
+		$this->_template_args['admin_page_content'] = $content;
789
+		$this->display_admin_page_with_sidebar();
790
+	}
791
+
792
+
793
+	/**
794
+	 * _import_events
795
+	 * This handles displaying the screen and running imports for importing events.
796
+	 *
797
+	 * @return void
798
+	 * @throws EE_Error
799
+	 * @throws InvalidArgumentException
800
+	 * @throws InvalidDataTypeException
801
+	 * @throws InvalidInterfaceException
802
+	 */
803
+	protected function _import_events()
804
+	{
805
+		require_once(EE_CLASSES . 'EE_Import.class.php');
806
+		$success = EE_Import::instance()->import();
807
+		$this->_redirect_after_action($success, 'Import File', 'ran', ['action' => 'import_page'], true);
808
+	}
809
+
810
+
811
+	/**
812
+	 * _events_export
813
+	 * Will export all (or just the given event) to a Excel compatible file.
814
+	 *
815
+	 * @access protected
816
+	 * @return void
817
+	 */
818
+	protected function _events_export()
819
+	{
820
+		if (isset($this->_req_data['EVT_ID'])) {
821
+			$event_ids = $this->_req_data['EVT_ID'];
822
+		} elseif (isset($this->_req_data['EVT_IDs'])) {
823
+			$event_ids = $this->_req_data['EVT_IDs'];
824
+		} else {
825
+			$event_ids = null;
826
+		}
827
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
828
+		$new_request_args = [
829
+			'export' => 'report',
830
+			'action' => 'all_event_data',
831
+			'EVT_ID' => $event_ids,
832
+		];
833
+		$this->_req_data = array_merge($this->_req_data, $new_request_args);
834
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
835
+			require_once(EE_CLASSES . 'EE_Export.class.php');
836
+			$EE_Export = EE_Export::instance($this->_req_data);
837
+			if ($EE_Export instanceof EE_Export) {
838
+				$EE_Export->export();
839
+			}
840
+		}
841
+	}
842
+
843
+
844
+	/**
845
+	 * handle category exports()
846
+	 *
847
+	 * @return void
848
+	 */
849
+	protected function _categories_export()
850
+	{
851
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
852
+		$new_request_args = [
853
+			'export'       => 'report',
854
+			'action'       => 'categories',
855
+			'category_ids' => $this->_req_data['EVT_CAT_ID'],
856
+		];
857
+		$this->_req_data = array_merge($this->_req_data, $new_request_args);
858
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
859
+			require_once(EE_CLASSES . 'EE_Export.class.php');
860
+			$EE_Export = EE_Export::instance($this->_req_data);
861
+			if ($EE_Export instanceof EE_Export) {
862
+				$EE_Export->export();
863
+			}
864
+		}
865
+	}
866
+
867
+
868
+	/**
869
+	 * Creates a sample CSV file for importing
870
+	 */
871
+	protected function _sample_export_file()
872
+	{
873
+		$EE_Export = EE_Export::instance();
874
+		if ($EE_Export instanceof EE_Export) {
875
+			$EE_Export->export();
876
+		}
877
+	}
878
+
879
+
880
+	/*************        Template Settings        *************/
881
+	/**
882
+	 * Generates template settings page output
883
+	 *
884
+	 * @throws DomainException
885
+	 * @throws EE_Error
886
+	 * @throws InvalidArgumentException
887
+	 * @throws InvalidDataTypeException
888
+	 * @throws InvalidInterfaceException
889
+	 */
890
+	protected function _template_settings()
891
+	{
892
+		$this->_template_args['values'] = $this->_yes_no_values;
893
+		/**
894
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
895
+		 * from General_Settings_Admin_Page to here.
896
+		 */
897
+		$this->_template_args = apply_filters(
898
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
899
+			$this->_template_args
900
+		);
901
+		$this->_set_add_edit_form_tags('update_template_settings');
902
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
903
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
904
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
905
+			$this->_template_args,
906
+			true
907
+		);
908
+		$this->display_admin_page_with_sidebar();
909
+	}
910
+
911
+
912
+	/**
913
+	 * Handler for updating template settings.
914
+	 *
915
+	 * @throws EE_Error
916
+	 * @throws InvalidArgumentException
917
+	 * @throws InvalidDataTypeException
918
+	 * @throws InvalidInterfaceException
919
+	 */
920
+	protected function _update_template_settings()
921
+	{
922
+		/**
923
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
924
+		 * from General_Settings_Admin_Page to here.
925
+		 */
926
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
927
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
928
+			EE_Registry::instance()->CFG->template_settings,
929
+			$this->_req_data
930
+		);
931
+		// update custom post type slugs and detect if we need to flush rewrite rules
932
+		$old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
933
+		EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
934
+			? EE_Registry::instance()->CFG->core->event_cpt_slug
935
+			: EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
936
+		$what = 'Template Settings';
937
+		$success = $this->_update_espresso_configuration(
938
+			$what,
939
+			EE_Registry::instance()->CFG->template_settings,
940
+			__FILE__,
941
+			__FUNCTION__,
942
+			__LINE__
943
+		);
944
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
945
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
946
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
947
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
948
+			);
949
+			$rewrite_rules->flush();
950
+		}
951
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
952
+	}
953
+
954
+
955
+	/**
956
+	 * _premium_event_editor_meta_boxes
957
+	 * add all metaboxes related to the event_editor
958
+	 *
959
+	 * @access protected
960
+	 * @return void
961
+	 * @throws EE_Error
962
+	 * @throws InvalidArgumentException
963
+	 * @throws InvalidDataTypeException
964
+	 * @throws InvalidInterfaceException
965
+	 * @throws ReflectionException
966
+	 */
967
+	protected function _premium_event_editor_meta_boxes()
968
+	{
969
+		$this->verify_cpt_object();
970
+		/** @var FeatureFlags $flags */
971
+		$flags = $this->loader->getShared('EventEspresso\core\domain\services\capabilities\FeatureFlags');
972
+		// check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
973
+		if (! $this->admin_config->useAdvancedEditor() || ! $flags->featureAllowed('use_reg_options_meta_box')) {
974
+			add_meta_box(
975
+				'espresso_event_editor_event_options',
976
+				esc_html__('Event Registration Options', 'event_espresso'),
977
+				[$this, 'registration_options_meta_box'],
978
+				$this->page_slug,
979
+				'side',
980
+				'core'
981
+			);
982
+		}
983
+	}
984
+
985
+
986
+	/**
987
+	 * override caf metabox
988
+	 *
989
+	 * @return void
990
+	 * @throws DomainException
991
+	 * @throws EE_Error
992
+	 */
993
+	public function registration_options_meta_box()
994
+	{
995
+		$yes_no_values = [
996
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
997
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
998
+		];
999
+		$default_reg_status_values = EEM_Registration::reg_status_array(
1000
+			[
1001
+				EEM_Registration::status_id_cancelled,
1002
+				EEM_Registration::status_id_declined,
1003
+				EEM_Registration::status_id_incomplete,
1004
+				EEM_Registration::status_id_wait_list,
1005
+			],
1006
+			true
1007
+		);
1008
+		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1009
+		$template_args['_event'] = $this->_cpt_model_obj;
1010
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1011
+		$template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1012
+			'default_reg_status',
1013
+			$default_reg_status_values,
1014
+			$this->_cpt_model_obj->default_registration_status()
1015
+		);
1016
+		$template_args['display_description'] = EEH_Form_Fields::select_input(
1017
+			'display_desc',
1018
+			$yes_no_values,
1019
+			$this->_cpt_model_obj->display_description()
1020
+		);
1021
+		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1022
+			'display_ticket_selector',
1023
+			$yes_no_values,
1024
+			$this->_cpt_model_obj->display_ticket_selector(),
1025
+			'',
1026
+			'',
1027
+			false
1028
+		);
1029
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
1030
+			'EVT_default_registration_status',
1031
+			$default_reg_status_values,
1032
+			$this->_cpt_model_obj->default_registration_status()
1033
+		);
1034
+		$template_args['additional_registration_options'] = apply_filters(
1035
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1036
+			'',
1037
+			$template_args,
1038
+			$yes_no_values,
1039
+			$default_reg_status_values
1040
+		);
1041
+		EEH_Template::display_template(
1042
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1043
+			$template_args
1044
+		);
1045
+	}
1046
+
1047
+
1048
+
1049
+	/**
1050
+	 * wp_list_table_mods for caf
1051
+	 * ============================
1052
+	 */
1053
+	/**
1054
+	 * hook into list table filters and provide filters for caffeinated list table
1055
+	 *
1056
+	 * @param array $old_filters    any existing filters present
1057
+	 * @param array $list_table_obj the list table object
1058
+	 * @return array                  new filters
1059
+	 * @throws EE_Error
1060
+	 * @throws InvalidArgumentException
1061
+	 * @throws InvalidDataTypeException
1062
+	 * @throws InvalidInterfaceException
1063
+	 * @throws ReflectionException
1064
+	 */
1065
+	public function list_table_filters($old_filters, $list_table_obj)
1066
+	{
1067
+		$filters = [];
1068
+		// first month/year filters
1069
+		$filters[] = $this->espresso_event_months_dropdown();
1070
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1071
+		// active status dropdown
1072
+		if ($status !== 'draft') {
1073
+			$filters[] = $this->active_status_dropdown(
1074
+				isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
1075
+			);
1076
+			$filters[] = $this->venuesDropdown(
1077
+				isset($this->_req_data['venue']) ? $this->_req_data['venue'] : ''
1078
+			);
1079
+		}
1080
+		// category filter
1081
+		$filters[] = $this->category_dropdown();
1082
+		return array_merge($old_filters, $filters);
1083
+	}
1084
+
1085
+
1086
+	/**
1087
+	 * espresso_event_months_dropdown
1088
+	 *
1089
+	 * @access public
1090
+	 * @return string                dropdown listing month/year selections for events.
1091
+	 */
1092
+	public function espresso_event_months_dropdown()
1093
+	{
1094
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
1095
+		// Note we need to include any other filters that are set!
1096
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : '';
1097
+		// categories?
1098
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1099
+			? $this->_req_data['EVT_CAT']
1100
+			: '';
1101
+		// active status?
1102
+		$active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '';
1103
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1104
+		return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1105
+	}
1106
+
1107
+
1108
+	/**
1109
+	 * returns a list of "active" statuses on the event
1110
+	 *
1111
+	 * @param string $current_value whatever the current active status is
1112
+	 * @return string
1113
+	 */
1114
+	public function active_status_dropdown($current_value = '')
1115
+	{
1116
+		$select_name = 'active_status';
1117
+		$values = [
1118
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1119
+			'active'   => esc_html__('Active', 'event_espresso'),
1120
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1121
+			'expired'  => esc_html__('Expired', 'event_espresso'),
1122
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
1123
+		];
1124
+
1125
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1126
+	}
1127
+
1128
+
1129
+
1130
+	/**
1131
+	 * returns a list of "venues"
1132
+	 *
1133
+	 * @param string $current_value whatever the current active status is
1134
+	 * @return string
1135
+	 * @throws EE_Error
1136
+	 * @throws InvalidArgumentException
1137
+	 * @throws InvalidDataTypeException
1138
+	 * @throws InvalidInterfaceException
1139
+	 * @throws ReflectionException
1140
+	 */
1141
+	protected function venuesDropdown($current_value = '')
1142
+	{
1143
+		$select_name = 'venue';
1144
+		$values = [
1145
+			'' => esc_html__('All Venues', 'event_espresso'),
1146
+		];
1147
+		// populate the list of venues.
1148
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1149
+		$venues = $venue_model->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1150
+
1151
+		foreach ($venues as $venue) {
1152
+			$values[ $venue->ID() ] = $venue->name();
1153
+		}
1154
+
1155
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1156
+	}
1157
+
1158
+
1159
+	/**
1160
+	 * output a dropdown of the categories for the category filter on the event admin list table
1161
+	 *
1162
+	 * @access  public
1163
+	 * @return string html
1164
+	 */
1165
+	public function category_dropdown()
1166
+	{
1167
+		$cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1168
+		return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1169
+	}
1170
+
1171
+
1172
+	/**
1173
+	 * get total number of events today
1174
+	 *
1175
+	 * @access public
1176
+	 * @return int
1177
+	 * @throws EE_Error
1178
+	 * @throws InvalidArgumentException
1179
+	 * @throws InvalidDataTypeException
1180
+	 * @throws InvalidInterfaceException
1181
+	 */
1182
+	public function total_events_today()
1183
+	{
1184
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1185
+			'DTT_EVT_start',
1186
+			date('Y-m-d') . ' 00:00:00',
1187
+			'Y-m-d H:i:s',
1188
+			'UTC'
1189
+		);
1190
+		$end = EEM_Datetime::instance()->convert_datetime_for_query(
1191
+			'DTT_EVT_start',
1192
+			date('Y-m-d') . ' 23:59:59',
1193
+			'Y-m-d H:i:s',
1194
+			'UTC'
1195
+		);
1196
+		$where = [
1197
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1198
+		];
1199
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1200
+	}
1201
+
1202
+
1203
+	/**
1204
+	 * get total number of events this month
1205
+	 *
1206
+	 * @access public
1207
+	 * @return int
1208
+	 * @throws EE_Error
1209
+	 * @throws InvalidArgumentException
1210
+	 * @throws InvalidDataTypeException
1211
+	 * @throws InvalidInterfaceException
1212
+	 */
1213
+	public function total_events_this_month()
1214
+	{
1215
+		// Dates
1216
+		$this_year_r = date('Y');
1217
+		$this_month_r = date('m');
1218
+		$days_this_month = date('t');
1219
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1220
+			'DTT_EVT_start',
1221
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1222
+			'Y-m-d H:i:s',
1223
+			'UTC'
1224
+		);
1225
+		$end = EEM_Datetime::instance()->convert_datetime_for_query(
1226
+			'DTT_EVT_start',
1227
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1228
+			'Y-m-d H:i:s',
1229
+			'UTC'
1230
+		);
1231
+		$where = [
1232
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1233
+		];
1234
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1235
+	}
1236
+
1237
+
1238
+	/** DEFAULT TICKETS STUFF **/
1239
+
1240
+	/**
1241
+	 * Output default tickets list table view.
1242
+	 *
1243
+	 * @throws DomainException
1244
+	 * @throws EE_Error
1245
+	 * @throws InvalidArgumentException
1246
+	 * @throws InvalidDataTypeException
1247
+	 * @throws InvalidInterfaceException
1248
+	 */
1249
+	public function _tickets_overview_list_table()
1250
+	{
1251
+		$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1252
+		$this->display_admin_list_table_page_with_no_sidebar();
1253
+	}
1254
+
1255
+
1256
+	/**
1257
+	 * @param int  $per_page
1258
+	 * @param bool $count
1259
+	 * @param bool $trashed
1260
+	 * @return EE_Soft_Delete_Base_Class[]|int
1261
+	 * @throws EE_Error
1262
+	 * @throws InvalidArgumentException
1263
+	 * @throws InvalidDataTypeException
1264
+	 * @throws InvalidInterfaceException
1265
+	 */
1266
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1267
+	{
1268
+		$orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1269
+		$order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1270
+		switch ($orderby) {
1271
+			case 'TKT_name':
1272
+				$orderby = ['TKT_name' => $order];
1273
+				break;
1274
+			case 'TKT_price':
1275
+				$orderby = ['TKT_price' => $order];
1276
+				break;
1277
+			case 'TKT_uses':
1278
+				$orderby = ['TKT_uses' => $order];
1279
+				break;
1280
+			case 'TKT_min':
1281
+				$orderby = ['TKT_min' => $order];
1282
+				break;
1283
+			case 'TKT_max':
1284
+				$orderby = ['TKT_max' => $order];
1285
+				break;
1286
+			case 'TKT_qty':
1287
+				$orderby = ['TKT_qty' => $order];
1288
+				break;
1289
+		}
1290
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1291
+			? $this->_req_data['paged']
1292
+			: 1;
1293
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1294
+			? $this->_req_data['perpage']
1295
+			: $per_page;
1296
+		$_where = [
1297
+			'TKT_is_default' => 1,
1298
+			'TKT_deleted'    => $trashed,
1299
+		];
1300
+		$offset = ($current_page - 1) * $per_page;
1301
+		$limit = [$offset, $per_page];
1302
+		if (isset($this->_req_data['s'])) {
1303
+			$sstr = '%' . $this->_req_data['s'] . '%';
1304
+			$_where['OR'] = [
1305
+				'TKT_name'        => ['LIKE', $sstr],
1306
+				'TKT_description' => ['LIKE', $sstr],
1307
+			];
1308
+		}
1309
+		$query_params = [
1310
+			$_where,
1311
+			'order_by' => $orderby,
1312
+			'limit'    => $limit,
1313
+			'group_by' => 'TKT_ID',
1314
+		];
1315
+		if ($count) {
1316
+			return EEM_Ticket::instance()->count_deleted_and_undeleted([$_where]);
1317
+		}
1318
+		return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1319
+	}
1320
+
1321
+
1322
+	/**
1323
+	 * @param bool $trash
1324
+	 * @throws EE_Error
1325
+	 * @throws InvalidArgumentException
1326
+	 * @throws InvalidDataTypeException
1327
+	 * @throws InvalidInterfaceException
1328
+	 */
1329
+	protected function _trash_or_restore_ticket($trash = false)
1330
+	{
1331
+		$success = 1;
1332
+		$TKT = EEM_Ticket::instance();
1333
+		// checkboxes?
1334
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1335
+			// if array has more than one element then success message should be plural
1336
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1337
+			// cycle thru the boxes
1338
+			foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1339
+				if ($trash) {
1340
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1341
+						$success = 0;
1342
+					}
1343
+				} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1344
+					$success = 0;
1345
+				}
1346
+			}
1347
+		} else {
1348
+			// grab single id and trash
1349
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1350
+			if ($trash) {
1351
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1352
+					$success = 0;
1353
+				}
1354
+			} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1355
+				$success = 0;
1356
+			}
1357
+		}
1358
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1359
+		$query_args = [
1360
+			'action' => 'ticket_list_table',
1361
+			'status' => $trash ? '' : 'trashed',
1362
+		];
1363
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1364
+	}
1365
+
1366
+
1367
+	/**
1368
+	 * Handles trashing default ticket.
1369
+	 *
1370
+	 * @throws EE_Error
1371
+	 * @throws InvalidArgumentException
1372
+	 * @throws InvalidDataTypeException
1373
+	 * @throws InvalidInterfaceException
1374
+	 * @throws ReflectionException
1375
+	 */
1376
+	protected function _delete_ticket()
1377
+	{
1378
+		$success = 1;
1379
+		// checkboxes?
1380
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1381
+			// if array has more than one element then success message should be plural
1382
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1383
+			// cycle thru the boxes
1384
+			foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1385
+				// delete
1386
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1387
+					$success = 0;
1388
+				}
1389
+			}
1390
+		} else {
1391
+			// grab single id and trash
1392
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1393
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1394
+				$success = 0;
1395
+			}
1396
+		}
1397
+		$action_desc = 'deleted';
1398
+		// fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1399
+		$ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
1400
+			[['TKT_is_default' => 1]],
1401
+			'TKT_ID',
1402
+			true
1403
+		);
1404
+		$query_args = $ticket_count
1405
+			? []
1406
+			: [
1407
+				'action' => 'ticket_list_table',
1408
+				'status' => 'trashed',
1409
+			];
1410
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1411
+	}
1412
+
1413
+
1414
+	/**
1415
+	 * @param int $TKT_ID
1416
+	 * @return bool|int
1417
+	 * @throws EE_Error
1418
+	 * @throws InvalidArgumentException
1419
+	 * @throws InvalidDataTypeException
1420
+	 * @throws InvalidInterfaceException
1421
+	 * @throws ReflectionException
1422
+	 */
1423
+	protected function _delete_the_ticket($TKT_ID)
1424
+	{
1425
+		$ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1426
+		if (! $ticket instanceof EE_Ticket) {
1427
+			return false;
1428
+		}
1429
+		$ticket->_remove_relations('Datetime');
1430
+		// delete all related prices first
1431
+		$ticket->delete_related_permanently('Price');
1432
+		return $ticket->delete_permanently();
1433
+	}
1434 1434
 }
Please login to merge, or discard this patch.