Completed
Branch RELEASE (416965)
by
unknown
12:55 queued 13s
created
core/db_classes/EE_Payment_Method.class.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -445,11 +445,11 @@  discard block
 block discarded – undo
445 445
      */
446 446
     public function type_obj()
447 447
     {
448
-        if (! $this->_type_obj) {
448
+        if ( ! $this->_type_obj) {
449 449
             EE_Registry::instance()->load_lib('Payment_Method_Manager');
450 450
             if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($this->type())) {
451 451
                 $class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type($this->type());
452
-                if (! class_exists($class_name)) {
452
+                if ( ! class_exists($class_name)) {
453 453
                     throw new EE_Error(
454 454
                         sprintf(
455 455
                             esc_html__(
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
                             ),
459 459
                             $class_name,
460 460
                             '<br />',
461
-                            '<a href="' . admin_url('plugins.php') . '">',
461
+                            '<a href="'.admin_url('plugins.php').'">',
462 462
                             '</a>'
463 463
                         )
464 464
                     );
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
         foreach ($fields as $key => $value) {
500 500
             if (strpos($key, 'PMD_') === 0) {
501 501
                 $key_sans_model_prefix = str_replace('PMD_', '', $key);
502
-                $combined_settings_array [ $key_sans_model_prefix ] = $value;
502
+                $combined_settings_array [$key_sans_model_prefix] = $value;
503 503
             }
504 504
         }
505 505
         $combined_settings_array = array_merge($extra_meta, $combined_settings_array);
@@ -522,14 +522,14 @@  discard block
 block discarded – undo
522 522
 		 <div id="'
523 523
                . $this->slug()
524 524
                . '-payment-option-dv" class="'
525
-               . $payment_occurs . '-payment-gateway reg-page-payment-option-dv' . $css_class . '">
525
+               . $payment_occurs.'-payment-gateway reg-page-payment-option-dv'.$css_class.'">
526 526
 			<a id="payment-gateway-button-' . $this->slug()
527 527
                . '" class="reg-page-payment-option-lnk" rel="'
528
-               . $this->slug() . '" href="' . $url . '" >
529
-				<img src="' . $this->button_url() . '" alt="' . sprintf(
528
+               . $this->slug().'" href="'.$url.'" >
529
+				<img src="' . $this->button_url().'" alt="'.sprintf(
530 530
                    esc_attr__('Pay using %s', 'event_espresso'),
531 531
                    $this->get_pretty('PMD_name', 'form_input')
532
-               ) . '" />
532
+               ).'" />
533 533
 			</a>
534 534
 		</div>
535 535
 ';
Please login to merge, or discard this patch.
Indentation   +572 added lines, -572 removed lines patch added patch discarded remove patch
@@ -13,582 +13,582 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Payment_Method extends EE_Base_Class
15 15
 {
16
-    /**
17
-     * Payment Method type object, which has all the info about this type of payment method,
18
-     * including functions for processing payments, to get settings forms, etc.
19
-     *
20
-     * @var EE_PMT_Base
21
-     */
22
-    protected $_type_obj;
23
-
24
-
25
-    /**
26
-     * @param array $props_n_values
27
-     * @return EE_Payment_Method
28
-     * @throws EE_Error
29
-     */
30
-    public static function new_instance($props_n_values = array())
31
-    {
32
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
33
-        return $has_object ? $has_object : new self($props_n_values, false);
34
-    }
35
-
36
-
37
-    /**
38
-     * @param array $props_n_values
39
-     * @return EE_Payment_Method
40
-     * @throws EE_Error
41
-     */
42
-    public static function new_instance_from_db($props_n_values = array())
43
-    {
44
-        return new self($props_n_values, true);
45
-    }
46
-
47
-
48
-
49
-    /**
50
-     * Checks if there is a payment method class of the given 'PMD_type', and if so returns the classname.
51
-     * Otherwise returns a normal EE_Payment_Method
52
-     *
53
-     * @param array $props_n_values where 'PMD_type' is a gateway name like 'Paypal_Standard','Invoice',etc (basically
54
-     *                              the classname minus 'EEPM_')
55
-     * @return string
56
-     */
57
-    // private static function _payment_method_type($props_n_values)
58
-    // {
59
-    //     EE_Registry::instance()->load_lib('Payment_Method_Manager');
60
-    //     $type_string = isset($props_n_values['PMD_type']) ? $props_n_values['PMD_type'] : null;
61
-    //     if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($type_string)) {
62
-    //         return 'EEPM_' . $type_string;
63
-    //     } else {
64
-    //         return __CLASS__;
65
-    //     }
66
-    // }
67
-
68
-
69
-    /**
70
-     * Gets whether this payment method can be used anywhere at all (ie frontend cart, admin, etc)
71
-     *
72
-     * @return boolean
73
-     */
74
-    public function active()
75
-    {
76
-        return array_intersect(array_keys(EEM_Payment_Method::instance()->scopes()), $this->scope());
77
-    }
78
-
79
-
80
-    /**
81
-     * Sets this PM as active by making it usable within the CART scope. Offline gateways
82
-     * are also usable from the admin-scope as well. DOES NOT SAVE it
83
-     *
84
-     * @throws EE_Error
85
-     */
86
-    public function set_active()
87
-    {
88
-        $default_scopes = array(EEM_Payment_Method::scope_cart);
89
-        if (
90
-            $this->type_obj() &&
91
-            $this->type_obj()->payment_occurs() === EE_PMT_Base::offline
92
-        ) {
93
-            $default_scopes[] = EEM_Payment_Method::scope_admin;
94
-        }
95
-        $this->set_scope($default_scopes);
96
-    }
97
-
98
-
99
-    /**
100
-     * Makes this payment method apply to NO scopes at all. DOES NOT SAVE it.
101
-     */
102
-    public function deactivate()
103
-    {
104
-        $this->set_scope(array());
105
-    }
106
-
107
-
108
-    /**
109
-     * Gets button_url
110
-     *
111
-     * @return string
112
-     */
113
-    public function button_url()
114
-    {
115
-        return $this->get('PMD_button_url');
116
-    }
117
-
118
-
119
-    /**
120
-     * Sets button_url
121
-     *
122
-     * @param string $button_url
123
-     */
124
-    public function set_button_url($button_url)
125
-    {
126
-        $this->set('PMD_button_url', $button_url);
127
-    }
128
-
129
-
130
-    /**
131
-     * Gets debug_mode
132
-     *
133
-     * @return boolean
134
-     */
135
-    public function debug_mode()
136
-    {
137
-        return (bool) $this->get('PMD_debug_mode');
138
-    }
139
-
140
-
141
-    /**
142
-     * Sets debug_mode
143
-     *
144
-     * @param boolean $debug_mode
145
-     */
146
-    public function set_debug_mode($debug_mode)
147
-    {
148
-        $this->set('PMD_debug_mode', $debug_mode);
149
-    }
150
-
151
-
152
-    /**
153
-     * Gets description
154
-     *
155
-     * @return string
156
-     */
157
-    public function description()
158
-    {
159
-        return $this->get('PMD_desc');
160
-    }
161
-
162
-
163
-    /**
164
-     * Sets description
165
-     *
166
-     * @param string $description
167
-     */
168
-    public function set_description($description)
169
-    {
170
-        $this->set('PMD_desc', $description);
171
-    }
172
-
173
-
174
-    /**
175
-     * Gets name
176
-     *
177
-     * @return string
178
-     */
179
-    public function name()
180
-    {
181
-        return $this->get('PMD_name');
182
-    }
183
-
184
-
185
-    /**
186
-     * Sets name
187
-     *
188
-     * @param string $name
189
-     */
190
-    public function set_name($name)
191
-    {
192
-        $this->set('PMD_name', $name);
193
-    }
194
-
195
-
196
-    /**
197
-     * Gets open_by_default
198
-     *
199
-     * @return boolean
200
-     */
201
-    public function open_by_default()
202
-    {
203
-        return $this->get('PMD_open_by_default');
204
-    }
205
-
206
-
207
-    /**
208
-     * Sets open_by_default
209
-     *
210
-     * @param boolean $open_by_default
211
-     */
212
-    public function set_open_by_default($open_by_default)
213
-    {
214
-        $this->set('PMD_open_by_default', $open_by_default);
215
-    }
216
-
217
-
218
-    /**
219
-     * Gets order
220
-     *
221
-     * @return int
222
-     */
223
-    public function order()
224
-    {
225
-        return $this->get('PMD_order');
226
-    }
227
-
228
-
229
-    /**
230
-     * Sets order
231
-     *
232
-     * @param int $order
233
-     */
234
-    public function set_order($order)
235
-    {
236
-        $this->set('PMD_order', $order);
237
-    }
238
-
239
-
240
-    /**
241
-     * Gets slug
242
-     *
243
-     * @return string
244
-     */
245
-    public function slug()
246
-    {
247
-        return $this->get('PMD_slug');
248
-    }
249
-
250
-
251
-    /**
252
-     * Sets slug
253
-     *
254
-     * @param string $slug
255
-     */
256
-    public function set_slug($slug)
257
-    {
258
-        $this->set('PMD_slug', $slug);
259
-    }
260
-
261
-
262
-    /**
263
-     * Gets type
264
-     *
265
-     * @return string
266
-     */
267
-    public function type()
268
-    {
269
-        return $this->get('PMD_type');
270
-    }
271
-
272
-
273
-    /**
274
-     * Sets type
275
-     *
276
-     * @param string $type
277
-     */
278
-    public function set_type($type)
279
-    {
280
-        $this->set('PMD_type', $type);
281
-    }
282
-
283
-
284
-    /**
285
-     * Gets wp_user
286
-     *
287
-     * @return int
288
-     */
289
-    public function wp_user()
290
-    {
291
-        return $this->get('PMD_wp_user');
292
-    }
293
-
294
-
295
-    /**
296
-     * Sets wp_user
297
-     *
298
-     * @param int $wp_user_id
299
-     */
300
-    public function set_wp_user($wp_user_id)
301
-    {
302
-        $this->set('PMD_wp_user', $wp_user_id);
303
-    }
304
-
305
-    /**
306
-     * Overrides parent so when PMD_type is changed we refresh the _type_obj
307
-     *
308
-     * @param string $field_name
309
-     * @param mixed $field_value
310
-     * @param boolean $use_default
311
-     */
312
-    public function set($field_name, $field_value, $use_default = false)
313
-    {
314
-        if ($field_name === 'PMD_type') {
315
-            // the type has probably changed, so forget about its old type object
316
-            $this->_type_obj = null;
317
-        }
318
-        parent::set($field_name, $field_value, $use_default);
319
-    }
320
-
321
-
322
-    /**
323
-     * Gets admin_name
324
-     *
325
-     * @return string
326
-     */
327
-    public function admin_name()
328
-    {
329
-        return $this->get('PMD_admin_name');
330
-    }
331
-
332
-
333
-    /**
334
-     * Sets admin_name
335
-     *
336
-     * @param string $admin_name
337
-     */
338
-    public function set_admin_name($admin_name)
339
-    {
340
-        $this->set('PMD_admin_name', $admin_name);
341
-    }
342
-
343
-
344
-    /**
345
-     * Gets admin_desc
346
-     *
347
-     * @return string
348
-     */
349
-    public function admin_desc()
350
-    {
351
-        return $this->get('PMD_admin_desc');
352
-    }
353
-
354
-
355
-    /**
356
-     * Sets admin_desc
357
-     *
358
-     * @param string $admin_desc
359
-     */
360
-    public function set_admin_desc($admin_desc)
361
-    {
362
-        $this->set('PMD_admin_desc', $admin_desc);
363
-    }
364
-
365
-
366
-    /**
367
-     * Gets scope
368
-     *
369
-     * @return array
370
-     */
371
-    public function scope()
372
-    {
373
-        return $this->get('PMD_scope');
374
-    }
375
-
376
-
377
-    /**
378
-     * Sets scope
379
-     *
380
-     * @param array $scope
381
-     */
382
-    public function set_scope($scope)
383
-    {
384
-        $this->set('PMD_scope', $scope);
385
-    }
386
-
387
-
388
-    /**
389
-     * Gets the payment method type for this payment method instance
390
-     *
391
-     * @return EE_PMT_Base
392
-     * @throws EE_Error
393
-     */
394
-    public function type_obj()
395
-    {
396
-        if (! $this->_type_obj) {
397
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
398
-            if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($this->type())) {
399
-                $class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type($this->type());
400
-                if (! class_exists($class_name)) {
401
-                    throw new EE_Error(
402
-                        sprintf(
403
-                            esc_html__(
404
-                                'An attempt to use the "%1$s" payment method failed, so it was deactivated.%2$sWas the "%1$s" Plugin recently deactivated? It can be reactivated on the %3$sPlugins Admin Page%4$s',
405
-                                'event_espresso'
406
-                            ),
407
-                            $class_name,
408
-                            '<br />',
409
-                            '<a href="' . admin_url('plugins.php') . '">',
410
-                            '</a>'
411
-                        )
412
-                    );
413
-                }
414
-                $r = new ReflectionClass($class_name);
415
-                $this->_type_obj = $r->newInstanceArgs(array($this));
416
-            } else {
417
-                throw new EE_Error(
418
-                    sprintf(
419
-                        esc_html__(
420
-                            'A payment method of type "%1$s" does not exist. Only ones existing are: %2$s',
421
-                            'event_espresso'
422
-                        ),
423
-                        $this->type(),
424
-                        implode(',', EE_Payment_Method_Manager::instance()->payment_method_type_names())
425
-                    )
426
-                );
427
-            }
428
-        }
429
-        return $this->_type_obj;
430
-    }
431
-
432
-
433
-    /**
434
-     * Returns a simple array of key-value pairs combining the payment method's fields (without the 'PMD_' prefix)
435
-     * and the extra meta. Mostly used for passing off ot gateways.     *
436
-     *
437
-     * @return array
438
-     */
439
-    public function settings_array()
440
-    {
441
-        $fields = $this->model_field_array();
442
-        $extra_meta = $this->all_extra_meta_array();
443
-        // remove the model's prefix from the fields
444
-        $combined_settings_array = array();
445
-        foreach ($fields as $key => $value) {
446
-            if (strpos($key, 'PMD_') === 0) {
447
-                $key_sans_model_prefix = str_replace('PMD_', '', $key);
448
-                $combined_settings_array [ $key_sans_model_prefix ] = $value;
449
-            }
450
-        }
451
-        $combined_settings_array = array_merge($extra_meta, $combined_settings_array);
452
-        return $combined_settings_array;
453
-    }
454
-
455
-
456
-    /**
457
-     * Gets the HTML for displaying the payment method on a page.
458
-     *
459
-     * @param string $url
460
-     * @param string $css_class
461
-     * @return string of HTML for displaying the button
462
-     * @throws EE_Error
463
-     */
464
-    public function button_html($url = '', $css_class = '')
465
-    {
466
-        $payment_occurs = $this->type_obj()->payment_occurs();
467
-        return '
16
+	/**
17
+	 * Payment Method type object, which has all the info about this type of payment method,
18
+	 * including functions for processing payments, to get settings forms, etc.
19
+	 *
20
+	 * @var EE_PMT_Base
21
+	 */
22
+	protected $_type_obj;
23
+
24
+
25
+	/**
26
+	 * @param array $props_n_values
27
+	 * @return EE_Payment_Method
28
+	 * @throws EE_Error
29
+	 */
30
+	public static function new_instance($props_n_values = array())
31
+	{
32
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
33
+		return $has_object ? $has_object : new self($props_n_values, false);
34
+	}
35
+
36
+
37
+	/**
38
+	 * @param array $props_n_values
39
+	 * @return EE_Payment_Method
40
+	 * @throws EE_Error
41
+	 */
42
+	public static function new_instance_from_db($props_n_values = array())
43
+	{
44
+		return new self($props_n_values, true);
45
+	}
46
+
47
+
48
+
49
+	/**
50
+	 * Checks if there is a payment method class of the given 'PMD_type', and if so returns the classname.
51
+	 * Otherwise returns a normal EE_Payment_Method
52
+	 *
53
+	 * @param array $props_n_values where 'PMD_type' is a gateway name like 'Paypal_Standard','Invoice',etc (basically
54
+	 *                              the classname minus 'EEPM_')
55
+	 * @return string
56
+	 */
57
+	// private static function _payment_method_type($props_n_values)
58
+	// {
59
+	//     EE_Registry::instance()->load_lib('Payment_Method_Manager');
60
+	//     $type_string = isset($props_n_values['PMD_type']) ? $props_n_values['PMD_type'] : null;
61
+	//     if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($type_string)) {
62
+	//         return 'EEPM_' . $type_string;
63
+	//     } else {
64
+	//         return __CLASS__;
65
+	//     }
66
+	// }
67
+
68
+
69
+	/**
70
+	 * Gets whether this payment method can be used anywhere at all (ie frontend cart, admin, etc)
71
+	 *
72
+	 * @return boolean
73
+	 */
74
+	public function active()
75
+	{
76
+		return array_intersect(array_keys(EEM_Payment_Method::instance()->scopes()), $this->scope());
77
+	}
78
+
79
+
80
+	/**
81
+	 * Sets this PM as active by making it usable within the CART scope. Offline gateways
82
+	 * are also usable from the admin-scope as well. DOES NOT SAVE it
83
+	 *
84
+	 * @throws EE_Error
85
+	 */
86
+	public function set_active()
87
+	{
88
+		$default_scopes = array(EEM_Payment_Method::scope_cart);
89
+		if (
90
+			$this->type_obj() &&
91
+			$this->type_obj()->payment_occurs() === EE_PMT_Base::offline
92
+		) {
93
+			$default_scopes[] = EEM_Payment_Method::scope_admin;
94
+		}
95
+		$this->set_scope($default_scopes);
96
+	}
97
+
98
+
99
+	/**
100
+	 * Makes this payment method apply to NO scopes at all. DOES NOT SAVE it.
101
+	 */
102
+	public function deactivate()
103
+	{
104
+		$this->set_scope(array());
105
+	}
106
+
107
+
108
+	/**
109
+	 * Gets button_url
110
+	 *
111
+	 * @return string
112
+	 */
113
+	public function button_url()
114
+	{
115
+		return $this->get('PMD_button_url');
116
+	}
117
+
118
+
119
+	/**
120
+	 * Sets button_url
121
+	 *
122
+	 * @param string $button_url
123
+	 */
124
+	public function set_button_url($button_url)
125
+	{
126
+		$this->set('PMD_button_url', $button_url);
127
+	}
128
+
129
+
130
+	/**
131
+	 * Gets debug_mode
132
+	 *
133
+	 * @return boolean
134
+	 */
135
+	public function debug_mode()
136
+	{
137
+		return (bool) $this->get('PMD_debug_mode');
138
+	}
139
+
140
+
141
+	/**
142
+	 * Sets debug_mode
143
+	 *
144
+	 * @param boolean $debug_mode
145
+	 */
146
+	public function set_debug_mode($debug_mode)
147
+	{
148
+		$this->set('PMD_debug_mode', $debug_mode);
149
+	}
150
+
151
+
152
+	/**
153
+	 * Gets description
154
+	 *
155
+	 * @return string
156
+	 */
157
+	public function description()
158
+	{
159
+		return $this->get('PMD_desc');
160
+	}
161
+
162
+
163
+	/**
164
+	 * Sets description
165
+	 *
166
+	 * @param string $description
167
+	 */
168
+	public function set_description($description)
169
+	{
170
+		$this->set('PMD_desc', $description);
171
+	}
172
+
173
+
174
+	/**
175
+	 * Gets name
176
+	 *
177
+	 * @return string
178
+	 */
179
+	public function name()
180
+	{
181
+		return $this->get('PMD_name');
182
+	}
183
+
184
+
185
+	/**
186
+	 * Sets name
187
+	 *
188
+	 * @param string $name
189
+	 */
190
+	public function set_name($name)
191
+	{
192
+		$this->set('PMD_name', $name);
193
+	}
194
+
195
+
196
+	/**
197
+	 * Gets open_by_default
198
+	 *
199
+	 * @return boolean
200
+	 */
201
+	public function open_by_default()
202
+	{
203
+		return $this->get('PMD_open_by_default');
204
+	}
205
+
206
+
207
+	/**
208
+	 * Sets open_by_default
209
+	 *
210
+	 * @param boolean $open_by_default
211
+	 */
212
+	public function set_open_by_default($open_by_default)
213
+	{
214
+		$this->set('PMD_open_by_default', $open_by_default);
215
+	}
216
+
217
+
218
+	/**
219
+	 * Gets order
220
+	 *
221
+	 * @return int
222
+	 */
223
+	public function order()
224
+	{
225
+		return $this->get('PMD_order');
226
+	}
227
+
228
+
229
+	/**
230
+	 * Sets order
231
+	 *
232
+	 * @param int $order
233
+	 */
234
+	public function set_order($order)
235
+	{
236
+		$this->set('PMD_order', $order);
237
+	}
238
+
239
+
240
+	/**
241
+	 * Gets slug
242
+	 *
243
+	 * @return string
244
+	 */
245
+	public function slug()
246
+	{
247
+		return $this->get('PMD_slug');
248
+	}
249
+
250
+
251
+	/**
252
+	 * Sets slug
253
+	 *
254
+	 * @param string $slug
255
+	 */
256
+	public function set_slug($slug)
257
+	{
258
+		$this->set('PMD_slug', $slug);
259
+	}
260
+
261
+
262
+	/**
263
+	 * Gets type
264
+	 *
265
+	 * @return string
266
+	 */
267
+	public function type()
268
+	{
269
+		return $this->get('PMD_type');
270
+	}
271
+
272
+
273
+	/**
274
+	 * Sets type
275
+	 *
276
+	 * @param string $type
277
+	 */
278
+	public function set_type($type)
279
+	{
280
+		$this->set('PMD_type', $type);
281
+	}
282
+
283
+
284
+	/**
285
+	 * Gets wp_user
286
+	 *
287
+	 * @return int
288
+	 */
289
+	public function wp_user()
290
+	{
291
+		return $this->get('PMD_wp_user');
292
+	}
293
+
294
+
295
+	/**
296
+	 * Sets wp_user
297
+	 *
298
+	 * @param int $wp_user_id
299
+	 */
300
+	public function set_wp_user($wp_user_id)
301
+	{
302
+		$this->set('PMD_wp_user', $wp_user_id);
303
+	}
304
+
305
+	/**
306
+	 * Overrides parent so when PMD_type is changed we refresh the _type_obj
307
+	 *
308
+	 * @param string $field_name
309
+	 * @param mixed $field_value
310
+	 * @param boolean $use_default
311
+	 */
312
+	public function set($field_name, $field_value, $use_default = false)
313
+	{
314
+		if ($field_name === 'PMD_type') {
315
+			// the type has probably changed, so forget about its old type object
316
+			$this->_type_obj = null;
317
+		}
318
+		parent::set($field_name, $field_value, $use_default);
319
+	}
320
+
321
+
322
+	/**
323
+	 * Gets admin_name
324
+	 *
325
+	 * @return string
326
+	 */
327
+	public function admin_name()
328
+	{
329
+		return $this->get('PMD_admin_name');
330
+	}
331
+
332
+
333
+	/**
334
+	 * Sets admin_name
335
+	 *
336
+	 * @param string $admin_name
337
+	 */
338
+	public function set_admin_name($admin_name)
339
+	{
340
+		$this->set('PMD_admin_name', $admin_name);
341
+	}
342
+
343
+
344
+	/**
345
+	 * Gets admin_desc
346
+	 *
347
+	 * @return string
348
+	 */
349
+	public function admin_desc()
350
+	{
351
+		return $this->get('PMD_admin_desc');
352
+	}
353
+
354
+
355
+	/**
356
+	 * Sets admin_desc
357
+	 *
358
+	 * @param string $admin_desc
359
+	 */
360
+	public function set_admin_desc($admin_desc)
361
+	{
362
+		$this->set('PMD_admin_desc', $admin_desc);
363
+	}
364
+
365
+
366
+	/**
367
+	 * Gets scope
368
+	 *
369
+	 * @return array
370
+	 */
371
+	public function scope()
372
+	{
373
+		return $this->get('PMD_scope');
374
+	}
375
+
376
+
377
+	/**
378
+	 * Sets scope
379
+	 *
380
+	 * @param array $scope
381
+	 */
382
+	public function set_scope($scope)
383
+	{
384
+		$this->set('PMD_scope', $scope);
385
+	}
386
+
387
+
388
+	/**
389
+	 * Gets the payment method type for this payment method instance
390
+	 *
391
+	 * @return EE_PMT_Base
392
+	 * @throws EE_Error
393
+	 */
394
+	public function type_obj()
395
+	{
396
+		if (! $this->_type_obj) {
397
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
398
+			if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($this->type())) {
399
+				$class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type($this->type());
400
+				if (! class_exists($class_name)) {
401
+					throw new EE_Error(
402
+						sprintf(
403
+							esc_html__(
404
+								'An attempt to use the "%1$s" payment method failed, so it was deactivated.%2$sWas the "%1$s" Plugin recently deactivated? It can be reactivated on the %3$sPlugins Admin Page%4$s',
405
+								'event_espresso'
406
+							),
407
+							$class_name,
408
+							'<br />',
409
+							'<a href="' . admin_url('plugins.php') . '">',
410
+							'</a>'
411
+						)
412
+					);
413
+				}
414
+				$r = new ReflectionClass($class_name);
415
+				$this->_type_obj = $r->newInstanceArgs(array($this));
416
+			} else {
417
+				throw new EE_Error(
418
+					sprintf(
419
+						esc_html__(
420
+							'A payment method of type "%1$s" does not exist. Only ones existing are: %2$s',
421
+							'event_espresso'
422
+						),
423
+						$this->type(),
424
+						implode(',', EE_Payment_Method_Manager::instance()->payment_method_type_names())
425
+					)
426
+				);
427
+			}
428
+		}
429
+		return $this->_type_obj;
430
+	}
431
+
432
+
433
+	/**
434
+	 * Returns a simple array of key-value pairs combining the payment method's fields (without the 'PMD_' prefix)
435
+	 * and the extra meta. Mostly used for passing off ot gateways.     *
436
+	 *
437
+	 * @return array
438
+	 */
439
+	public function settings_array()
440
+	{
441
+		$fields = $this->model_field_array();
442
+		$extra_meta = $this->all_extra_meta_array();
443
+		// remove the model's prefix from the fields
444
+		$combined_settings_array = array();
445
+		foreach ($fields as $key => $value) {
446
+			if (strpos($key, 'PMD_') === 0) {
447
+				$key_sans_model_prefix = str_replace('PMD_', '', $key);
448
+				$combined_settings_array [ $key_sans_model_prefix ] = $value;
449
+			}
450
+		}
451
+		$combined_settings_array = array_merge($extra_meta, $combined_settings_array);
452
+		return $combined_settings_array;
453
+	}
454
+
455
+
456
+	/**
457
+	 * Gets the HTML for displaying the payment method on a page.
458
+	 *
459
+	 * @param string $url
460
+	 * @param string $css_class
461
+	 * @return string of HTML for displaying the button
462
+	 * @throws EE_Error
463
+	 */
464
+	public function button_html($url = '', $css_class = '')
465
+	{
466
+		$payment_occurs = $this->type_obj()->payment_occurs();
467
+		return '
468 468
 		 <div id="'
469
-               . $this->slug()
470
-               . '-payment-option-dv" class="'
471
-               . $payment_occurs . '-payment-gateway reg-page-payment-option-dv' . $css_class . '">
469
+			   . $this->slug()
470
+			   . '-payment-option-dv" class="'
471
+			   . $payment_occurs . '-payment-gateway reg-page-payment-option-dv' . $css_class . '">
472 472
 			<a id="payment-gateway-button-' . $this->slug()
473
-               . '" class="reg-page-payment-option-lnk" rel="'
474
-               . $this->slug() . '" href="' . $url . '" >
473
+			   . '" class="reg-page-payment-option-lnk" rel="'
474
+			   . $this->slug() . '" href="' . $url . '" >
475 475
 				<img src="' . $this->button_url() . '" alt="' . sprintf(
476
-                   esc_attr__('Pay using %s', 'event_espresso'),
477
-                   $this->get_pretty('PMD_name', 'form_input')
478
-               ) . '" />
476
+				   esc_attr__('Pay using %s', 'event_espresso'),
477
+				   $this->get_pretty('PMD_name', 'form_input')
478
+			   ) . '" />
479 479
 			</a>
480 480
 		</div>
481 481
 ';
482
-    }
483
-
484
-
485
-    /**
486
-     * Gets all the currencies which are an option for this payment method
487
-     * (as defined by the gateway and the currently active currencies)
488
-     *
489
-     * @return EE_Currency[]
490
-     * @throws EE_Error
491
-     */
492
-    public function get_all_usable_currencies()
493
-    {
494
-        return EEM_Currency::instance()->get_all_currencies_usable_by($this->type_obj());
495
-    }
496
-
497
-
498
-    /**
499
-     * Reports whether or not this payment method can be used for this payment method
500
-     *
501
-     * @param string $currency_code currency ID (code)
502
-     * @return boolean
503
-     * @throws EE_Error
504
-     */
505
-    public function usable_for_currency($currency_code)
506
-    {
507
-        foreach ($this->get_all_usable_currencies() as $currency_obj) {
508
-            if ($currency_obj->ID() === $currency_code) {
509
-                return true;
510
-            }
511
-        }
512
-        return false;
513
-    }
514
-
515
-
516
-    /**
517
-     * Returns TRUE if this payment method's gateway is an instance of EE_Onsite_Gateway
518
-     *
519
-     * @return bool
520
-     * @throws EE_Error
521
-     */
522
-    public function is_on_site()
523
-    {
524
-        return $this->type_obj()->payment_occurs() === EE_PMT_Base::onsite;
525
-    }
526
-
527
-
528
-    /**
529
-     * Returns TRUE if this payment method's gateway is an instance of EE_Offsite_Gateway
530
-     *
531
-     * @return bool
532
-     * @throws EE_Error
533
-     */
534
-    public function is_off_site()
535
-    {
536
-        return $this->type_obj()->payment_occurs() === EE_PMT_Base::offsite;
537
-    }
538
-
539
-
540
-    /**
541
-     * Returns TRUE if this payment method does not utilize a gateway
542
-     *
543
-     * @return bool
544
-     * @throws EE_Error
545
-     */
546
-    public function is_off_line()
547
-    {
548
-        return $this->type_obj()->payment_occurs() === EE_PMT_Base::offline;
549
-    }
550
-
551
-    /**
552
-     * Overrides default __sleep so the object type is NOT cached.
553
-     * This way we can rely on the normal EE_Payment_Method::type_obj() logic
554
-     * to load the required classes, and don't need them at the time of unserialization
555
-     *
556
-     * @return array
557
-     */
558
-    public function __sleep()
559
-    {
560
-        $properties = get_object_vars($this);
561
-        unset($properties['_type_obj']);
562
-        return array_keys($properties);
563
-    }
564
-
565
-
566
-    /**
567
-     * Overrides parent to add some logging for when payment methods get deactivated
568
-     *
569
-     * @param array $set_cols_n_values
570
-     * @return int @see EE_Base_Class::save()
571
-     * @throws EE_Error
572
-     */
573
-    public function save($set_cols_n_values = array())
574
-    {
575
-        $results = parent::save($set_cols_n_values);
576
-        if ($this->get_original('PMD_scope') !== $this->get('PMD_scope')) {
577
-            /** @var CurrentPage $current_page */
578
-            $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
579
-            EE_Log::instance()->log(
580
-                __FILE__,
581
-                __FUNCTION__,
582
-                sprintf(
583
-                    esc_html__('Set new scope on payment method %1$s to %2$s from %3$s on URL %4$s', 'event_espresso'),
584
-                    $this->name(),
585
-                    serialize($this->get_original('PMD_scope')),
586
-                    serialize($this->get('PMD_scope')),
587
-                    $current_page->getPermalink()
588
-                ),
589
-                'payment_method_change'
590
-            );
591
-        }
592
-        return $results;
593
-    }
482
+	}
483
+
484
+
485
+	/**
486
+	 * Gets all the currencies which are an option for this payment method
487
+	 * (as defined by the gateway and the currently active currencies)
488
+	 *
489
+	 * @return EE_Currency[]
490
+	 * @throws EE_Error
491
+	 */
492
+	public function get_all_usable_currencies()
493
+	{
494
+		return EEM_Currency::instance()->get_all_currencies_usable_by($this->type_obj());
495
+	}
496
+
497
+
498
+	/**
499
+	 * Reports whether or not this payment method can be used for this payment method
500
+	 *
501
+	 * @param string $currency_code currency ID (code)
502
+	 * @return boolean
503
+	 * @throws EE_Error
504
+	 */
505
+	public function usable_for_currency($currency_code)
506
+	{
507
+		foreach ($this->get_all_usable_currencies() as $currency_obj) {
508
+			if ($currency_obj->ID() === $currency_code) {
509
+				return true;
510
+			}
511
+		}
512
+		return false;
513
+	}
514
+
515
+
516
+	/**
517
+	 * Returns TRUE if this payment method's gateway is an instance of EE_Onsite_Gateway
518
+	 *
519
+	 * @return bool
520
+	 * @throws EE_Error
521
+	 */
522
+	public function is_on_site()
523
+	{
524
+		return $this->type_obj()->payment_occurs() === EE_PMT_Base::onsite;
525
+	}
526
+
527
+
528
+	/**
529
+	 * Returns TRUE if this payment method's gateway is an instance of EE_Offsite_Gateway
530
+	 *
531
+	 * @return bool
532
+	 * @throws EE_Error
533
+	 */
534
+	public function is_off_site()
535
+	{
536
+		return $this->type_obj()->payment_occurs() === EE_PMT_Base::offsite;
537
+	}
538
+
539
+
540
+	/**
541
+	 * Returns TRUE if this payment method does not utilize a gateway
542
+	 *
543
+	 * @return bool
544
+	 * @throws EE_Error
545
+	 */
546
+	public function is_off_line()
547
+	{
548
+		return $this->type_obj()->payment_occurs() === EE_PMT_Base::offline;
549
+	}
550
+
551
+	/**
552
+	 * Overrides default __sleep so the object type is NOT cached.
553
+	 * This way we can rely on the normal EE_Payment_Method::type_obj() logic
554
+	 * to load the required classes, and don't need them at the time of unserialization
555
+	 *
556
+	 * @return array
557
+	 */
558
+	public function __sleep()
559
+	{
560
+		$properties = get_object_vars($this);
561
+		unset($properties['_type_obj']);
562
+		return array_keys($properties);
563
+	}
564
+
565
+
566
+	/**
567
+	 * Overrides parent to add some logging for when payment methods get deactivated
568
+	 *
569
+	 * @param array $set_cols_n_values
570
+	 * @return int @see EE_Base_Class::save()
571
+	 * @throws EE_Error
572
+	 */
573
+	public function save($set_cols_n_values = array())
574
+	{
575
+		$results = parent::save($set_cols_n_values);
576
+		if ($this->get_original('PMD_scope') !== $this->get('PMD_scope')) {
577
+			/** @var CurrentPage $current_page */
578
+			$current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
579
+			EE_Log::instance()->log(
580
+				__FILE__,
581
+				__FUNCTION__,
582
+				sprintf(
583
+					esc_html__('Set new scope on payment method %1$s to %2$s from %3$s on URL %4$s', 'event_espresso'),
584
+					$this->name(),
585
+					serialize($this->get_original('PMD_scope')),
586
+					serialize($this->get('PMD_scope')),
587
+					$current_page->getPermalink()
588
+				),
589
+				'payment_method_change'
590
+			);
591
+		}
592
+		return $results;
593
+	}
594 594
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/enums/TicketVisibilityEnum.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
      */
23 23
     public function __construct()
24 24
     {
25
-        $this->setName($this->namespace . 'TicketVisibilityEnum');
25
+        $this->setName($this->namespace.'TicketVisibilityEnum');
26 26
         $this->setDescription(esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso'));
27 27
         parent::__construct();
28 28
     }
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -17,24 +17,24 @@
 block discarded – undo
17 17
  */
18 18
 class TicketVisibilityEnum extends EnumBase
19 19
 {
20
-    /**
21
-     * TicketVisibilityEnum constructor.
22
-     */
23
-    public function __construct()
24
-    {
25
-        $this->setName($this->namespace . 'TicketVisibilityEnum');
26
-        $this->setDescription(esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso'));
27
-        parent::__construct();
28
-    }
20
+	/**
21
+	 * TicketVisibilityEnum constructor.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$this->setName($this->namespace . 'TicketVisibilityEnum');
26
+		$this->setDescription(esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso'));
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * @return array
33
-     * @throws EE_Error
34
-     * @throws ReflectionException
35
-     */
36
-    protected function getValues()
37
-    {
38
-        return EEM_Ticket::instance()->getTicketVisibilityValues();
39
-    }
31
+	/**
32
+	 * @return array
33
+	 * @throws EE_Error
34
+	 * @throws ReflectionException
35
+	 */
36
+	protected function getValues()
37
+	{
38
+		return EEM_Ticket::instance()->getTicketVisibilityValues();
39
+	}
40 40
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/mutations/TicketMutation.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $args = [];
37 37
 
38
-        if (! empty($input['datetimes'])) {
38
+        if ( ! empty($input['datetimes'])) {
39 39
             $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']);
40 40
         }
41 41
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
             $args['TKT_description'] = wp_kses_post($input['description']);
44 44
         }
45 45
 
46
-        if (! empty($input['endDate'])) {
46
+        if ( ! empty($input['endDate'])) {
47 47
             $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate']));
48 48
         }
49 49
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
             $args['TKT_order'] = (int) $input['order'];
80 80
         }
81 81
 
82
-        if (! empty($input['parent'])) {
82
+        if ( ! empty($input['parent'])) {
83 83
             $parts = Relay::fromGlobalId(sanitize_text_field($input['parent']));
84
-            $args['TKT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
84
+            $args['TKT_parent'] = ( ! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
85 85
         }
86 86
 
87 87
         // price can be 0
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             $args['TKT_sold'] = (int) $input['sold'];
115 115
         }
116 116
 
117
-        if (! empty($input['startDate'])) {
117
+        if ( ! empty($input['startDate'])) {
118 118
             $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate']));
119 119
         }
120 120
 
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
             $args['TKT_uses'] = (int) $input['uses'];
123 123
         }
124 124
 
125
-        if (! empty($input['wpUser'])) {
125
+        if ( ! empty($input['wpUser'])) {
126 126
             $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser']));
127
-            $args['TKT_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
127
+            $args['TKT_wp_user'] = ( ! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
128 128
         }
129 129
 
130 130
         if (array_key_exists('visibility', $input)) {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         // @todo replace loop with single query
160 160
         foreach ($datetimes as $ID) {
161 161
             $parts = Relay::fromGlobalId($ID);
162
-            if (! empty($parts['id']) && absint($parts['id'])) {
162
+            if ( ! empty($parts['id']) && absint($parts['id'])) {
163 163
                 $entity->_add_relation_to(
164 164
                     $parts['id'],
165 165
                     $relationName
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         // @todo replace loop with single query
190 190
         foreach ($prices as $ID) {
191 191
             $parts = Relay::fromGlobalId($ID);
192
-            if (! empty($parts['id']) && absint($parts['id'])) {
192
+            if ( ! empty($parts['id']) && absint($parts['id'])) {
193 193
                 $entity->_add_relation_to(
194 194
                     $parts['id'],
195 195
                     $relationName
Please login to merge, or discard this patch.
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -22,195 +22,195 @@
 block discarded – undo
22 22
  */
23 23
 class TicketMutation
24 24
 {
25
-    /**
26
-     * Maps the GraphQL input to a format that the model functions can use
27
-     *
28
-     * @param array $input Data coming from the GraphQL mutation query input
29
-     * @return array
30
-     * @throws Exception
31
-     */
32
-    public static function prepareFields($input)
33
-    {
34
-        $args = [];
35
-
36
-        if (! empty($input['datetimes'])) {
37
-            $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']);
38
-        }
39
-
40
-        if (isset($input['description'])) {
41
-            $args['TKT_description'] = wp_kses_post($input['description']);
42
-        }
43
-
44
-        if (! empty($input['endDate'])) {
45
-            $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate']));
46
-        }
47
-
48
-        if (array_key_exists('isDefault', $input)) {
49
-            $args['TKT_is_default'] = (bool) $input['isDefault'];
50
-        }
51
-
52
-        if (array_key_exists('isRequired', $input)) {
53
-            $args['TKT_required'] = (bool) $input['isRequired'];
54
-        }
55
-
56
-        if (array_key_exists('isTaxable', $input)) {
57
-            $args['TKT_taxable'] = (bool) $input['isTaxable'];
58
-        }
59
-
60
-        if (array_key_exists('isTrashed', $input)) {
61
-            $args['TKT_deleted'] = (bool) $input['isTrashed'];
62
-        }
63
-
64
-        if (array_key_exists('max', $input)) {
65
-            $args['TKT_max'] = (int) $input['max'];
66
-        }
67
-
68
-        if (array_key_exists('min', $input)) {
69
-            $args['TKT_min'] = (int) $input['min'];
70
-        }
71
-
72
-        if (isset($input['name'])) {
73
-            $args['TKT_name'] = sanitize_text_field($input['name']);
74
-        }
75
-
76
-        if (array_key_exists('order', $input)) {
77
-            $args['TKT_order'] = (int) $input['order'];
78
-        }
79
-
80
-        if (! empty($input['parent'])) {
81
-            $parts = Relay::fromGlobalId(sanitize_text_field($input['parent']));
82
-            $args['TKT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
83
-        }
84
-
85
-        // price can be 0
86
-        if (array_key_exists('price', $input)) {
87
-            $args['TKT_price'] = (float) $input['price'];
88
-        }
89
-
90
-        // prices can be an empty array when all prices are deleted
91
-        if (array_key_exists('prices', $input) && is_array($input['prices'])) {
92
-            $args['prices'] = array_map('sanitize_text_field', $input['prices']);
93
-        }
94
-
95
-        if (array_key_exists('quantity', $input)) {
96
-            $args['TKT_qty'] = (int) $input['quantity'];
97
-        }
98
-
99
-        if (array_key_exists('reserved', $input)) {
100
-            $args['TKT_reserved'] = (int) $input['reserved'];
101
-        }
102
-
103
-        if (array_key_exists('reverseCalculate', $input)) {
104
-            $args['TKT_reverse_calculate'] = (bool) $input['reverseCalculate'];
105
-        }
106
-
107
-        if (array_key_exists('row', $input)) {
108
-            $args['TKT_row'] = (int) $input['row'];
109
-        }
110
-
111
-        if (array_key_exists('sold', $input)) {
112
-            $args['TKT_sold'] = (int) $input['sold'];
113
-        }
114
-
115
-        if (! empty($input['startDate'])) {
116
-            $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate']));
117
-        }
118
-
119
-        if (array_key_exists('uses', $input)) {
120
-            $args['TKT_uses'] = (int) $input['uses'];
121
-        }
122
-
123
-        if (! empty($input['wpUser'])) {
124
-            $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser']));
125
-            $args['TKT_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
126
-        }
127
-
128
-        if (array_key_exists('visibility', $input)) {
129
-            $args['TKT_visibility'] = (int) $input['visibility'];
130
-        }
131
-
132
-        return apply_filters(
133
-            'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__ticket_args',
134
-            $args,
135
-            $input
136
-        );
137
-    }
138
-
139
-
140
-    /**
141
-     * Sets the related datetimes for the given ticket.
142
-     *
143
-     * @param EE_Ticket $entity    The Ticket instance.
144
-     * @param array     $datetimes Array of datetime IDs to relate.
145
-     * @throws EE_Error
146
-     * @throws InvalidArgumentException
147
-     * @throws InvalidDataTypeException
148
-     * @throws InvalidInterfaceException
149
-     * @throws ReflectionException
150
-     */
151
-    public static function setRelatedDatetimes($entity, $datetimes)
152
-    {
153
-        $relationName = 'Datetime';
154
-        // Remove all the existing related datetimes
155
-
156
-        $entity->_remove_relations($relationName);
157
-        // @todo replace loop with single query
158
-        foreach ($datetimes as $ID) {
159
-            $parts = Relay::fromGlobalId($ID);
160
-            if (! empty($parts['id']) && absint($parts['id'])) {
161
-                $entity->_add_relation_to(
162
-                    $parts['id'],
163
-                    $relationName
164
-                );
165
-            }
166
-        }
167
-    }
168
-
169
-
170
-    /**
171
-     * Sets the related prices for the given ticket.
172
-     *
173
-     * @param EE_Ticket $entity The Ticket instance.
174
-     * @param array     $prices Array of entity IDs to relate.
175
-     * @throws EE_Error
176
-     * @throws InvalidArgumentException
177
-     * @throws InvalidDataTypeException
178
-     * @throws InvalidInterfaceException
179
-     * @throws ReflectionException
180
-     */
181
-    public static function setRelatedPrices($entity, $prices)
182
-    {
183
-        $relationName = 'Price';
184
-        // Remove all the existing related entities
185
-        $entity->_remove_relations($relationName);
186
-
187
-        // @todo replace loop with single query
188
-        foreach ($prices as $ID) {
189
-            $parts = Relay::fromGlobalId($ID);
190
-            if (! empty($parts['id']) && absint($parts['id'])) {
191
-                $entity->_add_relation_to(
192
-                    $parts['id'],
193
-                    $relationName
194
-                );
195
-            }
196
-        }
197
-    }
198
-
199
-
200
-    /**
201
-     * @param EE_Ticket  $ticket_entity
202
-     * @throws EE_Error
203
-     * @throws InvalidArgumentException
204
-     * @throws InvalidDataTypeException
205
-     * @throws InvalidInterfaceException
206
-     * @throws ReflectionException
207
-     */
208
-    public static function addDefaultPrices($ticket_entity)
209
-    {
210
-        /** @var DefaultPrices $default_prices */
211
-        $default_prices = LoaderFactory::getLoader()->getShared(
212
-            'EventEspresso\core\domain\services\admin\entities\DefaultPrices'
213
-        );
214
-        $default_prices->create($ticket_entity);
215
-    }
25
+	/**
26
+	 * Maps the GraphQL input to a format that the model functions can use
27
+	 *
28
+	 * @param array $input Data coming from the GraphQL mutation query input
29
+	 * @return array
30
+	 * @throws Exception
31
+	 */
32
+	public static function prepareFields($input)
33
+	{
34
+		$args = [];
35
+
36
+		if (! empty($input['datetimes'])) {
37
+			$args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']);
38
+		}
39
+
40
+		if (isset($input['description'])) {
41
+			$args['TKT_description'] = wp_kses_post($input['description']);
42
+		}
43
+
44
+		if (! empty($input['endDate'])) {
45
+			$args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate']));
46
+		}
47
+
48
+		if (array_key_exists('isDefault', $input)) {
49
+			$args['TKT_is_default'] = (bool) $input['isDefault'];
50
+		}
51
+
52
+		if (array_key_exists('isRequired', $input)) {
53
+			$args['TKT_required'] = (bool) $input['isRequired'];
54
+		}
55
+
56
+		if (array_key_exists('isTaxable', $input)) {
57
+			$args['TKT_taxable'] = (bool) $input['isTaxable'];
58
+		}
59
+
60
+		if (array_key_exists('isTrashed', $input)) {
61
+			$args['TKT_deleted'] = (bool) $input['isTrashed'];
62
+		}
63
+
64
+		if (array_key_exists('max', $input)) {
65
+			$args['TKT_max'] = (int) $input['max'];
66
+		}
67
+
68
+		if (array_key_exists('min', $input)) {
69
+			$args['TKT_min'] = (int) $input['min'];
70
+		}
71
+
72
+		if (isset($input['name'])) {
73
+			$args['TKT_name'] = sanitize_text_field($input['name']);
74
+		}
75
+
76
+		if (array_key_exists('order', $input)) {
77
+			$args['TKT_order'] = (int) $input['order'];
78
+		}
79
+
80
+		if (! empty($input['parent'])) {
81
+			$parts = Relay::fromGlobalId(sanitize_text_field($input['parent']));
82
+			$args['TKT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
83
+		}
84
+
85
+		// price can be 0
86
+		if (array_key_exists('price', $input)) {
87
+			$args['TKT_price'] = (float) $input['price'];
88
+		}
89
+
90
+		// prices can be an empty array when all prices are deleted
91
+		if (array_key_exists('prices', $input) && is_array($input['prices'])) {
92
+			$args['prices'] = array_map('sanitize_text_field', $input['prices']);
93
+		}
94
+
95
+		if (array_key_exists('quantity', $input)) {
96
+			$args['TKT_qty'] = (int) $input['quantity'];
97
+		}
98
+
99
+		if (array_key_exists('reserved', $input)) {
100
+			$args['TKT_reserved'] = (int) $input['reserved'];
101
+		}
102
+
103
+		if (array_key_exists('reverseCalculate', $input)) {
104
+			$args['TKT_reverse_calculate'] = (bool) $input['reverseCalculate'];
105
+		}
106
+
107
+		if (array_key_exists('row', $input)) {
108
+			$args['TKT_row'] = (int) $input['row'];
109
+		}
110
+
111
+		if (array_key_exists('sold', $input)) {
112
+			$args['TKT_sold'] = (int) $input['sold'];
113
+		}
114
+
115
+		if (! empty($input['startDate'])) {
116
+			$args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate']));
117
+		}
118
+
119
+		if (array_key_exists('uses', $input)) {
120
+			$args['TKT_uses'] = (int) $input['uses'];
121
+		}
122
+
123
+		if (! empty($input['wpUser'])) {
124
+			$parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser']));
125
+			$args['TKT_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
126
+		}
127
+
128
+		if (array_key_exists('visibility', $input)) {
129
+			$args['TKT_visibility'] = (int) $input['visibility'];
130
+		}
131
+
132
+		return apply_filters(
133
+			'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__ticket_args',
134
+			$args,
135
+			$input
136
+		);
137
+	}
138
+
139
+
140
+	/**
141
+	 * Sets the related datetimes for the given ticket.
142
+	 *
143
+	 * @param EE_Ticket $entity    The Ticket instance.
144
+	 * @param array     $datetimes Array of datetime IDs to relate.
145
+	 * @throws EE_Error
146
+	 * @throws InvalidArgumentException
147
+	 * @throws InvalidDataTypeException
148
+	 * @throws InvalidInterfaceException
149
+	 * @throws ReflectionException
150
+	 */
151
+	public static function setRelatedDatetimes($entity, $datetimes)
152
+	{
153
+		$relationName = 'Datetime';
154
+		// Remove all the existing related datetimes
155
+
156
+		$entity->_remove_relations($relationName);
157
+		// @todo replace loop with single query
158
+		foreach ($datetimes as $ID) {
159
+			$parts = Relay::fromGlobalId($ID);
160
+			if (! empty($parts['id']) && absint($parts['id'])) {
161
+				$entity->_add_relation_to(
162
+					$parts['id'],
163
+					$relationName
164
+				);
165
+			}
166
+		}
167
+	}
168
+
169
+
170
+	/**
171
+	 * Sets the related prices for the given ticket.
172
+	 *
173
+	 * @param EE_Ticket $entity The Ticket instance.
174
+	 * @param array     $prices Array of entity IDs to relate.
175
+	 * @throws EE_Error
176
+	 * @throws InvalidArgumentException
177
+	 * @throws InvalidDataTypeException
178
+	 * @throws InvalidInterfaceException
179
+	 * @throws ReflectionException
180
+	 */
181
+	public static function setRelatedPrices($entity, $prices)
182
+	{
183
+		$relationName = 'Price';
184
+		// Remove all the existing related entities
185
+		$entity->_remove_relations($relationName);
186
+
187
+		// @todo replace loop with single query
188
+		foreach ($prices as $ID) {
189
+			$parts = Relay::fromGlobalId($ID);
190
+			if (! empty($parts['id']) && absint($parts['id'])) {
191
+				$entity->_add_relation_to(
192
+					$parts['id'],
193
+					$relationName
194
+				);
195
+			}
196
+		}
197
+	}
198
+
199
+
200
+	/**
201
+	 * @param EE_Ticket  $ticket_entity
202
+	 * @throws EE_Error
203
+	 * @throws InvalidArgumentException
204
+	 * @throws InvalidDataTypeException
205
+	 * @throws InvalidInterfaceException
206
+	 * @throws ReflectionException
207
+	 */
208
+	public static function addDefaultPrices($ticket_entity)
209
+	{
210
+		/** @var DefaultPrices $default_prices */
211
+		$default_prices = LoaderFactory::getLoader()->getShared(
212
+			'EventEspresso\core\domain\services\admin\entities\DefaultPrices'
213
+		);
214
+		$default_prices->create($ticket_entity);
215
+	}
216 216
 }
Please login to merge, or discard this patch.
core/domain/entities/users/EventManagers.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
             if ($role instanceof WP_Role) {
72 72
                 foreach ($this->capabilities as $capability) {
73 73
                     // we're using the role name as the array index to prevent duplicates
74
-                    if (! isset($event_manager_roles[ $role->name ]) && $role->has_cap($capability)) {
75
-                        $event_manager_roles[ $role->name ] = $role;
74
+                    if ( ! isset($event_manager_roles[$role->name]) && $role->has_cap($capability)) {
75
+                        $event_manager_roles[$role->name] = $role;
76 76
                     }
77 77
                 }
78 78
             }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
             $this->user_list = [];
90 90
         }
91 91
         // begin to build our query
92
-        $SQL      = "SELECT u1.ID, u1.display_name FROM $wpdb->users AS u1 "
92
+        $SQL = "SELECT u1.ID, u1.display_name FROM $wpdb->users AS u1 "
93 93
                     . "INNER JOIN $wpdb->usermeta AS u2 ON u1.ID = u2.user_id "
94 94
                     . "AND u2.meta_key='{$wpdb->prefix}capabilities' "
95 95
                     . 'WHERE';
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
         foreach ($this->roles as $role) {
98 98
             // for each role, add a WHERE clause
99 99
             if ($role instanceof WP_Role) {
100
-                $SQL .= $operator . ' u2.meta_value LIKE \'%"' . $role->name . '"%\' ';
100
+                $SQL .= $operator.' u2.meta_value LIKE \'%"'.$role->name.'"%\' ';
101 101
                 // subsequent clauses will use OR so that any role is accepted
102 102
                 $operator = 'OR';
103 103
             }
104 104
         }
105 105
         foreach ($this->capabilities as $capability) {
106 106
             // for each capability, add a WHERE clause
107
-            $SQL .= $operator . ' u2.meta_value LIKE \'%"' . $capability . '";b:1;%\' ';
107
+            $SQL .= $operator.' u2.meta_value LIKE \'%"'.$capability.'";b:1;%\' ';
108 108
             // subsequent clauses will use OR so that any role is accepted
109 109
             $operator = 'OR';
110 110
         }
111
-        $SQL   .= 'ORDER BY user_id ASC';
111
+        $SQL .= 'ORDER BY user_id ASC';
112 112
         $users = $wpdb->get_results($SQL);
113 113
 
114 114
         $this->user_list = ! empty($users) ? $users : [];
Please login to merge, or discard this patch.
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -15,144 +15,144 @@
 block discarded – undo
15 15
  */
16 16
 class EventManagers
17 17
 {
18
-    /**
19
-     * @var string[]
20
-     */
21
-    private $capabilities = [];
22
-
23
-    /**
24
-     * @var WP_Role[]
25
-     */
26
-    private $roles = [];
27
-
28
-    /**
29
-     * @var array
30
-     */
31
-    private $user_list = [];
32
-
33
-    /**
34
-     * @var WP_Role[]
35
-     */
36
-    private $wp_roles;
37
-
38
-
39
-    /**
40
-     * EventManagerRoles constructor.
41
-     */
42
-    public function __construct()
43
-    {
44
-        global $wp_roles;
45
-        // first let's grab ALL of the WP_Role objects
46
-        $this->wp_roles = $wp_roles->role_objects;
47
-        $this->setCapabilities();
48
-        $this->buildRolesArray();
49
-        $this->buildUserList();
50
-    }
51
-
52
-
53
-    /**
54
-     * @return void
55
-     */
56
-    private function setCapabilities()
57
-    {
58
-        // filter a list of capabilities we want to use to define an event manager
59
-        $capabilities = (array) apply_filters(
60
-            'FHEE__EventEspresso_core_domain_services_capabilities_EventManagers__setCapabilities',
61
-            ['ee_edit_events', 'ee_edit_event'],
62
-            $this->wp_roles
63
-        );
64
-        $this->capabilities = array_map('sanitize_text_field', $capabilities);
65
-    }
66
-
67
-
68
-    /**
69
-     * @return void
70
-     */
71
-    private function buildRolesArray()
72
-    {
73
-        // we'll use this array to capture all of the WP_Role objects that have any of the caps we are targeting
74
-        $event_manager_roles = [];
75
-        foreach ($this->wp_roles as $role) {
76
-            if ($role instanceof WP_Role) {
77
-                foreach ($this->capabilities as $capability) {
78
-                    // we're using the role name as the array index to prevent duplicates
79
-                    if (! isset($event_manager_roles[ $role->name ]) && $role->has_cap($capability)) {
80
-                        $event_manager_roles[ $role->name ] = $role;
81
-                    }
82
-                }
83
-            }
84
-        }
85
-        $this->roles = $event_manager_roles;
86
-    }
87
-
88
-
89
-    /**
90
-     * @return void
91
-     */
92
-    private function buildUserList()
93
-    {
94
-        global $wpdb;
95
-        // no roles ?!!? then nothing to query for
96
-        if (empty($this->roles)) {
97
-            $this->user_list = [];
98
-        }
99
-        // begin to build our query
100
-        $SQL      = "SELECT u1.ID, u1.display_name FROM $wpdb->users AS u1 "
101
-                    . "INNER JOIN $wpdb->usermeta AS u2 ON u1.ID = u2.user_id "
102
-                    . "AND u2.meta_key='{$wpdb->prefix}capabilities' "
103
-                    . 'WHERE';
104
-        $operator = '';
105
-        foreach ($this->roles as $role) {
106
-            // for each role, add a WHERE clause
107
-            if ($role instanceof WP_Role) {
108
-                $SQL .= $operator . ' u2.meta_value LIKE \'%"' . $role->name . '"%\' ';
109
-                // subsequent clauses will use OR so that any role is accepted
110
-                $operator = 'OR';
111
-            }
112
-        }
113
-        foreach ($this->capabilities as $capability) {
114
-            // for each capability, add a WHERE clause
115
-            $SQL .= $operator . ' u2.meta_value LIKE \'%"' . $capability . '";b:1;%\' ';
116
-            // subsequent clauses will use OR so that any role is accepted
117
-            $operator = 'OR';
118
-        }
119
-        $SQL   .= 'ORDER BY user_id ASC';
120
-        $users = $wpdb->get_results($SQL);
121
-
122
-        $this->user_list = ! empty($users) ? $users : [];
123
-    }
124
-
125
-
126
-    /**
127
-     * @return array
128
-     */
129
-    public function capabilities()
130
-    {
131
-        return $this->capabilities;
132
-    }
133
-
134
-
135
-    /**
136
-     * Returns a list of WP_Role objects that have "event manager" capabilities
137
-     * The list of "event manager" capabilities is filtered but defaults to:
138
-     *      - 'ee_edit_events'
139
-     *      - 'ee_edit_event'
140
-     *
141
-     * @return WP_Role[]
142
-     */
143
-    public function roles()
144
-    {
145
-        return $this->roles;
146
-    }
147
-
148
-
149
-    /**
150
-     * Returns a list of users that have any of the Event Manager roles
151
-     *
152
-     * @return stdClass[]
153
-     */
154
-    public function userList()
155
-    {
156
-        return $this->user_list;
157
-    }
18
+	/**
19
+	 * @var string[]
20
+	 */
21
+	private $capabilities = [];
22
+
23
+	/**
24
+	 * @var WP_Role[]
25
+	 */
26
+	private $roles = [];
27
+
28
+	/**
29
+	 * @var array
30
+	 */
31
+	private $user_list = [];
32
+
33
+	/**
34
+	 * @var WP_Role[]
35
+	 */
36
+	private $wp_roles;
37
+
38
+
39
+	/**
40
+	 * EventManagerRoles constructor.
41
+	 */
42
+	public function __construct()
43
+	{
44
+		global $wp_roles;
45
+		// first let's grab ALL of the WP_Role objects
46
+		$this->wp_roles = $wp_roles->role_objects;
47
+		$this->setCapabilities();
48
+		$this->buildRolesArray();
49
+		$this->buildUserList();
50
+	}
51
+
52
+
53
+	/**
54
+	 * @return void
55
+	 */
56
+	private function setCapabilities()
57
+	{
58
+		// filter a list of capabilities we want to use to define an event manager
59
+		$capabilities = (array) apply_filters(
60
+			'FHEE__EventEspresso_core_domain_services_capabilities_EventManagers__setCapabilities',
61
+			['ee_edit_events', 'ee_edit_event'],
62
+			$this->wp_roles
63
+		);
64
+		$this->capabilities = array_map('sanitize_text_field', $capabilities);
65
+	}
66
+
67
+
68
+	/**
69
+	 * @return void
70
+	 */
71
+	private function buildRolesArray()
72
+	{
73
+		// we'll use this array to capture all of the WP_Role objects that have any of the caps we are targeting
74
+		$event_manager_roles = [];
75
+		foreach ($this->wp_roles as $role) {
76
+			if ($role instanceof WP_Role) {
77
+				foreach ($this->capabilities as $capability) {
78
+					// we're using the role name as the array index to prevent duplicates
79
+					if (! isset($event_manager_roles[ $role->name ]) && $role->has_cap($capability)) {
80
+						$event_manager_roles[ $role->name ] = $role;
81
+					}
82
+				}
83
+			}
84
+		}
85
+		$this->roles = $event_manager_roles;
86
+	}
87
+
88
+
89
+	/**
90
+	 * @return void
91
+	 */
92
+	private function buildUserList()
93
+	{
94
+		global $wpdb;
95
+		// no roles ?!!? then nothing to query for
96
+		if (empty($this->roles)) {
97
+			$this->user_list = [];
98
+		}
99
+		// begin to build our query
100
+		$SQL      = "SELECT u1.ID, u1.display_name FROM $wpdb->users AS u1 "
101
+					. "INNER JOIN $wpdb->usermeta AS u2 ON u1.ID = u2.user_id "
102
+					. "AND u2.meta_key='{$wpdb->prefix}capabilities' "
103
+					. 'WHERE';
104
+		$operator = '';
105
+		foreach ($this->roles as $role) {
106
+			// for each role, add a WHERE clause
107
+			if ($role instanceof WP_Role) {
108
+				$SQL .= $operator . ' u2.meta_value LIKE \'%"' . $role->name . '"%\' ';
109
+				// subsequent clauses will use OR so that any role is accepted
110
+				$operator = 'OR';
111
+			}
112
+		}
113
+		foreach ($this->capabilities as $capability) {
114
+			// for each capability, add a WHERE clause
115
+			$SQL .= $operator . ' u2.meta_value LIKE \'%"' . $capability . '";b:1;%\' ';
116
+			// subsequent clauses will use OR so that any role is accepted
117
+			$operator = 'OR';
118
+		}
119
+		$SQL   .= 'ORDER BY user_id ASC';
120
+		$users = $wpdb->get_results($SQL);
121
+
122
+		$this->user_list = ! empty($users) ? $users : [];
123
+	}
124
+
125
+
126
+	/**
127
+	 * @return array
128
+	 */
129
+	public function capabilities()
130
+	{
131
+		return $this->capabilities;
132
+	}
133
+
134
+
135
+	/**
136
+	 * Returns a list of WP_Role objects that have "event manager" capabilities
137
+	 * The list of "event manager" capabilities is filtered but defaults to:
138
+	 *      - 'ee_edit_events'
139
+	 *      - 'ee_edit_event'
140
+	 *
141
+	 * @return WP_Role[]
142
+	 */
143
+	public function roles()
144
+	{
145
+		return $this->roles;
146
+	}
147
+
148
+
149
+	/**
150
+	 * Returns a list of users that have any of the Event Manager roles
151
+	 *
152
+	 * @return stdClass[]
153
+	 */
154
+	public function userList()
155
+	{
156
+		return $this->user_list;
157
+	}
158 158
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Message.model.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             self::priority_low    => esc_html__('low', 'event_espresso'),
127 127
         );
128 128
 
129
-        $this->_fields          = array(
129
+        $this->_fields = array(
130 130
             'Message' => array(
131 131
                 'MSG_ID'             => new EE_Primary_Key_Int_Field('MSG_ID', esc_html__('Message ID', 'event_espresso')),
132 132
                 'MSG_token'          => new EE_Plain_Text_Field(
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
                         );
437 437
                         break;
438 438
                     default:
439
-                        $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value;
439
+                        $query_params[0]['AND**filter_by']['OR**filter_by_'.$request_key][$model_name.'.'.$request_key] = $request_value;
440 440
                         break;
441 441
                 }
442 442
             }
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
         if ($label_parts) {
500 500
             // prepend to the last element of $label_parts an "and".
501 501
             if (count($label_parts) > 1) {
502
-                $label_parts_index_to_prepend               = count($label_parts) - 1;
503
-                $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ];
502
+                $label_parts_index_to_prepend = count($label_parts) - 1;
503
+                $label_parts[$label_parts_index_to_prepend] = 'and'.$label_parts[$label_parts_index_to_prepend];
504 504
             }
505 505
 
506 506
             $pretty_label .= sprintf(
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
             $is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES;
561 561
         }
562 562
 
563
-        if (! is_null($set_debug)) {
563
+        if ( ! is_null($set_debug)) {
564 564
             $is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN);
565 565
         }
566 566
 
@@ -627,13 +627,13 @@  discard block
 block discarded – undo
627 627
             )
628 628
         );
629 629
 
630
-        if (! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
630
+        if ( ! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
631 631
             global $wpdb;
632 632
             $number_deleted = $wpdb->query('
633 633
                 DELETE
634
-                FROM ' . $this->table() . '
634
+                FROM ' . $this->table().'
635 635
                 WHERE
636
-                    MSG_ID IN (' . implode(",", $message_ids_to_delete) . ')
636
+                    MSG_ID IN (' . implode(",", $message_ids_to_delete).')
637 637
             ');
638 638
         }
639 639
 
Please login to merge, or discard this patch.
Indentation   +640 added lines, -640 removed lines patch added patch discarded remove patch
@@ -12,649 +12,649 @@
 block discarded – undo
12 12
  */
13 13
 class EEM_Message extends EEM_Base implements EEI_Query_Filter
14 14
 {
15
-    // private instance of the Message object
16
-    protected static $_instance = null;
17
-
18
-
19
-    /**
20
-     * This priority indicates a message should be generated and sent ASAP
21
-     *
22
-     * @type int
23
-     */
24
-    const priority_high = 10;
25
-
26
-
27
-    /**
28
-     * This priority indicates a message should be generated ASAP and queued for sending.
29
-     *
30
-     * @type
31
-     */
32
-    const priority_medium = 20;
33
-
34
-
35
-    /**
36
-     * This priority indicates a message should be queued for generating.
37
-     *
38
-     * @type int
39
-     */
40
-    const priority_low = 30;
41
-
42
-
43
-    /**
44
-     * indicates this message was sent at the time modified
45
-     */
46
-    const status_sent = 'MSN';
47
-
48
-
49
-    /**
50
-     * indicates this message is waiting to be sent
51
-     */
52
-    const status_idle = 'MID';
53
-
54
-
55
-    /**
56
-     * indicates an attempt was a made to send this message
57
-     * at the scheduled time, but it failed at the time modified.  This differs from MDO status in that it will ALWAYS
58
-     * appear to the end user.
59
-     */
60
-    const status_failed = 'MFL';
61
-
62
-
63
-    /**
64
-     * indicates the message has been flagged for resending (at the time modified).
65
-     */
66
-    const status_resend = 'MRS';
67
-
68
-
69
-    /**
70
-     * indicates the message has been flagged for generation but has not been generated yet.  Messages always start as
71
-     * this status when added to the queue.
72
-     */
73
-    const status_incomplete = 'MIC';
74
-
75
-
76
-    /**
77
-     * Indicates everything was generated fine for the message, however, the messenger was unable to send.
78
-     * This status means that its possible to retry sending the message.
79
-     */
80
-    const status_retry = 'MRT';
81
-
82
-
83
-    /**
84
-     * This is used for more informational messages that may not indicate anything is broken but still cannot be
85
-     * generated or sent correctly. An example of a message that would get flagged this way would be when a not
86
-     * approved message was queued for generation, but at time of generation, the attached registration(s) are
87
-     * approved. So the message queued for generation is no longer valid.  Messages for this status will only persist
88
-     * in the db and be viewable in the message activity list table when the messages system is in debug mode.
89
-     *
90
-     * @see EEM_Message::debug()
91
-     */
92
-    const status_debug_only = 'MDO';
93
-
94
-
95
-    /**
96
-     * This status is given to messages it is processed by the messenger send method.
97
-     * Messages with this status should rarely be seen in the Message List table, but if they are, that's usually
98
-     * indicative of a PHP timeout or memory limit issue.
99
-     */
100
-    const status_messenger_executing = 'MEX';
101
-
102
-
103
-    /**
104
-     *    Private constructor to prevent direct creation.
105
-     *
106
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and
107
-     *                         any incoming timezone data that gets saved).  Note this just sends the timezone info to
108
-     *                         the date time model field objects.  Default is null (and will be assumed using the set
109
-     *                         timezone in the 'timezone_string' wp option)
110
-     * @throws EE_Error
111
-     * @throws EE_Error
112
-     * @throws EE_Error
113
-     */
114
-    protected function __construct($timezone = null)
115
-    {
116
-        $this->singular_item = esc_html__('Message', 'event_espresso');
117
-        $this->plural_item   = esc_html__('Messages', 'event_espresso');
118
-
119
-        $this->_tables = array(
120
-            'Message' => new EE_Primary_Table('esp_message', 'MSG_ID'),
121
-        );
122
-
123
-        $allowed_priority = array(
124
-            self::priority_high   => esc_html__('high', 'event_espresso'),
125
-            self::priority_medium => esc_html__('medium', 'event_espresso'),
126
-            self::priority_low    => esc_html__('low', 'event_espresso'),
127
-        );
128
-
129
-        $this->_fields          = array(
130
-            'Message' => array(
131
-                'MSG_ID'             => new EE_Primary_Key_Int_Field('MSG_ID', esc_html__('Message ID', 'event_espresso')),
132
-                'MSG_token'          => new EE_Plain_Text_Field(
133
-                    'MSG_token',
134
-                    esc_html__(
135
-                        'Unique Token used to represent this row in publicly viewable contexts (eg. a url).',
136
-                        'event_espresso'
137
-                    ),
138
-                    false,
139
-                    EEH_URL::generate_unique_token()
140
-                ),
141
-                'GRP_ID'             => new EE_Foreign_Key_Int_Field(
142
-                    'GRP_ID',
143
-                    esc_html__('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'),
144
-                    true,
145
-                    0,
146
-                    'Message_Template_Group'
147
-                ),
148
-                'TXN_ID'             => new EE_Foreign_Key_Int_Field(
149
-                    'TXN_ID',
150
-                    esc_html__(
151
-                        'Foreign key to the related EE_Transaction.  This is required to give context for regenerating the specific message',
152
-                        'event_espresso'
153
-                    ),
154
-                    true,
155
-                    0,
156
-                    'Transaction'
157
-                ),
158
-                'MSG_messenger'      => new EE_Plain_Text_Field(
159
-                    'MSG_messenger',
160
-                    esc_html__(
161
-                        'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.',
162
-                        'event_espresso'
163
-                    ),
164
-                    false,
165
-                    'email'
166
-                ),
167
-                'MSG_message_type'   => new EE_Plain_Text_Field(
168
-                    'MSG_message_type',
169
-                    esc_html__('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'),
170
-                    false,
171
-                    'receipt'
172
-                ),
173
-                'MSG_context'        => new EE_Plain_Text_Field('MSG_context', esc_html__('Context', 'event_espresso'), false),
174
-                'MSG_recipient_ID'   => new EE_Foreign_Key_Int_Field(
175
-                    'MSG_recipient_ID',
176
-                    esc_html__('Recipient ID', 'event_espresso'),
177
-                    true,
178
-                    null,
179
-                    array('Registration', 'Attendee', 'WP_User')
180
-                ),
181
-                'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field(
182
-                    'MSG_recipient_type',
183
-                    esc_html__('Recipient Type', 'event_espresso'),
184
-                    true,
185
-                    null,
186
-                    array('Registration', 'Attendee', 'WP_User')
187
-                ),
188
-                'MSG_content'        => new EE_Maybe_Serialized_Text_Field(
189
-                    'MSG_content',
190
-                    esc_html__('Content', 'event_espresso'),
191
-                    true,
192
-                    ''
193
-                ),
194
-                'MSG_to'             => new EE_Maybe_Serialized_Text_Field(
195
-                    'MSG_to',
196
-                    esc_html__('Address To', 'event_espresso'),
197
-                    true
198
-                ),
199
-                'MSG_from'           => new EE_Maybe_Serialized_Text_Field(
200
-                    'MSG_from',
201
-                    esc_html__('Address From', 'event_espresso'),
202
-                    true
203
-                ),
204
-                'MSG_subject'        => new EE_Maybe_Serialized_Text_Field(
205
-                    'MSG_subject',
206
-                    esc_html__('Subject', 'event_espresso'),
207
-                    true,
208
-                    ''
209
-                ),
210
-                'MSG_priority'       => new EE_Enum_Integer_Field(
211
-                    'MSG_priority',
212
-                    esc_html__('Priority', 'event_espresso'),
213
-                    false,
214
-                    self::priority_low,
215
-                    $allowed_priority
216
-                ),
217
-                'STS_ID'             => new EE_Foreign_Key_String_Field(
218
-                    'STS_ID',
219
-                    esc_html__('Status', 'event_espresso'),
220
-                    false,
221
-                    self::status_incomplete,
222
-                    'Status'
223
-                ),
224
-                'MSG_created'        => new EE_Datetime_Field(
225
-                    'MSG_created',
226
-                    esc_html__('Created', 'event_espresso'),
227
-                    false,
228
-                    EE_Datetime_Field::now
229
-                ),
230
-                'MSG_modified'       => new EE_Datetime_Field(
231
-                    'MSG_modified',
232
-                    esc_html__('Modified', 'event_espresso'),
233
-                    true,
234
-                    EE_Datetime_Field::now
235
-                ),
236
-            ),
237
-        );
238
-        $this->_model_relations = array(
239
-            'Attendee'               => new EE_Belongs_To_Any_Relation(),
240
-            'Registration'           => new EE_Belongs_To_Any_Relation(),
241
-            'WP_User'                => new EE_Belongs_To_Any_Relation(),
242
-            'Message_Template_Group' => new EE_Belongs_To_Relation(),
243
-            'Transaction'            => new EE_Belongs_To_Relation(),
244
-        );
245
-        parent::__construct($timezone);
246
-    }
247
-
248
-
249
-    /**
250
-     * @return EE_Message
251
-     * @throws EE_Error
252
-     */
253
-    public function create_default_object()
254
-    {
255
-        /** @type EE_Message $message */
256
-        $message = parent::create_default_object();
257
-        if ($message instanceof EE_Message) {
258
-            return EE_Message_Factory::set_messenger_and_message_type($message);
259
-        }
260
-        return null;
261
-    }
262
-
263
-
264
-    /**
265
-     * @param mixed $cols_n_values
266
-     * @return EE_Message
267
-     * @throws EE_Error
268
-     * @throws EE_Error
269
-     */
270
-    public function instantiate_class_from_array_or_object($cols_n_values)
271
-    {
272
-        /** @type EE_Message $message */
273
-        $message = parent::instantiate_class_from_array_or_object($cols_n_values);
274
-        if ($message instanceof EE_Message) {
275
-            return EE_Message_Factory::set_messenger_and_message_type($message);
276
-        }
277
-        return null;
278
-    }
279
-
280
-
281
-    /**
282
-     * Returns whether or not a message of that type was sent for a given attendee.
283
-     *
284
-     * @param EE_Attendee|int $attendee
285
-     * @param string          $message_type the message type slug
286
-     * @return boolean
287
-     * @throws EE_Error
288
-     * @throws EE_Error
289
-     * @throws EE_Error
290
-     */
291
-    public function message_sent_for_attendee($attendee, $message_type)
292
-    {
293
-        $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee);
294
-        return $this->exists(array(
295
-            array(
296
-                'Attendee.ATT_ID'  => $attendee_ID,
297
-                'MSG_message_type' => $message_type,
298
-                'STS_ID'           => array('IN', $this->stati_indicating_sent()),
299
-            ),
300
-        ));
301
-    }
302
-
303
-
304
-    /**
305
-     * Returns whether or not a message of that type was sent for a given registration
306
-     *
307
-     * @param EE_Registration|int $registration
308
-     * @param string              $message_type the message type slug
309
-     * @return boolean
310
-     * @throws EE_Error
311
-     * @throws EE_Error
312
-     * @throws EE_Error
313
-     */
314
-    public function message_sent_for_registration($registration, $message_type)
315
-    {
316
-        $registrationID = EEM_Registration::instance()->ensure_is_ID($registration);
317
-        return $this->exists(array(
318
-            array(
319
-                'Registration.REG_ID' => $registrationID,
320
-                'MSG_message_type'    => $message_type,
321
-                'STS_ID'              => array('IN', $this->stati_indicating_sent()),
322
-            ),
323
-        ));
324
-    }
325
-
326
-
327
-    /**
328
-     * This retrieves an EE_Message object from the db matching the given token string.
329
-     *
330
-     * @param string $token
331
-     * @return EE_Message
332
-     * @throws EE_Error
333
-     */
334
-    public function get_one_by_token($token)
335
-    {
336
-        return $this->get_one(array(
337
-            array(
338
-                'MSG_token' => $token,
339
-            ),
340
-        ));
341
-    }
342
-
343
-
344
-    /**
345
-     * Returns stati that indicate the message HAS been sent
346
-     *
347
-     * @return array of strings for possible stati
348
-     */
349
-    public function stati_indicating_sent()
350
-    {
351
-        return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent));
352
-    }
353
-
354
-
355
-    /**
356
-     * Returns stati that indicate the message is waiting to be sent.
357
-     *
358
-     * @return array of strings for possible stati.
359
-     */
360
-    public function stati_indicating_to_send()
361
-    {
362
-        return apply_filters(
363
-            'FHEE__EEM_Message__stati_indicating_to_send',
364
-            array(self::status_idle, self::status_resend)
365
-        );
366
-    }
367
-
368
-
369
-    /**
370
-     * Returns stati that indicate the message has failed sending
371
-     *
372
-     * @return array  array of strings for possible stati.
373
-     */
374
-    public function stati_indicating_failed_sending()
375
-    {
376
-        $failed_stati = array(
377
-            self::status_failed,
378
-            self::status_retry,
379
-            self::status_messenger_executing,
380
-        );
381
-        // if WP_DEBUG is set, then let's include debug_only fails
382
-        if (WP_DEBUG) {
383
-            $failed_stati[] = self::status_debug_only;
384
-        }
385
-        return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati);
386
-    }
387
-
388
-
389
-    /**
390
-     * Returns filterable array of all EEM_Message statuses.
391
-     *
392
-     * @return array
393
-     */
394
-    public function all_statuses()
395
-    {
396
-        return apply_filters(
397
-            'FHEE__EEM_Message__all_statuses',
398
-            array(
399
-                EEM_Message::status_sent,
400
-                EEM_Message::status_incomplete,
401
-                EEM_Message::status_idle,
402
-                EEM_Message::status_resend,
403
-                EEM_Message::status_retry,
404
-                EEM_Message::status_failed,
405
-                EEM_Message::status_messenger_executing,
406
-                EEM_Message::status_debug_only,
407
-            )
408
-        );
409
-    }
410
-
411
-    /**
412
-     * Detects any specific query variables in the request and uses those to setup appropriate
413
-     * filter for any queries.
414
-     *
415
-     * @return array
416
-     */
417
-    public function filter_by_query_params()
418
-    {
419
-        /** @var RequestInterface $request */
420
-        $request = EEM_Base::$loader->getShared(RequestInterface::class);
421
-        // expected possible query_vars, the key in this array matches an expected key in the request,
422
-        // the value, matches the corresponding EEM_Base child reference.
423
-        $expected_vars   = $this->_expected_vars_for_query_inject();
424
-        $query_params[0] = array();
425
-        foreach ($expected_vars as $request_key => $model_name) {
426
-            $request_value = $request->getRequestParam($request_key);
427
-            if ($request_value) {
428
-                // special case
429
-                switch ($request_key) {
430
-                    case '_REG_ID':
431
-                        $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array(
432
-                            'Transaction.Registration.REG_ID' => $request_value,
433
-                        );
434
-                        break;
435
-                    case 'EVT_ID':
436
-                        $query_params[0]['AND**filter_by']['OR**filter_by_EVT_ID'] = array(
437
-                            'Transaction.Registration.EVT_ID' => $request_value,
438
-                        );
439
-                        break;
440
-                    default:
441
-                        $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value;
442
-                        break;
443
-                }
444
-            }
445
-        }
446
-        return $query_params;
447
-    }
448
-
449
-
450
-    /**
451
-     * @return string
452
-     * @throws EE_Error
453
-     * @throws ReflectionException
454
-     */
455
-    public function get_pretty_label_for_results()
456
-    {
457
-        /** @var RequestInterface $request */
458
-        $request = EEM_Base::$loader->getShared(RequestInterface::class);
459
-        $expected_vars = $this->_expected_vars_for_query_inject();
460
-        $pretty_label  = '';
461
-        $label_parts   = array();
462
-        foreach ($expected_vars as $request_key => $model_name) {
463
-            $model_name = strpos($model_name, 'EEM_', true) === 0 ? $model_name : "EEM_{$model_name}";
464
-            $model = EEM_Base::$loader->getShared($model_name);
465
-            $model_field_value = $request->getRequestParam($request_key);
466
-            if ($model instanceof EEM_Base && $model_field_value !== '') {
467
-                switch ($request_key) {
468
-                    case '_REG_ID':
469
-                        $label_parts[] = sprintf(
470
-                            esc_html__('Registration with the ID: %s', 'event_espresso'),
471
-                            $model_field_value
472
-                        );
473
-                        break;
474
-                    case 'ATT_ID':
475
-                        /** @var EE_Attendee $attendee */
476
-                        $attendee      = $model->get_one_by_ID($model_field_value);
477
-                        $label_parts[] = $attendee instanceof EE_Attendee
478
-                            ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name())
479
-                            : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value);
480
-                        break;
481
-                    case 'ID':
482
-                        /** @var EE_WP_User $wpUser */
483
-                        $wpUser        = $model->get_one_by_ID($model_field_value);
484
-                        $label_parts[] = $wpUser instanceof EE_WP_User
485
-                            ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name())
486
-                            : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value);
487
-                        break;
488
-                    case 'TXN_ID':
489
-                        $label_parts[] = sprintf(
490
-                            esc_html__('Transaction with the ID: %s', 'event_espresso'),
491
-                            $model_field_value
492
-                        );
493
-                        break;
494
-                    case 'EVT_ID':
495
-                        /** @var EE_Event $Event */
496
-                        $Event         = $model->get_one_by_ID($model_field_value);
497
-                        $label_parts[] = $Event instanceof EE_Event
498
-                            ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name())
499
-                            : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value);
500
-                        break;
501
-                }
502
-            }
503
-        }
504
-
505
-        if ($label_parts) {
506
-            // prepend to the last element of $label_parts an "and".
507
-            if (count($label_parts) > 1) {
508
-                $label_parts_index_to_prepend               = count($label_parts) - 1;
509
-                $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ];
510
-            }
511
-
512
-            $pretty_label .= sprintf(
513
-                esc_html_x(
514
-                    'Showing messages for %s',
515
-                    'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.',
516
-                    'event_espresso'
517
-                ),
518
-                implode(', ', $label_parts)
519
-            );
520
-        }
521
-        return $pretty_label;
522
-    }
523
-
524
-
525
-    /**
526
-     * This returns the array of expected variables for the EEI_Query_Filter methods being implemented
527
-     * The array is in the format:
528
-     * array(
529
-     *  {$field_name} => {$model_name}
530
-     * );
531
-     *
532
-     * @since 4.9.0
533
-     * @return array
534
-     */
535
-    protected function _expected_vars_for_query_inject()
536
-    {
537
-        return array(
538
-            '_REG_ID' => 'Registration',
539
-            'ATT_ID'  => 'Attendee',
540
-            'ID'      => 'WP_User',
541
-            'TXN_ID'  => 'Transaction',
542
-            'EVT_ID'  => 'Event',
543
-        );
544
-    }
545
-
546
-
547
-    /**
548
-     * This returns whether EEM_Message is in debug mode or not.
549
-     * Currently "debug mode" is used to control the handling of the EEM_Message::debug_only status when
550
-     * generating/sending messages. Debug mode can be set by either:
551
-     * 1. Sending in a value for the $set_debug argument
552
-     * 2. Defining `EE_DEBUG_MESSAGES` constant in wp-config.php
553
-     * 3. Overriding the above via the provided filter.
554
-     *
555
-     * @param bool|null $set_debug      If provided, then the debug mode will be set internally until reset via the
556
-     *                                  provided boolean. When no argument is provided (default null) then the debug
557
-     *                                  mode will be returned.
558
-     * @return bool         true means Messages is in debug mode.  false means messages system is not in debug mode.
559
-     */
560
-    public static function debug($set_debug = null)
561
-    {
562
-        static $is_debugging = null;
563
-
564
-        // initialize (use constant if set).
565
-        if (is_null($set_debug) && is_null($is_debugging)) {
566
-            $is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES;
567
-        }
568
-
569
-        if (! is_null($set_debug)) {
570
-            $is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN);
571
-        }
572
-
573
-        // return filtered value
574
-        return apply_filters('FHEE__EEM_Message__debug', $is_debugging);
575
-    }
576
-
577
-
578
-    /**
579
-     * Deletes old messages meeting certain criteria for removal from the database.
580
-     * By default, this will delete messages that:
581
-     * - are older than the value of the delete_threshold in months.
582
-     * - have a STS_ID other than EEM_Message::status_idle
583
-     *
584
-     * @param int $delete_threshold This integer will be used to set the boundary for what messages are deleted in
585
-     *                              months.
586
-     * @return bool|false|int Either the number of records affected or false if there was an error (you can call
587
-     *                              $wpdb->last_error to find out what the error was.
588
-     * @throws EE_Error
589
-     * @throws EE_Error
590
-     * @throws EE_Error
591
-     */
592
-    public function delete_old_messages($delete_threshold = 6)
593
-    {
594
-        $number_deleted = 0;
595
-        /**
596
-         * Allows code to change the boundary for what messages are kept.
597
-         * Uses the value of the `delete_threshold` variable by default.
598
-         *
599
-         * @param int $seconds seconds that will be subtracted from the timestamp for now.
600
-         * @return int
601
-         */
602
-        $time_to_leave_alone = absint(
603
-            apply_filters(
604
-                'FHEE__EEM_Message__delete_old_messages__time_to_leave_alone',
605
-                ((int) $delete_threshold) * MONTH_IN_SECONDS
606
-            )
607
-        );
608
-
609
-
610
-        /**
611
-         * Allows code to change what message stati are ignored when deleting.
612
-         * Defaults to only ignore EEM_Message::status_idle messages.
613
-         *
614
-         * @param string $message_stati_to_keep  An array of message statuses that will be ignored when deleting.
615
-         */
616
-        $message_stati_to_keep = (array) apply_filters(
617
-            'FHEE__EEM_Message__delete_old_messages__message_stati_to_keep',
618
-            array(
619
-                EEM_Message::status_idle
620
-            )
621
-        );
622
-
623
-        // first get all the ids of messages being deleted
624
-        $message_ids_to_delete = EEM_Message::instance()->get_col(
625
-            array(
626
-                0 => array(
627
-                    'STS_ID' => array('NOT_IN', $message_stati_to_keep),
628
-                    'MSG_modified' => array('<', time() - $time_to_leave_alone)
629
-                ),
630
-                'limit' => apply_filters(
631
-                    'EEM_Message__delete_old_messages__limit',
632
-                    2000,
633
-                    $delete_threshold
634
-                )
635
-            )
636
-        );
637
-
638
-        if (! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
639
-            global $wpdb;
640
-            $number_deleted = $wpdb->query('
15
+	// private instance of the Message object
16
+	protected static $_instance = null;
17
+
18
+
19
+	/**
20
+	 * This priority indicates a message should be generated and sent ASAP
21
+	 *
22
+	 * @type int
23
+	 */
24
+	const priority_high = 10;
25
+
26
+
27
+	/**
28
+	 * This priority indicates a message should be generated ASAP and queued for sending.
29
+	 *
30
+	 * @type
31
+	 */
32
+	const priority_medium = 20;
33
+
34
+
35
+	/**
36
+	 * This priority indicates a message should be queued for generating.
37
+	 *
38
+	 * @type int
39
+	 */
40
+	const priority_low = 30;
41
+
42
+
43
+	/**
44
+	 * indicates this message was sent at the time modified
45
+	 */
46
+	const status_sent = 'MSN';
47
+
48
+
49
+	/**
50
+	 * indicates this message is waiting to be sent
51
+	 */
52
+	const status_idle = 'MID';
53
+
54
+
55
+	/**
56
+	 * indicates an attempt was a made to send this message
57
+	 * at the scheduled time, but it failed at the time modified.  This differs from MDO status in that it will ALWAYS
58
+	 * appear to the end user.
59
+	 */
60
+	const status_failed = 'MFL';
61
+
62
+
63
+	/**
64
+	 * indicates the message has been flagged for resending (at the time modified).
65
+	 */
66
+	const status_resend = 'MRS';
67
+
68
+
69
+	/**
70
+	 * indicates the message has been flagged for generation but has not been generated yet.  Messages always start as
71
+	 * this status when added to the queue.
72
+	 */
73
+	const status_incomplete = 'MIC';
74
+
75
+
76
+	/**
77
+	 * Indicates everything was generated fine for the message, however, the messenger was unable to send.
78
+	 * This status means that its possible to retry sending the message.
79
+	 */
80
+	const status_retry = 'MRT';
81
+
82
+
83
+	/**
84
+	 * This is used for more informational messages that may not indicate anything is broken but still cannot be
85
+	 * generated or sent correctly. An example of a message that would get flagged this way would be when a not
86
+	 * approved message was queued for generation, but at time of generation, the attached registration(s) are
87
+	 * approved. So the message queued for generation is no longer valid.  Messages for this status will only persist
88
+	 * in the db and be viewable in the message activity list table when the messages system is in debug mode.
89
+	 *
90
+	 * @see EEM_Message::debug()
91
+	 */
92
+	const status_debug_only = 'MDO';
93
+
94
+
95
+	/**
96
+	 * This status is given to messages it is processed by the messenger send method.
97
+	 * Messages with this status should rarely be seen in the Message List table, but if they are, that's usually
98
+	 * indicative of a PHP timeout or memory limit issue.
99
+	 */
100
+	const status_messenger_executing = 'MEX';
101
+
102
+
103
+	/**
104
+	 *    Private constructor to prevent direct creation.
105
+	 *
106
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and
107
+	 *                         any incoming timezone data that gets saved).  Note this just sends the timezone info to
108
+	 *                         the date time model field objects.  Default is null (and will be assumed using the set
109
+	 *                         timezone in the 'timezone_string' wp option)
110
+	 * @throws EE_Error
111
+	 * @throws EE_Error
112
+	 * @throws EE_Error
113
+	 */
114
+	protected function __construct($timezone = null)
115
+	{
116
+		$this->singular_item = esc_html__('Message', 'event_espresso');
117
+		$this->plural_item   = esc_html__('Messages', 'event_espresso');
118
+
119
+		$this->_tables = array(
120
+			'Message' => new EE_Primary_Table('esp_message', 'MSG_ID'),
121
+		);
122
+
123
+		$allowed_priority = array(
124
+			self::priority_high   => esc_html__('high', 'event_espresso'),
125
+			self::priority_medium => esc_html__('medium', 'event_espresso'),
126
+			self::priority_low    => esc_html__('low', 'event_espresso'),
127
+		);
128
+
129
+		$this->_fields          = array(
130
+			'Message' => array(
131
+				'MSG_ID'             => new EE_Primary_Key_Int_Field('MSG_ID', esc_html__('Message ID', 'event_espresso')),
132
+				'MSG_token'          => new EE_Plain_Text_Field(
133
+					'MSG_token',
134
+					esc_html__(
135
+						'Unique Token used to represent this row in publicly viewable contexts (eg. a url).',
136
+						'event_espresso'
137
+					),
138
+					false,
139
+					EEH_URL::generate_unique_token()
140
+				),
141
+				'GRP_ID'             => new EE_Foreign_Key_Int_Field(
142
+					'GRP_ID',
143
+					esc_html__('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'),
144
+					true,
145
+					0,
146
+					'Message_Template_Group'
147
+				),
148
+				'TXN_ID'             => new EE_Foreign_Key_Int_Field(
149
+					'TXN_ID',
150
+					esc_html__(
151
+						'Foreign key to the related EE_Transaction.  This is required to give context for regenerating the specific message',
152
+						'event_espresso'
153
+					),
154
+					true,
155
+					0,
156
+					'Transaction'
157
+				),
158
+				'MSG_messenger'      => new EE_Plain_Text_Field(
159
+					'MSG_messenger',
160
+					esc_html__(
161
+						'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.',
162
+						'event_espresso'
163
+					),
164
+					false,
165
+					'email'
166
+				),
167
+				'MSG_message_type'   => new EE_Plain_Text_Field(
168
+					'MSG_message_type',
169
+					esc_html__('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'),
170
+					false,
171
+					'receipt'
172
+				),
173
+				'MSG_context'        => new EE_Plain_Text_Field('MSG_context', esc_html__('Context', 'event_espresso'), false),
174
+				'MSG_recipient_ID'   => new EE_Foreign_Key_Int_Field(
175
+					'MSG_recipient_ID',
176
+					esc_html__('Recipient ID', 'event_espresso'),
177
+					true,
178
+					null,
179
+					array('Registration', 'Attendee', 'WP_User')
180
+				),
181
+				'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field(
182
+					'MSG_recipient_type',
183
+					esc_html__('Recipient Type', 'event_espresso'),
184
+					true,
185
+					null,
186
+					array('Registration', 'Attendee', 'WP_User')
187
+				),
188
+				'MSG_content'        => new EE_Maybe_Serialized_Text_Field(
189
+					'MSG_content',
190
+					esc_html__('Content', 'event_espresso'),
191
+					true,
192
+					''
193
+				),
194
+				'MSG_to'             => new EE_Maybe_Serialized_Text_Field(
195
+					'MSG_to',
196
+					esc_html__('Address To', 'event_espresso'),
197
+					true
198
+				),
199
+				'MSG_from'           => new EE_Maybe_Serialized_Text_Field(
200
+					'MSG_from',
201
+					esc_html__('Address From', 'event_espresso'),
202
+					true
203
+				),
204
+				'MSG_subject'        => new EE_Maybe_Serialized_Text_Field(
205
+					'MSG_subject',
206
+					esc_html__('Subject', 'event_espresso'),
207
+					true,
208
+					''
209
+				),
210
+				'MSG_priority'       => new EE_Enum_Integer_Field(
211
+					'MSG_priority',
212
+					esc_html__('Priority', 'event_espresso'),
213
+					false,
214
+					self::priority_low,
215
+					$allowed_priority
216
+				),
217
+				'STS_ID'             => new EE_Foreign_Key_String_Field(
218
+					'STS_ID',
219
+					esc_html__('Status', 'event_espresso'),
220
+					false,
221
+					self::status_incomplete,
222
+					'Status'
223
+				),
224
+				'MSG_created'        => new EE_Datetime_Field(
225
+					'MSG_created',
226
+					esc_html__('Created', 'event_espresso'),
227
+					false,
228
+					EE_Datetime_Field::now
229
+				),
230
+				'MSG_modified'       => new EE_Datetime_Field(
231
+					'MSG_modified',
232
+					esc_html__('Modified', 'event_espresso'),
233
+					true,
234
+					EE_Datetime_Field::now
235
+				),
236
+			),
237
+		);
238
+		$this->_model_relations = array(
239
+			'Attendee'               => new EE_Belongs_To_Any_Relation(),
240
+			'Registration'           => new EE_Belongs_To_Any_Relation(),
241
+			'WP_User'                => new EE_Belongs_To_Any_Relation(),
242
+			'Message_Template_Group' => new EE_Belongs_To_Relation(),
243
+			'Transaction'            => new EE_Belongs_To_Relation(),
244
+		);
245
+		parent::__construct($timezone);
246
+	}
247
+
248
+
249
+	/**
250
+	 * @return EE_Message
251
+	 * @throws EE_Error
252
+	 */
253
+	public function create_default_object()
254
+	{
255
+		/** @type EE_Message $message */
256
+		$message = parent::create_default_object();
257
+		if ($message instanceof EE_Message) {
258
+			return EE_Message_Factory::set_messenger_and_message_type($message);
259
+		}
260
+		return null;
261
+	}
262
+
263
+
264
+	/**
265
+	 * @param mixed $cols_n_values
266
+	 * @return EE_Message
267
+	 * @throws EE_Error
268
+	 * @throws EE_Error
269
+	 */
270
+	public function instantiate_class_from_array_or_object($cols_n_values)
271
+	{
272
+		/** @type EE_Message $message */
273
+		$message = parent::instantiate_class_from_array_or_object($cols_n_values);
274
+		if ($message instanceof EE_Message) {
275
+			return EE_Message_Factory::set_messenger_and_message_type($message);
276
+		}
277
+		return null;
278
+	}
279
+
280
+
281
+	/**
282
+	 * Returns whether or not a message of that type was sent for a given attendee.
283
+	 *
284
+	 * @param EE_Attendee|int $attendee
285
+	 * @param string          $message_type the message type slug
286
+	 * @return boolean
287
+	 * @throws EE_Error
288
+	 * @throws EE_Error
289
+	 * @throws EE_Error
290
+	 */
291
+	public function message_sent_for_attendee($attendee, $message_type)
292
+	{
293
+		$attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee);
294
+		return $this->exists(array(
295
+			array(
296
+				'Attendee.ATT_ID'  => $attendee_ID,
297
+				'MSG_message_type' => $message_type,
298
+				'STS_ID'           => array('IN', $this->stati_indicating_sent()),
299
+			),
300
+		));
301
+	}
302
+
303
+
304
+	/**
305
+	 * Returns whether or not a message of that type was sent for a given registration
306
+	 *
307
+	 * @param EE_Registration|int $registration
308
+	 * @param string              $message_type the message type slug
309
+	 * @return boolean
310
+	 * @throws EE_Error
311
+	 * @throws EE_Error
312
+	 * @throws EE_Error
313
+	 */
314
+	public function message_sent_for_registration($registration, $message_type)
315
+	{
316
+		$registrationID = EEM_Registration::instance()->ensure_is_ID($registration);
317
+		return $this->exists(array(
318
+			array(
319
+				'Registration.REG_ID' => $registrationID,
320
+				'MSG_message_type'    => $message_type,
321
+				'STS_ID'              => array('IN', $this->stati_indicating_sent()),
322
+			),
323
+		));
324
+	}
325
+
326
+
327
+	/**
328
+	 * This retrieves an EE_Message object from the db matching the given token string.
329
+	 *
330
+	 * @param string $token
331
+	 * @return EE_Message
332
+	 * @throws EE_Error
333
+	 */
334
+	public function get_one_by_token($token)
335
+	{
336
+		return $this->get_one(array(
337
+			array(
338
+				'MSG_token' => $token,
339
+			),
340
+		));
341
+	}
342
+
343
+
344
+	/**
345
+	 * Returns stati that indicate the message HAS been sent
346
+	 *
347
+	 * @return array of strings for possible stati
348
+	 */
349
+	public function stati_indicating_sent()
350
+	{
351
+		return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent));
352
+	}
353
+
354
+
355
+	/**
356
+	 * Returns stati that indicate the message is waiting to be sent.
357
+	 *
358
+	 * @return array of strings for possible stati.
359
+	 */
360
+	public function stati_indicating_to_send()
361
+	{
362
+		return apply_filters(
363
+			'FHEE__EEM_Message__stati_indicating_to_send',
364
+			array(self::status_idle, self::status_resend)
365
+		);
366
+	}
367
+
368
+
369
+	/**
370
+	 * Returns stati that indicate the message has failed sending
371
+	 *
372
+	 * @return array  array of strings for possible stati.
373
+	 */
374
+	public function stati_indicating_failed_sending()
375
+	{
376
+		$failed_stati = array(
377
+			self::status_failed,
378
+			self::status_retry,
379
+			self::status_messenger_executing,
380
+		);
381
+		// if WP_DEBUG is set, then let's include debug_only fails
382
+		if (WP_DEBUG) {
383
+			$failed_stati[] = self::status_debug_only;
384
+		}
385
+		return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati);
386
+	}
387
+
388
+
389
+	/**
390
+	 * Returns filterable array of all EEM_Message statuses.
391
+	 *
392
+	 * @return array
393
+	 */
394
+	public function all_statuses()
395
+	{
396
+		return apply_filters(
397
+			'FHEE__EEM_Message__all_statuses',
398
+			array(
399
+				EEM_Message::status_sent,
400
+				EEM_Message::status_incomplete,
401
+				EEM_Message::status_idle,
402
+				EEM_Message::status_resend,
403
+				EEM_Message::status_retry,
404
+				EEM_Message::status_failed,
405
+				EEM_Message::status_messenger_executing,
406
+				EEM_Message::status_debug_only,
407
+			)
408
+		);
409
+	}
410
+
411
+	/**
412
+	 * Detects any specific query variables in the request and uses those to setup appropriate
413
+	 * filter for any queries.
414
+	 *
415
+	 * @return array
416
+	 */
417
+	public function filter_by_query_params()
418
+	{
419
+		/** @var RequestInterface $request */
420
+		$request = EEM_Base::$loader->getShared(RequestInterface::class);
421
+		// expected possible query_vars, the key in this array matches an expected key in the request,
422
+		// the value, matches the corresponding EEM_Base child reference.
423
+		$expected_vars   = $this->_expected_vars_for_query_inject();
424
+		$query_params[0] = array();
425
+		foreach ($expected_vars as $request_key => $model_name) {
426
+			$request_value = $request->getRequestParam($request_key);
427
+			if ($request_value) {
428
+				// special case
429
+				switch ($request_key) {
430
+					case '_REG_ID':
431
+						$query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array(
432
+							'Transaction.Registration.REG_ID' => $request_value,
433
+						);
434
+						break;
435
+					case 'EVT_ID':
436
+						$query_params[0]['AND**filter_by']['OR**filter_by_EVT_ID'] = array(
437
+							'Transaction.Registration.EVT_ID' => $request_value,
438
+						);
439
+						break;
440
+					default:
441
+						$query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value;
442
+						break;
443
+				}
444
+			}
445
+		}
446
+		return $query_params;
447
+	}
448
+
449
+
450
+	/**
451
+	 * @return string
452
+	 * @throws EE_Error
453
+	 * @throws ReflectionException
454
+	 */
455
+	public function get_pretty_label_for_results()
456
+	{
457
+		/** @var RequestInterface $request */
458
+		$request = EEM_Base::$loader->getShared(RequestInterface::class);
459
+		$expected_vars = $this->_expected_vars_for_query_inject();
460
+		$pretty_label  = '';
461
+		$label_parts   = array();
462
+		foreach ($expected_vars as $request_key => $model_name) {
463
+			$model_name = strpos($model_name, 'EEM_', true) === 0 ? $model_name : "EEM_{$model_name}";
464
+			$model = EEM_Base::$loader->getShared($model_name);
465
+			$model_field_value = $request->getRequestParam($request_key);
466
+			if ($model instanceof EEM_Base && $model_field_value !== '') {
467
+				switch ($request_key) {
468
+					case '_REG_ID':
469
+						$label_parts[] = sprintf(
470
+							esc_html__('Registration with the ID: %s', 'event_espresso'),
471
+							$model_field_value
472
+						);
473
+						break;
474
+					case 'ATT_ID':
475
+						/** @var EE_Attendee $attendee */
476
+						$attendee      = $model->get_one_by_ID($model_field_value);
477
+						$label_parts[] = $attendee instanceof EE_Attendee
478
+							? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name())
479
+							: sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value);
480
+						break;
481
+					case 'ID':
482
+						/** @var EE_WP_User $wpUser */
483
+						$wpUser        = $model->get_one_by_ID($model_field_value);
484
+						$label_parts[] = $wpUser instanceof EE_WP_User
485
+							? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name())
486
+							: sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value);
487
+						break;
488
+					case 'TXN_ID':
489
+						$label_parts[] = sprintf(
490
+							esc_html__('Transaction with the ID: %s', 'event_espresso'),
491
+							$model_field_value
492
+						);
493
+						break;
494
+					case 'EVT_ID':
495
+						/** @var EE_Event $Event */
496
+						$Event         = $model->get_one_by_ID($model_field_value);
497
+						$label_parts[] = $Event instanceof EE_Event
498
+							? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name())
499
+							: sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value);
500
+						break;
501
+				}
502
+			}
503
+		}
504
+
505
+		if ($label_parts) {
506
+			// prepend to the last element of $label_parts an "and".
507
+			if (count($label_parts) > 1) {
508
+				$label_parts_index_to_prepend               = count($label_parts) - 1;
509
+				$label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ];
510
+			}
511
+
512
+			$pretty_label .= sprintf(
513
+				esc_html_x(
514
+					'Showing messages for %s',
515
+					'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.',
516
+					'event_espresso'
517
+				),
518
+				implode(', ', $label_parts)
519
+			);
520
+		}
521
+		return $pretty_label;
522
+	}
523
+
524
+
525
+	/**
526
+	 * This returns the array of expected variables for the EEI_Query_Filter methods being implemented
527
+	 * The array is in the format:
528
+	 * array(
529
+	 *  {$field_name} => {$model_name}
530
+	 * );
531
+	 *
532
+	 * @since 4.9.0
533
+	 * @return array
534
+	 */
535
+	protected function _expected_vars_for_query_inject()
536
+	{
537
+		return array(
538
+			'_REG_ID' => 'Registration',
539
+			'ATT_ID'  => 'Attendee',
540
+			'ID'      => 'WP_User',
541
+			'TXN_ID'  => 'Transaction',
542
+			'EVT_ID'  => 'Event',
543
+		);
544
+	}
545
+
546
+
547
+	/**
548
+	 * This returns whether EEM_Message is in debug mode or not.
549
+	 * Currently "debug mode" is used to control the handling of the EEM_Message::debug_only status when
550
+	 * generating/sending messages. Debug mode can be set by either:
551
+	 * 1. Sending in a value for the $set_debug argument
552
+	 * 2. Defining `EE_DEBUG_MESSAGES` constant in wp-config.php
553
+	 * 3. Overriding the above via the provided filter.
554
+	 *
555
+	 * @param bool|null $set_debug      If provided, then the debug mode will be set internally until reset via the
556
+	 *                                  provided boolean. When no argument is provided (default null) then the debug
557
+	 *                                  mode will be returned.
558
+	 * @return bool         true means Messages is in debug mode.  false means messages system is not in debug mode.
559
+	 */
560
+	public static function debug($set_debug = null)
561
+	{
562
+		static $is_debugging = null;
563
+
564
+		// initialize (use constant if set).
565
+		if (is_null($set_debug) && is_null($is_debugging)) {
566
+			$is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES;
567
+		}
568
+
569
+		if (! is_null($set_debug)) {
570
+			$is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN);
571
+		}
572
+
573
+		// return filtered value
574
+		return apply_filters('FHEE__EEM_Message__debug', $is_debugging);
575
+	}
576
+
577
+
578
+	/**
579
+	 * Deletes old messages meeting certain criteria for removal from the database.
580
+	 * By default, this will delete messages that:
581
+	 * - are older than the value of the delete_threshold in months.
582
+	 * - have a STS_ID other than EEM_Message::status_idle
583
+	 *
584
+	 * @param int $delete_threshold This integer will be used to set the boundary for what messages are deleted in
585
+	 *                              months.
586
+	 * @return bool|false|int Either the number of records affected or false if there was an error (you can call
587
+	 *                              $wpdb->last_error to find out what the error was.
588
+	 * @throws EE_Error
589
+	 * @throws EE_Error
590
+	 * @throws EE_Error
591
+	 */
592
+	public function delete_old_messages($delete_threshold = 6)
593
+	{
594
+		$number_deleted = 0;
595
+		/**
596
+		 * Allows code to change the boundary for what messages are kept.
597
+		 * Uses the value of the `delete_threshold` variable by default.
598
+		 *
599
+		 * @param int $seconds seconds that will be subtracted from the timestamp for now.
600
+		 * @return int
601
+		 */
602
+		$time_to_leave_alone = absint(
603
+			apply_filters(
604
+				'FHEE__EEM_Message__delete_old_messages__time_to_leave_alone',
605
+				((int) $delete_threshold) * MONTH_IN_SECONDS
606
+			)
607
+		);
608
+
609
+
610
+		/**
611
+		 * Allows code to change what message stati are ignored when deleting.
612
+		 * Defaults to only ignore EEM_Message::status_idle messages.
613
+		 *
614
+		 * @param string $message_stati_to_keep  An array of message statuses that will be ignored when deleting.
615
+		 */
616
+		$message_stati_to_keep = (array) apply_filters(
617
+			'FHEE__EEM_Message__delete_old_messages__message_stati_to_keep',
618
+			array(
619
+				EEM_Message::status_idle
620
+			)
621
+		);
622
+
623
+		// first get all the ids of messages being deleted
624
+		$message_ids_to_delete = EEM_Message::instance()->get_col(
625
+			array(
626
+				0 => array(
627
+					'STS_ID' => array('NOT_IN', $message_stati_to_keep),
628
+					'MSG_modified' => array('<', time() - $time_to_leave_alone)
629
+				),
630
+				'limit' => apply_filters(
631
+					'EEM_Message__delete_old_messages__limit',
632
+					2000,
633
+					$delete_threshold
634
+				)
635
+			)
636
+		);
637
+
638
+		if (! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
639
+			global $wpdb;
640
+			$number_deleted = $wpdb->query('
641 641
                 DELETE
642 642
                 FROM ' . $this->table() . '
643 643
                 WHERE
644 644
                     MSG_ID IN (' . implode(",", $message_ids_to_delete) . ')
645 645
             ');
646
-        }
647
-
648
-        /**
649
-         * This will get called if the number of records deleted 0 or greater.  So a successful deletion is one where
650
-         * there were no errors.  An unsuccessful deletion is where there were errors.  Keep that in mind for the actions
651
-         * below.
652
-         */
653
-        if ($number_deleted !== false) {
654
-            do_action('AHEE__EEM_Message__delete_old_messages__after_successful_deletion', $message_ids_to_delete, $number_deleted);
655
-        } else {
656
-            do_action('AHEE__EEM_Message__delete_old_messages__after_deletion_fail', $message_ids_to_delete, $number_deleted);
657
-        }
658
-        return $number_deleted;
659
-    }
646
+		}
647
+
648
+		/**
649
+		 * This will get called if the number of records deleted 0 or greater.  So a successful deletion is one where
650
+		 * there were no errors.  An unsuccessful deletion is where there were errors.  Keep that in mind for the actions
651
+		 * below.
652
+		 */
653
+		if ($number_deleted !== false) {
654
+			do_action('AHEE__EEM_Message__delete_old_messages__after_successful_deletion', $message_ids_to_delete, $number_deleted);
655
+		} else {
656
+			do_action('AHEE__EEM_Message__delete_old_messages__after_deletion_fail', $message_ids_to_delete, $number_deleted);
657
+		}
658
+		return $number_deleted;
659
+	}
660 660
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Field_With_Model_Name.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,10 +79,10 @@
 block discarded – undo
79 79
         $model_names = [];
80 80
         if (is_array($this->_model_name_pointed_to)) {
81 81
             foreach ($this->_model_name_pointed_to as $model_name) {
82
-                $model_names[] = "EE_" . $model_name;
82
+                $model_names[] = "EE_".$model_name;
83 83
             }
84 84
         } else {
85
-            $model_names = ["EE_" . $this->_model_name_pointed_to];
85
+            $model_names = ["EE_".$this->_model_name_pointed_to];
86 86
         }
87 87
         return $model_names;
88 88
     }
Please login to merge, or discard this patch.
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -8,94 +8,94 @@
 block discarded – undo
8 8
  */
9 9
 abstract class EE_Field_With_Model_Name extends EE_Model_Field_Base
10 10
 {
11
-    /**
12
-     * Usually the name of a single model. However, as in the case for custom post types,
13
-     * it can actually be an array of models
14
-     *
15
-     * @var string[]
16
-     */
17
-    protected $_model_name_pointed_to;
11
+	/**
12
+	 * Usually the name of a single model. However, as in the case for custom post types,
13
+	 * it can actually be an array of models
14
+	 *
15
+	 * @var string[]
16
+	 */
17
+	protected $_model_name_pointed_to;
18 18
 
19 19
 
20
-    /**
21
-     * @param string          $table_column  name of column for field
22
-     * @param string          $nicename      should be internationalized with __('blah','event_espresso')
23
-     * @param boolean         $nullable
24
-     * @param int|string      $default_value data type should match field type
25
-     * @param string|string[] $model_name    eg 'Event','Answer','Term', etc.
26
-     *                                       Basically its the model class's name without the "EEM_"
27
-     */
28
-    public function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
29
-    {
30
-        $this->_model_name_pointed_to = (array) $model_name;
31
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
32
-    }
20
+	/**
21
+	 * @param string          $table_column  name of column for field
22
+	 * @param string          $nicename      should be internationalized with __('blah','event_espresso')
23
+	 * @param boolean         $nullable
24
+	 * @param int|string      $default_value data type should match field type
25
+	 * @param string|string[] $model_name    eg 'Event','Answer','Term', etc.
26
+	 *                                       Basically its the model class's name without the "EEM_"
27
+	 */
28
+	public function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
29
+	{
30
+		$this->_model_name_pointed_to = (array) $model_name;
31
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
32
+	}
33 33
 
34 34
 
35
-    /**
36
-     * Returns the name of the model(s) pointed to
37
-     *
38
-     * @return string[] string or array of strings
39
-     * @deprecated since version 4.6.7
40
-     */
41
-    public function get_model_name_pointed_to()
42
-    {
43
-        EE_Error::doing_it_wrong(
44
-            'get_model_name_pointed_to',
45
-            esc_html__(
46
-                'This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array',
47
-                'event_espresso'
48
-            ),
49
-            '4.6.7'
50
-        );
51
-        return $this->_model_name_pointed_to;
52
-    }
35
+	/**
36
+	 * Returns the name of the model(s) pointed to
37
+	 *
38
+	 * @return string[] string or array of strings
39
+	 * @deprecated since version 4.6.7
40
+	 */
41
+	public function get_model_name_pointed_to()
42
+	{
43
+		EE_Error::doing_it_wrong(
44
+			'get_model_name_pointed_to',
45
+			esc_html__(
46
+				'This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array',
47
+				'event_espresso'
48
+			),
49
+			'4.6.7'
50
+		);
51
+		return $this->_model_name_pointed_to;
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Gets the model names pointed to by this field, always as an array
57
-     * (even if there's only one)
58
-     *
59
-     * @return string[] of model names pointed to by this field
60
-     */
61
-    public function get_model_names_pointed_to()
62
-    {
63
-        return is_array($this->_model_name_pointed_to)
64
-            ? $this->_model_name_pointed_to
65
-            : [$this->_model_name_pointed_to];
66
-    }
55
+	/**
56
+	 * Gets the model names pointed to by this field, always as an array
57
+	 * (even if there's only one)
58
+	 *
59
+	 * @return string[] of model names pointed to by this field
60
+	 */
61
+	public function get_model_names_pointed_to()
62
+	{
63
+		return is_array($this->_model_name_pointed_to)
64
+			? $this->_model_name_pointed_to
65
+			: [$this->_model_name_pointed_to];
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * Returns the model's classname (eg EE_Event instead of just Event)
71
-     *
72
-     * @return string[]
73
-     */
74
-    public function get_model_class_names_pointed_to()
75
-    {
76
-        $model_names = [];
77
-        if (is_array($this->_model_name_pointed_to)) {
78
-            foreach ($this->_model_name_pointed_to as $model_name) {
79
-                $model_names[] = "EE_" . $model_name;
80
-            }
81
-        } else {
82
-            $model_names = ["EE_" . $this->_model_name_pointed_to];
83
-        }
84
-        return $model_names;
85
-    }
69
+	/**
70
+	 * Returns the model's classname (eg EE_Event instead of just Event)
71
+	 *
72
+	 * @return string[]
73
+	 */
74
+	public function get_model_class_names_pointed_to()
75
+	{
76
+		$model_names = [];
77
+		if (is_array($this->_model_name_pointed_to)) {
78
+			foreach ($this->_model_name_pointed_to as $model_name) {
79
+				$model_names[] = "EE_" . $model_name;
80
+			}
81
+		} else {
82
+			$model_names = ["EE_" . $this->_model_name_pointed_to];
83
+		}
84
+		return $model_names;
85
+	}
86 86
 
87 87
 
88
-    /**
89
-     * @param int|EE_Base_Class $model_obj
90
-     * @return bool
91
-     */
92
-    public function is_model_obj_of_type_pointed_to($model_obj)
93
-    {
94
-        foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) {
95
-            if ($model_obj instanceof $model_obj_classname) {
96
-                return true;
97
-            }
98
-        }
99
-        return false;
100
-    }
88
+	/**
89
+	 * @param int|EE_Base_Class $model_obj
90
+	 * @return bool
91
+	 */
92
+	public function is_model_obj_of_type_pointed_to($model_obj)
93
+	{
94
+		foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) {
95
+			if ($model_obj instanceof $model_obj_classname) {
96
+				return true;
97
+			}
98
+		}
99
+		return false;
100
+	}
101 101
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_WP_Post_Type_Field.php.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@
 block discarded – undo
5 5
  */
6 6
 class EE_WP_Post_Type_Field extends EE_DB_Only_Text_Field
7 7
 {
8
-    /**
9
-     * @param string $post_type the exact string to be used for the post type
10
-     *                          of all these post type model objects/rows
11
-     */
12
-    public function __construct($post_type)
13
-    {
14
-        parent::__construct('post_type', esc_html__("Post Type", 'event_espresso'), false, $post_type);
15
-    }
8
+	/**
9
+	 * @param string $post_type the exact string to be used for the post type
10
+	 *                          of all these post type model objects/rows
11
+	 */
12
+	public function __construct($post_type)
13
+	{
14
+		parent::__construct('post_type', esc_html__("Post Type", 'event_espresso'), false, $post_type);
15
+	}
16 16
 }
Please login to merge, or discard this patch.
core/services/form/meta/inputs/Phone.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
      */
74 74
     public function __construct()
75 75
     {
76
-        $this->regex_patterns     = (array) apply_filters(
76
+        $this->regex_patterns = (array) apply_filters(
77 77
             'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns',
78 78
             [
79 79
                 'de_DE' => Phone::PATTERN_DE,
Please login to merge, or discard this patch.
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -4,109 +4,109 @@
 block discarded – undo
4 4
 
5 5
 class Phone
6 6
 {
7
-    /**
8
-     * indicates that the HTML input type is 'tel'
9
-     */
10
-    const INPUT_TYPE = 'tel';
7
+	/**
8
+	 * indicates that the HTML input type is 'tel'
9
+	 */
10
+	const INPUT_TYPE = 'tel';
11 11
 
12
-    /**
13
-     * indicates that the 'tel' input regex pattern is for a US formatted phone number, examples:
14
-     *      ##########
15
-     *      ###-###-####
16
-     *      ### ### ####
17
-     *      (###)-###-####
18
-     *      (###) ###-####
19
-     *
20
-     * captures the intl code to the first group (+1) and the rest of the number to group 2
21
-     *      +1 (###) ###-####
22
-     */
23
-    const PATTERN_US = '(\+?\d{1,3})?[\ \-]?(\(?\d{3}\)?[\ \-]?\d{3}[\ \-]?\d{4})';
12
+	/**
13
+	 * indicates that the 'tel' input regex pattern is for a US formatted phone number, examples:
14
+	 *      ##########
15
+	 *      ###-###-####
16
+	 *      ### ### ####
17
+	 *      (###)-###-####
18
+	 *      (###) ###-####
19
+	 *
20
+	 * captures the intl code to the first group (+1) and the rest of the number to group 2
21
+	 *      +1 (###) ###-####
22
+	 */
23
+	const PATTERN_US = '(\+?\d{1,3})?[\ \-]?(\(?\d{3}\)?[\ \-]?\d{3}[\ \-]?\d{4})';
24 24
 
25
-    /**
26
-     * indicates that the 'tel' input regex pattern is for a UK formatted phone number, examples:
27
-     *      (###) #### ####
28
-     *      (####) ### ####
29
-     *      (#####) ## ####
30
-     *
31
-     * captures the intl code to the first group (+44) and the rest of the number to group 2
32
-     *      +44 (###) #### ####
33
-     */
34
-    const PATTERN_UK = '(\+?44)?[\ ]?(\(?(?:(?:\d{3,5})|(?:\d{4} \d{2}))\)?[\-\ ]?\d{2,4}[\-\ ]?\d{2,4})';
25
+	/**
26
+	 * indicates that the 'tel' input regex pattern is for a UK formatted phone number, examples:
27
+	 *      (###) #### ####
28
+	 *      (####) ### ####
29
+	 *      (#####) ## ####
30
+	 *
31
+	 * captures the intl code to the first group (+44) and the rest of the number to group 2
32
+	 *      +44 (###) #### ####
33
+	 */
34
+	const PATTERN_UK = '(\+?44)?[\ ]?(\(?(?:(?:\d{3,5})|(?:\d{4} \d{2}))\)?[\-\ ]?\d{2,4}[\-\ ]?\d{2,4})';
35 35
 
36
-    /**
37
-     * indicates that the 'tel' input regex pattern is for a France formatted phone number, examples:
38
-     *      0# ## ## ## ##
39
-     *      0### ## ## ##
40
-     *
41
-     * captures the intl code to the first group (+33) and the rest of the number to group 2
42
-     *      +33 # ## ## ## ##
43
-     *      0033 # ## ## ## ##
44
-     */
45
-    const PATTERN_FR = '((?:\+|00)33)?[\ \.\-]*((?:(?:\(0\)[\ \.\-]{0,3})?|0)[1-9](?:(?:[\ \.\-]?\d{2}){4}|\d{2}(?:[\ \.\-]?\d{3}){2}))';
36
+	/**
37
+	 * indicates that the 'tel' input regex pattern is for a France formatted phone number, examples:
38
+	 *      0# ## ## ## ##
39
+	 *      0### ## ## ##
40
+	 *
41
+	 * captures the intl code to the first group (+33) and the rest of the number to group 2
42
+	 *      +33 # ## ## ## ##
43
+	 *      0033 # ## ## ## ##
44
+	 */
45
+	const PATTERN_FR = '((?:\+|00)33)?[\ \.\-]*((?:(?:\(0\)[\ \.\-]{0,3})?|0)[1-9](?:(?:[\ \.\-]?\d{2}){4}|\d{2}(?:[\ \.\-]?\d{3}){2}))';
46 46
 
47
-    /**
48
-     * indicates that the 'tel' input regex pattern is for a German formatted phone number, examples:
49
-     *      (0##) ####-####
50
-     *      (0###) ####-####
51
-     *      (0####) ###-####
52
-     *      (03####) ##-####
53
-     *
54
-     * captures the intl code to the first group (+49) and the rest of the number to group 2
55
-     *      +49 (0##) ####-####
56
-     */
57
-    const PATTERN_DE = '(\+?49)?[\ \.\-]?(\(?(?:[\d \-\)\–\/\(]+){6,}\)?(?:[\ \.\-–\/]?)(?:[\d]+))';
47
+	/**
48
+	 * indicates that the 'tel' input regex pattern is for a German formatted phone number, examples:
49
+	 *      (0##) ####-####
50
+	 *      (0###) ####-####
51
+	 *      (0####) ###-####
52
+	 *      (03####) ##-####
53
+	 *
54
+	 * captures the intl code to the first group (+49) and the rest of the number to group 2
55
+	 *      +49 (0##) ####-####
56
+	 */
57
+	const PATTERN_DE = '(\+?49)?[\ \.\-]?(\(?(?:[\d \-\)\–\/\(]+){6,}\)?(?:[\ \.\-–\/]?)(?:[\d]+))';
58 58
 
59
-    /**
60
-     * @var array
61
-     */
62
-    private $regex_patterns;
59
+	/**
60
+	 * @var array
61
+	 */
62
+	private $regex_patterns;
63 63
 
64
-    /**
65
-     * @var array
66
-     */
67
-    private $valid_type_options;
64
+	/**
65
+	 * @var array
66
+	 */
67
+	private $valid_type_options;
68 68
 
69 69
 
70
-    /**
71
-     * Phone constructor.
72
-     */
73
-    public function __construct()
74
-    {
75
-        $this->regex_patterns     = (array) apply_filters(
76
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns',
77
-            [
78
-                'de_DE' => Phone::PATTERN_DE,
79
-                'fr_FR' => Phone::PATTERN_FR,
80
-                'en_UK' => Phone::PATTERN_UK,
81
-                'en_US' => Phone::PATTERN_US,
82
-            ]
83
-        );
84
-        $this->valid_type_options = apply_filters(
85
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__valid_type_options',
86
-            [
87
-                Phone::INPUT_TYPE => esc_html__('Phone Number', 'event_espresso'),
88
-            ]
89
-        );
90
-    }
70
+	/**
71
+	 * Phone constructor.
72
+	 */
73
+	public function __construct()
74
+	{
75
+		$this->regex_patterns     = (array) apply_filters(
76
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns',
77
+			[
78
+				'de_DE' => Phone::PATTERN_DE,
79
+				'fr_FR' => Phone::PATTERN_FR,
80
+				'en_UK' => Phone::PATTERN_UK,
81
+				'en_US' => Phone::PATTERN_US,
82
+			]
83
+		);
84
+		$this->valid_type_options = apply_filters(
85
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__valid_type_options',
86
+			[
87
+				Phone::INPUT_TYPE => esc_html__('Phone Number', 'event_espresso'),
88
+			]
89
+		);
90
+	}
91 91
 
92 92
 
93
-    /**
94
-     * @return array
95
-     */
96
-    public function regexPatterns()
97
-    {
98
-        return $this->regex_patterns;
99
-    }
93
+	/**
94
+	 * @return array
95
+	 */
96
+	public function regexPatterns()
97
+	{
98
+		return $this->regex_patterns;
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * @param bool $constants_only
104
-     * @return array
105
-     */
106
-    public function validTypeOptions($constants_only = false)
107
-    {
108
-        return $constants_only
109
-            ? array_keys($this->valid_type_options)
110
-            : $this->valid_type_options;
111
-    }
102
+	/**
103
+	 * @param bool $constants_only
104
+	 * @return array
105
+	 */
106
+	public function validTypeOptions($constants_only = false)
107
+	{
108
+		return $constants_only
109
+			? array_keys($this->valid_type_options)
110
+			: $this->valid_type_options;
111
+	}
112 112
 }
Please login to merge, or discard this patch.
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 
54 54
     public function translate_js_strings()
55 55
     {
56
-        EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
56
+        EE_Registry::$i18n_js_strings['required_field'] = esc_html__(
57 57
             ' is a required question.',
58 58
             'event_espresso'
59 59
         );
60
-        EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
60
+        EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__(
61 61
             ' is a required question. Please enter a value for at least one of the options.',
62 62
             'event_espresso'
63 63
         );
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             'Please answer all required questions correctly before proceeding.',
66 66
             'event_espresso'
67 67
         );
68
-        EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
68
+        EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(
69 69
             esc_html_x(
70 70
                 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
71 71
                 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
             ),
74 74
             '<br/>'
75 75
         );
76
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
76
+        EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__(
77 77
             'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
78 78
             'event_espresso'
79 79
         );
80
-        EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
80
+        EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__(
81 81
             'You must enter a valid email address.',
82 82
             'event_espresso'
83 83
         );
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
         if (empty($valid_data)) {
323 323
             return $this->inValidDataError();
324 324
         }
325
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
325
+        if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
326 326
             return $this->inValidTransactionError();
327 327
         }
328 328
         // get cached registrations
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
         /** @var RegFormHandler $reg_form_handler */
335 335
         $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]);
336 336
         // extract attendee info from form data and save to model objects
337
-        if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
337
+        if ( ! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
338 338
             // return immediately if the previous step exited early due to errors
339 339
             return false;
340 340
         }
341 341
         // if first pass thru SPCO,
342 342
         // then let's check processed registrations against the total number of tickets in the cart
343 343
         $registrations_processed = $reg_form_handler->attendeeCount();
344
-        if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
344
+        if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
345 345
             return $this->registrationProcessingError($registrations_processed);
346 346
         }
347 347
         // mark this reg step as completed
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
                 '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
409 409
                 'event_espresso'
410 410
             ),
411
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
411
+            '<a href="'.get_post_type_archive_link('espresso_events').'" >',
412 412
             '</a>',
413 413
             '<br />'
414 414
         );
Please login to merge, or discard this patch.
Indentation   +859 added lines, -859 removed lines patch added patch discarded remove patch
@@ -22,863 +22,863 @@
 block discarded – undo
22 22
  */
23 23
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step
24 24
 {
25
-    /**
26
-     * @var RegForm
27
-     */
28
-    public $reg_form;
29
-
30
-    /**
31
-     * @var int
32
-     */
33
-    protected $reg_form_count = 0;
34
-
35
-
36
-    /**
37
-     *    class constructor
38
-     *
39
-     * @access    public
40
-     * @param EE_Checkout $checkout
41
-     */
42
-    public function __construct(EE_Checkout $checkout)
43
-    {
44
-        $this->_slug    = 'attendee_information';
45
-        $this->_name    = esc_html__('Attendee Information', 'event_espresso');
46
-        $this->checkout = $checkout;
47
-        $this->_reset_success_message();
48
-        $this->set_instructions(
49
-            esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
50
-        );
51
-    }
52
-
53
-
54
-    public function translate_js_strings()
55
-    {
56
-        EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
57
-            ' is a required question.',
58
-            'event_espresso'
59
-        );
60
-        EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
61
-            ' is a required question. Please enter a value for at least one of the options.',
62
-            'event_espresso'
63
-        );
64
-        EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
65
-            'Please answer all required questions correctly before proceeding.',
66
-            'event_espresso'
67
-        );
68
-        EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
69
-            esc_html_x(
70
-                'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
71
-                'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
72
-                'event_espresso'
73
-            ),
74
-            '<br/>'
75
-        );
76
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
77
-            'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
78
-            'event_espresso'
79
-        );
80
-        EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
81
-            'You must enter a valid email address.',
82
-            'event_espresso'
83
-        );
84
-        EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
85
-            'You must enter a valid email address and answer all other required questions before you can proceed.',
86
-            'event_espresso'
87
-        );
88
-    }
89
-
90
-
91
-    public function enqueue_styles_and_scripts()
92
-    {
93
-    }
94
-
95
-
96
-    /**
97
-     * @return boolean
98
-     */
99
-    public function initialize_reg_step()
100
-    {
101
-        return true;
102
-    }
103
-
104
-
105
-    /**
106
-     * @return RegForm
107
-     * @throws DomainException
108
-     * @throws InvalidArgumentException
109
-     * @throws EntityNotFoundException
110
-     * @throws InvalidDataTypeException
111
-     * @throws InvalidInterfaceException
112
-     */
113
-    public function generate_reg_form()
114
-    {
115
-        $this->setLegacyFiltersForRegFormGeneration();
116
-        /** @var RegFormDependencyHandler $dependency_handler */
117
-        $dependency_handler = LoaderFactory::getShared(RegFormDependencyHandler::class);
118
-        $dependency_handler->registerDependencies();
119
-        // TODO detect if event has a reg form UUID and swap this out for form generated by new reg form builder
120
-        return LoaderFactory::getShared(RegForm::class, [$this]);
121
-    }
122
-
123
-
124
-    /**
125
-     * @since   $VID:$
126
-     */
127
-    private function setLegacyFiltersForRegFormGeneration()
128
-    {
129
-        add_filter(
130
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_groups_query_parameters',
131
-            [$this, 'registrationQuestionGroupsQueryParameters'],
132
-            1,
133
-            2
134
-        );
135
-        add_filter(
136
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_group_reg_form',
137
-            [$this, 'registrationQuestionGroupsRegForm'],
138
-            1,
139
-            3
140
-        );
141
-        add_filter(
142
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__printCopyInfo',
143
-            [$this, 'registrationRegFormPrintCopyInfo'],
144
-            1,
145
-            2
146
-        );
147
-        add_filter(
148
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__related_questions_query_params',
149
-            [$this, 'registrationRegFormRelatedQuestionsQueryParams'],
150
-            1,
151
-            3
152
-        );
153
-        add_filter(
154
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__before_question_group_questions',
155
-            [$this, 'registrationRegFormBeforeQuestionGroupQuestions'],
156
-            1,
157
-            3
158
-        );
159
-        add_filter(
160
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__subsections_array',
161
-            [$this, 'registrationRegFormSubsections'],
162
-            1,
163
-            3
164
-        );
165
-        add_filter(
166
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__after_question_group_questions',
167
-            [$this, 'registrationRegFormAfterQuestionGroupQuestions'],
168
-            1,
169
-            3
170
-        );
171
-        add_filter(
172
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_AutoCopyAttendeeInfoForm__construct__template_args',
173
-            [$this, 'autoCopyAttendeeInfoTemplateArgs'],
174
-            1
175
-        );
176
-        add_filter(
177
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_CountryOptions__generateLegacyCountryOptions__country_options',
178
-            [$this, 'generateQuestionInputCountryOptions'],
179
-            1,
180
-            4
181
-        );
182
-        add_filter(
183
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_StateOptions__generateLegacyStateOptions__state_options',
184
-            [$this, 'generateQuestionInputStateOptions'],
185
-            1,
186
-            4
187
-        );
188
-    }
189
-
190
-
191
-    /**
192
-     * @param array           $query_params
193
-     * @param EE_Registration $registration
194
-     * @return mixed|void
195
-     * @since   $VID:$
196
-     */
197
-    public function registrationQuestionGroupsQueryParameters(
198
-        $query_params,
199
-        $registration
200
-    ) {
201
-        return apply_filters(
202
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
203
-            $query_params,
204
-            $registration,
205
-            $this
206
-        );
207
-    }
208
-
209
-
210
-    /**
211
-     * @param RegFormQuestionGroup $question_group_reg_form
212
-     * @param EE_Registration      $registration
213
-     * @param EE_Question_Group    $question_group
214
-     * @return mixed|void
215
-     * @since   $VID:$
216
-     */
217
-    public function registrationQuestionGroupsRegForm(
218
-        $question_group_reg_form,
219
-        $registration,
220
-        $question_group
221
-    ) {
222
-        return apply_filters(
223
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
224
-            $question_group_reg_form,
225
-            $registration,
226
-            $question_group,
227
-            $this
228
-        );
229
-    }
230
-
231
-
232
-    /**
233
-     * @param int $print_copy_info
234
-     * @param int $attendee_nmbr
235
-     * @return mixed|void
236
-     * @since   $VID:$
237
-     */
238
-    public function registrationRegFormPrintCopyInfo(
239
-        $print_copy_info,
240
-        $attendee_nmbr
241
-    ) {
242
-        return apply_filters(
243
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo',
244
-            $print_copy_info,
245
-            $attendee_nmbr
246
-        );
247
-    }
248
-
249
-
250
-    /**
251
-     * @param array             $query_params
252
-     * @param EE_Question_Group $question_group
253
-     * @param EE_Registration   $registration
254
-     * @return mixed|void
255
-     * @since   $VID:$
256
-     */
257
-    public function registrationRegFormRelatedQuestionsQueryParams(
258
-        $query_params,
259
-        $question_group,
260
-        $registration
261
-    ) {
262
-        return apply_filters(
263
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
264
-            $query_params,
265
-            $question_group,
266
-            $registration,
267
-            $this
268
-        );
269
-    }
270
-
271
-
272
-    /**
273
-     * @param                   $html
274
-     * @param EE_Registration   $registration
275
-     * @param EE_Question_Group $question_group
276
-     * @return mixed|void
277
-     * @since   $VID:$
278
-     */
279
-    public function registrationRegFormBeforeQuestionGroupQuestions(
280
-        $html,
281
-        $registration,
282
-        $question_group
283
-    ) {
284
-        return apply_filters(
285
-            'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
286
-            $html,
287
-            $registration,
288
-            $question_group,
289
-            $this
290
-        );
291
-    }
292
-
293
-
294
-    /**
295
-     * @param array             $form_subsections
296
-     * @param EE_Registration   $registration
297
-     * @param EE_Question_Group $question_group
298
-     * @return mixed|void
299
-     * @since   $VID:$
300
-     */
301
-    public function registrationRegFormSubsections(
302
-        $form_subsections,
303
-        $registration,
304
-        $question_group
305
-    ) {
306
-        return apply_filters(
307
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
308
-            $form_subsections,
309
-            $registration,
310
-            $question_group,
311
-            $this
312
-        );
313
-    }
314
-
315
-
316
-    /**
317
-     * @param                   $html
318
-     * @param EE_Registration   $registration
319
-     * @param EE_Question_Group $question_group
320
-     * @return mixed|void
321
-     * @since   $VID:$
322
-     */
323
-    public function registrationRegFormAfterQuestionGroupQuestions(
324
-        $html,
325
-        $registration,
326
-        $question_group
327
-    ) {
328
-        return apply_filters(
329
-            'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
330
-            $html,
331
-            $registration,
332
-            $question_group,
333
-            $this
334
-        );
335
-    }
336
-
337
-
338
-    /**
339
-     * @param array $template_args
340
-     * @return mixed|void
341
-     * @since   $VID:$
342
-     */
343
-    public function autoCopyAttendeeInfoTemplateArgs($template_args = [])
344
-    {
345
-        return apply_filters(
346
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
347
-            $template_args
348
-        );
349
-    }
350
-
351
-
352
-    /**
353
-     * @param array           $country_options
354
-     * @param EE_Registration $registration
355
-     * @param EE_Question     $question
356
-     * @param EE_Answer|null  $answer
357
-     * @return mixed|void
358
-     * @since   $VID:$
359
-     */
360
-    public function generateQuestionInputCountryOptions(
361
-        $country_options,
362
-        $registration,
363
-        $question,
364
-        $answer
365
-    ) {
366
-        return apply_filters(
367
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
368
-            $country_options,
369
-            $this,
370
-            $registration,
371
-            $question,
372
-            $answer
373
-        );
374
-    }
375
-
376
-
377
-    /**
378
-     * @param array           $state_options
379
-     * @param EE_Registration $registration
380
-     * @param EE_Question     $question
381
-     * @param EE_Answer|null  $answer
382
-     * @return mixed|void
383
-     * @since   $VID:$
384
-     */
385
-    public function generateQuestionInputStateOptions(
386
-        $state_options,
387
-        $registration,
388
-        $question,
389
-        $answer
390
-    ) {
391
-        return apply_filters(
392
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
393
-            $state_options,
394
-            $this,
395
-            $registration,
396
-            $question,
397
-            $answer
398
-        );
399
-    }
400
-
401
-
402
-    /**
403
-     * looking for hooks?
404
-     * this method has been replaced by:
405
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm()
406
-     *
407
-     * @deprecated   $VID:$
408
-     */
409
-    private function _registrations_reg_form()
410
-    {
411
-    }
412
-
413
-
414
-    /**
415
-     * looking for hooks?
416
-     * this method has been replaced by:
417
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput()
418
-     *
419
-     * @deprecated   $VID:$
420
-     */
421
-    private function _additional_attendee_reg_info_input()
422
-    {
423
-    }
424
-
425
-
426
-    /**
427
-     * looking for hooks?
428
-     * this method has been replaced by:
429
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm()
430
-     *
431
-     * @deprecated   $VID:$
432
-     */
433
-    private function _question_group_reg_form()
434
-    {
435
-    }
436
-
437
-
438
-    /**
439
-     * looking for hooks?
440
-     * this method has been replaced by:
441
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader()
442
-     *
443
-     * @deprecated   $VID:$
444
-     */
445
-    private function _question_group_header()
446
-    {
447
-    }
448
-
449
-
450
-    /**
451
-     * looking for hooks?
452
-     * this method has been replaced by:
453
-     * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
454
-     *
455
-     * @deprecated   $VID:$
456
-     */
457
-    private function _copy_attendee_info_form()
458
-    {
459
-    }
460
-
461
-
462
-    /**
463
-     * looking for hooks?
464
-     * this method has been replaced by:
465
-     * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm
466
-     *
467
-     * @deprecated   $VID:$
468
-     */
469
-    private function _auto_copy_attendee_info()
470
-    {
471
-    }
472
-
473
-
474
-    /**
475
-     * looking for hooks?
476
-     * this method has been replaced by:
477
-     * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
478
-     *
479
-     * @deprecated   $VID:$
480
-     */
481
-    private function _copy_attendee_info_inputs()
482
-    {
483
-    }
484
-
485
-
486
-    /**
487
-     * looking for hooks?
488
-     * this method has been replaced by:
489
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs()
490
-     *
491
-     * @deprecated   $VID:$
492
-     */
493
-    private function _additional_primary_registrant_inputs()
494
-    {
495
-    }
496
-
497
-
498
-    /**
499
-     * looking for hooks?
500
-     * this method has been replaced by:
501
-     * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create()
502
-     *
503
-     * @param EE_Registration $registration
504
-     * @param EE_Question     $question
505
-     * @return EE_Form_Input_Base
506
-     * @throws EE_Error
507
-     * @throws ReflectionException
508
-     * @deprecated   $VID:$
509
-     */
510
-    public function reg_form_question($registration, $question)
511
-    {
512
-        /** @var RegFormQuestionFactory $reg_form_question_factory */
513
-        $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class);
514
-        return $reg_form_question_factory->create($registration, $question);
515
-    }
516
-
517
-
518
-    /**
519
-     * looking for hooks?
520
-     * this method has been replaced by:
521
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput()
522
-     *
523
-     * @deprecated   $VID:$
524
-     */
525
-    private function _generate_question_input()
526
-    {
527
-    }
528
-
529
-
530
-    /**
531
-     * looking for hooks?
532
-     * this method has been replaced by:
533
-     * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput()
534
-     *
535
-     * @param array|null           $countries_list
536
-     * @param EE_Question|null     $question
537
-     * @param EE_Registration|null $registration
538
-     * @param EE_Answer|null       $answer
539
-     * @return array 2d keys are country IDs, values are their names
540
-     * @throws EE_Error
541
-     * @throws ReflectionException
542
-     * @deprecated   $VID:$
543
-     */
544
-    public function use_cached_countries_for_form_input(
545
-        $countries_list = null,
546
-        $question = null,
547
-        $registration = null,
548
-        $answer = null
549
-    ) {
550
-        /** @var CountryOptions $country_options */
551
-        $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]);
552
-        return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer);
553
-    }
554
-
555
-
556
-    /**
557
-     * looking for hooks?
558
-     * this method has been replaced by:
559
-     * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput()
560
-     *
561
-     * @param array|null           $states_list
562
-     * @param EE_Question|null     $question
563
-     * @param EE_Registration|null $registration
564
-     * @param EE_Answer|null       $answer
565
-     * @return array 2d keys are state IDs, values are their names
566
-     * @throws EE_Error
567
-     * @throws ReflectionException
568
-     * @deprecated   $VID:$
569
-     */
570
-    public function use_cached_states_for_form_input(
571
-        $states_list = null,
572
-        $question = null,
573
-        $registration = null,
574
-        $answer = null
575
-    ) {
576
-        /** @var StateOptions $state_options */
577
-        $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]);
578
-        return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer);
579
-    }
580
-
581
-
582
-    /********************************************************************************************************/
583
-    /****************************************  PROCESS REG STEP  ****************************************/
584
-    /********************************************************************************************************/
585
-
586
-
587
-    /**
588
-     * @return bool
589
-     * @throws EE_Error
590
-     * @throws InvalidArgumentException
591
-     * @throws ReflectionException
592
-     * @throws RuntimeException
593
-     * @throws InvalidDataTypeException
594
-     * @throws InvalidInterfaceException
595
-     */
596
-    public function process_reg_step()
597
-    {
598
-        $this->setLegacyFiltersForRegFormProcessing();
599
-        // grab validated data from form
600
-        $valid_data = $this->checkout->current_step->valid_data();
601
-        // if we don't have any $valid_data then something went TERRIBLY WRONG !!!
602
-        if (empty($valid_data)) {
603
-            return $this->inValidDataError();
604
-        }
605
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
606
-            return $this->inValidTransactionError();
607
-        }
608
-        // get cached registrations
609
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
610
-        // verify we got the goods
611
-        if (empty($registrations)) {
612
-            return $this->noRegistrationsError();
613
-        }
614
-        /** @var RegFormHandler $reg_form_handler */
615
-        $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]);
616
-        // extract attendee info from form data and save to model objects
617
-        if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
618
-            // return immediately if the previous step exited early due to errors
619
-            return false;
620
-        }
621
-        // if first pass thru SPCO,
622
-        // then let's check processed registrations against the total number of tickets in the cart
623
-        $registrations_processed = $reg_form_handler->attendeeCount();
624
-        if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
625
-            return $this->registrationProcessingError($registrations_processed);
626
-        }
627
-        // mark this reg step as completed
628
-        $this->set_completed();
629
-        $this->_set_success_message(
630
-            esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
631
-        );
632
-        // do action in case a plugin wants to do something with the data submitted in step 1.
633
-        // passes EE_Single_Page_Checkout, and it's posted data
634
-        do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
635
-        return true;
636
-    }
637
-
638
-
639
-    /**
640
-     * @since   $VID:$
641
-     */
642
-    private function setLegacyFiltersForRegFormProcessing()
643
-    {
644
-        add_filter(
645
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegistrations__bypass',
646
-            [$this, 'preRegistrationProcess'],
647
-            1,
648
-            5
649
-        );
650
-        add_filter(
651
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegFormData__registrant_form_data',
652
-            [$this, 'validDataLineItem'],
653
-            1,
654
-            2
655
-        );
656
-        add_filter(
657
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput',
658
-            [$this, 'saveRegistrationFormInput'],
659
-            1,
660
-            4
661
-        );
662
-        add_filter(
663
-            'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet',
664
-            [$this, 'mergeAddressDetailsWithCriticalAttendeeDetails'],
665
-            1
666
-        );
667
-    }
668
-
669
-
670
-    /**
671
-     * @param bool            $bypass
672
-     * @param int             $attendee_count
673
-     * @param EE_Registration $registration
674
-     * @param array           $registrations
675
-     * @param array           $reg_form_data
676
-     * @return mixed|void
677
-     * @since   $VID:$
678
-     */
679
-    public function preRegistrationProcess(
680
-        $bypass,
681
-        $attendee_count,
682
-        $registration,
683
-        $registrations,
684
-        $reg_form_data
685
-    ) {
686
-        return apply_filters(
687
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
688
-            $bypass,
689
-            $attendee_count,
690
-            $registration,
691
-            $registrations,
692
-            $reg_form_data,
693
-            $this
694
-        );
695
-    }
696
-
697
-
698
-    /**
699
-     * @param array           $reg_form_data
700
-     * @param EE_Registration $registration
701
-     * @return mixed|void
702
-     * @since   $VID:$
703
-     */
704
-    public function validDataLineItem($reg_form_data, $registration)
705
-    {
706
-        return apply_filters(
707
-            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
708
-            $reg_form_data,
709
-            $registration
710
-        );
711
-    }
712
-
713
-
714
-    /**
715
-     * @param bool            $save
716
-     * @param EE_Registration $registration
717
-     * @param                 $form_input
718
-     * @param                 $input_value
719
-     * @return mixed|void
720
-     * @since   $VID:$
721
-     */
722
-    public function saveRegistrationFormInput($save, $registration, $form_input, $input_value)
723
-    {
724
-        return apply_filters(
725
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
726
-            $save,
727
-            $registration,
728
-            $form_input,
729
-            $input_value,
730
-            $this
731
-        );
732
-    }
733
-
734
-
735
-    /**
736
-     * @param bool $merge_data
737
-     * @return mixed|void
738
-     * @since   $VID:$
739
-     */
740
-    public function mergeAddressDetailsWithCriticalAttendeeDetails($merge_data)
741
-    {
742
-        return apply_filters(
743
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
744
-            $merge_data
745
-        );
746
-    }
747
-
748
-
749
-    /**
750
-     * @return bool
751
-     * @since   $VID:$
752
-     */
753
-    private function inValidDataError()
754
-    {
755
-        EE_Error::add_error(
756
-            esc_html__('No valid question responses were received.', 'event_espresso'),
757
-            __FILE__,
758
-            __FUNCTION__,
759
-            __LINE__
760
-        );
761
-        return false;
762
-    }
763
-
764
-
765
-    /**
766
-     * @return bool
767
-     * @since   $VID:$
768
-     */
769
-    private function inValidTransactionError()
770
-    {
771
-        EE_Error::add_error(
772
-            esc_html__(
773
-                'A valid transaction could not be initiated for processing your registrations.',
774
-                'event_espresso'
775
-            ),
776
-            __FILE__,
777
-            __FUNCTION__,
778
-            __LINE__
779
-        );
780
-        return false;
781
-    }
782
-
783
-
784
-    /**
785
-     * @return bool
786
-     * @since   $VID:$
787
-     */
788
-    private function noRegistrationsError()
789
-    {
790
-        // combine the old translated string with a new one, in order to not break translations
791
-        $error_message = esc_html__(
792
-            'Your form data could not be applied to any valid registrations.',
793
-            'event_espresso'
794
-        );
795
-        $error_message .= sprintf(
796
-            esc_html_x(
797
-                '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.',
798
-                '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
799
-                'event_espresso'
800
-            ),
801
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
802
-            '</a>',
803
-            '<br />'
804
-        );
805
-        EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__);
806
-        return false;
807
-    }
808
-
809
-
810
-    /**
811
-     * @param int $registrations_processed
812
-     * @return bool
813
-     * @since   $VID:$
814
-     */
815
-    private function registrationProcessingError($registrations_processed)
816
-    {
817
-        $registrations_processed = (int) $registrations_processed;
818
-        // generate a correctly translated string for all possible singular/plural combinations
819
-        if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
820
-            $error_msg = sprintf(
821
-                esc_html_x(
822
-                    'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
823
-                    'There was 1 ticket in the Event Queue, but 2 registrations were processed',
824
-                    'event_espresso'
825
-                ),
826
-                $this->checkout->total_ticket_count,
827
-                $registrations_processed
828
-            );
829
-        } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
830
-            $error_msg = sprintf(
831
-                esc_html_x(
832
-                    'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
833
-                    'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed',
834
-                    'event_espresso'
835
-                ),
836
-                $this->checkout->total_ticket_count,
837
-                $registrations_processed
838
-            );
839
-        } else {
840
-            $error_msg = sprintf(
841
-                esc_html__(
842
-                    'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed',
843
-                    'event_espresso'
844
-                ),
845
-                $this->checkout->total_ticket_count,
846
-                $registrations_processed
847
-            );
848
-        }
849
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
850
-        return false;
851
-    }
852
-
853
-
854
-    /**
855
-     *    update_reg_step
856
-     *    this is the final step after a user  revisits the site to edit their attendee information
857
-     *    this gets called AFTER the process_reg_step() method above
858
-     *
859
-     * @return bool
860
-     * @throws EE_Error
861
-     * @throws InvalidArgumentException
862
-     * @throws ReflectionException
863
-     * @throws RuntimeException
864
-     * @throws InvalidDataTypeException
865
-     * @throws InvalidInterfaceException
866
-     */
867
-    public function update_reg_step()
868
-    {
869
-        // save everything
870
-        if ($this->process_reg_step()) {
871
-            $this->checkout->redirect     = true;
872
-            $this->checkout->redirect_url = add_query_arg(
873
-                [
874
-                    'e_reg_url_link' => $this->checkout->reg_url_link,
875
-                    'revisit'        => true,
876
-                ],
877
-                $this->checkout->thank_you_page_url
878
-            );
879
-            $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
880
-            return true;
881
-        }
882
-        return false;
883
-    }
25
+	/**
26
+	 * @var RegForm
27
+	 */
28
+	public $reg_form;
29
+
30
+	/**
31
+	 * @var int
32
+	 */
33
+	protected $reg_form_count = 0;
34
+
35
+
36
+	/**
37
+	 *    class constructor
38
+	 *
39
+	 * @access    public
40
+	 * @param EE_Checkout $checkout
41
+	 */
42
+	public function __construct(EE_Checkout $checkout)
43
+	{
44
+		$this->_slug    = 'attendee_information';
45
+		$this->_name    = esc_html__('Attendee Information', 'event_espresso');
46
+		$this->checkout = $checkout;
47
+		$this->_reset_success_message();
48
+		$this->set_instructions(
49
+			esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
50
+		);
51
+	}
52
+
53
+
54
+	public function translate_js_strings()
55
+	{
56
+		EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
57
+			' is a required question.',
58
+			'event_espresso'
59
+		);
60
+		EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
61
+			' is a required question. Please enter a value for at least one of the options.',
62
+			'event_espresso'
63
+		);
64
+		EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
65
+			'Please answer all required questions correctly before proceeding.',
66
+			'event_espresso'
67
+		);
68
+		EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
69
+			esc_html_x(
70
+				'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
71
+				'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
72
+				'event_espresso'
73
+			),
74
+			'<br/>'
75
+		);
76
+		EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
77
+			'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
78
+			'event_espresso'
79
+		);
80
+		EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
81
+			'You must enter a valid email address.',
82
+			'event_espresso'
83
+		);
84
+		EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
85
+			'You must enter a valid email address and answer all other required questions before you can proceed.',
86
+			'event_espresso'
87
+		);
88
+	}
89
+
90
+
91
+	public function enqueue_styles_and_scripts()
92
+	{
93
+	}
94
+
95
+
96
+	/**
97
+	 * @return boolean
98
+	 */
99
+	public function initialize_reg_step()
100
+	{
101
+		return true;
102
+	}
103
+
104
+
105
+	/**
106
+	 * @return RegForm
107
+	 * @throws DomainException
108
+	 * @throws InvalidArgumentException
109
+	 * @throws EntityNotFoundException
110
+	 * @throws InvalidDataTypeException
111
+	 * @throws InvalidInterfaceException
112
+	 */
113
+	public function generate_reg_form()
114
+	{
115
+		$this->setLegacyFiltersForRegFormGeneration();
116
+		/** @var RegFormDependencyHandler $dependency_handler */
117
+		$dependency_handler = LoaderFactory::getShared(RegFormDependencyHandler::class);
118
+		$dependency_handler->registerDependencies();
119
+		// TODO detect if event has a reg form UUID and swap this out for form generated by new reg form builder
120
+		return LoaderFactory::getShared(RegForm::class, [$this]);
121
+	}
122
+
123
+
124
+	/**
125
+	 * @since   $VID:$
126
+	 */
127
+	private function setLegacyFiltersForRegFormGeneration()
128
+	{
129
+		add_filter(
130
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_groups_query_parameters',
131
+			[$this, 'registrationQuestionGroupsQueryParameters'],
132
+			1,
133
+			2
134
+		);
135
+		add_filter(
136
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_group_reg_form',
137
+			[$this, 'registrationQuestionGroupsRegForm'],
138
+			1,
139
+			3
140
+		);
141
+		add_filter(
142
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__printCopyInfo',
143
+			[$this, 'registrationRegFormPrintCopyInfo'],
144
+			1,
145
+			2
146
+		);
147
+		add_filter(
148
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__related_questions_query_params',
149
+			[$this, 'registrationRegFormRelatedQuestionsQueryParams'],
150
+			1,
151
+			3
152
+		);
153
+		add_filter(
154
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__before_question_group_questions',
155
+			[$this, 'registrationRegFormBeforeQuestionGroupQuestions'],
156
+			1,
157
+			3
158
+		);
159
+		add_filter(
160
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__subsections_array',
161
+			[$this, 'registrationRegFormSubsections'],
162
+			1,
163
+			3
164
+		);
165
+		add_filter(
166
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__after_question_group_questions',
167
+			[$this, 'registrationRegFormAfterQuestionGroupQuestions'],
168
+			1,
169
+			3
170
+		);
171
+		add_filter(
172
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_AutoCopyAttendeeInfoForm__construct__template_args',
173
+			[$this, 'autoCopyAttendeeInfoTemplateArgs'],
174
+			1
175
+		);
176
+		add_filter(
177
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_CountryOptions__generateLegacyCountryOptions__country_options',
178
+			[$this, 'generateQuestionInputCountryOptions'],
179
+			1,
180
+			4
181
+		);
182
+		add_filter(
183
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_StateOptions__generateLegacyStateOptions__state_options',
184
+			[$this, 'generateQuestionInputStateOptions'],
185
+			1,
186
+			4
187
+		);
188
+	}
189
+
190
+
191
+	/**
192
+	 * @param array           $query_params
193
+	 * @param EE_Registration $registration
194
+	 * @return mixed|void
195
+	 * @since   $VID:$
196
+	 */
197
+	public function registrationQuestionGroupsQueryParameters(
198
+		$query_params,
199
+		$registration
200
+	) {
201
+		return apply_filters(
202
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
203
+			$query_params,
204
+			$registration,
205
+			$this
206
+		);
207
+	}
208
+
209
+
210
+	/**
211
+	 * @param RegFormQuestionGroup $question_group_reg_form
212
+	 * @param EE_Registration      $registration
213
+	 * @param EE_Question_Group    $question_group
214
+	 * @return mixed|void
215
+	 * @since   $VID:$
216
+	 */
217
+	public function registrationQuestionGroupsRegForm(
218
+		$question_group_reg_form,
219
+		$registration,
220
+		$question_group
221
+	) {
222
+		return apply_filters(
223
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
224
+			$question_group_reg_form,
225
+			$registration,
226
+			$question_group,
227
+			$this
228
+		);
229
+	}
230
+
231
+
232
+	/**
233
+	 * @param int $print_copy_info
234
+	 * @param int $attendee_nmbr
235
+	 * @return mixed|void
236
+	 * @since   $VID:$
237
+	 */
238
+	public function registrationRegFormPrintCopyInfo(
239
+		$print_copy_info,
240
+		$attendee_nmbr
241
+	) {
242
+		return apply_filters(
243
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo',
244
+			$print_copy_info,
245
+			$attendee_nmbr
246
+		);
247
+	}
248
+
249
+
250
+	/**
251
+	 * @param array             $query_params
252
+	 * @param EE_Question_Group $question_group
253
+	 * @param EE_Registration   $registration
254
+	 * @return mixed|void
255
+	 * @since   $VID:$
256
+	 */
257
+	public function registrationRegFormRelatedQuestionsQueryParams(
258
+		$query_params,
259
+		$question_group,
260
+		$registration
261
+	) {
262
+		return apply_filters(
263
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
264
+			$query_params,
265
+			$question_group,
266
+			$registration,
267
+			$this
268
+		);
269
+	}
270
+
271
+
272
+	/**
273
+	 * @param                   $html
274
+	 * @param EE_Registration   $registration
275
+	 * @param EE_Question_Group $question_group
276
+	 * @return mixed|void
277
+	 * @since   $VID:$
278
+	 */
279
+	public function registrationRegFormBeforeQuestionGroupQuestions(
280
+		$html,
281
+		$registration,
282
+		$question_group
283
+	) {
284
+		return apply_filters(
285
+			'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
286
+			$html,
287
+			$registration,
288
+			$question_group,
289
+			$this
290
+		);
291
+	}
292
+
293
+
294
+	/**
295
+	 * @param array             $form_subsections
296
+	 * @param EE_Registration   $registration
297
+	 * @param EE_Question_Group $question_group
298
+	 * @return mixed|void
299
+	 * @since   $VID:$
300
+	 */
301
+	public function registrationRegFormSubsections(
302
+		$form_subsections,
303
+		$registration,
304
+		$question_group
305
+	) {
306
+		return apply_filters(
307
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
308
+			$form_subsections,
309
+			$registration,
310
+			$question_group,
311
+			$this
312
+		);
313
+	}
314
+
315
+
316
+	/**
317
+	 * @param                   $html
318
+	 * @param EE_Registration   $registration
319
+	 * @param EE_Question_Group $question_group
320
+	 * @return mixed|void
321
+	 * @since   $VID:$
322
+	 */
323
+	public function registrationRegFormAfterQuestionGroupQuestions(
324
+		$html,
325
+		$registration,
326
+		$question_group
327
+	) {
328
+		return apply_filters(
329
+			'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
330
+			$html,
331
+			$registration,
332
+			$question_group,
333
+			$this
334
+		);
335
+	}
336
+
337
+
338
+	/**
339
+	 * @param array $template_args
340
+	 * @return mixed|void
341
+	 * @since   $VID:$
342
+	 */
343
+	public function autoCopyAttendeeInfoTemplateArgs($template_args = [])
344
+	{
345
+		return apply_filters(
346
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
347
+			$template_args
348
+		);
349
+	}
350
+
351
+
352
+	/**
353
+	 * @param array           $country_options
354
+	 * @param EE_Registration $registration
355
+	 * @param EE_Question     $question
356
+	 * @param EE_Answer|null  $answer
357
+	 * @return mixed|void
358
+	 * @since   $VID:$
359
+	 */
360
+	public function generateQuestionInputCountryOptions(
361
+		$country_options,
362
+		$registration,
363
+		$question,
364
+		$answer
365
+	) {
366
+		return apply_filters(
367
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
368
+			$country_options,
369
+			$this,
370
+			$registration,
371
+			$question,
372
+			$answer
373
+		);
374
+	}
375
+
376
+
377
+	/**
378
+	 * @param array           $state_options
379
+	 * @param EE_Registration $registration
380
+	 * @param EE_Question     $question
381
+	 * @param EE_Answer|null  $answer
382
+	 * @return mixed|void
383
+	 * @since   $VID:$
384
+	 */
385
+	public function generateQuestionInputStateOptions(
386
+		$state_options,
387
+		$registration,
388
+		$question,
389
+		$answer
390
+	) {
391
+		return apply_filters(
392
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
393
+			$state_options,
394
+			$this,
395
+			$registration,
396
+			$question,
397
+			$answer
398
+		);
399
+	}
400
+
401
+
402
+	/**
403
+	 * looking for hooks?
404
+	 * this method has been replaced by:
405
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm()
406
+	 *
407
+	 * @deprecated   $VID:$
408
+	 */
409
+	private function _registrations_reg_form()
410
+	{
411
+	}
412
+
413
+
414
+	/**
415
+	 * looking for hooks?
416
+	 * this method has been replaced by:
417
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput()
418
+	 *
419
+	 * @deprecated   $VID:$
420
+	 */
421
+	private function _additional_attendee_reg_info_input()
422
+	{
423
+	}
424
+
425
+
426
+	/**
427
+	 * looking for hooks?
428
+	 * this method has been replaced by:
429
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm()
430
+	 *
431
+	 * @deprecated   $VID:$
432
+	 */
433
+	private function _question_group_reg_form()
434
+	{
435
+	}
436
+
437
+
438
+	/**
439
+	 * looking for hooks?
440
+	 * this method has been replaced by:
441
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader()
442
+	 *
443
+	 * @deprecated   $VID:$
444
+	 */
445
+	private function _question_group_header()
446
+	{
447
+	}
448
+
449
+
450
+	/**
451
+	 * looking for hooks?
452
+	 * this method has been replaced by:
453
+	 * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
454
+	 *
455
+	 * @deprecated   $VID:$
456
+	 */
457
+	private function _copy_attendee_info_form()
458
+	{
459
+	}
460
+
461
+
462
+	/**
463
+	 * looking for hooks?
464
+	 * this method has been replaced by:
465
+	 * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm
466
+	 *
467
+	 * @deprecated   $VID:$
468
+	 */
469
+	private function _auto_copy_attendee_info()
470
+	{
471
+	}
472
+
473
+
474
+	/**
475
+	 * looking for hooks?
476
+	 * this method has been replaced by:
477
+	 * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
478
+	 *
479
+	 * @deprecated   $VID:$
480
+	 */
481
+	private function _copy_attendee_info_inputs()
482
+	{
483
+	}
484
+
485
+
486
+	/**
487
+	 * looking for hooks?
488
+	 * this method has been replaced by:
489
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs()
490
+	 *
491
+	 * @deprecated   $VID:$
492
+	 */
493
+	private function _additional_primary_registrant_inputs()
494
+	{
495
+	}
496
+
497
+
498
+	/**
499
+	 * looking for hooks?
500
+	 * this method has been replaced by:
501
+	 * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create()
502
+	 *
503
+	 * @param EE_Registration $registration
504
+	 * @param EE_Question     $question
505
+	 * @return EE_Form_Input_Base
506
+	 * @throws EE_Error
507
+	 * @throws ReflectionException
508
+	 * @deprecated   $VID:$
509
+	 */
510
+	public function reg_form_question($registration, $question)
511
+	{
512
+		/** @var RegFormQuestionFactory $reg_form_question_factory */
513
+		$reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class);
514
+		return $reg_form_question_factory->create($registration, $question);
515
+	}
516
+
517
+
518
+	/**
519
+	 * looking for hooks?
520
+	 * this method has been replaced by:
521
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput()
522
+	 *
523
+	 * @deprecated   $VID:$
524
+	 */
525
+	private function _generate_question_input()
526
+	{
527
+	}
528
+
529
+
530
+	/**
531
+	 * looking for hooks?
532
+	 * this method has been replaced by:
533
+	 * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput()
534
+	 *
535
+	 * @param array|null           $countries_list
536
+	 * @param EE_Question|null     $question
537
+	 * @param EE_Registration|null $registration
538
+	 * @param EE_Answer|null       $answer
539
+	 * @return array 2d keys are country IDs, values are their names
540
+	 * @throws EE_Error
541
+	 * @throws ReflectionException
542
+	 * @deprecated   $VID:$
543
+	 */
544
+	public function use_cached_countries_for_form_input(
545
+		$countries_list = null,
546
+		$question = null,
547
+		$registration = null,
548
+		$answer = null
549
+	) {
550
+		/** @var CountryOptions $country_options */
551
+		$country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]);
552
+		return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer);
553
+	}
554
+
555
+
556
+	/**
557
+	 * looking for hooks?
558
+	 * this method has been replaced by:
559
+	 * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput()
560
+	 *
561
+	 * @param array|null           $states_list
562
+	 * @param EE_Question|null     $question
563
+	 * @param EE_Registration|null $registration
564
+	 * @param EE_Answer|null       $answer
565
+	 * @return array 2d keys are state IDs, values are their names
566
+	 * @throws EE_Error
567
+	 * @throws ReflectionException
568
+	 * @deprecated   $VID:$
569
+	 */
570
+	public function use_cached_states_for_form_input(
571
+		$states_list = null,
572
+		$question = null,
573
+		$registration = null,
574
+		$answer = null
575
+	) {
576
+		/** @var StateOptions $state_options */
577
+		$state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]);
578
+		return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer);
579
+	}
580
+
581
+
582
+	/********************************************************************************************************/
583
+	/****************************************  PROCESS REG STEP  ****************************************/
584
+	/********************************************************************************************************/
585
+
586
+
587
+	/**
588
+	 * @return bool
589
+	 * @throws EE_Error
590
+	 * @throws InvalidArgumentException
591
+	 * @throws ReflectionException
592
+	 * @throws RuntimeException
593
+	 * @throws InvalidDataTypeException
594
+	 * @throws InvalidInterfaceException
595
+	 */
596
+	public function process_reg_step()
597
+	{
598
+		$this->setLegacyFiltersForRegFormProcessing();
599
+		// grab validated data from form
600
+		$valid_data = $this->checkout->current_step->valid_data();
601
+		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
602
+		if (empty($valid_data)) {
603
+			return $this->inValidDataError();
604
+		}
605
+		if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
606
+			return $this->inValidTransactionError();
607
+		}
608
+		// get cached registrations
609
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
610
+		// verify we got the goods
611
+		if (empty($registrations)) {
612
+			return $this->noRegistrationsError();
613
+		}
614
+		/** @var RegFormHandler $reg_form_handler */
615
+		$reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]);
616
+		// extract attendee info from form data and save to model objects
617
+		if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
618
+			// return immediately if the previous step exited early due to errors
619
+			return false;
620
+		}
621
+		// if first pass thru SPCO,
622
+		// then let's check processed registrations against the total number of tickets in the cart
623
+		$registrations_processed = $reg_form_handler->attendeeCount();
624
+		if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
625
+			return $this->registrationProcessingError($registrations_processed);
626
+		}
627
+		// mark this reg step as completed
628
+		$this->set_completed();
629
+		$this->_set_success_message(
630
+			esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
631
+		);
632
+		// do action in case a plugin wants to do something with the data submitted in step 1.
633
+		// passes EE_Single_Page_Checkout, and it's posted data
634
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
635
+		return true;
636
+	}
637
+
638
+
639
+	/**
640
+	 * @since   $VID:$
641
+	 */
642
+	private function setLegacyFiltersForRegFormProcessing()
643
+	{
644
+		add_filter(
645
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegistrations__bypass',
646
+			[$this, 'preRegistrationProcess'],
647
+			1,
648
+			5
649
+		);
650
+		add_filter(
651
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegFormData__registrant_form_data',
652
+			[$this, 'validDataLineItem'],
653
+			1,
654
+			2
655
+		);
656
+		add_filter(
657
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput',
658
+			[$this, 'saveRegistrationFormInput'],
659
+			1,
660
+			4
661
+		);
662
+		add_filter(
663
+			'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet',
664
+			[$this, 'mergeAddressDetailsWithCriticalAttendeeDetails'],
665
+			1
666
+		);
667
+	}
668
+
669
+
670
+	/**
671
+	 * @param bool            $bypass
672
+	 * @param int             $attendee_count
673
+	 * @param EE_Registration $registration
674
+	 * @param array           $registrations
675
+	 * @param array           $reg_form_data
676
+	 * @return mixed|void
677
+	 * @since   $VID:$
678
+	 */
679
+	public function preRegistrationProcess(
680
+		$bypass,
681
+		$attendee_count,
682
+		$registration,
683
+		$registrations,
684
+		$reg_form_data
685
+	) {
686
+		return apply_filters(
687
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
688
+			$bypass,
689
+			$attendee_count,
690
+			$registration,
691
+			$registrations,
692
+			$reg_form_data,
693
+			$this
694
+		);
695
+	}
696
+
697
+
698
+	/**
699
+	 * @param array           $reg_form_data
700
+	 * @param EE_Registration $registration
701
+	 * @return mixed|void
702
+	 * @since   $VID:$
703
+	 */
704
+	public function validDataLineItem($reg_form_data, $registration)
705
+	{
706
+		return apply_filters(
707
+			'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
708
+			$reg_form_data,
709
+			$registration
710
+		);
711
+	}
712
+
713
+
714
+	/**
715
+	 * @param bool            $save
716
+	 * @param EE_Registration $registration
717
+	 * @param                 $form_input
718
+	 * @param                 $input_value
719
+	 * @return mixed|void
720
+	 * @since   $VID:$
721
+	 */
722
+	public function saveRegistrationFormInput($save, $registration, $form_input, $input_value)
723
+	{
724
+		return apply_filters(
725
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
726
+			$save,
727
+			$registration,
728
+			$form_input,
729
+			$input_value,
730
+			$this
731
+		);
732
+	}
733
+
734
+
735
+	/**
736
+	 * @param bool $merge_data
737
+	 * @return mixed|void
738
+	 * @since   $VID:$
739
+	 */
740
+	public function mergeAddressDetailsWithCriticalAttendeeDetails($merge_data)
741
+	{
742
+		return apply_filters(
743
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
744
+			$merge_data
745
+		);
746
+	}
747
+
748
+
749
+	/**
750
+	 * @return bool
751
+	 * @since   $VID:$
752
+	 */
753
+	private function inValidDataError()
754
+	{
755
+		EE_Error::add_error(
756
+			esc_html__('No valid question responses were received.', 'event_espresso'),
757
+			__FILE__,
758
+			__FUNCTION__,
759
+			__LINE__
760
+		);
761
+		return false;
762
+	}
763
+
764
+
765
+	/**
766
+	 * @return bool
767
+	 * @since   $VID:$
768
+	 */
769
+	private function inValidTransactionError()
770
+	{
771
+		EE_Error::add_error(
772
+			esc_html__(
773
+				'A valid transaction could not be initiated for processing your registrations.',
774
+				'event_espresso'
775
+			),
776
+			__FILE__,
777
+			__FUNCTION__,
778
+			__LINE__
779
+		);
780
+		return false;
781
+	}
782
+
783
+
784
+	/**
785
+	 * @return bool
786
+	 * @since   $VID:$
787
+	 */
788
+	private function noRegistrationsError()
789
+	{
790
+		// combine the old translated string with a new one, in order to not break translations
791
+		$error_message = esc_html__(
792
+			'Your form data could not be applied to any valid registrations.',
793
+			'event_espresso'
794
+		);
795
+		$error_message .= sprintf(
796
+			esc_html_x(
797
+				'%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.',
798
+				'(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
799
+				'event_espresso'
800
+			),
801
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" >',
802
+			'</a>',
803
+			'<br />'
804
+		);
805
+		EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__);
806
+		return false;
807
+	}
808
+
809
+
810
+	/**
811
+	 * @param int $registrations_processed
812
+	 * @return bool
813
+	 * @since   $VID:$
814
+	 */
815
+	private function registrationProcessingError($registrations_processed)
816
+	{
817
+		$registrations_processed = (int) $registrations_processed;
818
+		// generate a correctly translated string for all possible singular/plural combinations
819
+		if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
820
+			$error_msg = sprintf(
821
+				esc_html_x(
822
+					'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
823
+					'There was 1 ticket in the Event Queue, but 2 registrations were processed',
824
+					'event_espresso'
825
+				),
826
+				$this->checkout->total_ticket_count,
827
+				$registrations_processed
828
+			);
829
+		} elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
830
+			$error_msg = sprintf(
831
+				esc_html_x(
832
+					'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
833
+					'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed',
834
+					'event_espresso'
835
+				),
836
+				$this->checkout->total_ticket_count,
837
+				$registrations_processed
838
+			);
839
+		} else {
840
+			$error_msg = sprintf(
841
+				esc_html__(
842
+					'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed',
843
+					'event_espresso'
844
+				),
845
+				$this->checkout->total_ticket_count,
846
+				$registrations_processed
847
+			);
848
+		}
849
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
850
+		return false;
851
+	}
852
+
853
+
854
+	/**
855
+	 *    update_reg_step
856
+	 *    this is the final step after a user  revisits the site to edit their attendee information
857
+	 *    this gets called AFTER the process_reg_step() method above
858
+	 *
859
+	 * @return bool
860
+	 * @throws EE_Error
861
+	 * @throws InvalidArgumentException
862
+	 * @throws ReflectionException
863
+	 * @throws RuntimeException
864
+	 * @throws InvalidDataTypeException
865
+	 * @throws InvalidInterfaceException
866
+	 */
867
+	public function update_reg_step()
868
+	{
869
+		// save everything
870
+		if ($this->process_reg_step()) {
871
+			$this->checkout->redirect     = true;
872
+			$this->checkout->redirect_url = add_query_arg(
873
+				[
874
+					'e_reg_url_link' => $this->checkout->reg_url_link,
875
+					'revisit'        => true,
876
+				],
877
+				$this->checkout->thank_you_page_url
878
+			);
879
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
880
+			return true;
881
+		}
882
+		return false;
883
+	}
884 884
 }
Please login to merge, or discard this patch.