Completed
Branch master (d65695)
by
unknown
04:25
created
core/db_models/EEM_Question.model.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
                 EEM_Question::QST_type_year          => esc_html__('Year', 'event_espresso'),
133 133
             ]
134 134
         );
135
-        $this->_question_descriptions         = apply_filters(
135
+        $this->_question_descriptions = apply_filters(
136 136
             'FHEE__EEM_Question__construct__question_descriptions',
137 137
             [
138 138
                 EEM_Question::QST_type_checkbox      => esc_html__(
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
                 ),
206 206
             ]
207 207
         );
208
-        $this->_question_type_categories      = (array) apply_filters(
208
+        $this->_question_type_categories = (array) apply_filters(
209 209
             'FHEE__EEM_Question__construct__question_type_categories',
210 210
             [
211 211
                 'text'               => [
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
             'WP_User'                 => new EE_Belongs_To_Relation(),
327 327
         ];
328 328
         // this model is generally available for reading
329
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
329
+        $this->_cap_restriction_generators[EEM_Base::caps_read]       =
330 330
             new EE_Restriction_Generator_Public();
331
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
331
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] =
332 332
             new EE_Restriction_Generator_Reg_Form('QST_system');
333
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
333
+        $this->_cap_restriction_generators[EEM_Base::caps_edit]       =
334 334
             new EE_Restriction_Generator_Reg_Form('QST_system');
335
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
335
+        $this->_cap_restriction_generators[EEM_Base::caps_delete]     =
336 336
             new EE_Restriction_Generator_Reg_Form('QST_system');
337 337
 
338 338
         parent::__construct($timezone);
@@ -380,10 +380,10 @@  discard block
 block discarded – undo
380 380
      */
381 381
     public function question_type_is_in_category(string $question_type, string $category): bool
382 382
     {
383
-        if (! isset($this->_question_type_categories[ $category ])) {
383
+        if ( ! isset($this->_question_type_categories[$category])) {
384 384
             return false;
385 385
         }
386
-        return in_array($question_type, $this->_question_type_categories[ $category ]);
386
+        return in_array($question_type, $this->_question_type_categories[$category]);
387 387
     }
388 388
 
389 389
 
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
      */
396 396
     public function question_types_in_category(string $category): array
397 397
     {
398
-        if (isset($this->_question_type_categories[ $category ])) {
399
-            return $this->_question_type_categories[ $category ];
398
+        if (isset($this->_question_type_categories[$category])) {
399
+            return $this->_question_type_categories[$category];
400 400
         }
401 401
         return [];
402 402
     }
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
     public function absolute_max_for_system_question(string $system_question_value)
561 561
     {
562 562
         $maxes = $this->system_question_maxes();
563
-        return isset($maxes[ $system_question_value ]) ?
564
-            $maxes[ $system_question_value ]
563
+        return isset($maxes[$system_question_value]) ?
564
+            $maxes[$system_question_value]
565 565
             : EE_INF;
566 566
     }
567 567
 
Please login to merge, or discard this patch.
Indentation   +573 added lines, -573 removed lines patch added patch discarded remove patch
@@ -9,578 +9,578 @@
 block discarded – undo
9 9
  */
10 10
 class EEM_Question extends EEM_Soft_Delete_Base
11 11
 {
12
-    // constant used to indicate that the question type is CHECKBOX
13
-    const QST_type_checkbox = 'CHECKBOX';
12
+	// constant used to indicate that the question type is CHECKBOX
13
+	const QST_type_checkbox = 'CHECKBOX';
14 14
 
15
-    // constant used to indicate that the question type is COUNTRY
16
-    const QST_type_country = 'COUNTRY';
17
-
18
-    // constant used to indicate that the question type is DATE
19
-    const QST_type_date = 'DATE';
20
-
21
-    // constant used to indicate that the question type is a decimal (float)
22
-    const QST_type_decimal = 'DECIMAL';
23
-
24
-    // constant used to indicate that the question type is DROPDOWN
25
-    const QST_type_dropdown = 'DROPDOWN';
26
-
27
-    // constant used to indicate that the question type is an email input
28
-    const QST_type_email = 'EMAIL';
29
-
30
-    // constant used to indicate that the question type is an email input
31
-    const QST_type_email_confirm = 'EMAIL_CONFIRM';
32
-
33
-    // constant used to indicate that the question type is a TEXTAREA that allows simple html
34
-    const QST_type_html_textarea = 'HTML_TEXTAREA';
35
-
36
-    // constant used to indicate that the question type is an integer (whole number)
37
-    const QST_type_int = 'INTEGER';
38
-
39
-    // constant used to indicate that the question type is a multi-select
40
-    const QST_type_multi_select = 'MULTI_SELECT';
41
-
42
-    // constant used to indicate that the question type is RADIO_BTN
43
-    const QST_type_radio = 'RADIO_BTN';
44
-
45
-    // constant used to indicate that the question type is STATE
46
-    const QST_type_state = 'STATE';
47
-
48
-    // constant used to indicate that the question type is TEXT
49
-    const QST_type_text = 'TEXT';
50
-
51
-    // constant used to indicate that the question type is TEXTAREA
52
-    const QST_type_textarea = 'TEXTAREA';
53
-
54
-    // constant used to indicate that the question type is a valid URL
55
-    const QST_type_url = 'URL';
56
-
57
-    // constant used to indicate that the question type is a US-formatted phone number
58
-    const QST_type_us_phone = 'US_PHONE';
59
-
60
-    // constant used to indicate that the question type is a YEAR
61
-    const QST_type_year = 'YEAR';
62
-
63
-    /**
64
-     * lists all the question types which should be allowed. Ideally, this will be extensible.
65
-     *
66
-     * @var array $_allowed_question_types
67
-     */
68
-    protected $_allowed_question_types = [];
69
-
70
-
71
-    // private instance of the Attendee object
72
-    protected static $_instance = null;
73
-
74
-    /**
75
-     * brief descriptions for all the question types
76
-     *
77
-     * @var EEM_Question $_instance
78
-     */
79
-    protected $_question_descriptions;
80
-
81
-    /**
82
-     * Question types that are interchangeable, even after answers have been provided for them.
83
-     * Top-level keys are category slugs, next level is an array of question types. If question types
84
-     * aren't in this array, it is assumed they AREN'T interchangeable with any other question types.
85
-     *
86
-     * @var array   $_question_type_categories {
87
-     * @type string $text
88
-     * @type string $single                    -answer-enum
89
-     * @type string $multi                     -answer-enum
90
-     *                    }
91
-     */
92
-    protected $_question_type_categories = [];
93
-
94
-
95
-    /**
96
-     * Question types that should have an admin-defined max input length
97
-     *
98
-     * @var array
99
-     */
100
-    protected $question_types_with_max_length;
101
-
102
-
103
-    /**
104
-     * EEM_Question constructor.
105
-     *
106
-     * @param null $timezone
107
-     */
108
-    protected function __construct($timezone = null)
109
-    {
110
-        $this->singular_item                  = esc_html__('Question', 'event_espresso');
111
-        $this->plural_item                    = esc_html__('Questions', 'event_espresso');
112
-        $this->_allowed_question_types        = apply_filters(
113
-            'FHEE__EEM_Question__construct__allowed_question_types',
114
-            [
115
-                EEM_Question::QST_type_checkbox      => esc_html__('Checkboxes', 'event_espresso'),
116
-                EEM_Question::QST_type_country       => esc_html__('Country Dropdown', 'event_espresso'),
117
-                EEM_Question::QST_type_date          => esc_html__('Date Picker', 'event_espresso'),
118
-                EEM_Question::QST_type_decimal       => esc_html__('Number', 'event_espresso'),
119
-                EEM_Question::QST_type_dropdown      => esc_html__('Dropdown', 'event_espresso'),
120
-                EEM_Question::QST_type_email         => esc_html__('Email', 'event_espresso'),
121
-                EEM_Question::QST_type_email_confirm => esc_html__('Confirm Email', 'event_espresso'),
122
-                EEM_Question::QST_type_html_textarea => esc_html__('HTML Textarea', 'event_espresso'),
123
-                EEM_Question::QST_type_int           => esc_html__('Whole Number', 'event_espresso'),
124
-                EEM_Question::QST_type_multi_select  => esc_html__('Multi Select', 'event_espresso'),
125
-                EEM_Question::QST_type_radio         => esc_html__('Radio Buttons', 'event_espresso'),
126
-                EEM_Question::QST_type_state         => esc_html__('State/Province Dropdown', 'event_espresso'),
127
-                EEM_Question::QST_type_text          => esc_html__('Text', 'event_espresso'),
128
-                EEM_Question::QST_type_textarea      => esc_html__('Textarea', 'event_espresso'),
129
-                EEM_Question::QST_type_url           => esc_html__('URL', 'event_espresso'),
130
-                EEM_Question::QST_type_us_phone      => esc_html__('USA - Format Phone', 'event_espresso'),
131
-                EEM_Question::QST_type_year          => esc_html__('Year', 'event_espresso'),
132
-            ]
133
-        );
134
-        $this->_question_descriptions         = apply_filters(
135
-            'FHEE__EEM_Question__construct__question_descriptions',
136
-            [
137
-                EEM_Question::QST_type_checkbox      => esc_html__(
138
-                    'Allows multiple preset options to be selected',
139
-                    'event_espresso'
140
-                ),
141
-                EEM_Question::QST_type_country       => esc_html__(
142
-                    'A dropdown that lists countries',
143
-                    'event_espresso'
144
-                ),
145
-                EEM_Question::QST_type_date          => esc_html__(
146
-                    'A popup calendar that allows date selections',
147
-                    'event_espresso'
148
-                ),
149
-                EEM_Question::QST_type_decimal       => esc_html__(
150
-                    'A text field that allows number values with decimals',
151
-                    'event_espresso'
152
-                ),
153
-                EEM_Question::QST_type_dropdown      => esc_html__(
154
-                    'A dropdown that allows a single selection',
155
-                    'event_espresso'
156
-                ),
157
-                EEM_Question::QST_type_email         => esc_html__(
158
-                    'A text field that must contain a valid Email address',
159
-                    'event_espresso'
160
-                ),
161
-                EEM_Question::QST_type_email_confirm => esc_html__(
162
-                    'A text field that must contain a valid Email address and be equal to Email field',
163
-                    'event_espresso'
164
-                ),
165
-                EEM_Question::QST_type_html_textarea => esc_html__(
166
-                    'A multi line text input field that allows HTML',
167
-                    'event_espresso'
168
-                ),
169
-                EEM_Question::QST_type_int           => esc_html__(
170
-                    'A text field that only allows whole numbers (no decimals)',
171
-                    'event_espresso'
172
-                ),
173
-                EEM_Question::QST_type_multi_select  => esc_html__(
174
-                    'A dropdown that allows multiple selections',
175
-                    'event_espresso'
176
-                ),
177
-                EEM_Question::QST_type_radio         => esc_html__(
178
-                    'Allows a single preset option to be selected',
179
-                    'event_espresso'
180
-                ),
181
-                EEM_Question::QST_type_state         => esc_html__(
182
-                    'A dropdown that lists states/provinces',
183
-                    'event_espresso'
184
-                ),
185
-                EEM_Question::QST_type_text          => esc_html__(
186
-                    'A single line text input field',
187
-                    'event_espresso'
188
-                ),
189
-                EEM_Question::QST_type_textarea      => esc_html__(
190
-                    'A multi line text input field',
191
-                    'event_espresso'
192
-                ),
193
-                EEM_Question::QST_type_url           => esc_html__(
194
-                    'A text field that must contain a valid URL',
195
-                    'event_espresso'
196
-                ),
197
-                EEM_Question::QST_type_us_phone      => esc_html__(
198
-                    'A text field that must contain a valid US phone number',
199
-                    'event_espresso'
200
-                ),
201
-                EEM_Question::QST_type_year          => esc_html__(
202
-                    'A dropdown that lists the last 100 years',
203
-                    'event_espresso'
204
-                ),
205
-            ]
206
-        );
207
-        $this->_question_type_categories      = (array) apply_filters(
208
-            'FHEE__EEM_Question__construct__question_type_categories',
209
-            [
210
-                'text'               => [
211
-                    EEM_Question::QST_type_date,
212
-                    EEM_Question::QST_type_decimal,
213
-                    EEM_Question::QST_type_email,
214
-                    EEM_Question::QST_type_email_confirm,
215
-                    EEM_Question::QST_type_html_textarea,
216
-                    EEM_Question::QST_type_int,
217
-                    EEM_Question::QST_type_text,
218
-                    EEM_Question::QST_type_textarea,
219
-                    EEM_Question::QST_type_url,
220
-                    EEM_Question::QST_type_us_phone,
221
-                    EEM_Question::QST_type_year,
222
-                ],
223
-                'single-answer-enum' => [
224
-                    EEM_Question::QST_type_dropdown,
225
-                    EEM_Question::QST_type_radio,
226
-                ],
227
-                'multi-answer-enum'  => [
228
-                    EEM_Question::QST_type_multi_select,
229
-                    EEM_Question::QST_type_checkbox,
230
-                ],
231
-            ]
232
-        );
233
-        $this->question_types_with_max_length = apply_filters(
234
-            'FHEE__EEM_Question___construct__question_types_with_max_length',
235
-            [
236
-                EEM_Question::QST_type_html_textarea,
237
-                EEM_Question::QST_type_text,
238
-                EEM_Question::QST_type_textarea,
239
-            ]
240
-        );
241
-
242
-        $this->_tables          = [
243
-            'Question' => new EE_Primary_Table('esp_question', 'QST_ID'),
244
-        ];
245
-        $this->_fields          = [
246
-            'Question' => [
247
-                'QST_ID'            => new EE_Primary_Key_Int_Field(
248
-                    'QST_ID',
249
-                    esc_html__('Question ID', 'event_espresso')
250
-                ),
251
-                'QST_admin_label'   => new EE_Plain_Text_Field(
252
-                    'QST_admin_label',
253
-                    esc_html__('Question Label (admin-only)', 'event_espresso'),
254
-                    true,
255
-                    ''
256
-                ),
257
-                'QST_admin_only'    => new EE_Boolean_Field(
258
-                    'QST_admin_only',
259
-                    esc_html__('Admin-Only Question?', 'event_espresso'),
260
-                    false,
261
-                    false
262
-                ),
263
-                'QST_deleted'       => new EE_Trashed_Flag_Field(
264
-                    'QST_deleted',
265
-                    esc_html__('Flag Indicating question was deleted', 'event_espresso'),
266
-                    false,
267
-                    false
268
-                ),
269
-                'QST_display_text'  => new EE_Post_Content_Field(
270
-                    'QST_display_text',
271
-                    esc_html__('Question Text', 'event_espresso'),
272
-                    true,
273
-                    ''
274
-                ),
275
-                'QST_max'           => new EE_Infinite_Integer_Field(
276
-                    'QST_max',
277
-                    esc_html__('Max Size', 'event_espresso'),
278
-                    false,
279
-                    EE_INF
280
-                ),
281
-                'QST_order'         => new EE_Integer_Field(
282
-                    'QST_order',
283
-                    esc_html__('Question Order', 'event_espresso'),
284
-                    false,
285
-                    0
286
-                ),
287
-                'QST_required'      => new EE_Boolean_Field(
288
-                    'QST_required',
289
-                    esc_html__('Required Question?', 'event_espresso'),
290
-                    false,
291
-                    false
292
-                ),
293
-                'QST_required_text' => new EE_Simple_HTML_Field(
294
-                    'QST_required_text',
295
-                    esc_html__('Text to Display if Not Provided', 'event_espresso'),
296
-                    true,
297
-                    ''
298
-                ),
299
-                'QST_system'        => new EE_Plain_Text_Field(
300
-                    'QST_system',
301
-                    esc_html__('Internal string ID for question', 'event_espresso'),
302
-                    false,
303
-                    ''
304
-                ),
305
-                'QST_type'          => new EE_Enum_Text_Field(
306
-                    'QST_type',
307
-                    esc_html__('Question Type', 'event_espresso'),
308
-                    false,
309
-                    'TEXT',
310
-                    $this->_allowed_question_types
311
-                ),
312
-                'QST_wp_user'       => new EE_WP_User_Field(
313
-                    'QST_wp_user',
314
-                    esc_html__('Question Creator ID', 'event_espresso'),
315
-                    false
316
-                ),
317
-            ],
318
-        ];
319
-        $this->_model_relations = [
320
-            'Answer'                  => new EE_Has_Many_Relation(),
321
-            'Question_Group'          => new EE_HABTM_Relation('Question_Group_Question'),
322
-            // for QST_order column
323
-            'Question_Group_Question' => new EE_Has_Many_Relation(),
324
-            'Question_Option'         => new EE_Has_Many_Relation(),
325
-            'WP_User'                 => new EE_Belongs_To_Relation(),
326
-        ];
327
-        // this model is generally available for reading
328
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
329
-            new EE_Restriction_Generator_Public();
330
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
331
-            new EE_Restriction_Generator_Reg_Form('QST_system');
332
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
333
-            new EE_Restriction_Generator_Reg_Form('QST_system');
334
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
335
-            new EE_Restriction_Generator_Reg_Form('QST_system');
336
-
337
-        parent::__construct($timezone);
338
-    }
339
-
340
-
341
-    /**
342
-     * Returns the list of allowed question types, which are normally:
343
-     * 'TEXT','TEXTAREA','RADIO_BTN','DROPDOWN','CHECKBOX','DATE' but they can be extended
344
-     *
345
-     * @return string[]
346
-     */
347
-    public function allowed_question_types(): array
348
-    {
349
-        return $this->_allowed_question_types;
350
-    }
351
-
352
-
353
-    /**
354
-     * Gets all the question types in the same category
355
-     *
356
-     * @param string $question_type one of EEM_Question::allowed_question_types(
357
-     * @return string[] like EEM_Question::allowed_question_types()
358
-     */
359
-    public function question_types_in_same_category(string $question_type): array
360
-    {
361
-        $question_types = [$question_type];
362
-        foreach ($this->_question_type_categories as $category => $question_types_in_category) {
363
-            if (in_array($question_type, $question_types_in_category)) {
364
-                $question_types = $question_types_in_category;
365
-                break;
366
-            }
367
-        }
368
-
369
-        return array_intersect_key($this->allowed_question_types(), array_flip($question_types));
370
-    }
371
-
372
-
373
-    /**
374
-     * Determines if the given question type is in the given question type category
375
-     *
376
-     * @param string $question_type one of EEM_Question::allowed_question_types()
377
-     * @param string $category      one of the top-level keys of EEM_Question::question_type_categories()
378
-     * @return boolean
379
-     */
380
-    public function question_type_is_in_category(string $question_type, string $category): bool
381
-    {
382
-        if (! isset($this->_question_type_categories[ $category ])) {
383
-            return false;
384
-        }
385
-        return in_array($question_type, $this->_question_type_categories[ $category ]);
386
-    }
387
-
388
-
389
-    /**
390
-     * Returns all the question types in the given category
391
-     *
392
-     * @param string $category
393
-     * @return array|mixed
394
-     */
395
-    public function question_types_in_category(string $category): array
396
-    {
397
-        if (isset($this->_question_type_categories[ $category ])) {
398
-            return $this->_question_type_categories[ $category ];
399
-        }
400
-        return [];
401
-    }
402
-
403
-
404
-    /**
405
-     * Returns all the question types that should have question options
406
-     *
407
-     * @return array
408
-     */
409
-    public function question_types_with_options(): array
410
-    {
411
-        return array_merge(
412
-            $this->question_types_in_category('single-answer-enum'),
413
-            $this->question_types_in_category('multi-answer-enum')
414
-        );
415
-    }
416
-
417
-
418
-    /**
419
-     * Returns the question type categories 2d array
420
-     *
421
-     * @return array see EEM_Question::_question_type_categories
422
-     */
423
-    public function question_type_categories(): array
424
-    {
425
-        return $this->_question_type_categories;
426
-    }
427
-
428
-
429
-    /**
430
-     * Returns an array of all the QST_system values that can be allowed in the system question group
431
-     * identified by $system_question_group_id
432
-     *
433
-     * @param string $system_question_group_id QSG_system
434
-     * @return array of system question names (QST_system)
435
-     */
436
-    public function allowed_system_questions_in_system_question_group(string $system_question_group_id): array
437
-    {
438
-        $question_system_ids = [];
439
-        switch ($system_question_group_id) {
440
-            case EEM_Question_Group::system_personal:
441
-                $question_system_ids = [
442
-                    EEM_Attendee::system_question_fname,
443
-                    EEM_Attendee::system_question_lname,
444
-                    EEM_Attendee::system_question_email,
445
-                    EEM_Attendee::system_question_email_confirm,
446
-                    EEM_Attendee::system_question_phone,
447
-                ];
448
-                break;
449
-            case EEM_Question_Group::system_address:
450
-                $question_system_ids = [
451
-                    EEM_Attendee::system_question_address,
452
-                    EEM_Attendee::system_question_address2,
453
-                    EEM_Attendee::system_question_city,
454
-                    EEM_Attendee::system_question_state,
455
-                    EEM_Attendee::system_question_country,
456
-                    EEM_Attendee::system_question_zip,
457
-                    EEM_Attendee::system_question_phone,
458
-                ];
459
-                break;
460
-        }
461
-        return apply_filters(
462
-            'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return',
463
-            $question_system_ids,
464
-            $system_question_group_id
465
-        );
466
-    }
467
-
468
-
469
-    /**
470
-     * Returns an array of all the QST_system values that are required in the system question group
471
-     * identified by $system_question_group_id
472
-     *
473
-     * @param string $system_question_group_id QSG_system
474
-     * @return array of system question names (QST_system)
475
-     */
476
-    public function required_system_questions_in_system_question_group(string $system_question_group_id): array
477
-    {
478
-        $question_system_ids = null;
479
-        switch ($system_question_group_id) {
480
-            case EEM_Question_Group::system_personal:
481
-                $question_system_ids = [
482
-                    EEM_Attendee::system_question_fname,
483
-                    EEM_Attendee::system_question_email,
484
-                ];
485
-                break;
486
-            default:
487
-                $question_system_ids = [];
488
-        }
489
-        return apply_filters(
490
-            'FHEE__EEM_Question__system_questions_required_in_system_question_group',
491
-            $question_system_ids,
492
-            $system_question_group_id
493
-        );
494
-    }
495
-
496
-
497
-    /**
498
-     * Gets an array for converting between QST_system and QST_IDs for system questions. Eg, if you want to know
499
-     * which system question QST_ID corresponds to the QST_system 'city', use
500
-     * EEM_Question::instance()->get_Question_ID_from_system_string('city');
501
-     *
502
-     * @param $QST_system
503
-     * @return int of QST_ID for the question that corresponds to that QST_system
504
-     * @throws EE_Error
505
-     */
506
-    public function get_Question_ID_from_system_string($QST_system): int
507
-    {
508
-        return $this->get_var([['QST_system' => $QST_system]]);
509
-    }
510
-
511
-
512
-    /**
513
-     * searches the db for the question with the latest question order and returns that value.
514
-     *
515
-     * @return int
516
-     * @throws EE_Error
517
-     */
518
-    public function get_latest_question_order(): int
519
-    {
520
-        $columns_to_select = [
521
-            'max_order' => ["MAX(QST_order)", "%d"],
522
-        ];
523
-        $max               = $this->_get_all_wpdb_results([], ARRAY_A, $columns_to_select);
524
-        return isset($max[0], $max[0]['max_order']) ? $max[0]['max_order'] : 0;
525
-    }
526
-
527
-
528
-    /**
529
-     * Returns an array where keys are system question QST_system values,
530
-     * and values are the highest question max the admin can set on the question
531
-     * (aka the "max max"; eg, a site admin can change the zip question to have a max
532
-     * of 5, but no larger than 12)
533
-     *
534
-     * @return array
535
-     */
536
-    public function system_question_maxes(): array
537
-    {
538
-        return [
539
-            'fname'         => 45,
540
-            'lname'         => 45,
541
-            'address'       => 255,
542
-            'address2'      => 255,
543
-            'city'          => 45,
544
-            'zip'           => 12,
545
-            'email'         => 255,
546
-            'email_confirm' => 255,
547
-            'phone'         => 45,
548
-        ];
549
-    }
550
-
551
-
552
-    /**
553
-     * Given a QST_system value, gets the question's largest allowable max input.
554
-     *
555
-     * @param string $system_question_value
556
-     * @return int|float
557
-     * @see Registration_Form_Admin_Page::system_question_maxes()
558
-     */
559
-    public function absolute_max_for_system_question(string $system_question_value)
560
-    {
561
-        $maxes = $this->system_question_maxes();
562
-        return isset($maxes[ $system_question_value ]) ?
563
-            $maxes[ $system_question_value ]
564
-            : EE_INF;
565
-    }
566
-
567
-
568
-    /**
569
-     * @return array
570
-     */
571
-    public function question_descriptions(): array
572
-    {
573
-        return $this->_question_descriptions;
574
-    }
575
-
576
-
577
-    /**
578
-     * Returns all the question types that should have an admin-defined max input length
579
-     *
580
-     * @return array
581
-     */
582
-    public function questionTypesWithMaxLength(): array
583
-    {
584
-        return (array) $this->question_types_with_max_length;
585
-    }
15
+	// constant used to indicate that the question type is COUNTRY
16
+	const QST_type_country = 'COUNTRY';
17
+
18
+	// constant used to indicate that the question type is DATE
19
+	const QST_type_date = 'DATE';
20
+
21
+	// constant used to indicate that the question type is a decimal (float)
22
+	const QST_type_decimal = 'DECIMAL';
23
+
24
+	// constant used to indicate that the question type is DROPDOWN
25
+	const QST_type_dropdown = 'DROPDOWN';
26
+
27
+	// constant used to indicate that the question type is an email input
28
+	const QST_type_email = 'EMAIL';
29
+
30
+	// constant used to indicate that the question type is an email input
31
+	const QST_type_email_confirm = 'EMAIL_CONFIRM';
32
+
33
+	// constant used to indicate that the question type is a TEXTAREA that allows simple html
34
+	const QST_type_html_textarea = 'HTML_TEXTAREA';
35
+
36
+	// constant used to indicate that the question type is an integer (whole number)
37
+	const QST_type_int = 'INTEGER';
38
+
39
+	// constant used to indicate that the question type is a multi-select
40
+	const QST_type_multi_select = 'MULTI_SELECT';
41
+
42
+	// constant used to indicate that the question type is RADIO_BTN
43
+	const QST_type_radio = 'RADIO_BTN';
44
+
45
+	// constant used to indicate that the question type is STATE
46
+	const QST_type_state = 'STATE';
47
+
48
+	// constant used to indicate that the question type is TEXT
49
+	const QST_type_text = 'TEXT';
50
+
51
+	// constant used to indicate that the question type is TEXTAREA
52
+	const QST_type_textarea = 'TEXTAREA';
53
+
54
+	// constant used to indicate that the question type is a valid URL
55
+	const QST_type_url = 'URL';
56
+
57
+	// constant used to indicate that the question type is a US-formatted phone number
58
+	const QST_type_us_phone = 'US_PHONE';
59
+
60
+	// constant used to indicate that the question type is a YEAR
61
+	const QST_type_year = 'YEAR';
62
+
63
+	/**
64
+	 * lists all the question types which should be allowed. Ideally, this will be extensible.
65
+	 *
66
+	 * @var array $_allowed_question_types
67
+	 */
68
+	protected $_allowed_question_types = [];
69
+
70
+
71
+	// private instance of the Attendee object
72
+	protected static $_instance = null;
73
+
74
+	/**
75
+	 * brief descriptions for all the question types
76
+	 *
77
+	 * @var EEM_Question $_instance
78
+	 */
79
+	protected $_question_descriptions;
80
+
81
+	/**
82
+	 * Question types that are interchangeable, even after answers have been provided for them.
83
+	 * Top-level keys are category slugs, next level is an array of question types. If question types
84
+	 * aren't in this array, it is assumed they AREN'T interchangeable with any other question types.
85
+	 *
86
+	 * @var array   $_question_type_categories {
87
+	 * @type string $text
88
+	 * @type string $single                    -answer-enum
89
+	 * @type string $multi                     -answer-enum
90
+	 *                    }
91
+	 */
92
+	protected $_question_type_categories = [];
93
+
94
+
95
+	/**
96
+	 * Question types that should have an admin-defined max input length
97
+	 *
98
+	 * @var array
99
+	 */
100
+	protected $question_types_with_max_length;
101
+
102
+
103
+	/**
104
+	 * EEM_Question constructor.
105
+	 *
106
+	 * @param null $timezone
107
+	 */
108
+	protected function __construct($timezone = null)
109
+	{
110
+		$this->singular_item                  = esc_html__('Question', 'event_espresso');
111
+		$this->plural_item                    = esc_html__('Questions', 'event_espresso');
112
+		$this->_allowed_question_types        = apply_filters(
113
+			'FHEE__EEM_Question__construct__allowed_question_types',
114
+			[
115
+				EEM_Question::QST_type_checkbox      => esc_html__('Checkboxes', 'event_espresso'),
116
+				EEM_Question::QST_type_country       => esc_html__('Country Dropdown', 'event_espresso'),
117
+				EEM_Question::QST_type_date          => esc_html__('Date Picker', 'event_espresso'),
118
+				EEM_Question::QST_type_decimal       => esc_html__('Number', 'event_espresso'),
119
+				EEM_Question::QST_type_dropdown      => esc_html__('Dropdown', 'event_espresso'),
120
+				EEM_Question::QST_type_email         => esc_html__('Email', 'event_espresso'),
121
+				EEM_Question::QST_type_email_confirm => esc_html__('Confirm Email', 'event_espresso'),
122
+				EEM_Question::QST_type_html_textarea => esc_html__('HTML Textarea', 'event_espresso'),
123
+				EEM_Question::QST_type_int           => esc_html__('Whole Number', 'event_espresso'),
124
+				EEM_Question::QST_type_multi_select  => esc_html__('Multi Select', 'event_espresso'),
125
+				EEM_Question::QST_type_radio         => esc_html__('Radio Buttons', 'event_espresso'),
126
+				EEM_Question::QST_type_state         => esc_html__('State/Province Dropdown', 'event_espresso'),
127
+				EEM_Question::QST_type_text          => esc_html__('Text', 'event_espresso'),
128
+				EEM_Question::QST_type_textarea      => esc_html__('Textarea', 'event_espresso'),
129
+				EEM_Question::QST_type_url           => esc_html__('URL', 'event_espresso'),
130
+				EEM_Question::QST_type_us_phone      => esc_html__('USA - Format Phone', 'event_espresso'),
131
+				EEM_Question::QST_type_year          => esc_html__('Year', 'event_espresso'),
132
+			]
133
+		);
134
+		$this->_question_descriptions         = apply_filters(
135
+			'FHEE__EEM_Question__construct__question_descriptions',
136
+			[
137
+				EEM_Question::QST_type_checkbox      => esc_html__(
138
+					'Allows multiple preset options to be selected',
139
+					'event_espresso'
140
+				),
141
+				EEM_Question::QST_type_country       => esc_html__(
142
+					'A dropdown that lists countries',
143
+					'event_espresso'
144
+				),
145
+				EEM_Question::QST_type_date          => esc_html__(
146
+					'A popup calendar that allows date selections',
147
+					'event_espresso'
148
+				),
149
+				EEM_Question::QST_type_decimal       => esc_html__(
150
+					'A text field that allows number values with decimals',
151
+					'event_espresso'
152
+				),
153
+				EEM_Question::QST_type_dropdown      => esc_html__(
154
+					'A dropdown that allows a single selection',
155
+					'event_espresso'
156
+				),
157
+				EEM_Question::QST_type_email         => esc_html__(
158
+					'A text field that must contain a valid Email address',
159
+					'event_espresso'
160
+				),
161
+				EEM_Question::QST_type_email_confirm => esc_html__(
162
+					'A text field that must contain a valid Email address and be equal to Email field',
163
+					'event_espresso'
164
+				),
165
+				EEM_Question::QST_type_html_textarea => esc_html__(
166
+					'A multi line text input field that allows HTML',
167
+					'event_espresso'
168
+				),
169
+				EEM_Question::QST_type_int           => esc_html__(
170
+					'A text field that only allows whole numbers (no decimals)',
171
+					'event_espresso'
172
+				),
173
+				EEM_Question::QST_type_multi_select  => esc_html__(
174
+					'A dropdown that allows multiple selections',
175
+					'event_espresso'
176
+				),
177
+				EEM_Question::QST_type_radio         => esc_html__(
178
+					'Allows a single preset option to be selected',
179
+					'event_espresso'
180
+				),
181
+				EEM_Question::QST_type_state         => esc_html__(
182
+					'A dropdown that lists states/provinces',
183
+					'event_espresso'
184
+				),
185
+				EEM_Question::QST_type_text          => esc_html__(
186
+					'A single line text input field',
187
+					'event_espresso'
188
+				),
189
+				EEM_Question::QST_type_textarea      => esc_html__(
190
+					'A multi line text input field',
191
+					'event_espresso'
192
+				),
193
+				EEM_Question::QST_type_url           => esc_html__(
194
+					'A text field that must contain a valid URL',
195
+					'event_espresso'
196
+				),
197
+				EEM_Question::QST_type_us_phone      => esc_html__(
198
+					'A text field that must contain a valid US phone number',
199
+					'event_espresso'
200
+				),
201
+				EEM_Question::QST_type_year          => esc_html__(
202
+					'A dropdown that lists the last 100 years',
203
+					'event_espresso'
204
+				),
205
+			]
206
+		);
207
+		$this->_question_type_categories      = (array) apply_filters(
208
+			'FHEE__EEM_Question__construct__question_type_categories',
209
+			[
210
+				'text'               => [
211
+					EEM_Question::QST_type_date,
212
+					EEM_Question::QST_type_decimal,
213
+					EEM_Question::QST_type_email,
214
+					EEM_Question::QST_type_email_confirm,
215
+					EEM_Question::QST_type_html_textarea,
216
+					EEM_Question::QST_type_int,
217
+					EEM_Question::QST_type_text,
218
+					EEM_Question::QST_type_textarea,
219
+					EEM_Question::QST_type_url,
220
+					EEM_Question::QST_type_us_phone,
221
+					EEM_Question::QST_type_year,
222
+				],
223
+				'single-answer-enum' => [
224
+					EEM_Question::QST_type_dropdown,
225
+					EEM_Question::QST_type_radio,
226
+				],
227
+				'multi-answer-enum'  => [
228
+					EEM_Question::QST_type_multi_select,
229
+					EEM_Question::QST_type_checkbox,
230
+				],
231
+			]
232
+		);
233
+		$this->question_types_with_max_length = apply_filters(
234
+			'FHEE__EEM_Question___construct__question_types_with_max_length',
235
+			[
236
+				EEM_Question::QST_type_html_textarea,
237
+				EEM_Question::QST_type_text,
238
+				EEM_Question::QST_type_textarea,
239
+			]
240
+		);
241
+
242
+		$this->_tables          = [
243
+			'Question' => new EE_Primary_Table('esp_question', 'QST_ID'),
244
+		];
245
+		$this->_fields          = [
246
+			'Question' => [
247
+				'QST_ID'            => new EE_Primary_Key_Int_Field(
248
+					'QST_ID',
249
+					esc_html__('Question ID', 'event_espresso')
250
+				),
251
+				'QST_admin_label'   => new EE_Plain_Text_Field(
252
+					'QST_admin_label',
253
+					esc_html__('Question Label (admin-only)', 'event_espresso'),
254
+					true,
255
+					''
256
+				),
257
+				'QST_admin_only'    => new EE_Boolean_Field(
258
+					'QST_admin_only',
259
+					esc_html__('Admin-Only Question?', 'event_espresso'),
260
+					false,
261
+					false
262
+				),
263
+				'QST_deleted'       => new EE_Trashed_Flag_Field(
264
+					'QST_deleted',
265
+					esc_html__('Flag Indicating question was deleted', 'event_espresso'),
266
+					false,
267
+					false
268
+				),
269
+				'QST_display_text'  => new EE_Post_Content_Field(
270
+					'QST_display_text',
271
+					esc_html__('Question Text', 'event_espresso'),
272
+					true,
273
+					''
274
+				),
275
+				'QST_max'           => new EE_Infinite_Integer_Field(
276
+					'QST_max',
277
+					esc_html__('Max Size', 'event_espresso'),
278
+					false,
279
+					EE_INF
280
+				),
281
+				'QST_order'         => new EE_Integer_Field(
282
+					'QST_order',
283
+					esc_html__('Question Order', 'event_espresso'),
284
+					false,
285
+					0
286
+				),
287
+				'QST_required'      => new EE_Boolean_Field(
288
+					'QST_required',
289
+					esc_html__('Required Question?', 'event_espresso'),
290
+					false,
291
+					false
292
+				),
293
+				'QST_required_text' => new EE_Simple_HTML_Field(
294
+					'QST_required_text',
295
+					esc_html__('Text to Display if Not Provided', 'event_espresso'),
296
+					true,
297
+					''
298
+				),
299
+				'QST_system'        => new EE_Plain_Text_Field(
300
+					'QST_system',
301
+					esc_html__('Internal string ID for question', 'event_espresso'),
302
+					false,
303
+					''
304
+				),
305
+				'QST_type'          => new EE_Enum_Text_Field(
306
+					'QST_type',
307
+					esc_html__('Question Type', 'event_espresso'),
308
+					false,
309
+					'TEXT',
310
+					$this->_allowed_question_types
311
+				),
312
+				'QST_wp_user'       => new EE_WP_User_Field(
313
+					'QST_wp_user',
314
+					esc_html__('Question Creator ID', 'event_espresso'),
315
+					false
316
+				),
317
+			],
318
+		];
319
+		$this->_model_relations = [
320
+			'Answer'                  => new EE_Has_Many_Relation(),
321
+			'Question_Group'          => new EE_HABTM_Relation('Question_Group_Question'),
322
+			// for QST_order column
323
+			'Question_Group_Question' => new EE_Has_Many_Relation(),
324
+			'Question_Option'         => new EE_Has_Many_Relation(),
325
+			'WP_User'                 => new EE_Belongs_To_Relation(),
326
+		];
327
+		// this model is generally available for reading
328
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
329
+			new EE_Restriction_Generator_Public();
330
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
331
+			new EE_Restriction_Generator_Reg_Form('QST_system');
332
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
333
+			new EE_Restriction_Generator_Reg_Form('QST_system');
334
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
335
+			new EE_Restriction_Generator_Reg_Form('QST_system');
336
+
337
+		parent::__construct($timezone);
338
+	}
339
+
340
+
341
+	/**
342
+	 * Returns the list of allowed question types, which are normally:
343
+	 * 'TEXT','TEXTAREA','RADIO_BTN','DROPDOWN','CHECKBOX','DATE' but they can be extended
344
+	 *
345
+	 * @return string[]
346
+	 */
347
+	public function allowed_question_types(): array
348
+	{
349
+		return $this->_allowed_question_types;
350
+	}
351
+
352
+
353
+	/**
354
+	 * Gets all the question types in the same category
355
+	 *
356
+	 * @param string $question_type one of EEM_Question::allowed_question_types(
357
+	 * @return string[] like EEM_Question::allowed_question_types()
358
+	 */
359
+	public function question_types_in_same_category(string $question_type): array
360
+	{
361
+		$question_types = [$question_type];
362
+		foreach ($this->_question_type_categories as $category => $question_types_in_category) {
363
+			if (in_array($question_type, $question_types_in_category)) {
364
+				$question_types = $question_types_in_category;
365
+				break;
366
+			}
367
+		}
368
+
369
+		return array_intersect_key($this->allowed_question_types(), array_flip($question_types));
370
+	}
371
+
372
+
373
+	/**
374
+	 * Determines if the given question type is in the given question type category
375
+	 *
376
+	 * @param string $question_type one of EEM_Question::allowed_question_types()
377
+	 * @param string $category      one of the top-level keys of EEM_Question::question_type_categories()
378
+	 * @return boolean
379
+	 */
380
+	public function question_type_is_in_category(string $question_type, string $category): bool
381
+	{
382
+		if (! isset($this->_question_type_categories[ $category ])) {
383
+			return false;
384
+		}
385
+		return in_array($question_type, $this->_question_type_categories[ $category ]);
386
+	}
387
+
388
+
389
+	/**
390
+	 * Returns all the question types in the given category
391
+	 *
392
+	 * @param string $category
393
+	 * @return array|mixed
394
+	 */
395
+	public function question_types_in_category(string $category): array
396
+	{
397
+		if (isset($this->_question_type_categories[ $category ])) {
398
+			return $this->_question_type_categories[ $category ];
399
+		}
400
+		return [];
401
+	}
402
+
403
+
404
+	/**
405
+	 * Returns all the question types that should have question options
406
+	 *
407
+	 * @return array
408
+	 */
409
+	public function question_types_with_options(): array
410
+	{
411
+		return array_merge(
412
+			$this->question_types_in_category('single-answer-enum'),
413
+			$this->question_types_in_category('multi-answer-enum')
414
+		);
415
+	}
416
+
417
+
418
+	/**
419
+	 * Returns the question type categories 2d array
420
+	 *
421
+	 * @return array see EEM_Question::_question_type_categories
422
+	 */
423
+	public function question_type_categories(): array
424
+	{
425
+		return $this->_question_type_categories;
426
+	}
427
+
428
+
429
+	/**
430
+	 * Returns an array of all the QST_system values that can be allowed in the system question group
431
+	 * identified by $system_question_group_id
432
+	 *
433
+	 * @param string $system_question_group_id QSG_system
434
+	 * @return array of system question names (QST_system)
435
+	 */
436
+	public function allowed_system_questions_in_system_question_group(string $system_question_group_id): array
437
+	{
438
+		$question_system_ids = [];
439
+		switch ($system_question_group_id) {
440
+			case EEM_Question_Group::system_personal:
441
+				$question_system_ids = [
442
+					EEM_Attendee::system_question_fname,
443
+					EEM_Attendee::system_question_lname,
444
+					EEM_Attendee::system_question_email,
445
+					EEM_Attendee::system_question_email_confirm,
446
+					EEM_Attendee::system_question_phone,
447
+				];
448
+				break;
449
+			case EEM_Question_Group::system_address:
450
+				$question_system_ids = [
451
+					EEM_Attendee::system_question_address,
452
+					EEM_Attendee::system_question_address2,
453
+					EEM_Attendee::system_question_city,
454
+					EEM_Attendee::system_question_state,
455
+					EEM_Attendee::system_question_country,
456
+					EEM_Attendee::system_question_zip,
457
+					EEM_Attendee::system_question_phone,
458
+				];
459
+				break;
460
+		}
461
+		return apply_filters(
462
+			'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return',
463
+			$question_system_ids,
464
+			$system_question_group_id
465
+		);
466
+	}
467
+
468
+
469
+	/**
470
+	 * Returns an array of all the QST_system values that are required in the system question group
471
+	 * identified by $system_question_group_id
472
+	 *
473
+	 * @param string $system_question_group_id QSG_system
474
+	 * @return array of system question names (QST_system)
475
+	 */
476
+	public function required_system_questions_in_system_question_group(string $system_question_group_id): array
477
+	{
478
+		$question_system_ids = null;
479
+		switch ($system_question_group_id) {
480
+			case EEM_Question_Group::system_personal:
481
+				$question_system_ids = [
482
+					EEM_Attendee::system_question_fname,
483
+					EEM_Attendee::system_question_email,
484
+				];
485
+				break;
486
+			default:
487
+				$question_system_ids = [];
488
+		}
489
+		return apply_filters(
490
+			'FHEE__EEM_Question__system_questions_required_in_system_question_group',
491
+			$question_system_ids,
492
+			$system_question_group_id
493
+		);
494
+	}
495
+
496
+
497
+	/**
498
+	 * Gets an array for converting between QST_system and QST_IDs for system questions. Eg, if you want to know
499
+	 * which system question QST_ID corresponds to the QST_system 'city', use
500
+	 * EEM_Question::instance()->get_Question_ID_from_system_string('city');
501
+	 *
502
+	 * @param $QST_system
503
+	 * @return int of QST_ID for the question that corresponds to that QST_system
504
+	 * @throws EE_Error
505
+	 */
506
+	public function get_Question_ID_from_system_string($QST_system): int
507
+	{
508
+		return $this->get_var([['QST_system' => $QST_system]]);
509
+	}
510
+
511
+
512
+	/**
513
+	 * searches the db for the question with the latest question order and returns that value.
514
+	 *
515
+	 * @return int
516
+	 * @throws EE_Error
517
+	 */
518
+	public function get_latest_question_order(): int
519
+	{
520
+		$columns_to_select = [
521
+			'max_order' => ["MAX(QST_order)", "%d"],
522
+		];
523
+		$max               = $this->_get_all_wpdb_results([], ARRAY_A, $columns_to_select);
524
+		return isset($max[0], $max[0]['max_order']) ? $max[0]['max_order'] : 0;
525
+	}
526
+
527
+
528
+	/**
529
+	 * Returns an array where keys are system question QST_system values,
530
+	 * and values are the highest question max the admin can set on the question
531
+	 * (aka the "max max"; eg, a site admin can change the zip question to have a max
532
+	 * of 5, but no larger than 12)
533
+	 *
534
+	 * @return array
535
+	 */
536
+	public function system_question_maxes(): array
537
+	{
538
+		return [
539
+			'fname'         => 45,
540
+			'lname'         => 45,
541
+			'address'       => 255,
542
+			'address2'      => 255,
543
+			'city'          => 45,
544
+			'zip'           => 12,
545
+			'email'         => 255,
546
+			'email_confirm' => 255,
547
+			'phone'         => 45,
548
+		];
549
+	}
550
+
551
+
552
+	/**
553
+	 * Given a QST_system value, gets the question's largest allowable max input.
554
+	 *
555
+	 * @param string $system_question_value
556
+	 * @return int|float
557
+	 * @see Registration_Form_Admin_Page::system_question_maxes()
558
+	 */
559
+	public function absolute_max_for_system_question(string $system_question_value)
560
+	{
561
+		$maxes = $this->system_question_maxes();
562
+		return isset($maxes[ $system_question_value ]) ?
563
+			$maxes[ $system_question_value ]
564
+			: EE_INF;
565
+	}
566
+
567
+
568
+	/**
569
+	 * @return array
570
+	 */
571
+	public function question_descriptions(): array
572
+	{
573
+		return $this->_question_descriptions;
574
+	}
575
+
576
+
577
+	/**
578
+	 * Returns all the question types that should have an admin-defined max input length
579
+	 *
580
+	 * @return array
581
+	 */
582
+	public function questionTypesWithMaxLength(): array
583
+	{
584
+		return (array) $this->question_types_with_max_length;
585
+	}
586 586
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_Base.strategy.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function model()
84 84
     {
85
-        if (! $this->_model instanceof EEM_Base) {
85
+        if ( ! $this->_model instanceof EEM_Base) {
86 86
             throw new EE_Error(
87 87
                 sprintf(
88 88
                     esc_html__(
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function action(): string
108 108
     {
109
-        if (! $this->_action) {
109
+        if ( ! $this->_action) {
110 110
             throw new EE_Error(
111 111
                 sprintf(
112 112
                     esc_html__(
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
             || strpos($path_to_event_model, 'Event') !== false
261 261
         ) {
262 262
             $where_conditions['OR*status'] = [
263
-                $path_to_event_model . 'status' => $published_value,
263
+                $path_to_event_model.'status' => $published_value,
264 264
                 'AND'                           => [
265
-                    $path_to_event_model .
265
+                    $path_to_event_model.
266 266
                     'Post_Meta.meta_key'                          => '_previous_event_status',
267
-                    $path_to_event_model .
267
+                    $path_to_event_model.
268 268
                     'Post_Meta.meta_value'                        => $published_value,
269 269
                 ],
270 270
             ];
271 271
         } else {
272
-            $where_conditions[ $path_to_event_model . 'status' ] =
272
+            $where_conditions[$path_to_event_model.'status'] =
273 273
                 $published_value;
274 274
         }
275 275
         return $where_conditions;
Please login to merge, or discard this patch.
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -36,242 +36,242 @@
 block discarded – undo
36 36
  */
37 37
 abstract class EE_Restriction_Generator_Base
38 38
 {
39
-    /**
40
-     * One of EEM_Base::valid_cap_contexts()
41
-     *
42
-     * @var string
43
-     */
44
-    protected $_action;
39
+	/**
40
+	 * One of EEM_Base::valid_cap_contexts()
41
+	 *
42
+	 * @var string
43
+	 */
44
+	protected $_action;
45 45
 
46
-    /**
47
-     * The restrictions generated by this object. FALSE before any are made.
48
-     *
49
-     * @var EE_Default_Where_Conditions[]
50
-     */
51
-    protected $_cap_restrictions_generated;
46
+	/**
47
+	 * The restrictions generated by this object. FALSE before any are made.
48
+	 *
49
+	 * @var EE_Default_Where_Conditions[]
50
+	 */
51
+	protected $_cap_restrictions_generated;
52 52
 
53
-    /**
54
-     * Model for which restrictions are generated
55
-     *
56
-     * @var EEM_Base
57
-     */
58
-    protected $_model;
53
+	/**
54
+	 * Model for which restrictions are generated
55
+	 *
56
+	 * @var EEM_Base
57
+	 */
58
+	protected $_model;
59 59
 
60 60
 
61
-    /**
62
-     * Puts the last necessary info onto the restriction generator class. This
63
-     * is usually called by EEM_Base during its constructor, so child classes
64
-     * don't have to always provide this info.
65
-     *
66
-     * @param EEM_Base $model
67
-     * @param string   $action
68
-     */
69
-    public function _construct_finalize(EEM_Base $model, string $action)
70
-    {
71
-        $this->_model  = $model;
72
-        $this->_action = $action;
73
-    }
61
+	/**
62
+	 * Puts the last necessary info onto the restriction generator class. This
63
+	 * is usually called by EEM_Base during its constructor, so child classes
64
+	 * don't have to always provide this info.
65
+	 *
66
+	 * @param EEM_Base $model
67
+	 * @param string   $action
68
+	 */
69
+	public function _construct_finalize(EEM_Base $model, string $action)
70
+	{
71
+		$this->_model  = $model;
72
+		$this->_action = $action;
73
+	}
74 74
 
75 75
 
76
-    /**
77
-     * Returns the model set for this restriction generator
78
-     *
79
-     * @return EEM_Base|EEM_Soft_Delete_Base
80
-     * @throws EE_Error
81
-     */
82
-    public function model()
83
-    {
84
-        if (! $this->_model instanceof EEM_Base) {
85
-            throw new EE_Error(
86
-                sprintf(
87
-                    esc_html__(
88
-                        'Cannot generate capability restrictions because model has not yet been set on the %s. Please ensure _construct_finalize() was called',
89
-                        'event_espresso'
90
-                    ),
91
-                    get_class($this)
92
-                )
93
-            );
94
-        }
95
-        return $this->_model;
96
-    }
76
+	/**
77
+	 * Returns the model set for this restriction generator
78
+	 *
79
+	 * @return EEM_Base|EEM_Soft_Delete_Base
80
+	 * @throws EE_Error
81
+	 */
82
+	public function model()
83
+	{
84
+		if (! $this->_model instanceof EEM_Base) {
85
+			throw new EE_Error(
86
+				sprintf(
87
+					esc_html__(
88
+						'Cannot generate capability restrictions because model has not yet been set on the %s. Please ensure _construct_finalize() was called',
89
+						'event_espresso'
90
+					),
91
+					get_class($this)
92
+				)
93
+			);
94
+		}
95
+		return $this->_model;
96
+	}
97 97
 
98 98
 
99
-    /**
100
-     * Returns the action this restriction generator will generate restrictions
101
-     * for. It should be one of EEM_Base::valid_cap_contexts()
102
-     *
103
-     * @return string
104
-     * @throws EE_Error
105
-     */
106
-    public function action(): string
107
-    {
108
-        if (! $this->_action) {
109
-            throw new EE_Error(
110
-                sprintf(
111
-                    esc_html__(
112
-                        'Cannot generate capability restrictions because model has not yet been set on the %s. Please ensure _construct_finalize() was called',
113
-                        'event_espresso'
114
-                    ),
115
-                    get_class($this)
116
-                )
117
-            );
118
-        }
119
-        return $this->_action;
120
-    }
99
+	/**
100
+	 * Returns the action this restriction generator will generate restrictions
101
+	 * for. It should be one of EEM_Base::valid_cap_contexts()
102
+	 *
103
+	 * @return string
104
+	 * @throws EE_Error
105
+	 */
106
+	public function action(): string
107
+	{
108
+		if (! $this->_action) {
109
+			throw new EE_Error(
110
+				sprintf(
111
+					esc_html__(
112
+						'Cannot generate capability restrictions because model has not yet been set on the %s. Please ensure _construct_finalize() was called',
113
+						'event_espresso'
114
+					),
115
+					get_class($this)
116
+				)
117
+			);
118
+		}
119
+		return $this->_action;
120
+	}
121 121
 
122 122
 
123
-    /**
124
-     * Returns whether or not _construct_finalize() has been called on this
125
-     * restriction generator object
126
-     *
127
-     * @return boolean
128
-     */
129
-    public function construction_finalized(): bool
130
-    {
131
-        return $this->_model instanceof EEM_Base && $this->_action;
132
-    }
123
+	/**
124
+	 * Returns whether or not _construct_finalize() has been called on this
125
+	 * restriction generator object
126
+	 *
127
+	 * @return boolean
128
+	 */
129
+	public function construction_finalized(): bool
130
+	{
131
+		return $this->_model instanceof EEM_Base && $this->_action;
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * Gets the capability restrictions generated by this object. Caches them in
137
-     * case they are required for subsequent requests
138
-     *
139
-     * @return array @see EEM_Base::_cap_restrictions
140
-     */
141
-    public function generate_restrictions(): array
142
-    {
143
-        if ($this->_cap_restrictions_generated === null) {
144
-            $this->_cap_restrictions_generated = apply_filters(
145
-                'FHEE__EE_Restriction_Generator_Base__generate_restrictions__first_time',
146
-                $this->_generate_restrictions(),
147
-                $this
148
-            );
149
-        }
150
-        return apply_filters(
151
-            'FHEE__EE_Restriction_Generator_Base__generate_restrictions__every_time',
152
-            $this->_cap_restrictions_generated,
153
-            $this
154
-        );
155
-    }
135
+	/**
136
+	 * Gets the capability restrictions generated by this object. Caches them in
137
+	 * case they are required for subsequent requests
138
+	 *
139
+	 * @return array @see EEM_Base::_cap_restrictions
140
+	 */
141
+	public function generate_restrictions(): array
142
+	{
143
+		if ($this->_cap_restrictions_generated === null) {
144
+			$this->_cap_restrictions_generated = apply_filters(
145
+				'FHEE__EE_Restriction_Generator_Base__generate_restrictions__first_time',
146
+				$this->_generate_restrictions(),
147
+				$this
148
+			);
149
+		}
150
+		return apply_filters(
151
+			'FHEE__EE_Restriction_Generator_Base__generate_restrictions__every_time',
152
+			$this->_cap_restrictions_generated,
153
+			$this
154
+		);
155
+	}
156 156
 
157 157
 
158
-    /**
159
-     * Provided with the model, and using global knowledge about what
160
-     * capabilities exist, generates an array for use in one of the sub-arrays
161
-     * in EEM_Base::_cap_restrictions, where keys are capability names, and
162
-     * values are children of EE_Default_Where_Conditions
163
-     *
164
-     * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
165
-     * @see EEM_Base::_cap_restrictions
166
-     */
167
-    abstract protected function _generate_restrictions(): array;
158
+	/**
159
+	 * Provided with the model, and using global knowledge about what
160
+	 * capabilities exist, generates an array for use in one of the sub-arrays
161
+	 * in EEM_Base::_cap_restrictions, where keys are capability names, and
162
+	 * values are children of EE_Default_Where_Conditions
163
+	 *
164
+	 * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
165
+	 * @see EEM_Base::_cap_restrictions
166
+	 */
167
+	abstract protected function _generate_restrictions(): array;
168 168
 
169 169
 
170
-    /**
171
-     * Whether or not this restriction generator has already done its job of
172
-     * making restrictions and caching them on itself in case its asked later
173
-     *
174
-     * @return boolean
175
-     */
176
-    public function has_generated_cap_restrictions(): bool
177
-    {
178
-        return $this->_cap_restrictions_generated !== null;
179
-    }
170
+	/**
171
+	 * Whether or not this restriction generator has already done its job of
172
+	 * making restrictions and caching them on itself in case its asked later
173
+	 *
174
+	 * @return boolean
175
+	 */
176
+	public function has_generated_cap_restrictions(): bool
177
+	{
178
+		return $this->_cap_restrictions_generated !== null;
179
+	}
180 180
 
181 181
 
182
-    /**
183
-     * Given an action like 'edit' generates the cap name based off
184
-     * the EEM_Base::_cap_slug, which for events would be 'events', to generate
185
-     * the cap name like 'ee_edit_events'. If a $qualifier is passed,
186
-     *
187
-     * @param EEM_Base $model
188
-     * @param string   $action
189
-     * @return string
190
-     */
191
-    public static function get_cap_name(EEM_Base $model, string $action): string
192
-    {
193
-        $prefix = $model->is_wp_core_model() ? '' : 'ee_';
194
-        $cap_slug = $model->cap_slug();
195
-        return apply_filters(
196
-            'FHEE__EE_Restriction_Generator__get_cap_name',
197
-            "{$prefix}{$action}_{$cap_slug}",
198
-            $model,
199
-            $action
200
-        );
201
-    }
182
+	/**
183
+	 * Given an action like 'edit' generates the cap name based off
184
+	 * the EEM_Base::_cap_slug, which for events would be 'events', to generate
185
+	 * the cap name like 'ee_edit_events'. If a $qualifier is passed,
186
+	 *
187
+	 * @param EEM_Base $model
188
+	 * @param string   $action
189
+	 * @return string
190
+	 */
191
+	public static function get_cap_name(EEM_Base $model, string $action): string
192
+	{
193
+		$prefix = $model->is_wp_core_model() ? '' : 'ee_';
194
+		$cap_slug = $model->cap_slug();
195
+		return apply_filters(
196
+			'FHEE__EE_Restriction_Generator__get_cap_name',
197
+			"{$prefix}{$action}_{$cap_slug}",
198
+			$model,
199
+			$action
200
+		);
201
+	}
202 202
 
203 203
 
204
-    /**
205
-     * Checks if there is a cap for this model and this action
206
-     *
207
-     * @param EEM_Base $model
208
-     * @param string   $action
209
-     * @return boolean
210
-     * @throws EE_Error
211
-     */
212
-    public static function is_cap(EEM_Base $model, string $action): bool
213
-    {
214
-        $caps_for_admin = EE_Registry::instance()->CAP->get_ee_capabilities();
215
-        return in_array(self::get_cap_name($model, $action), $caps_for_admin);
216
-    }
204
+	/**
205
+	 * Checks if there is a cap for this model and this action
206
+	 *
207
+	 * @param EEM_Base $model
208
+	 * @param string   $action
209
+	 * @return boolean
210
+	 * @throws EE_Error
211
+	 */
212
+	public static function is_cap(EEM_Base $model, string $action): bool
213
+	{
214
+		$caps_for_admin = EE_Registry::instance()->CAP->get_ee_capabilities();
215
+		return in_array(self::get_cap_name($model, $action), $caps_for_admin);
216
+	}
217 217
 
218 218
 
219
-    /**
220
-     * Returns the default capability used to determine if the current user can
221
-     * access something.
222
-     *
223
-     * @return string
224
-     */
225
-    public static function get_default_restrictions_cap(): string
226
-    {
227
-        return apply_filters(
228
-            'FHEE__EE_Restriction_Generator_Base__default_restrictions_cap',
229
-            'manage_options'
230
-        );
231
-    }
219
+	/**
220
+	 * Returns the default capability used to determine if the current user can
221
+	 * access something.
222
+	 *
223
+	 * @return string
224
+	 */
225
+	public static function get_default_restrictions_cap(): string
226
+	{
227
+		return apply_filters(
228
+			'FHEE__EE_Restriction_Generator_Base__default_restrictions_cap',
229
+			'manage_options'
230
+		);
231
+	}
232 232
 
233 233
 
234
-    /**
235
-     * Gets WHERE conditions for the query that show the post model is
236
-     * published, or that it's sold out and it was previously published
237
-     *
238
-     * @param array   $where_conditions
239
-     * @param boolean $check_if_published  if true, will add conditions like
240
-     *                                     status=publish if false, will add
241
-     *                                     conditions like status!=private
242
-     * @param string  $path_to_event_model including the period at the end
243
-     * @return array
244
-     * @throws EE_Error
245
-     */
246
-    protected function addPublishedPostConditions(
247
-        $where_conditions = [],
248
-        $check_if_published = true,
249
-        $path_to_event_model = ''
250
-    ): array {
251
-        if ($check_if_published) {
252
-            $published_value = 'publish';
253
-        } else {
254
-            $published_value = ['!=', 'private'];
255
-        }
256
-        // only add a check for the previous event status
257
-        // if the model is the event or it's related to the event model
258
-        if (
259
-            $this->model() instanceof EEM_Event
260
-            || strpos($path_to_event_model, 'Event') !== false
261
-        ) {
262
-            $where_conditions['OR*status'] = [
263
-                $path_to_event_model . 'status' => $published_value,
264
-                'AND'                           => [
265
-                    $path_to_event_model .
266
-                    'Post_Meta.meta_key'                          => '_previous_event_status',
267
-                    $path_to_event_model .
268
-                    'Post_Meta.meta_value'                        => $published_value,
269
-                ],
270
-            ];
271
-        } else {
272
-            $where_conditions[ $path_to_event_model . 'status' ] =
273
-                $published_value;
274
-        }
275
-        return $where_conditions;
276
-    }
234
+	/**
235
+	 * Gets WHERE conditions for the query that show the post model is
236
+	 * published, or that it's sold out and it was previously published
237
+	 *
238
+	 * @param array   $where_conditions
239
+	 * @param boolean $check_if_published  if true, will add conditions like
240
+	 *                                     status=publish if false, will add
241
+	 *                                     conditions like status!=private
242
+	 * @param string  $path_to_event_model including the period at the end
243
+	 * @return array
244
+	 * @throws EE_Error
245
+	 */
246
+	protected function addPublishedPostConditions(
247
+		$where_conditions = [],
248
+		$check_if_published = true,
249
+		$path_to_event_model = ''
250
+	): array {
251
+		if ($check_if_published) {
252
+			$published_value = 'publish';
253
+		} else {
254
+			$published_value = ['!=', 'private'];
255
+		}
256
+		// only add a check for the previous event status
257
+		// if the model is the event or it's related to the event model
258
+		if (
259
+			$this->model() instanceof EEM_Event
260
+			|| strpos($path_to_event_model, 'Event') !== false
261
+		) {
262
+			$where_conditions['OR*status'] = [
263
+				$path_to_event_model . 'status' => $published_value,
264
+				'AND'                           => [
265
+					$path_to_event_model .
266
+					'Post_Meta.meta_key'                          => '_previous_event_status',
267
+					$path_to_event_model .
268
+					'Post_Meta.meta_value'                        => $published_value,
269
+				],
270
+			];
271
+		} else {
272
+			$where_conditions[ $path_to_event_model . 'status' ] =
273
+				$published_value;
274
+		}
275
+		return $where_conditions;
276
+	}
277 277
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_Meta.strategy.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,21 +52,21 @@
 block discarded – undo
52 52
                 'FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys',
53 53
                 []
54 54
             );
55
-        $conditions            = [
55
+        $conditions = [
56 56
             $this->_key_field_name   => ['NOT_LIKE', "\\\\_%"],
57 57
             // each slash is escaped because we are using double quotes, and
58 58
             // stripslashes will be called on this because the models assume this is from user input
59 59
             $this->_value_field_name => ['NOT_REGEXP', '^[aOs]:[\d]:.*$'],
60 60
         ];
61
-        if (! empty($blacklisted_meta_keys)) {
62
-            $conditions[ $this->_key_field_name . '*blacklisted' ] =
61
+        if ( ! empty($blacklisted_meta_keys)) {
62
+            $conditions[$this->_key_field_name.'*blacklisted'] =
63 63
                 ['NOT_IN', $blacklisted_meta_keys];
64 64
         }
65
-        if (! empty($whitelisted_meta_keys)) {
65
+        if ( ! empty($whitelisted_meta_keys)) {
66 66
             $conditions = [
67 67
                 'OR*whitelisted-or-normal' => [
68 68
                     'AND'                                   => $conditions,
69
-                    $this->_key_field_name . '*whitelisted' => [
69
+                    $this->_key_field_name.'*whitelisted' => [
70 70
                         'IN',
71 71
                         $whitelisted_meta_keys,
72 72
                     ],
Please login to merge, or discard this patch.
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -11,75 +11,75 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Restriction_Generator_Meta extends EE_Restriction_Generator_Base
13 13
 {
14
-    /**
15
-     * @var string the name of the field containing the meta key
16
-     */
17
-    protected $_key_field_name = null;
14
+	/**
15
+	 * @var string the name of the field containing the meta key
16
+	 */
17
+	protected $_key_field_name = null;
18 18
 
19
-    /**
20
-     * @var string the name of the field containing the meta value
21
-     */
22
-    protected $_value_field_name = null;
19
+	/**
20
+	 * @var string the name of the field containing the meta value
21
+	 */
22
+	protected $_value_field_name = null;
23 23
 
24 24
 
25
-    /**
26
-     * Accepts the name of the field that indicates whether or not an object is
27
-     * a "system" one or not
28
-     *
29
-     * @param string $key_field_name
30
-     * @param string $value_field_name
31
-     */
32
-    public function __construct(string $key_field_name, string $value_field_name)
33
-    {
34
-        $this->_key_field_name   = $key_field_name;
35
-        $this->_value_field_name = $value_field_name;
36
-    }
25
+	/**
26
+	 * Accepts the name of the field that indicates whether or not an object is
27
+	 * a "system" one or not
28
+	 *
29
+	 * @param string $key_field_name
30
+	 * @param string $value_field_name
31
+	 */
32
+	public function __construct(string $key_field_name, string $value_field_name)
33
+	{
34
+		$this->_key_field_name   = $key_field_name;
35
+		$this->_value_field_name = $value_field_name;
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
41
-     */
42
-    protected function _generate_restrictions(): array
43
-    {
44
-        $whitelisted_meta_keys =
45
-            apply_filters(
46
-                'FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys',
47
-                []
48
-            );
49
-        $blacklisted_meta_keys =
50
-            apply_filters(
51
-                'FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys',
52
-                []
53
-            );
54
-        $conditions            = [
55
-            $this->_key_field_name   => ['NOT_LIKE', "\\\\_%"],
56
-            // each slash is escaped because we are using double quotes, and
57
-            // stripslashes will be called on this because the models assume this is from user input
58
-            $this->_value_field_name => ['NOT_REGEXP', '^[aOs]:[\d]:.*$'],
59
-        ];
60
-        if (! empty($blacklisted_meta_keys)) {
61
-            $conditions[ $this->_key_field_name . '*blacklisted' ] =
62
-                ['NOT_IN', $blacklisted_meta_keys];
63
-        }
64
-        if (! empty($whitelisted_meta_keys)) {
65
-            $conditions = [
66
-                'OR*whitelisted-or-normal' => [
67
-                    'AND'                                   => $conditions,
68
-                    $this->_key_field_name . '*whitelisted' => [
69
-                        'IN',
70
-                        $whitelisted_meta_keys,
71
-                    ],
72
-                ],
73
-            ];
74
-        }
75
-        return [
76
-            // only allow access to non-protected metas if they're an admin
77
-            EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(),
78
-            // don't allow access to protected metas to anyone.
79
-            // If they want that, don't apply caps to the query
80
-            'apply-to-all-queries-using-caps' => new EE_Default_Where_Conditions(
81
-                $conditions
82
-            ),
83
-        ];
84
-    }
39
+	/**
40
+	 * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
41
+	 */
42
+	protected function _generate_restrictions(): array
43
+	{
44
+		$whitelisted_meta_keys =
45
+			apply_filters(
46
+				'FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys',
47
+				[]
48
+			);
49
+		$blacklisted_meta_keys =
50
+			apply_filters(
51
+				'FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys',
52
+				[]
53
+			);
54
+		$conditions            = [
55
+			$this->_key_field_name   => ['NOT_LIKE', "\\\\_%"],
56
+			// each slash is escaped because we are using double quotes, and
57
+			// stripslashes will be called on this because the models assume this is from user input
58
+			$this->_value_field_name => ['NOT_REGEXP', '^[aOs]:[\d]:.*$'],
59
+		];
60
+		if (! empty($blacklisted_meta_keys)) {
61
+			$conditions[ $this->_key_field_name . '*blacklisted' ] =
62
+				['NOT_IN', $blacklisted_meta_keys];
63
+		}
64
+		if (! empty($whitelisted_meta_keys)) {
65
+			$conditions = [
66
+				'OR*whitelisted-or-normal' => [
67
+					'AND'                                   => $conditions,
68
+					$this->_key_field_name . '*whitelisted' => [
69
+						'IN',
70
+						$whitelisted_meta_keys,
71
+					],
72
+				],
73
+			];
74
+		}
75
+		return [
76
+			// only allow access to non-protected metas if they're an admin
77
+			EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(),
78
+			// don't allow access to protected metas to anyone.
79
+			// If they want that, don't apply caps to the query
80
+			'apply-to-all-queries-using-caps' => new EE_Default_Where_Conditions(
81
+				$conditions
82
+			),
83
+		];
84
+	}
85 85
 }
Please login to merge, or discard this patch.
strategies/EE_Restriction_Generator_Taxonomy_Protected.strategy.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
     protected function _generate_restrictions(): array
46 46
     {
47 47
         // if there are no standard caps for this model, then allow full access
48
-        if (! $this->model()->cap_slug()) {
48
+        if ( ! $this->model()->cap_slug()) {
49 49
             return [];
50 50
         }
51 51
 
52 52
         return [
53 53
             'ee_manage_event_categories' => new EE_Default_Where_Conditions(
54 54
                 [
55
-                    $this->_path_to_taxonomy_model .
55
+                    $this->_path_to_taxonomy_model.
56 56
                     'taxonomy*no_ee_manage_event_categories' => [
57 57
                         '!=',
58 58
                         'espresso_event_categories',
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             ),
62 62
             'ee_manage_venue_categories' => new EE_Default_Where_Conditions(
63 63
                 [
64
-                    $this->_path_to_taxonomy_model .
64
+                    $this->_path_to_taxonomy_model.
65 65
                     'taxonomy*no_ee_manage_venue_categories' => [
66 66
                         '!=',
67 67
                         'espresso_venue_categories',
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             ),
71 71
             'ee_manage_event_types'      => new EE_Default_Where_Conditions(
72 72
                 [
73
-                    $this->_path_to_taxonomy_model .
73
+                    $this->_path_to_taxonomy_model.
74 74
                     'taxonomy*ee_manage_event_types' => [
75 75
                         '!=',
76 76
                         'espresso_event_types'
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -11,71 +11,71 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Restriction_Generator_Taxonomy_Protected extends EE_Restriction_Generator_Base
13 13
 {
14
-    /**
15
-     * Model chain/path to taxonomy model,
16
-     * including the term_taxonomy model itself
17
-     *
18
-     * @var string
19
-     */
20
-    protected $_path_to_taxonomy_model;
14
+	/**
15
+	 * Model chain/path to taxonomy model,
16
+	 * including the term_taxonomy model itself
17
+	 *
18
+	 * @var string
19
+	 */
20
+	protected $_path_to_taxonomy_model;
21 21
 
22 22
 
23
-    /**
24
-     * @param string $path_to_taxonomy_model Model chain/path to taxonomy
25
-     *                                       model, including the term_taxonomy
26
-     *                                       model itself
27
-     */
28
-    public function __construct(string $path_to_taxonomy_model)
29
-    {
30
-        if (
31
-            $path_to_taxonomy_model !== '' &&
32
-            substr($path_to_taxonomy_model, -1, 1) != '.'
33
-        ) {
34
-            $path_to_taxonomy_model .= '.';
35
-        }
36
-        $this->_path_to_taxonomy_model = $path_to_taxonomy_model;
37
-    }
23
+	/**
24
+	 * @param string $path_to_taxonomy_model Model chain/path to taxonomy
25
+	 *                                       model, including the term_taxonomy
26
+	 *                                       model itself
27
+	 */
28
+	public function __construct(string $path_to_taxonomy_model)
29
+	{
30
+		if (
31
+			$path_to_taxonomy_model !== '' &&
32
+			substr($path_to_taxonomy_model, -1, 1) != '.'
33
+		) {
34
+			$path_to_taxonomy_model .= '.';
35
+		}
36
+		$this->_path_to_taxonomy_model = $path_to_taxonomy_model;
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
42
-     * @throws EE_Error
43
-     */
44
-    protected function _generate_restrictions(): array
45
-    {
46
-        // if there are no standard caps for this model, then allow full access
47
-        if (! $this->model()->cap_slug()) {
48
-            return [];
49
-        }
40
+	/**
41
+	 * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
42
+	 * @throws EE_Error
43
+	 */
44
+	protected function _generate_restrictions(): array
45
+	{
46
+		// if there are no standard caps for this model, then allow full access
47
+		if (! $this->model()->cap_slug()) {
48
+			return [];
49
+		}
50 50
 
51
-        return [
52
-            'ee_manage_event_categories' => new EE_Default_Where_Conditions(
53
-                [
54
-                    $this->_path_to_taxonomy_model .
55
-                    'taxonomy*no_ee_manage_event_categories' => [
56
-                        '!=',
57
-                        'espresso_event_categories',
58
-                    ],
59
-                ]
60
-            ),
61
-            'ee_manage_venue_categories' => new EE_Default_Where_Conditions(
62
-                [
63
-                    $this->_path_to_taxonomy_model .
64
-                    'taxonomy*no_ee_manage_venue_categories' => [
65
-                        '!=',
66
-                        'espresso_venue_categories',
67
-                    ],
68
-                ]
69
-            ),
70
-            'ee_manage_event_types'      => new EE_Default_Where_Conditions(
71
-                [
72
-                    $this->_path_to_taxonomy_model .
73
-                    'taxonomy*ee_manage_event_types' => [
74
-                        '!=',
75
-                        'espresso_event_types'
76
-                    ]
77
-                ]
78
-            ),
79
-        ];
80
-    }
51
+		return [
52
+			'ee_manage_event_categories' => new EE_Default_Where_Conditions(
53
+				[
54
+					$this->_path_to_taxonomy_model .
55
+					'taxonomy*no_ee_manage_event_categories' => [
56
+						'!=',
57
+						'espresso_event_categories',
58
+					],
59
+				]
60
+			),
61
+			'ee_manage_venue_categories' => new EE_Default_Where_Conditions(
62
+				[
63
+					$this->_path_to_taxonomy_model .
64
+					'taxonomy*no_ee_manage_venue_categories' => [
65
+						'!=',
66
+						'espresso_venue_categories',
67
+					],
68
+				]
69
+			),
70
+			'ee_manage_event_types'      => new EE_Default_Where_Conditions(
71
+				[
72
+					$this->_path_to_taxonomy_model .
73
+					'taxonomy*ee_manage_event_types' => [
74
+						'!=',
75
+						'espresso_event_types'
76
+					]
77
+				]
78
+			),
79
+		];
80
+	}
81 81
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_Reg_Form.strategy.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     {
41 41
         // if there are no standard caps for this model, then for now
42 42
         // all we know if they need the default cap to access this
43
-        if (! $this->model()->cap_slug()) {
43
+        if ( ! $this->model()->cap_slug()) {
44 44
             return [
45 45
                 EE_Restriction_Generator_Base::get_default_restrictions_cap(
46 46
                 ) => new EE_Return_None_Where_Conditions(),
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
         // there is also no "ee_delete_system_questions" cap.
58 58
         // But folks shouldn't be deleting system questions anyway
59 59
         if ($this->action() !== EEM_Base::caps_read) {
60
-            $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
60
+            $restrictions[EE_Restriction_Generator_Base::get_cap_name(
61 61
                 $this->model(),
62
-                $this->action() . '_system'
63
-            ) ] = new EE_Default_Where_Conditions(
62
+                $this->action().'_system'
63
+            )] = new EE_Default_Where_Conditions(
64 64
                 [
65
-                    'OR*no_' .
65
+                    'OR*no_'.
66 66
                     EE_Restriction_Generator_Base::get_cap_name(
67 67
                         $this->model(),
68
-                        $this->action() . '_system'
68
+                        $this->action().'_system'
69 69
                     ) => [
70 70
                         $this->_system_field_name => ['IN', ['', 0]],
71
-                        $this->_system_field_name . '*' => ['IS_NULL'],
71
+                        $this->_system_field_name.'*' => ['IS_NULL'],
72 72
                     ],
73 73
                 ]
74 74
             );
Please login to merge, or discard this patch.
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -12,66 +12,66 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Restriction_Generator_Reg_Form extends EE_Restriction_Generator_Base
14 14
 {
15
-    /**
16
-     * @var string  the name of the field that indicates
17
-     *              whether or not this is a system thing
18
-     */
19
-    protected $_system_field_name = null;
15
+	/**
16
+	 * @var string  the name of the field that indicates
17
+	 *              whether or not this is a system thing
18
+	 */
19
+	protected $_system_field_name = null;
20 20
 
21 21
 
22
-    /**
23
-     * Accepts the name of the field that indicates
24
-     * whether or not an object is a "system" one or not
25
-     *
26
-     * @param string $system_field_name
27
-     */
28
-    public function __construct(string $system_field_name)
29
-    {
30
-        $this->_system_field_name = $system_field_name;
31
-    }
22
+	/**
23
+	 * Accepts the name of the field that indicates
24
+	 * whether or not an object is a "system" one or not
25
+	 *
26
+	 * @param string $system_field_name
27
+	 */
28
+	public function __construct(string $system_field_name)
29
+	{
30
+		$this->_system_field_name = $system_field_name;
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
36
-     * @throws EE_Error
37
-     */
38
-    protected function _generate_restrictions(): array
39
-    {
40
-        // if there are no standard caps for this model, then for now
41
-        // all we know if they need the default cap to access this
42
-        if (! $this->model()->cap_slug()) {
43
-            return [
44
-                EE_Restriction_Generator_Base::get_default_restrictions_cap(
45
-                ) => new EE_Return_None_Where_Conditions(),
46
-            ];
47
-        }
48
-        $restrictions = [
49
-            EE_Restriction_Generator_Base::get_cap_name(
50
-                $this->model(),
51
-                $this->action()
52
-            ) => new EE_Return_None_Where_Conditions(),
53
-        ];
54
-        // there is no "ee_read_system_questions" cap;
55
-        // in order to read reg form items you only need "ee_read_{model_name}".
56
-        // there is also no "ee_delete_system_questions" cap.
57
-        // But folks shouldn't be deleting system questions anyway
58
-        if ($this->action() !== EEM_Base::caps_read) {
59
-            $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
60
-                $this->model(),
61
-                $this->action() . '_system'
62
-            ) ] = new EE_Default_Where_Conditions(
63
-                [
64
-                    'OR*no_' .
65
-                    EE_Restriction_Generator_Base::get_cap_name(
66
-                        $this->model(),
67
-                        $this->action() . '_system'
68
-                    ) => [
69
-                        $this->_system_field_name => ['IN', ['', 0]],
70
-                        $this->_system_field_name . '*' => ['IS_NULL'],
71
-                    ],
72
-                ]
73
-            );
74
-        }
75
-        return $restrictions;
76
-    }
34
+	/**
35
+	 * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
36
+	 * @throws EE_Error
37
+	 */
38
+	protected function _generate_restrictions(): array
39
+	{
40
+		// if there are no standard caps for this model, then for now
41
+		// all we know if they need the default cap to access this
42
+		if (! $this->model()->cap_slug()) {
43
+			return [
44
+				EE_Restriction_Generator_Base::get_default_restrictions_cap(
45
+				) => new EE_Return_None_Where_Conditions(),
46
+			];
47
+		}
48
+		$restrictions = [
49
+			EE_Restriction_Generator_Base::get_cap_name(
50
+				$this->model(),
51
+				$this->action()
52
+			) => new EE_Return_None_Where_Conditions(),
53
+		];
54
+		// there is no "ee_read_system_questions" cap;
55
+		// in order to read reg form items you only need "ee_read_{model_name}".
56
+		// there is also no "ee_delete_system_questions" cap.
57
+		// But folks shouldn't be deleting system questions anyway
58
+		if ($this->action() !== EEM_Base::caps_read) {
59
+			$restrictions[ EE_Restriction_Generator_Base::get_cap_name(
60
+				$this->model(),
61
+				$this->action() . '_system'
62
+			) ] = new EE_Default_Where_Conditions(
63
+				[
64
+					'OR*no_' .
65
+					EE_Restriction_Generator_Base::get_cap_name(
66
+						$this->model(),
67
+						$this->action() . '_system'
68
+					) => [
69
+						$this->_system_field_name => ['IN', ['', 0]],
70
+						$this->_system_field_name . '*' => ['IS_NULL'],
71
+					],
72
+				]
73
+			);
74
+		}
75
+		return $restrictions;
76
+	}
77 77
 }
Please login to merge, or discard this patch.
payment_methods/Bank/templates/bank_intro.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 esc_html_e(
4
-    'Bank is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a bank transfer.',
5
-    'event_espresso'
4
+	'Bank is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a bank transfer.',
5
+	'event_espresso'
6 6
 );
Please login to merge, or discard this patch.
payment_methods/Check/templates/check_intro.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 esc_html_e(
4
-    'Check is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a check.',
5
-    'event_espresso'
4
+	'Check is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a check.',
5
+	'event_espresso'
6 6
 );
Please login to merge, or discard this patch.
payment_methods/Invoice/EE_PMT_Invoice.pm.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             '<br />'
41 41
         );
42 42
         parent::__construct($pm_instance);
43
-        $this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
43
+        $this->_default_button_url = $this->file_url().'lib/invoice-logo.png';
44 44
     }
45 45
 
46 46
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     {
66 66
         $pdf_payee_input_name = 'pdf_payee_name';
67 67
         $confirmation_text_input_name = 'page_confirmation_text';
68
-        $form =  new EE_Payment_Method_Form(array(
68
+        $form = new EE_Payment_Method_Form(array(
69 69
 //              'payment_method_type' => $this,
70 70
                 'extra_meta_inputs' => array(
71 71
                     $pdf_payee_input_name => new EE_Text_Input(array(
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
                         )),
80 80
                     'pdf_payee_address' => new EE_Text_Area_Input(array(
81 81
                         'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
82
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
82
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
83 83
                     )),
84 84
                     'pdf_instructions' => new EE_Text_Area_Input(array(
85 85
                         'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
86 86
                         'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
87
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
87
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
88 88
                     )),
89 89
                     'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
90 90
                         'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
                     $confirmation_text_input_name => new EE_Text_Area_Input(array(
95 95
                         'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
96 96
                         'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
97
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
97
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
98 98
                     )),
99 99
                     'page_extra_info' => new EE_Text_Area_Input(array(
100 100
                         'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
101
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
101
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
102 102
                     )),
103 103
                 ),
104 104
                 'include' => array(
105
-                    'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
106
-                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
105
+                    'PMD_ID', 'PMD_name', 'PMD_desc', 'PMD_admin_name', 'PMD_admin_desc', 'PMD_type', 'PMD_slug', 'PMD_open_by_default', 'PMD_button_url', 'PMD_scope', 'Currency', 'PMD_order',
106
+                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions', 'pdf_logo_image',
107 107
                     $confirmation_text_input_name, 'page_extra_info'),
108 108
             ));
109 109
         $form->add_subsections(
110
-            array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
110
+            array('header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
111 111
             $pdf_payee_input_name
112 112
         );
113 113
         $form->add_subsections(
114
-            array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
114
+            array('header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
115 115
             $confirmation_text_input_name
116 116
         );
117 117
         return $form;
Please login to merge, or discard this patch.
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -24,143 +24,143 @@
 block discarded – undo
24 24
  */
25 25
 class EE_PMT_Invoice extends EE_PMT_Base
26 26
 {
27
-    /**
28
-     * @param EE_Payment_Method|null $pm_instance
29
-     * @throws ReflectionException
30
-     * @throws EE_Error
31
-     */
32
-    public function __construct($pm_instance = null)
33
-    {
34
-        $this->_pretty_name = esc_html__("Invoice", 'event_espresso');
35
-        $this->_default_description = sprintf(
36
-            esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
37
-            '<br />'
38
-        );
39
-        parent::__construct($pm_instance);
40
-        $this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
41
-    }
27
+	/**
28
+	 * @param EE_Payment_Method|null $pm_instance
29
+	 * @throws ReflectionException
30
+	 * @throws EE_Error
31
+	 */
32
+	public function __construct($pm_instance = null)
33
+	{
34
+		$this->_pretty_name = esc_html__("Invoice", 'event_espresso');
35
+		$this->_default_description = sprintf(
36
+			esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
37
+			'<br />'
38
+		);
39
+		parent::__construct($pm_instance);
40
+		$this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
41
+	}
42 42
 
43 43
 
44 44
 
45
-    /**
46
-     * Creates the billing form for this payment method type
47
-     * @param EE_Transaction|null $transaction
48
-     * @return EE_Billing_Info_Form|null
49
-     * @throws EE_Error
50
-     * @throws ReflectionException
51
-     */
52
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
53
-    {    return null;
54
-    }
45
+	/**
46
+	 * Creates the billing form for this payment method type
47
+	 * @param EE_Transaction|null $transaction
48
+	 * @return EE_Billing_Info_Form|null
49
+	 * @throws EE_Error
50
+	 * @throws ReflectionException
51
+	 */
52
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
53
+	{    return null;
54
+	}
55 55
 
56 56
 
57 57
 
58
-    /**
59
-     * Gets the form for all the settings related to this payment method type
60
-     *
61
-     * @return EE_Payment_Method_Form
62
-     * @throws EE_Error
63
-     * @throws ReflectionException
64
-     */
65
-    public function generate_new_settings_form()
66
-    {
67
-        $pdf_payee_input_name = 'pdf_payee_name';
68
-        $confirmation_text_input_name = 'page_confirmation_text';
69
-        $form =  new EE_Payment_Method_Form(array(
58
+	/**
59
+	 * Gets the form for all the settings related to this payment method type
60
+	 *
61
+	 * @return EE_Payment_Method_Form
62
+	 * @throws EE_Error
63
+	 * @throws ReflectionException
64
+	 */
65
+	public function generate_new_settings_form()
66
+	{
67
+		$pdf_payee_input_name = 'pdf_payee_name';
68
+		$confirmation_text_input_name = 'page_confirmation_text';
69
+		$form =  new EE_Payment_Method_Form(array(
70 70
 //              'payment_method_type' => $this,
71
-                'extra_meta_inputs' => array(
72
-                    $pdf_payee_input_name => new EE_Text_Input(array(
73
-                        'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
74
-                    )),
75
-                    'pdf_payee_email' => new EE_Email_Input(array(
76
-                        'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
77
-                    )),
78
-                    'pdf_payee_tax_number' => new EE_Text_Input(array(
79
-                        'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
80
-                        )),
81
-                    'pdf_payee_address' => new EE_Text_Area_Input(array(
82
-                        'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
83
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
84
-                    )),
85
-                    'pdf_instructions' => new EE_Text_Area_Input(array(
86
-                        'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
87
-                        'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
88
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
89
-                    )),
90
-                    'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
91
-                        'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
92
-                        'default' =>  EE_Config::instance()->organization->logo_url,
93
-                        'html_help_text' =>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
94
-                    )),
95
-                    $confirmation_text_input_name => new EE_Text_Area_Input(array(
96
-                        'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
97
-                        'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
98
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
99
-                    )),
100
-                    'page_extra_info' => new EE_Text_Area_Input(array(
101
-                        'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
102
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
103
-                    )),
104
-                ),
105
-                'include' => array(
106
-                    'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
107
-                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
108
-                    $confirmation_text_input_name, 'page_extra_info'),
109
-            ));
110
-        $form->add_subsections(
111
-            array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
112
-            $pdf_payee_input_name
113
-        );
114
-        $form->add_subsections(
115
-            array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
116
-            $confirmation_text_input_name
117
-        );
118
-        return $form;
119
-    }
71
+				'extra_meta_inputs' => array(
72
+					$pdf_payee_input_name => new EE_Text_Input(array(
73
+						'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
74
+					)),
75
+					'pdf_payee_email' => new EE_Email_Input(array(
76
+						'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
77
+					)),
78
+					'pdf_payee_tax_number' => new EE_Text_Input(array(
79
+						'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
80
+						)),
81
+					'pdf_payee_address' => new EE_Text_Area_Input(array(
82
+						'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
83
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
84
+					)),
85
+					'pdf_instructions' => new EE_Text_Area_Input(array(
86
+						'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
87
+						'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
88
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
89
+					)),
90
+					'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
91
+						'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
92
+						'default' =>  EE_Config::instance()->organization->logo_url,
93
+						'html_help_text' =>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
94
+					)),
95
+					$confirmation_text_input_name => new EE_Text_Area_Input(array(
96
+						'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
97
+						'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
98
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
99
+					)),
100
+					'page_extra_info' => new EE_Text_Area_Input(array(
101
+						'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
102
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
103
+					)),
104
+				),
105
+				'include' => array(
106
+					'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
107
+					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
108
+					$confirmation_text_input_name, 'page_extra_info'),
109
+			));
110
+		$form->add_subsections(
111
+			array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
112
+			$pdf_payee_input_name
113
+		);
114
+		$form->add_subsections(
115
+			array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
116
+			$confirmation_text_input_name
117
+		);
118
+		return $form;
119
+	}
120 120
 
121 121
 
122 122
 
123
-    /**
124
-     * Adds the help tab
125
-     *
126
-     * @return array
127
-     * @see EE_PMT_Base::help_tabs_config()
128
-     */
129
-    public function help_tabs_config()
130
-    {
131
-        return array(
132
-            $this->get_help_tab_name() => array(
133
-                'title' => esc_html__('Invoice Settings', 'event_espresso'),
134
-                'filename' => 'payment_methods_overview_invoice'
135
-            ),
136
-        );
137
-    }
123
+	/**
124
+	 * Adds the help tab
125
+	 *
126
+	 * @return array
127
+	 * @see EE_PMT_Base::help_tabs_config()
128
+	 */
129
+	public function help_tabs_config()
130
+	{
131
+		return array(
132
+			$this->get_help_tab_name() => array(
133
+				'title' => esc_html__('Invoice Settings', 'event_espresso'),
134
+				'filename' => 'payment_methods_overview_invoice'
135
+			),
136
+		);
137
+	}
138 138
 
139 139
 
140
-    /**
141
-     * For adding any html output above the payment overview.
142
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
143
-     * Other gateways may want to override this, such as offline gateways.
144
-     *
145
-     * @param EE_Payment $payment
146
-     * @return string
147
-     * @throws EE_Error
148
-     * @throws ReflectionException
149
-     */
150
-    public function payment_overview_content(EE_Payment $payment)
151
-    {
152
-        return EEH_Template::locate_template(
153
-            'payment_methods/Invoice/templates/invoice_payment_details_content.template.php',
154
-            array_merge(
155
-                array(
156
-                    'payment_method'            => $this->_pm_instance,
157
-                    'payment'                       => $payment,
158
-                    'page_confirmation_text'                    => '',
159
-                    'page_extra_info'   => '',
160
-                    'invoice_url'                   => $payment->transaction()->primary_registration()->invoice_url('html')
161
-                ),
162
-                $this->_pm_instance->all_extra_meta_array()
163
-            )
164
-        );
165
-    }
140
+	/**
141
+	 * For adding any html output above the payment overview.
142
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
143
+	 * Other gateways may want to override this, such as offline gateways.
144
+	 *
145
+	 * @param EE_Payment $payment
146
+	 * @return string
147
+	 * @throws EE_Error
148
+	 * @throws ReflectionException
149
+	 */
150
+	public function payment_overview_content(EE_Payment $payment)
151
+	{
152
+		return EEH_Template::locate_template(
153
+			'payment_methods/Invoice/templates/invoice_payment_details_content.template.php',
154
+			array_merge(
155
+				array(
156
+					'payment_method'            => $this->_pm_instance,
157
+					'payment'                       => $payment,
158
+					'page_confirmation_text'                    => '',
159
+					'page_extra_info'   => '',
160
+					'invoice_url'                   => $payment->transaction()->primary_registration()->invoice_url('html')
161
+				),
162
+				$this->_pm_instance->all_extra_meta_array()
163
+			)
164
+		);
165
+	}
166 166
 }
Please login to merge, or discard this patch.
payment_methods/Invoice/templates/invoice_intro.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 esc_html_e(
4
-    'Invoice is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay their invoice.',
5
-    'event_espresso'
4
+	'Invoice is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay their invoice.',
5
+	'event_espresso'
6 6
 );
Please login to merge, or discard this patch.