Completed
Pull Request — Gutenberg/master (#668)
by Darren
08:39
created
caffeinated/payment_methods/Aim/EE_PMT_Aim.pm.php 1 patch
Indentation   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -12,275 +12,275 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * @param EE_Payment_Method $pm_instance
17
-     * @return EE_PMT_Aim
18
-     * @throws \EE_Error
19
-     */
20
-    public function __construct($pm_instance = null)
21
-    {
22
-        $this->_setup_properties();
23
-        parent::__construct($pm_instance);
24
-    }
15
+	/**
16
+	 * @param EE_Payment_Method $pm_instance
17
+	 * @return EE_PMT_Aim
18
+	 * @throws \EE_Error
19
+	 */
20
+	public function __construct($pm_instance = null)
21
+	{
22
+		$this->_setup_properties();
23
+		parent::__construct($pm_instance);
24
+	}
25 25
     
26
-    /**
27
-     * Sets up payment method type properties for this gateway, which is normally
28
-     * done in the constructor, but we want this to be easy for similar gateways to override
29
-     * while still calling the parent constructor.
30
-     * So children should override this method instead of __construct
31
-     */
32
-    protected function _setup_properties()
33
-    {
34
-        require_once($this->file_folder().'EEG_Aim.gateway.php');
35
-        $this->_gateway = new EEG_Aim();
36
-        $this->_pretty_name = __("Authorize.net AIM", 'event_espresso');
37
-        $this->_default_description = __('Please provide the following billing information.', 'event_espresso');
38
-        $this->_requires_https = true;
39
-    }
26
+	/**
27
+	 * Sets up payment method type properties for this gateway, which is normally
28
+	 * done in the constructor, but we want this to be easy for similar gateways to override
29
+	 * while still calling the parent constructor.
30
+	 * So children should override this method instead of __construct
31
+	 */
32
+	protected function _setup_properties()
33
+	{
34
+		require_once($this->file_folder().'EEG_Aim.gateway.php');
35
+		$this->_gateway = new EEG_Aim();
36
+		$this->_pretty_name = __("Authorize.net AIM", 'event_espresso');
37
+		$this->_default_description = __('Please provide the following billing information.', 'event_espresso');
38
+		$this->_requires_https = true;
39
+	}
40 40
 
41 41
 
42 42
 
43
-    /**
44
-     * Creates the billing form for this payment method type
45
-     *
46
-     * @param \EE_Transaction $transaction
47
-     * @return EE_Billing_Info_Form
48
-     * @throws \EE_Error
49
-     */
50
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
51
-    {
52
-        $billing_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, array(
53
-            'name'=>'AIM_Form',
54
-            'subsections'=>array(
55
-                'credit_card'=>new EE_Credit_Card_Input(array(
56
-                    'required'=>true,
57
-                    'html_label_text' => __('Card Number', 'event_espresso')
58
-                )),
59
-                'exp_month'=>new EE_Credit_Card_Month_Input(true, array(
60
-                    'required'=>true,
61
-                    'html_label_text' => __('Expiry Month', 'event_espresso')
62
-                )),
63
-                'exp_year'=>new EE_Credit_Card_Year_Input(array(
64
-                    'required'=>true,
65
-                    'html_label_text' => __('Expiry Year', 'event_espresso')
66
-                )),
67
-                'cvv'=>new EE_CVV_Input(array(
68
-                    'required'=>true,
69
-                    'html_label_text' => __('CVV', 'event_espresso') )),
70
-            )
71
-        ));
72
-        $billing_form->add_subsections(array(
73
-            'company' => new EE_Text_Input(array(
74
-                'html_label_text' => __('Company', 'event_espresso')
75
-            ))
76
-        ), 'email', false);
77
-        $billing_form->add_subsections(
78
-            array(
79
-                    'fax' => new EE_Text_Input(array(
80
-                        'html_label_text' => __('Fax', 'event_espresso')
81
-                    ))
82
-                ),
83
-            'phone',
84
-            false
85
-        );
86
-        $settings_form = $this->settings_form();
87
-        if ($settings_form->get_input('excluded_billing_inputs') instanceof EE_Checkbox_Multi_Input) {
88
-                $billing_form->exclude($settings_form->get_input('excluded_billing_inputs')->normalized_value());
89
-        }
90
-        if ($settings_form->get_input('required_billing_inputs') instanceof EE_Checkbox_Multi_Input) {
91
-            $required_inputs = $settings_form->get_input('required_billing_inputs')->normalized_value();
92
-            // only change the requirement of inputs which are allowed to be changed
93
-            /** @var EE_Form_Input_Base[] $inputs_to_evaluate */
94
-            $inputs_to_evaluate = array_intersect_key(
95
-                $billing_form->inputs(),
96
-                $this->billing_input_names()
97
-            );
98
-            foreach ($inputs_to_evaluate as $input_name => $input) {
99
-                if (in_array($input_name, $required_inputs)) {
100
-                    $input->set_required(true);
101
-                } else {
102
-                    $input->set_required(false);
103
-                }
104
-            }
105
-        }
106
-        return $this->apply_billing_form_debug_settings($billing_form);
107
-    }
43
+	/**
44
+	 * Creates the billing form for this payment method type
45
+	 *
46
+	 * @param \EE_Transaction $transaction
47
+	 * @return EE_Billing_Info_Form
48
+	 * @throws \EE_Error
49
+	 */
50
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
51
+	{
52
+		$billing_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, array(
53
+			'name'=>'AIM_Form',
54
+			'subsections'=>array(
55
+				'credit_card'=>new EE_Credit_Card_Input(array(
56
+					'required'=>true,
57
+					'html_label_text' => __('Card Number', 'event_espresso')
58
+				)),
59
+				'exp_month'=>new EE_Credit_Card_Month_Input(true, array(
60
+					'required'=>true,
61
+					'html_label_text' => __('Expiry Month', 'event_espresso')
62
+				)),
63
+				'exp_year'=>new EE_Credit_Card_Year_Input(array(
64
+					'required'=>true,
65
+					'html_label_text' => __('Expiry Year', 'event_espresso')
66
+				)),
67
+				'cvv'=>new EE_CVV_Input(array(
68
+					'required'=>true,
69
+					'html_label_text' => __('CVV', 'event_espresso') )),
70
+			)
71
+		));
72
+		$billing_form->add_subsections(array(
73
+			'company' => new EE_Text_Input(array(
74
+				'html_label_text' => __('Company', 'event_espresso')
75
+			))
76
+		), 'email', false);
77
+		$billing_form->add_subsections(
78
+			array(
79
+					'fax' => new EE_Text_Input(array(
80
+						'html_label_text' => __('Fax', 'event_espresso')
81
+					))
82
+				),
83
+			'phone',
84
+			false
85
+		);
86
+		$settings_form = $this->settings_form();
87
+		if ($settings_form->get_input('excluded_billing_inputs') instanceof EE_Checkbox_Multi_Input) {
88
+				$billing_form->exclude($settings_form->get_input('excluded_billing_inputs')->normalized_value());
89
+		}
90
+		if ($settings_form->get_input('required_billing_inputs') instanceof EE_Checkbox_Multi_Input) {
91
+			$required_inputs = $settings_form->get_input('required_billing_inputs')->normalized_value();
92
+			// only change the requirement of inputs which are allowed to be changed
93
+			/** @var EE_Form_Input_Base[] $inputs_to_evaluate */
94
+			$inputs_to_evaluate = array_intersect_key(
95
+				$billing_form->inputs(),
96
+				$this->billing_input_names()
97
+			);
98
+			foreach ($inputs_to_evaluate as $input_name => $input) {
99
+				if (in_array($input_name, $required_inputs)) {
100
+					$input->set_required(true);
101
+				} else {
102
+					$input->set_required(false);
103
+				}
104
+			}
105
+		}
106
+		return $this->apply_billing_form_debug_settings($billing_form);
107
+	}
108 108
 
109 109
 
110 110
 
111
-    /**
112
-     * apply_billing_form_debug_settings
113
-     * applies debug data to the form
114
-     *
115
-     * @param \EE_Billing_Info_Form $billing_form
116
-     * @return \EE_Billing_Info_Form
117
-     * @throws \EE_Error
118
-     */
119
-    public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
120
-    {
121
-        if ($this->_pm_instance->debug_mode()
122
-            || $this->_pm_instance->get_extra_meta('test_transactions', true, false)
123
-        ) {
124
-            $billing_form->get_input('credit_card')->set_default('4007000000027');
125
-            $billing_form->get_input('exp_year')->set_default('2020');
126
-            if ($billing_form->get_subsection('cvv') instanceof EE_Form_Input_Base) {
127
-                $billing_form->get_input('cvv')->set_default('123');
128
-            }
129
-            $billing_form->add_subsections(
130
-                array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ),
131
-                'credit_card'
132
-            );
133
-            $billing_form->add_subsections(
134
-                array(
135
-                    'debug_content' => new EE_Form_Section_HTML_From_Template(
136
-                        __DIR__.DS.'templates'.DS.'authorize_net_aim_debug_info.template.php'
137
-                    )
138
-                ),
139
-                'first_name'
140
-            );
141
-        }
142
-        return $billing_form;
143
-    }
111
+	/**
112
+	 * apply_billing_form_debug_settings
113
+	 * applies debug data to the form
114
+	 *
115
+	 * @param \EE_Billing_Info_Form $billing_form
116
+	 * @return \EE_Billing_Info_Form
117
+	 * @throws \EE_Error
118
+	 */
119
+	public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
120
+	{
121
+		if ($this->_pm_instance->debug_mode()
122
+			|| $this->_pm_instance->get_extra_meta('test_transactions', true, false)
123
+		) {
124
+			$billing_form->get_input('credit_card')->set_default('4007000000027');
125
+			$billing_form->get_input('exp_year')->set_default('2020');
126
+			if ($billing_form->get_subsection('cvv') instanceof EE_Form_Input_Base) {
127
+				$billing_form->get_input('cvv')->set_default('123');
128
+			}
129
+			$billing_form->add_subsections(
130
+				array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ),
131
+				'credit_card'
132
+			);
133
+			$billing_form->add_subsections(
134
+				array(
135
+					'debug_content' => new EE_Form_Section_HTML_From_Template(
136
+						__DIR__.DS.'templates'.DS.'authorize_net_aim_debug_info.template.php'
137
+					)
138
+				),
139
+				'first_name'
140
+			);
141
+		}
142
+		return $billing_form;
143
+	}
144 144
 
145 145
 
146 146
 
147
-    /**
148
-     * Gets the form for all the settings related to this payment method type
149
-     * @return EE_Payment_Method_Form
150
-     */
151
-    public function generate_new_settings_form()
152
-    {
153
-        $billing_input_names = $this->billing_input_names();
154
-        return new EE_Payment_Method_Form(
155
-            array(
156
-                'extra_meta_inputs'=>array(
157
-                    'login_id'=>new EE_Text_Input(
158
-                        array(
159
-                            'html_label_text'=>  sprintf(__("Authorize.net API Login ID %s", "event_espresso"), $this->get_help_tab_link()),
160
-                            'required' => true )
161
-                    ),
162
-                    'transaction_key'=>new EE_Text_Input(
163
-                        array(
164
-                            'html_label_text'=> sprintf(__("Authorize.net Transaction Key %s", "event_espresso"), $this->get_help_tab_link()),
165
-                            'required' => true )
166
-                    ),
167
-                    'test_transactions'=>new EE_Yes_No_Input(
168
-                        array(
169
-                            'html_label_text'=>  sprintf(__("Send test transactions? %s", 'event_espresso'), $this->get_help_tab_link()),
170
-                            'html_help_text'=>  __("Send test transactions, even to live server", 'event_espresso'),
171
-                            'default' => false,
172
-                            'required' => true
173
-                        )
174
-                    ),
175
-                    'excluded_billing_inputs' => new EE_Checkbox_Multi_Input(
176
-                        $billing_input_names,
177
-                        array(
178
-                        'html_label_text' => sprintf(__("Excluded Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()),
179
-                        'default' => array(
180
-                            'company',
181
-                            'fax',
182
-                        )
183
-                        )
184
-                    ),
185
-                    'required_billing_inputs' => new EE_Checkbox_Multi_Input(
186
-                        $billing_input_names,
187
-                        array(
188
-                            'html_label_text' => sprintf(__("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()),
189
-                            'default' => array_diff(
190
-                                array_keys($billing_input_names),
191
-                                array( 'address2', 'phone', 'company', 'fax' )
192
-                            ),
193
-                            'html_help_text' => __('Note: if fields are excluded they cannot be required.', 'event_espresso')
194
-                        )
195
-                    ),
196
-                    'server' => new EE_Select_Input(
197
-                        apply_filters(
198
-                            'FHEE__EE_PMT_Aim__generate_new_settings_form__server_select_input__options',
199
-                            array(
200
-                                'akamai' => __('Authorize.net/Akamai (default)', 'event_espresso'),
201
-                                'authorize.net' => __('Authorize.net (deprecated)', 'event_espresso'),
202
-                            ),
203
-                            $this
204
-                        ),
205
-                        array(
206
-                            'html_label_text' => __('Server', 'event_espresso'),
207
-                            'html_help_text' => __('The Gateway Server where payment requests will be sent', 'event_espresso')
208
-                        )
209
-                    )
147
+	/**
148
+	 * Gets the form for all the settings related to this payment method type
149
+	 * @return EE_Payment_Method_Form
150
+	 */
151
+	public function generate_new_settings_form()
152
+	{
153
+		$billing_input_names = $this->billing_input_names();
154
+		return new EE_Payment_Method_Form(
155
+			array(
156
+				'extra_meta_inputs'=>array(
157
+					'login_id'=>new EE_Text_Input(
158
+						array(
159
+							'html_label_text'=>  sprintf(__("Authorize.net API Login ID %s", "event_espresso"), $this->get_help_tab_link()),
160
+							'required' => true )
161
+					),
162
+					'transaction_key'=>new EE_Text_Input(
163
+						array(
164
+							'html_label_text'=> sprintf(__("Authorize.net Transaction Key %s", "event_espresso"), $this->get_help_tab_link()),
165
+							'required' => true )
166
+					),
167
+					'test_transactions'=>new EE_Yes_No_Input(
168
+						array(
169
+							'html_label_text'=>  sprintf(__("Send test transactions? %s", 'event_espresso'), $this->get_help_tab_link()),
170
+							'html_help_text'=>  __("Send test transactions, even to live server", 'event_espresso'),
171
+							'default' => false,
172
+							'required' => true
173
+						)
174
+					),
175
+					'excluded_billing_inputs' => new EE_Checkbox_Multi_Input(
176
+						$billing_input_names,
177
+						array(
178
+						'html_label_text' => sprintf(__("Excluded Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()),
179
+						'default' => array(
180
+							'company',
181
+							'fax',
182
+						)
183
+						)
184
+					),
185
+					'required_billing_inputs' => new EE_Checkbox_Multi_Input(
186
+						$billing_input_names,
187
+						array(
188
+							'html_label_text' => sprintf(__("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()),
189
+							'default' => array_diff(
190
+								array_keys($billing_input_names),
191
+								array( 'address2', 'phone', 'company', 'fax' )
192
+							),
193
+							'html_help_text' => __('Note: if fields are excluded they cannot be required.', 'event_espresso')
194
+						)
195
+					),
196
+					'server' => new EE_Select_Input(
197
+						apply_filters(
198
+							'FHEE__EE_PMT_Aim__generate_new_settings_form__server_select_input__options',
199
+							array(
200
+								'akamai' => __('Authorize.net/Akamai (default)', 'event_espresso'),
201
+								'authorize.net' => __('Authorize.net (deprecated)', 'event_espresso'),
202
+							),
203
+							$this
204
+						),
205
+						array(
206
+							'html_label_text' => __('Server', 'event_espresso'),
207
+							'html_help_text' => __('The Gateway Server where payment requests will be sent', 'event_espresso')
208
+						)
209
+					)
210 210
                         
211
-                )
212
-            )
213
-        );
214
-    }
211
+				)
212
+			)
213
+		);
214
+	}
215 215
     
216
-    /**
217
-     * Returns an array where keys are the slugs for billing inputs, and values
218
-     * are their i18n names
219
-     * @return array
220
-     */
221
-    public function billing_input_names()
222
-    {
223
-        return array(
224
-            'first_name' => __('First Name', 'event_espresso'),
225
-            'last_name' => __('Last Name', 'event_espresso'),
226
-            'email' => __('Email', 'event_espresso'),
227
-            'company' => __('Company', 'event_espresso'),
228
-            'address' => __('Address', 'event_espresso'),
229
-            'address2' => __('Address2', 'event_espresso'),
230
-            'city' => __('City', 'event_espresso'),
231
-            'state' => __('State', 'event_espresso'),
232
-            'country' => __('Country', 'event_espresso'),
233
-            'zip' =>  __('Zip', 'event_espresso'),
234
-            'phone' => __('Phone', 'event_espresso'),
235
-            'fax' => __('Fax', 'event_espresso'),
236
-            'cvv' => __('CVV', 'event_espresso')
237
-        );
238
-    }
216
+	/**
217
+	 * Returns an array where keys are the slugs for billing inputs, and values
218
+	 * are their i18n names
219
+	 * @return array
220
+	 */
221
+	public function billing_input_names()
222
+	{
223
+		return array(
224
+			'first_name' => __('First Name', 'event_espresso'),
225
+			'last_name' => __('Last Name', 'event_espresso'),
226
+			'email' => __('Email', 'event_espresso'),
227
+			'company' => __('Company', 'event_espresso'),
228
+			'address' => __('Address', 'event_espresso'),
229
+			'address2' => __('Address2', 'event_espresso'),
230
+			'city' => __('City', 'event_espresso'),
231
+			'state' => __('State', 'event_espresso'),
232
+			'country' => __('Country', 'event_espresso'),
233
+			'zip' =>  __('Zip', 'event_espresso'),
234
+			'phone' => __('Phone', 'event_espresso'),
235
+			'fax' => __('Fax', 'event_espresso'),
236
+			'cvv' => __('CVV', 'event_espresso')
237
+		);
238
+	}
239 239
     
240
-    /**
241
-     * Overrides parent so we always have all billing inputs in the returned array,
242
-     * not just the ones included at the time. This helps simplify the gateway code
243
-     *
244
-     * @param EE_Billing_Info_Form $billing_form
245
-     * @return array
246
-     */
247
-    protected function _get_billing_values_from_form($billing_form)
248
-    {
249
-        $all_billing_values_empty = array();
250
-        foreach (array_keys($this->billing_input_names()) as $input_name) {
251
-            $all_billing_values_empty[ $input_name ] = '';
252
-        }
253
-        return array_merge(
254
-            $all_billing_values_empty,
255
-            parent::_get_billing_values_from_form($billing_form)
256
-        );
257
-    }
240
+	/**
241
+	 * Overrides parent so we always have all billing inputs in the returned array,
242
+	 * not just the ones included at the time. This helps simplify the gateway code
243
+	 *
244
+	 * @param EE_Billing_Info_Form $billing_form
245
+	 * @return array
246
+	 */
247
+	protected function _get_billing_values_from_form($billing_form)
248
+	{
249
+		$all_billing_values_empty = array();
250
+		foreach (array_keys($this->billing_input_names()) as $input_name) {
251
+			$all_billing_values_empty[ $input_name ] = '';
252
+		}
253
+		return array_merge(
254
+			$all_billing_values_empty,
255
+			parent::_get_billing_values_from_form($billing_form)
256
+		);
257
+	}
258 258
 
259 259
 
260 260
 
261
-    /**
262
-     * Adds the help tab
263
-     * @see EE_PMT_Base::help_tabs_config()
264
-     * @return array
265
-     */
266
-    public function help_tabs_config()
267
-    {
268
-        return array(
269
-            $this->get_help_tab_name() => array(
270
-                'title' => __('Authorize.net AIM Settings', 'event_espresso'),
271
-                'filename' => 'payment_methods_overview_aim'
272
-            ),
273
-        );
274
-    }
261
+	/**
262
+	 * Adds the help tab
263
+	 * @see EE_PMT_Base::help_tabs_config()
264
+	 * @return array
265
+	 */
266
+	public function help_tabs_config()
267
+	{
268
+		return array(
269
+			$this->get_help_tab_name() => array(
270
+				'title' => __('Authorize.net AIM Settings', 'event_espresso'),
271
+				'filename' => 'payment_methods_overview_aim'
272
+			),
273
+		);
274
+	}
275 275
 
276 276
 
277 277
 
278
-    /**
279
-     * Gets a list of instructions and/or information regarding how the payment is to be completed
280
-     * @return string
281
-     */
282
-    public function payment_information()
283
-    {
284
-        // TODO: Implement payment_information() method.
285
-    }
278
+	/**
279
+	 * Gets a list of instructions and/or information regarding how the payment is to be completed
280
+	 * @return string
281
+	 */
282
+	public function payment_information()
283
+	{
284
+		// TODO: Implement payment_information() method.
285
+	}
286 286
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Question.model.php 1 patch
Indentation   +425 added lines, -425 removed lines patch added patch discarded remove patch
@@ -10,429 +10,429 @@
 block discarded – undo
10 10
 class EEM_Question extends EEM_Soft_Delete_Base
11 11
 {
12 12
 
13
-    // constant used to indicate that the question type is COUNTRY
14
-    const QST_type_country = 'COUNTRY';
15
-
16
-    // constant used to indicate that the question type is DATE
17
-    const QST_type_date = 'DATE';
18
-
19
-    // constant used to indicate that the question type is DROPDOWN
20
-    const QST_type_dropdown = 'DROPDOWN';
21
-
22
-    // constant used to indicate that the question type is CHECKBOX
23
-    const QST_type_checkbox = 'CHECKBOX';
24
-
25
-    // constant used to indicate that the question type is RADIO_BTN
26
-    const QST_type_radio = 'RADIO_BTN';
27
-
28
-    // constant used to indicate that the question type is STATE
29
-    const QST_type_state = 'STATE';
30
-
31
-    // constant used to indicate that the question type is TEXT
32
-    const QST_type_text = 'TEXT';
33
-
34
-    // constant used to indicate that the question type is TEXTAREA
35
-    const QST_type_textarea = 'TEXTAREA';
36
-
37
-    // constant used to indicate that the question type is a TEXTAREA that allows simple html
38
-    const QST_type_html_textarea = 'HTML_TEXTAREA';
39
-
40
-    // constant used to indicate that the question type is an email input
41
-    const QST_type_email = 'EMAIL';
42
-
43
-    // constant used to indicate that the question type is a US-formatted phone number
44
-    const QST_type_us_phone = 'US_PHONE';
45
-
46
-    // constant used to indicate that the question type is an integer (whole number)
47
-    const QST_type_int = 'INTEGER';
48
-
49
-    // constant used to indicate that the question type is a decimal (float)
50
-    const QST_type_decimal = 'DECIMAL';
51
-
52
-    // constant used to indicate that the question type is a valid URL
53
-    const QST_type_url = 'URL';
54
-
55
-    // constant used to indicate that the question type is a YEAR
56
-    const QST_type_year = 'YEAR';
57
-
58
-    // constant used to indicate that the question type is a multi-select
59
-    const QST_type_multi_select = 'MULTI_SELECT';
60
-
61
-    /**
62
-     * Question types that are interchangeable, even after answers have been provided for them.
63
-     * Top-level keys are category slugs, next level is an array of question types. If question types
64
-     * aren't in this array, it is assumed they AREN'T interchangeable with any other question types.
65
-     *
66
-     * @access protected
67
-     * @var array $_question_type_categories {
68
-     * @type string $text
69
-     * @type string $single -answer-enum
70
-     * @type string $multi -answer-enum
71
-     *                    }
72
-     */
73
-    protected $_question_type_categories = array();
74
-
75
-    /**
76
-     * lists all the question types which should be allowed. Ideally, this will be extensible.
77
-     *
78
-     * @access protected
79
-     * @var array $_allowed_question_types
80
-     */
81
-    protected $_allowed_question_types = array();
82
-
83
-    /**
84
-     * brief descriptions for all the question types
85
-     *
86
-     * @access protected
87
-     * @var EEM_Question $_instance
88
-     */
89
-    protected $_question_descriptions;
90
-
91
-
92
-    /**
93
-     * Question types that should have an admin-defined max input length
94
-     * @var array
95
-     */
96
-    protected $question_types_with_max_lengh;
97
-
98
-
99
-    // private instance of the Attendee object
100
-    protected static $_instance = null;
101
-
102
-
103
-    /**
104
-     * EEM_Question constructor.
105
-     *
106
-     * @param null $timezone
107
-     */
108
-    protected function __construct($timezone = null)
109
-    {
110
-        $this->singular_item = __('Question', 'event_espresso');
111
-        $this->plural_item = __('Questions', 'event_espresso');
112
-        $this->_allowed_question_types = apply_filters(
113
-            'FHEE__EEM_Question__construct__allowed_question_types',
114
-            array(
115
-                EEM_Question::QST_type_text => __('Text', 'event_espresso'),
116
-                EEM_Question::QST_type_textarea => __('Textarea', 'event_espresso'),
117
-                EEM_Question::QST_type_checkbox => __('Checkboxes', 'event_espresso'),
118
-                EEM_Question::QST_type_radio => __('Radio Buttons', 'event_espresso'),
119
-                EEM_Question::QST_type_dropdown => __('Dropdown', 'event_espresso'),
120
-                EEM_Question::QST_type_state => __('State/Province Dropdown', 'event_espresso'),
121
-                EEM_Question::QST_type_country => __('Country Dropdown', 'event_espresso'),
122
-                EEM_Question::QST_type_date => __('Date Picker', 'event_espresso'),
123
-                EEM_Question::QST_type_html_textarea => __('HTML Textarea', 'event_espresso'),
124
-                EEM_Question::QST_type_email => __('Email', 'event_espresso'),
125
-                EEM_Question::QST_type_us_phone => __('USA - Format Phone', 'event_espresso'),
126
-                EEM_Question::QST_type_decimal => __('Number', 'event_espresso'),
127
-                EEM_Question::QST_type_int => __('Whole Number', 'event_espresso'),
128
-                EEM_Question::QST_type_url => __('URL', 'event_espresso'),
129
-                EEM_Question::QST_type_year => __('Year', 'event_espresso'),
130
-                EEM_Question::QST_type_multi_select => __('Multi Select', 'event_espresso')
131
-            )
132
-        );
133
-        $this->_question_descriptions = apply_filters(
134
-            'FHEE__EEM_Question__construct__question_descriptions',
135
-            array(
136
-                EEM_Question::QST_type_text => __('A single line text input field', 'event_espresso'),
137
-                EEM_Question::QST_type_textarea => __('A multi line text input field', 'event_espresso'),
138
-                EEM_Question::QST_type_checkbox => __('Allows multiple preset options to be selected', 'event_espresso'),
139
-                EEM_Question::QST_type_radio => __('Allows a single preset option to be selected', 'event_espresso'),
140
-                EEM_Question::QST_type_dropdown => __('A dropdown that allows a single selection', 'event_espresso'),
141
-                EEM_Question::QST_type_state => __('A dropdown that lists states/provinces', 'event_espresso'),
142
-                EEM_Question::QST_type_country => __('A dropdown that lists countries', 'event_espresso'),
143
-                EEM_Question::QST_type_date => __('A popup calendar that allows date selections', 'event_espresso'),
144
-                EEM_Question::QST_type_html_textarea => __('A multi line text input field that allows HTML', 'event_espresso'),
145
-                EEM_Question::QST_type_email => __('A text field that must contain a valid Email address', 'event_espresso'),
146
-                EEM_Question::QST_type_us_phone => __('A text field that must contain a valid US phone number', 'event_espresso'),
147
-                EEM_Question::QST_type_decimal => __('A text field that allows number values with decimals', 'event_espresso'),
148
-                EEM_Question::QST_type_int => __('A text field that only allows whole numbers (no decimals)', 'event_espresso'),
149
-                EEM_Question::QST_type_url => __('A text field that must contain a valid URL', 'event_espresso'),
150
-                EEM_Question::QST_type_year => __('A dropdown that lists the last 100 years', 'event_espresso'),
151
-                EEM_Question::QST_type_multi_select => __('A dropdown that allows multiple selections', 'event_espresso')
152
-            )
153
-        );
154
-        $this->_question_type_categories = (array) apply_filters(
155
-            'FHEE__EEM_Question__construct__question_type_categories',
156
-            array(
157
-                'text' => array(
158
-                    EEM_Question::QST_type_text,
159
-                    EEM_Question::QST_type_textarea,
160
-                    EEM_Question::QST_type_date,
161
-                    EEM_Question::QST_type_html_textarea,
162
-                    EEM_Question::QST_type_email,
163
-                    EEM_Question::QST_type_us_phone,
164
-                    EEM_Question::QST_type_decimal,
165
-                    EEM_Question::QST_type_int,
166
-                    EEM_Question::QST_type_url,
167
-                    EEM_Question::QST_type_year
168
-                ),
169
-                'single-answer-enum' => array(
170
-                    EEM_Question::QST_type_radio,
171
-                    EEM_Question::QST_type_dropdown
172
-                ),
173
-                'multi-answer-enum' => array(
174
-                    EEM_Question::QST_type_checkbox,
175
-                    EEM_Question::QST_type_multi_select
176
-                )
177
-            )
178
-        );
179
-        $this->question_types_with_max_lengh = apply_filters(
180
-            'FHEE__EEM_Question___construct__question_types_with_max_length',
181
-            array(
182
-                EEM_Question::QST_type_text,
183
-                EEM_Question::QST_type_textarea,
184
-                EEM_Question::QST_type_html_textarea
185
-            )
186
-        );
187
-
188
-        $this->_tables = array(
189
-            'Question' => new EE_Primary_Table('esp_question', 'QST_ID')
190
-        );
191
-        $this->_fields = array(
192
-            'Question' => array(
193
-                'QST_ID' => new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')),
194
-                'QST_display_text' => new EE_Post_Content_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''),
195
-                'QST_admin_label' => new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''),
196
-                'QST_system' => new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), false, ''),
197
-                'QST_type' => new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types),
198
-                'QST_required' => new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false),
199
-                'QST_required_text' => new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''),
200
-                'QST_order' => new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0),
201
-                'QST_admin_only' => new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false),
202
-                'QST_max' => new EE_Infinite_Integer_Field('QST_max', __('Max Size', 'event_espresso'), false, EE_INF),
203
-                'QST_wp_user' => new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false),
204
-                'QST_deleted' => new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false)
205
-            )
206
-        );
207
-        $this->_model_relations = array(
208
-            'Question_Group' => new EE_HABTM_Relation('Question_Group_Question'),
209
-            'Question_Option' => new EE_Has_Many_Relation(),
210
-            'Answer' => new EE_Has_Many_Relation(),
211
-            'WP_User' => new EE_Belongs_To_Relation(),
212
-            // for QST_order column
213
-            'Question_Group_Question' => new EE_Has_Many_Relation()
214
-        );
215
-        // this model is generally available for reading
216
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
217
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QST_system');
218
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QST_system');
219
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QST_system');
220
-        parent::__construct($timezone);
221
-    }
222
-
223
-    /**
224
-     * Returns the list of allowed question types, which are normally: 'TEXT','TEXTAREA','RADIO_BTN','DROPDOWN','CHECKBOX','DATE'
225
-     * but they can be extended
226
-     * @return string[]
227
-     */
228
-    public function allowed_question_types()
229
-    {
230
-        return $this->_allowed_question_types;
231
-    }
232
-
233
-    /**
234
-     * Gets all the question types in the same category
235
-     * @param string $question_type one of EEM_Question::allowed_question_types(
236
-     * @return string[] like EEM_Question::allowed_question_types()
237
-     */
238
-    public function question_types_in_same_category($question_type)
239
-    {
240
-        $question_types = array($question_type);
241
-        foreach ($this->_question_type_categories as $category => $question_types_in_category) {
242
-            if (in_array($question_type, $question_types_in_category)) {
243
-                $question_types = $question_types_in_category;
244
-                break;
245
-            }
246
-        }
247
-
248
-        return array_intersect_key($this->allowed_question_types(), array_flip($question_types));
249
-    }
250
-
251
-    /**
252
-     * Determines if the given question type is in the given question type category
253
-     * @param string $question_type one of EEM_Question::allowed_question_types()
254
-     * @param string $category one of the top-level keys of EEM_Question::question_type_categories()
255
-     * @return boolean
256
-     */
257
-    public function question_type_is_in_category($question_type, $category)
258
-    {
259
-        if (!isset($this->_question_type_categories[ $category ])) {
260
-            return false;
261
-        }
262
-        return in_array($question_type, $this->_question_type_categories[ $category ]);
263
-    }
264
-
265
-
266
-    /**
267
-     * Returns all the question types in the given category
268
-     * @param string $category
269
-     * @return array|mixed
270
-     */
271
-    public function question_types_in_category($category)
272
-    {
273
-        if (isset($this->_question_type_categories[ $category ])) {
274
-            return $this->_question_type_categories[ $category ];
275
-        }
276
-        return array();
277
-    }
278
-
279
-
280
-    /**
281
-     * Returns all the question types that should have question options
282
-     * @return array
283
-     */
284
-    public function question_types_with_options()
285
-    {
286
-        return array_merge(
287
-            $this->question_types_in_category('single-answer-enum'),
288
-            $this->question_types_in_category('multi-answer-enum')
289
-        );
290
-    }
291
-
292
-    /**
293
-     * Returns the question type categories 2d array
294
-     * @return array see EEM_Question::_question_type_categories
295
-     */
296
-    public function question_type_categories()
297
-    {
298
-        return $this->_question_type_categories;
299
-    }
300
-
301
-    /**
302
-     * Returns an array of all the QST_system values that can be allowed in the system question group
303
-     * identified by $system_question_group_id
304
-     * @param string $system_question_group_id QSG_system
305
-     * @return array of system question names (QST_system)
306
-     */
307
-    public function allowed_system_questions_in_system_question_group($system_question_group_id)
308
-    {
309
-        $question_system_ids = array();
310
-        switch ($system_question_group_id) {
311
-            case EEM_Question_Group::system_personal:
312
-                $question_system_ids = array(
313
-                    EEM_Attendee::system_question_fname,
314
-                    EEM_Attendee::system_question_lname,
315
-                    EEM_Attendee::system_question_email,
316
-                    EEM_Attendee::system_question_phone
317
-                );
318
-                break;
319
-            case EEM_Question_Group::system_address:
320
-                $question_system_ids = array(
321
-                    EEM_Attendee::system_question_address,
322
-                    EEM_Attendee::system_question_address2,
323
-                    EEM_Attendee::system_question_city,
324
-                    EEM_Attendee::system_question_state,
325
-                    EEM_Attendee::system_question_country,
326
-                    EEM_Attendee::system_question_zip,
327
-                    EEM_Attendee::system_question_phone
328
-                );
329
-                break;
330
-        }
331
-        return apply_filters('FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id);
332
-    }
333
-
334
-    /**
335
-     * Returns an array of all the QST_system values that are required in the system question group
336
-     * identified by $system_question_group_id
337
-     * @param string $system_question_group_id QSG_system
338
-     * @return array of system question names (QST_system)
339
-     */
340
-    public function required_system_questions_in_system_question_group($system_question_group_id)
341
-    {
342
-        $question_system_ids = null;
343
-        switch ($system_question_group_id) {
344
-            case EEM_Question_Group::system_personal:
345
-                $question_system_ids = array(
346
-                    EEM_Attendee::system_question_fname,
347
-                    EEM_Attendee::system_question_email,
348
-                );
349
-                break;
350
-            default:
351
-                $question_system_ids = array();
352
-        }
353
-        return apply_filters('FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id);
354
-    }
355
-
356
-
357
-    /**
358
-     * Gets an array for converting between QST_system and QST_IDs for system questions. Eg, if you want to know
359
-     * which system question QST_ID corresponds to the QST_system 'city', use EEM_Question::instance()->get_Question_ID_from_system_string('city');
360
-     * @param $QST_system
361
-     * @return int of QST_ID for the question that corresponds to that QST_system
362
-     */
363
-    public function get_Question_ID_from_system_string($QST_system)
364
-    {
365
-        return $this->get_var(array(array('QST_system' => $QST_system)));
366
-    }
367
-
368
-
369
-    /**
370
-     * searches the db for the question with the latest question order and returns that value.
371
-     * @access public
372
-     * @return int
373
-     */
374
-    public function get_latest_question_order()
375
-    {
376
-        $columns_to_select = array(
377
-            'max_order' => array("MAX(QST_order)", "%d")
378
-        );
379
-        $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
380
-        return isset($max[0], $max[0]['max_order']) ? $max[0]['max_order'] : 0;
381
-    }
382
-
383
-    /**
384
-     * Returns an array where keys are system question QST_system values,
385
-     * and values are the highest question max the admin can set on the question
386
-     * (aka the "max max"; eg, a site admin can change the zip question to have a max
387
-     * of 5, but no larger than 12)
388
-     * @return array
389
-     */
390
-    public function system_question_maxes()
391
-    {
392
-        return array(
393
-            'fname' => 45,
394
-            'lname' => 45,
395
-            'address' => 255,
396
-            'address2' => 255,
397
-            'city' => 45,
398
-            'zip' => 12,
399
-            'email' => 255,
400
-            'phone' => 45,
401
-        );
402
-    }
403
-
404
-    /**
405
-     * Given a QST_system value, gets the question's largest allowable max input.
406
-     * @see Registration_Form_Admin_Page::system_question_maxes()
407
-     * @param string $system_question_value
408
-     * @return int|float
409
-     */
410
-    public function absolute_max_for_system_question($system_question_value)
411
-    {
412
-        $maxes = $this->system_question_maxes();
413
-        if (isset($maxes[ $system_question_value ])) {
414
-            return $maxes[ $system_question_value ];
415
-        } else {
416
-            return EE_INF;
417
-        }
418
-    }
419
-
420
-
421
-    /**
422
-     * @return array
423
-     */
424
-    public function question_descriptions()
425
-    {
426
-        return $this->_question_descriptions;
427
-    }
428
-
429
-
430
-    /**
431
-     * Returns all the question types that should have an admin-defined max input length
432
-     * @return array
433
-     */
434
-    public function questionTypesWithMaxLength()
435
-    {
436
-        return (array) $this->question_types_with_max_lengh;
437
-    }
13
+	// constant used to indicate that the question type is COUNTRY
14
+	const QST_type_country = 'COUNTRY';
15
+
16
+	// constant used to indicate that the question type is DATE
17
+	const QST_type_date = 'DATE';
18
+
19
+	// constant used to indicate that the question type is DROPDOWN
20
+	const QST_type_dropdown = 'DROPDOWN';
21
+
22
+	// constant used to indicate that the question type is CHECKBOX
23
+	const QST_type_checkbox = 'CHECKBOX';
24
+
25
+	// constant used to indicate that the question type is RADIO_BTN
26
+	const QST_type_radio = 'RADIO_BTN';
27
+
28
+	// constant used to indicate that the question type is STATE
29
+	const QST_type_state = 'STATE';
30
+
31
+	// constant used to indicate that the question type is TEXT
32
+	const QST_type_text = 'TEXT';
33
+
34
+	// constant used to indicate that the question type is TEXTAREA
35
+	const QST_type_textarea = 'TEXTAREA';
36
+
37
+	// constant used to indicate that the question type is a TEXTAREA that allows simple html
38
+	const QST_type_html_textarea = 'HTML_TEXTAREA';
39
+
40
+	// constant used to indicate that the question type is an email input
41
+	const QST_type_email = 'EMAIL';
42
+
43
+	// constant used to indicate that the question type is a US-formatted phone number
44
+	const QST_type_us_phone = 'US_PHONE';
45
+
46
+	// constant used to indicate that the question type is an integer (whole number)
47
+	const QST_type_int = 'INTEGER';
48
+
49
+	// constant used to indicate that the question type is a decimal (float)
50
+	const QST_type_decimal = 'DECIMAL';
51
+
52
+	// constant used to indicate that the question type is a valid URL
53
+	const QST_type_url = 'URL';
54
+
55
+	// constant used to indicate that the question type is a YEAR
56
+	const QST_type_year = 'YEAR';
57
+
58
+	// constant used to indicate that the question type is a multi-select
59
+	const QST_type_multi_select = 'MULTI_SELECT';
60
+
61
+	/**
62
+	 * Question types that are interchangeable, even after answers have been provided for them.
63
+	 * Top-level keys are category slugs, next level is an array of question types. If question types
64
+	 * aren't in this array, it is assumed they AREN'T interchangeable with any other question types.
65
+	 *
66
+	 * @access protected
67
+	 * @var array $_question_type_categories {
68
+	 * @type string $text
69
+	 * @type string $single -answer-enum
70
+	 * @type string $multi -answer-enum
71
+	 *                    }
72
+	 */
73
+	protected $_question_type_categories = array();
74
+
75
+	/**
76
+	 * lists all the question types which should be allowed. Ideally, this will be extensible.
77
+	 *
78
+	 * @access protected
79
+	 * @var array $_allowed_question_types
80
+	 */
81
+	protected $_allowed_question_types = array();
82
+
83
+	/**
84
+	 * brief descriptions for all the question types
85
+	 *
86
+	 * @access protected
87
+	 * @var EEM_Question $_instance
88
+	 */
89
+	protected $_question_descriptions;
90
+
91
+
92
+	/**
93
+	 * Question types that should have an admin-defined max input length
94
+	 * @var array
95
+	 */
96
+	protected $question_types_with_max_lengh;
97
+
98
+
99
+	// private instance of the Attendee object
100
+	protected static $_instance = null;
101
+
102
+
103
+	/**
104
+	 * EEM_Question constructor.
105
+	 *
106
+	 * @param null $timezone
107
+	 */
108
+	protected function __construct($timezone = null)
109
+	{
110
+		$this->singular_item = __('Question', 'event_espresso');
111
+		$this->plural_item = __('Questions', 'event_espresso');
112
+		$this->_allowed_question_types = apply_filters(
113
+			'FHEE__EEM_Question__construct__allowed_question_types',
114
+			array(
115
+				EEM_Question::QST_type_text => __('Text', 'event_espresso'),
116
+				EEM_Question::QST_type_textarea => __('Textarea', 'event_espresso'),
117
+				EEM_Question::QST_type_checkbox => __('Checkboxes', 'event_espresso'),
118
+				EEM_Question::QST_type_radio => __('Radio Buttons', 'event_espresso'),
119
+				EEM_Question::QST_type_dropdown => __('Dropdown', 'event_espresso'),
120
+				EEM_Question::QST_type_state => __('State/Province Dropdown', 'event_espresso'),
121
+				EEM_Question::QST_type_country => __('Country Dropdown', 'event_espresso'),
122
+				EEM_Question::QST_type_date => __('Date Picker', 'event_espresso'),
123
+				EEM_Question::QST_type_html_textarea => __('HTML Textarea', 'event_espresso'),
124
+				EEM_Question::QST_type_email => __('Email', 'event_espresso'),
125
+				EEM_Question::QST_type_us_phone => __('USA - Format Phone', 'event_espresso'),
126
+				EEM_Question::QST_type_decimal => __('Number', 'event_espresso'),
127
+				EEM_Question::QST_type_int => __('Whole Number', 'event_espresso'),
128
+				EEM_Question::QST_type_url => __('URL', 'event_espresso'),
129
+				EEM_Question::QST_type_year => __('Year', 'event_espresso'),
130
+				EEM_Question::QST_type_multi_select => __('Multi Select', 'event_espresso')
131
+			)
132
+		);
133
+		$this->_question_descriptions = apply_filters(
134
+			'FHEE__EEM_Question__construct__question_descriptions',
135
+			array(
136
+				EEM_Question::QST_type_text => __('A single line text input field', 'event_espresso'),
137
+				EEM_Question::QST_type_textarea => __('A multi line text input field', 'event_espresso'),
138
+				EEM_Question::QST_type_checkbox => __('Allows multiple preset options to be selected', 'event_espresso'),
139
+				EEM_Question::QST_type_radio => __('Allows a single preset option to be selected', 'event_espresso'),
140
+				EEM_Question::QST_type_dropdown => __('A dropdown that allows a single selection', 'event_espresso'),
141
+				EEM_Question::QST_type_state => __('A dropdown that lists states/provinces', 'event_espresso'),
142
+				EEM_Question::QST_type_country => __('A dropdown that lists countries', 'event_espresso'),
143
+				EEM_Question::QST_type_date => __('A popup calendar that allows date selections', 'event_espresso'),
144
+				EEM_Question::QST_type_html_textarea => __('A multi line text input field that allows HTML', 'event_espresso'),
145
+				EEM_Question::QST_type_email => __('A text field that must contain a valid Email address', 'event_espresso'),
146
+				EEM_Question::QST_type_us_phone => __('A text field that must contain a valid US phone number', 'event_espresso'),
147
+				EEM_Question::QST_type_decimal => __('A text field that allows number values with decimals', 'event_espresso'),
148
+				EEM_Question::QST_type_int => __('A text field that only allows whole numbers (no decimals)', 'event_espresso'),
149
+				EEM_Question::QST_type_url => __('A text field that must contain a valid URL', 'event_espresso'),
150
+				EEM_Question::QST_type_year => __('A dropdown that lists the last 100 years', 'event_espresso'),
151
+				EEM_Question::QST_type_multi_select => __('A dropdown that allows multiple selections', 'event_espresso')
152
+			)
153
+		);
154
+		$this->_question_type_categories = (array) apply_filters(
155
+			'FHEE__EEM_Question__construct__question_type_categories',
156
+			array(
157
+				'text' => array(
158
+					EEM_Question::QST_type_text,
159
+					EEM_Question::QST_type_textarea,
160
+					EEM_Question::QST_type_date,
161
+					EEM_Question::QST_type_html_textarea,
162
+					EEM_Question::QST_type_email,
163
+					EEM_Question::QST_type_us_phone,
164
+					EEM_Question::QST_type_decimal,
165
+					EEM_Question::QST_type_int,
166
+					EEM_Question::QST_type_url,
167
+					EEM_Question::QST_type_year
168
+				),
169
+				'single-answer-enum' => array(
170
+					EEM_Question::QST_type_radio,
171
+					EEM_Question::QST_type_dropdown
172
+				),
173
+				'multi-answer-enum' => array(
174
+					EEM_Question::QST_type_checkbox,
175
+					EEM_Question::QST_type_multi_select
176
+				)
177
+			)
178
+		);
179
+		$this->question_types_with_max_lengh = apply_filters(
180
+			'FHEE__EEM_Question___construct__question_types_with_max_length',
181
+			array(
182
+				EEM_Question::QST_type_text,
183
+				EEM_Question::QST_type_textarea,
184
+				EEM_Question::QST_type_html_textarea
185
+			)
186
+		);
187
+
188
+		$this->_tables = array(
189
+			'Question' => new EE_Primary_Table('esp_question', 'QST_ID')
190
+		);
191
+		$this->_fields = array(
192
+			'Question' => array(
193
+				'QST_ID' => new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')),
194
+				'QST_display_text' => new EE_Post_Content_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''),
195
+				'QST_admin_label' => new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''),
196
+				'QST_system' => new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), false, ''),
197
+				'QST_type' => new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types),
198
+				'QST_required' => new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false),
199
+				'QST_required_text' => new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''),
200
+				'QST_order' => new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0),
201
+				'QST_admin_only' => new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false),
202
+				'QST_max' => new EE_Infinite_Integer_Field('QST_max', __('Max Size', 'event_espresso'), false, EE_INF),
203
+				'QST_wp_user' => new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false),
204
+				'QST_deleted' => new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false)
205
+			)
206
+		);
207
+		$this->_model_relations = array(
208
+			'Question_Group' => new EE_HABTM_Relation('Question_Group_Question'),
209
+			'Question_Option' => new EE_Has_Many_Relation(),
210
+			'Answer' => new EE_Has_Many_Relation(),
211
+			'WP_User' => new EE_Belongs_To_Relation(),
212
+			// for QST_order column
213
+			'Question_Group_Question' => new EE_Has_Many_Relation()
214
+		);
215
+		// this model is generally available for reading
216
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
217
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QST_system');
218
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QST_system');
219
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QST_system');
220
+		parent::__construct($timezone);
221
+	}
222
+
223
+	/**
224
+	 * Returns the list of allowed question types, which are normally: 'TEXT','TEXTAREA','RADIO_BTN','DROPDOWN','CHECKBOX','DATE'
225
+	 * but they can be extended
226
+	 * @return string[]
227
+	 */
228
+	public function allowed_question_types()
229
+	{
230
+		return $this->_allowed_question_types;
231
+	}
232
+
233
+	/**
234
+	 * Gets all the question types in the same category
235
+	 * @param string $question_type one of EEM_Question::allowed_question_types(
236
+	 * @return string[] like EEM_Question::allowed_question_types()
237
+	 */
238
+	public function question_types_in_same_category($question_type)
239
+	{
240
+		$question_types = array($question_type);
241
+		foreach ($this->_question_type_categories as $category => $question_types_in_category) {
242
+			if (in_array($question_type, $question_types_in_category)) {
243
+				$question_types = $question_types_in_category;
244
+				break;
245
+			}
246
+		}
247
+
248
+		return array_intersect_key($this->allowed_question_types(), array_flip($question_types));
249
+	}
250
+
251
+	/**
252
+	 * Determines if the given question type is in the given question type category
253
+	 * @param string $question_type one of EEM_Question::allowed_question_types()
254
+	 * @param string $category one of the top-level keys of EEM_Question::question_type_categories()
255
+	 * @return boolean
256
+	 */
257
+	public function question_type_is_in_category($question_type, $category)
258
+	{
259
+		if (!isset($this->_question_type_categories[ $category ])) {
260
+			return false;
261
+		}
262
+		return in_array($question_type, $this->_question_type_categories[ $category ]);
263
+	}
264
+
265
+
266
+	/**
267
+	 * Returns all the question types in the given category
268
+	 * @param string $category
269
+	 * @return array|mixed
270
+	 */
271
+	public function question_types_in_category($category)
272
+	{
273
+		if (isset($this->_question_type_categories[ $category ])) {
274
+			return $this->_question_type_categories[ $category ];
275
+		}
276
+		return array();
277
+	}
278
+
279
+
280
+	/**
281
+	 * Returns all the question types that should have question options
282
+	 * @return array
283
+	 */
284
+	public function question_types_with_options()
285
+	{
286
+		return array_merge(
287
+			$this->question_types_in_category('single-answer-enum'),
288
+			$this->question_types_in_category('multi-answer-enum')
289
+		);
290
+	}
291
+
292
+	/**
293
+	 * Returns the question type categories 2d array
294
+	 * @return array see EEM_Question::_question_type_categories
295
+	 */
296
+	public function question_type_categories()
297
+	{
298
+		return $this->_question_type_categories;
299
+	}
300
+
301
+	/**
302
+	 * Returns an array of all the QST_system values that can be allowed in the system question group
303
+	 * identified by $system_question_group_id
304
+	 * @param string $system_question_group_id QSG_system
305
+	 * @return array of system question names (QST_system)
306
+	 */
307
+	public function allowed_system_questions_in_system_question_group($system_question_group_id)
308
+	{
309
+		$question_system_ids = array();
310
+		switch ($system_question_group_id) {
311
+			case EEM_Question_Group::system_personal:
312
+				$question_system_ids = array(
313
+					EEM_Attendee::system_question_fname,
314
+					EEM_Attendee::system_question_lname,
315
+					EEM_Attendee::system_question_email,
316
+					EEM_Attendee::system_question_phone
317
+				);
318
+				break;
319
+			case EEM_Question_Group::system_address:
320
+				$question_system_ids = array(
321
+					EEM_Attendee::system_question_address,
322
+					EEM_Attendee::system_question_address2,
323
+					EEM_Attendee::system_question_city,
324
+					EEM_Attendee::system_question_state,
325
+					EEM_Attendee::system_question_country,
326
+					EEM_Attendee::system_question_zip,
327
+					EEM_Attendee::system_question_phone
328
+				);
329
+				break;
330
+		}
331
+		return apply_filters('FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id);
332
+	}
333
+
334
+	/**
335
+	 * Returns an array of all the QST_system values that are required in the system question group
336
+	 * identified by $system_question_group_id
337
+	 * @param string $system_question_group_id QSG_system
338
+	 * @return array of system question names (QST_system)
339
+	 */
340
+	public function required_system_questions_in_system_question_group($system_question_group_id)
341
+	{
342
+		$question_system_ids = null;
343
+		switch ($system_question_group_id) {
344
+			case EEM_Question_Group::system_personal:
345
+				$question_system_ids = array(
346
+					EEM_Attendee::system_question_fname,
347
+					EEM_Attendee::system_question_email,
348
+				);
349
+				break;
350
+			default:
351
+				$question_system_ids = array();
352
+		}
353
+		return apply_filters('FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id);
354
+	}
355
+
356
+
357
+	/**
358
+	 * Gets an array for converting between QST_system and QST_IDs for system questions. Eg, if you want to know
359
+	 * which system question QST_ID corresponds to the QST_system 'city', use EEM_Question::instance()->get_Question_ID_from_system_string('city');
360
+	 * @param $QST_system
361
+	 * @return int of QST_ID for the question that corresponds to that QST_system
362
+	 */
363
+	public function get_Question_ID_from_system_string($QST_system)
364
+	{
365
+		return $this->get_var(array(array('QST_system' => $QST_system)));
366
+	}
367
+
368
+
369
+	/**
370
+	 * searches the db for the question with the latest question order and returns that value.
371
+	 * @access public
372
+	 * @return int
373
+	 */
374
+	public function get_latest_question_order()
375
+	{
376
+		$columns_to_select = array(
377
+			'max_order' => array("MAX(QST_order)", "%d")
378
+		);
379
+		$max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
380
+		return isset($max[0], $max[0]['max_order']) ? $max[0]['max_order'] : 0;
381
+	}
382
+
383
+	/**
384
+	 * Returns an array where keys are system question QST_system values,
385
+	 * and values are the highest question max the admin can set on the question
386
+	 * (aka the "max max"; eg, a site admin can change the zip question to have a max
387
+	 * of 5, but no larger than 12)
388
+	 * @return array
389
+	 */
390
+	public function system_question_maxes()
391
+	{
392
+		return array(
393
+			'fname' => 45,
394
+			'lname' => 45,
395
+			'address' => 255,
396
+			'address2' => 255,
397
+			'city' => 45,
398
+			'zip' => 12,
399
+			'email' => 255,
400
+			'phone' => 45,
401
+		);
402
+	}
403
+
404
+	/**
405
+	 * Given a QST_system value, gets the question's largest allowable max input.
406
+	 * @see Registration_Form_Admin_Page::system_question_maxes()
407
+	 * @param string $system_question_value
408
+	 * @return int|float
409
+	 */
410
+	public function absolute_max_for_system_question($system_question_value)
411
+	{
412
+		$maxes = $this->system_question_maxes();
413
+		if (isset($maxes[ $system_question_value ])) {
414
+			return $maxes[ $system_question_value ];
415
+		} else {
416
+			return EE_INF;
417
+		}
418
+	}
419
+
420
+
421
+	/**
422
+	 * @return array
423
+	 */
424
+	public function question_descriptions()
425
+	{
426
+		return $this->_question_descriptions;
427
+	}
428
+
429
+
430
+	/**
431
+	 * Returns all the question types that should have an admin-defined max input length
432
+	 * @return array
433
+	 */
434
+	public function questionTypesWithMaxLength()
435
+	{
436
+		return (array) $this->question_types_with_max_lengh;
437
+	}
438 438
 }
Please login to merge, or discard this patch.
core/domain/services/assets/CoreAssetManager.php 1 patch
Indentation   +445 added lines, -445 removed lines patch added patch discarded remove patch
@@ -29,466 +29,466 @@
 block discarded – undo
29 29
 class CoreAssetManager extends AssetManager
30 30
 {
31 31
 
32
-    // WordPress core / Third party JS asset handles
33
-    const JS_HANDLE_JQUERY = 'jquery';
32
+	// WordPress core / Third party JS asset handles
33
+	const JS_HANDLE_JQUERY = 'jquery';
34 34
 
35
-    const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
35
+	const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
36 36
 
37
-    const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
37
+	const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
38 38
 
39
-    const JS_HANDLE_UNDERSCORE = 'underscore';
39
+	const JS_HANDLE_UNDERSCORE = 'underscore';
40 40
 
41
-    const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
41
+	const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
42 42
 
43
-    // EE JS assets handles
44
-    const JS_HANDLE_EE_MANIFEST = 'ee-manifest';
43
+	// EE JS assets handles
44
+	const JS_HANDLE_EE_MANIFEST = 'ee-manifest';
45 45
 
46
-    const JS_HANDLE_EE_JS_CORE = 'eejs-core';
46
+	const JS_HANDLE_EE_JS_CORE = 'eejs-core';
47 47
 
48
-    const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor';
48
+	const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor';
49 49
 
50
-    const JS_HANDLE_EE_DATA_STORES = 'eventespresso-data-stores';
50
+	const JS_HANDLE_EE_DATA_STORES = 'eventespresso-data-stores';
51 51
 
52
-    const JS_HANDLE_EE_HELPERS = 'eventespresso-helpers';
52
+	const JS_HANDLE_EE_HELPERS = 'eventespresso-helpers';
53 53
 
54
-    const JS_HANDLE_EE_MODEL = 'eventespresso-model';
54
+	const JS_HANDLE_EE_MODEL = 'eventespresso-model';
55 55
 
56
-    const JS_HANDLE_EE_VALUE_OBJECTS = 'eventespresso-value-objects';
56
+	const JS_HANDLE_EE_VALUE_OBJECTS = 'eventespresso-value-objects';
57 57
 
58
-    const JS_HANDLE_EE_HOC_COMPONENTS = 'eventespresso-hoc-components';
58
+	const JS_HANDLE_EE_HOC_COMPONENTS = 'eventespresso-hoc-components';
59 59
 
60
-    const JS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
60
+	const JS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
61 61
 
62
-    const JS_HANDLE_EE_JS_API = 'eejs-api';
62
+	const JS_HANDLE_EE_JS_API = 'eejs-api';
63 63
 
64
-    const JS_HANDLE_EE_CORE = 'espresso_core';
64
+	const JS_HANDLE_EE_CORE = 'espresso_core';
65 65
 
66
-    const JS_HANDLE_EE_I18N = 'eei18n';
67
-
68
-    const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting';
69
-
70
-    const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
71
-
72
-    // EE CSS assets handles
73
-    const CSS_HANDLE_EE_DEFAULT = 'espresso_default';
74
-
75
-    const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css';
76
-
77
-    const CSS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
78
-
79
-    /**
80
-     * @var EE_Currency_Config $currency_config
81
-     */
82
-    protected $currency_config;
83
-
84
-    /**
85
-     * @var EE_Template_Config $template_config
86
-     */
87
-    protected $template_config;
88
-
89
-
90
-    /**
91
-     * CoreAssetRegister constructor.
92
-     *
93
-     * @param AssetCollection    $assets
94
-     * @param EE_Currency_Config $currency_config
95
-     * @param EE_Template_Config $template_config
96
-     * @param DomainInterface    $domain
97
-     * @param Registry           $registry
98
-     */
99
-    public function __construct(
100
-        AssetCollection $assets,
101
-        EE_Currency_Config $currency_config,
102
-        EE_Template_Config $template_config,
103
-        DomainInterface $domain,
104
-        Registry $registry
105
-    ) {
106
-        $this->currency_config = $currency_config;
107
-        $this->template_config = $template_config;
108
-        parent::__construct($domain, $assets, $registry);
109
-    }
110
-
111
-
112
-    /**
113
-     * @since 4.9.62.p
114
-     * @throws DuplicateCollectionIdentifierException
115
-     * @throws InvalidArgumentException
116
-     * @throws InvalidDataTypeException
117
-     * @throws InvalidEntityException
118
-     */
119
-    public function addAssets()
120
-    {
121
-        $this->addJavascriptFiles();
122
-        $this->addStylesheetFiles();
123
-    }
124
-
125
-
126
-    /**
127
-     * @since 4.9.62.p
128
-     * @throws DuplicateCollectionIdentifierException
129
-     * @throws InvalidArgumentException
130
-     * @throws InvalidDataTypeException
131
-     * @throws InvalidEntityException
132
-     */
133
-    public function addJavascriptFiles()
134
-    {
135
-        $this->loadCoreJs();
136
-        $this->loadJqueryValidate();
137
-        $this->loadAccountingJs();
138
-        add_action(
139
-            'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
140
-            array($this, 'loadQtipJs')
141
-        );
142
-        $this->registerAdminAssets();
143
-    }
144
-
145
-
146
-    /**
147
-     * @since 4.9.62.p
148
-     * @throws DuplicateCollectionIdentifierException
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidEntityException
151
-     */
152
-    public function addStylesheetFiles()
153
-    {
154
-        $this->loadCoreCss();
155
-    }
156
-
157
-
158
-    /**
159
-     * core default javascript
160
-     *
161
-     * @since 4.9.62.p
162
-     * @throws DuplicateCollectionIdentifierException
163
-     * @throws InvalidArgumentException
164
-     * @throws InvalidDataTypeException
165
-     * @throws InvalidEntityException
166
-     */
167
-    private function loadCoreJs()
168
-    {
169
-        $this->addJavascript(
170
-            CoreAssetManager::JS_HANDLE_EE_MANIFEST,
171
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
172
-        );
173
-
174
-        $this->addJavascript(
175
-            CoreAssetManager::JS_HANDLE_EE_JS_CORE,
176
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
177
-            array(CoreAssetManager::JS_HANDLE_EE_MANIFEST)
178
-        )
179
-        ->setHasInlineData();
180
-
181
-        $this->addJavascript(
182
-            CoreAssetManager::JS_HANDLE_EE_VENDOR,
183
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
184
-            array(CoreAssetManager::JS_HANDLE_EE_JS_CORE)
185
-        );
186
-
187
-        $this->addJavascript(
188
-            CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
189
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
190
-            array(CoreAssetManager::JS_HANDLE_EE_VENDOR, 'wp-data', 'wp-api-request')
191
-        )
192
-        ->setRequiresTranslation();
193
-
194
-        $this->addJavascript(
195
-            CoreAssetManager::JS_HANDLE_EE_HELPERS,
196
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers')
197
-        )->setRequiresTranslation();
198
-
199
-        $this->addJavascript(
200
-            CoreAssetManager::JS_HANDLE_EE_MODEL,
201
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
202
-            array(
203
-                CoreAssetManager::JS_HANDLE_EE_HELPERS
204
-            )
205
-        )->setRequiresTranslation();
206
-
207
-        $this->addJavascript(
208
-            CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
209
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
210
-            array(
211
-                CoreAssetManager::JS_HANDLE_EE_MODEL
212
-            )
213
-        )->setRequiresTranslation();
214
-
215
-        $this->addJavascript(
216
-            CoreAssetManager::JS_HANDLE_EE_HOC_COMPONENTS,
217
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocComponents'),
218
-            array(
219
-                CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
220
-                CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
221
-                'wp-components',
222
-            )
223
-        )->setRequiresTranslation();
224
-
225
-        $this->addJavascript(
226
-            CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
227
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
228
-            array(
229
-                CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
230
-                CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
231
-                'wp-components',
232
-            )
233
-        )
234
-        ->setRequiresTranslation();
235
-
236
-        global $wp_version;
237
-        if (version_compare($wp_version, '4.4.0', '>')) {
238
-            //js.api
239
-            $this->addJavascript(
240
-                CoreAssetManager::JS_HANDLE_EE_JS_API,
241
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
242
-                array(
243
-                    CoreAssetManager::JS_HANDLE_UNDERSCORE,
244
-                    CoreAssetManager::JS_HANDLE_EE_JS_CORE
245
-                )
246
-            );
247
-            $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
248
-            $this->registry->addData(
249
-                'paths',
250
-                array(
251
-                    'rest_route' => rest_url('ee/v4.8.36/'),
252
-                    'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
253
-                    'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
66
+	const JS_HANDLE_EE_I18N = 'eei18n';
67
+
68
+	const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting';
69
+
70
+	const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
71
+
72
+	// EE CSS assets handles
73
+	const CSS_HANDLE_EE_DEFAULT = 'espresso_default';
74
+
75
+	const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css';
76
+
77
+	const CSS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
78
+
79
+	/**
80
+	 * @var EE_Currency_Config $currency_config
81
+	 */
82
+	protected $currency_config;
83
+
84
+	/**
85
+	 * @var EE_Template_Config $template_config
86
+	 */
87
+	protected $template_config;
88
+
89
+
90
+	/**
91
+	 * CoreAssetRegister constructor.
92
+	 *
93
+	 * @param AssetCollection    $assets
94
+	 * @param EE_Currency_Config $currency_config
95
+	 * @param EE_Template_Config $template_config
96
+	 * @param DomainInterface    $domain
97
+	 * @param Registry           $registry
98
+	 */
99
+	public function __construct(
100
+		AssetCollection $assets,
101
+		EE_Currency_Config $currency_config,
102
+		EE_Template_Config $template_config,
103
+		DomainInterface $domain,
104
+		Registry $registry
105
+	) {
106
+		$this->currency_config = $currency_config;
107
+		$this->template_config = $template_config;
108
+		parent::__construct($domain, $assets, $registry);
109
+	}
110
+
111
+
112
+	/**
113
+	 * @since 4.9.62.p
114
+	 * @throws DuplicateCollectionIdentifierException
115
+	 * @throws InvalidArgumentException
116
+	 * @throws InvalidDataTypeException
117
+	 * @throws InvalidEntityException
118
+	 */
119
+	public function addAssets()
120
+	{
121
+		$this->addJavascriptFiles();
122
+		$this->addStylesheetFiles();
123
+	}
124
+
125
+
126
+	/**
127
+	 * @since 4.9.62.p
128
+	 * @throws DuplicateCollectionIdentifierException
129
+	 * @throws InvalidArgumentException
130
+	 * @throws InvalidDataTypeException
131
+	 * @throws InvalidEntityException
132
+	 */
133
+	public function addJavascriptFiles()
134
+	{
135
+		$this->loadCoreJs();
136
+		$this->loadJqueryValidate();
137
+		$this->loadAccountingJs();
138
+		add_action(
139
+			'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
140
+			array($this, 'loadQtipJs')
141
+		);
142
+		$this->registerAdminAssets();
143
+	}
144
+
145
+
146
+	/**
147
+	 * @since 4.9.62.p
148
+	 * @throws DuplicateCollectionIdentifierException
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidEntityException
151
+	 */
152
+	public function addStylesheetFiles()
153
+	{
154
+		$this->loadCoreCss();
155
+	}
156
+
157
+
158
+	/**
159
+	 * core default javascript
160
+	 *
161
+	 * @since 4.9.62.p
162
+	 * @throws DuplicateCollectionIdentifierException
163
+	 * @throws InvalidArgumentException
164
+	 * @throws InvalidDataTypeException
165
+	 * @throws InvalidEntityException
166
+	 */
167
+	private function loadCoreJs()
168
+	{
169
+		$this->addJavascript(
170
+			CoreAssetManager::JS_HANDLE_EE_MANIFEST,
171
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
172
+		);
173
+
174
+		$this->addJavascript(
175
+			CoreAssetManager::JS_HANDLE_EE_JS_CORE,
176
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
177
+			array(CoreAssetManager::JS_HANDLE_EE_MANIFEST)
178
+		)
179
+		->setHasInlineData();
180
+
181
+		$this->addJavascript(
182
+			CoreAssetManager::JS_HANDLE_EE_VENDOR,
183
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
184
+			array(CoreAssetManager::JS_HANDLE_EE_JS_CORE)
185
+		);
186
+
187
+		$this->addJavascript(
188
+			CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
189
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
190
+			array(CoreAssetManager::JS_HANDLE_EE_VENDOR, 'wp-data', 'wp-api-request')
191
+		)
192
+		->setRequiresTranslation();
193
+
194
+		$this->addJavascript(
195
+			CoreAssetManager::JS_HANDLE_EE_HELPERS,
196
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers')
197
+		)->setRequiresTranslation();
198
+
199
+		$this->addJavascript(
200
+			CoreAssetManager::JS_HANDLE_EE_MODEL,
201
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
202
+			array(
203
+				CoreAssetManager::JS_HANDLE_EE_HELPERS
204
+			)
205
+		)->setRequiresTranslation();
206
+
207
+		$this->addJavascript(
208
+			CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
209
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
210
+			array(
211
+				CoreAssetManager::JS_HANDLE_EE_MODEL
212
+			)
213
+		)->setRequiresTranslation();
214
+
215
+		$this->addJavascript(
216
+			CoreAssetManager::JS_HANDLE_EE_HOC_COMPONENTS,
217
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'hocComponents'),
218
+			array(
219
+				CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
220
+				CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
221
+				'wp-components',
222
+			)
223
+		)->setRequiresTranslation();
224
+
225
+		$this->addJavascript(
226
+			CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
227
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
228
+			array(
229
+				CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
230
+				CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
231
+				'wp-components',
232
+			)
233
+		)
234
+		->setRequiresTranslation();
235
+
236
+		global $wp_version;
237
+		if (version_compare($wp_version, '4.4.0', '>')) {
238
+			//js.api
239
+			$this->addJavascript(
240
+				CoreAssetManager::JS_HANDLE_EE_JS_API,
241
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
242
+				array(
243
+					CoreAssetManager::JS_HANDLE_UNDERSCORE,
244
+					CoreAssetManager::JS_HANDLE_EE_JS_CORE
245
+				)
246
+			);
247
+			$this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
248
+			$this->registry->addData(
249
+				'paths',
250
+				array(
251
+					'rest_route' => rest_url('ee/v4.8.36/'),
252
+					'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
253
+					'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
254 254
 					'site_url' => site_url('/'),
255
-                    'admin_url' => admin_url('/'),
256
-                )
257
-            );
258
-            /** site formatting values **/
259
-            $this->registry->addData(
260
-                'site_formats',
261
-                array(
262
-                    'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
263
-                )
264
-            );
265
-            /** currency data **/
266
-            $this->registry->addData(
267
-                'currency_config',
268
-                $this->getCurrencySettings()
269
-            );
270
-            /** site timezone */
271
-            $this->registry->addData(
272
-                'default_timezone',
273
-                array(
274
-                    'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
275
-                    'string' => get_option('timezone_string'),
276
-                    'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
277
-                )
278
-            );
279
-            /** site locale (user locale if user logged in) */
280
-            $this->registry->addData(
281
-                'locale',
282
-                array(
283
-                    'user' => get_user_locale(),
284
-                    'site' => get_locale()
285
-                )
286
-            );
287
-        }
288
-
289
-        $this->addJavascript(
290
-            CoreAssetManager::JS_HANDLE_EE_CORE,
291
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
292
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
293
-        )
294
-        ->setInlineDataCallback(
295
-            function () {
296
-                wp_localize_script(
297
-                    CoreAssetManager::JS_HANDLE_EE_CORE,
298
-                    CoreAssetManager::JS_HANDLE_EE_I18N,
299
-                    EE_Registry::$i18n_js_strings
300
-                );
301
-            }
302
-        );
303
-    }
304
-
305
-
306
-    /**
307
-     * Returns configuration data for the accounting-js library.
308
-     * @since $VID:$
309
-     * @return array
310
-     */
311
-    private function getAccountingSettings() {
312
-        return array(
313
-            'currency' => array(
314
-                'symbol'    => $this->currency_config->sign,
315
-                'format'    => array(
316
-                    'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
317
-                    'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
318
-                    'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
319
-                ),
320
-                'decimal'   => $this->currency_config->dec_mrk,
321
-                'thousand'  => $this->currency_config->thsnds,
322
-                'precision' => $this->currency_config->dec_plc,
323
-            ),
324
-            'number'   => array(
325
-                'precision' => $this->currency_config->dec_plc,
326
-                'thousand'  => $this->currency_config->thsnds,
327
-                'decimal'   => $this->currency_config->dec_mrk,
328
-            ),
329
-        );
330
-    }
331
-
332
-
333
-    /**
334
-     * Returns configuration data for the js Currency VO.
335
-     * @sinc $VID:$
336
-     * @return array
337
-     */
338
-    private function getCurrencySettings()
339
-    {
340
-        return array(
341
-            'code' => $this->currency_config->code,
342
-            'singularLabel' => $this->currency_config->name,
343
-            'pluralLabel' => $this->currency_config->plural,
344
-            'sign' => $this->currency_config->sign,
345
-            'signB4' => $this->currency_config->sign_b4,
346
-            'decimalPlaces' => $this->currency_config->dec_plc,
347
-            'decimalMark' => $this->currency_config->dec_mrk,
348
-            'thousandsSeparator' => $this->currency_config->thsnds,
349
-        );
350
-    }
351
-
352
-
353
-    /**
354
-     * @since 4.9.62.p
355
-     * @throws DuplicateCollectionIdentifierException
356
-     * @throws InvalidDataTypeException
357
-     * @throws InvalidEntityException
358
-     */
359
-    private function loadCoreCss()
360
-    {
361
-        if ($this->template_config->enable_default_style && ! is_admin()) {
362
-            $this->addStylesheet(
363
-                CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
364
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
365
-                    ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
366
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
367
-                array('dashicons')
368
-            );
369
-            //Load custom style sheet if available
370
-            if ($this->template_config->custom_style_sheet !== null) {
371
-                $this->addStylesheet(
372
-                    CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
373
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
374
-                    array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
375
-                );
376
-            }
377
-        }
378
-        $this->addStylesheet(
379
-            CoreAssetManager::CSS_HANDLE_EE_COMPONENTS,
380
-            $this->registry->getCssUrl(
381
-                $this->domain->assetNamespace(),
382
-                'components'
383
-            )
384
-        );
385
-    }
386
-
387
-
388
-    /**
389
-     * jQuery Validate for form validation
390
-     *
391
-     * @since 4.9.62.p
392
-     * @throws DuplicateCollectionIdentifierException
393
-     * @throws InvalidDataTypeException
394
-     * @throws InvalidEntityException
395
-     */
396
-    private function loadJqueryValidate()
397
-    {
398
-        $this->addJavascript(
399
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
400
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
401
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
402
-        )
403
-        ->setVersion('1.15.0');
404
-
405
-        $this->addJavascript(
406
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
407
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
408
-            array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
409
-        )
410
-        ->setVersion('1.15.0');
411
-    }
412
-
413
-
414
-    /**
415
-     * accounting.js for performing client-side calculations
416
-     *
417
-     * @since 4.9.62.p
418
-     * @throws DuplicateCollectionIdentifierException
419
-     * @throws InvalidDataTypeException
420
-     * @throws InvalidEntityException
421
-     */
422
-    private function loadAccountingJs()
423
-    {
424
-        //accounting.js library
425
-        // @link http://josscrowcroft.github.io/accounting.js/
426
-        $this->addJavascript(
427
-            CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
428
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
429
-            array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
430
-        )
431
-        ->setVersion('0.3.2');
432
-
433
-        $this->addJavascript(
434
-            CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
435
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
436
-            array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
437
-        )
438
-        ->setInlineDataCallback(
439
-            function () {
440
-                 wp_localize_script(
441
-                     CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
442
-                     'EE_ACCOUNTING_CFG',
443
-                     $this->getAccountingSettings()
444
-                 );
445
-            }
446
-        )
447
-        ->setVersion();
448
-    }
449
-
450
-
451
-    /**
452
-     * registers assets for cleaning your ears
453
-     *
454
-     * @param JavascriptAsset $script
455
-     */
456
-    public function loadQtipJs(JavascriptAsset $script)
457
-    {
458
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
459
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
460
-        if (
461
-            $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
462
-            && apply_filters('FHEE_load_qtip', false)
463
-        ) {
464
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
465
-        }
466
-    }
467
-
468
-
469
-    /**
470
-     * assets that are used in the WordPress admin
471
-     *
472
-     * @since 4.9.62.p
473
-     * @throws DuplicateCollectionIdentifierException
474
-     * @throws InvalidDataTypeException
475
-     * @throws InvalidEntityException
476
-     */
477
-    private function registerAdminAssets()
478
-    {
479
-        $this->addJavascript(
480
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
481
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
482
-            array(
483
-                CoreAssetManager::JS_HANDLE_JQUERY,
484
-                CoreAssetManager::JS_HANDLE_EE_VENDOR,
485
-            )
486
-        )
487
-        ->setRequiresTranslation();
488
-
489
-        $this->addStylesheet(
490
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
491
-            $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
492
-        );
493
-    }
255
+					'admin_url' => admin_url('/'),
256
+				)
257
+			);
258
+			/** site formatting values **/
259
+			$this->registry->addData(
260
+				'site_formats',
261
+				array(
262
+					'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
263
+				)
264
+			);
265
+			/** currency data **/
266
+			$this->registry->addData(
267
+				'currency_config',
268
+				$this->getCurrencySettings()
269
+			);
270
+			/** site timezone */
271
+			$this->registry->addData(
272
+				'default_timezone',
273
+				array(
274
+					'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
275
+					'string' => get_option('timezone_string'),
276
+					'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
277
+				)
278
+			);
279
+			/** site locale (user locale if user logged in) */
280
+			$this->registry->addData(
281
+				'locale',
282
+				array(
283
+					'user' => get_user_locale(),
284
+					'site' => get_locale()
285
+				)
286
+			);
287
+		}
288
+
289
+		$this->addJavascript(
290
+			CoreAssetManager::JS_HANDLE_EE_CORE,
291
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
292
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
293
+		)
294
+		->setInlineDataCallback(
295
+			function () {
296
+				wp_localize_script(
297
+					CoreAssetManager::JS_HANDLE_EE_CORE,
298
+					CoreAssetManager::JS_HANDLE_EE_I18N,
299
+					EE_Registry::$i18n_js_strings
300
+				);
301
+			}
302
+		);
303
+	}
304
+
305
+
306
+	/**
307
+	 * Returns configuration data for the accounting-js library.
308
+	 * @since $VID:$
309
+	 * @return array
310
+	 */
311
+	private function getAccountingSettings() {
312
+		return array(
313
+			'currency' => array(
314
+				'symbol'    => $this->currency_config->sign,
315
+				'format'    => array(
316
+					'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
317
+					'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
318
+					'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
319
+				),
320
+				'decimal'   => $this->currency_config->dec_mrk,
321
+				'thousand'  => $this->currency_config->thsnds,
322
+				'precision' => $this->currency_config->dec_plc,
323
+			),
324
+			'number'   => array(
325
+				'precision' => $this->currency_config->dec_plc,
326
+				'thousand'  => $this->currency_config->thsnds,
327
+				'decimal'   => $this->currency_config->dec_mrk,
328
+			),
329
+		);
330
+	}
331
+
332
+
333
+	/**
334
+	 * Returns configuration data for the js Currency VO.
335
+	 * @sinc $VID:$
336
+	 * @return array
337
+	 */
338
+	private function getCurrencySettings()
339
+	{
340
+		return array(
341
+			'code' => $this->currency_config->code,
342
+			'singularLabel' => $this->currency_config->name,
343
+			'pluralLabel' => $this->currency_config->plural,
344
+			'sign' => $this->currency_config->sign,
345
+			'signB4' => $this->currency_config->sign_b4,
346
+			'decimalPlaces' => $this->currency_config->dec_plc,
347
+			'decimalMark' => $this->currency_config->dec_mrk,
348
+			'thousandsSeparator' => $this->currency_config->thsnds,
349
+		);
350
+	}
351
+
352
+
353
+	/**
354
+	 * @since 4.9.62.p
355
+	 * @throws DuplicateCollectionIdentifierException
356
+	 * @throws InvalidDataTypeException
357
+	 * @throws InvalidEntityException
358
+	 */
359
+	private function loadCoreCss()
360
+	{
361
+		if ($this->template_config->enable_default_style && ! is_admin()) {
362
+			$this->addStylesheet(
363
+				CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
364
+				is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
365
+					? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
366
+					: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
367
+				array('dashicons')
368
+			);
369
+			//Load custom style sheet if available
370
+			if ($this->template_config->custom_style_sheet !== null) {
371
+				$this->addStylesheet(
372
+					CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
373
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
374
+					array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
375
+				);
376
+			}
377
+		}
378
+		$this->addStylesheet(
379
+			CoreAssetManager::CSS_HANDLE_EE_COMPONENTS,
380
+			$this->registry->getCssUrl(
381
+				$this->domain->assetNamespace(),
382
+				'components'
383
+			)
384
+		);
385
+	}
386
+
387
+
388
+	/**
389
+	 * jQuery Validate for form validation
390
+	 *
391
+	 * @since 4.9.62.p
392
+	 * @throws DuplicateCollectionIdentifierException
393
+	 * @throws InvalidDataTypeException
394
+	 * @throws InvalidEntityException
395
+	 */
396
+	private function loadJqueryValidate()
397
+	{
398
+		$this->addJavascript(
399
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
400
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
401
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
402
+		)
403
+		->setVersion('1.15.0');
404
+
405
+		$this->addJavascript(
406
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
407
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
408
+			array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
409
+		)
410
+		->setVersion('1.15.0');
411
+	}
412
+
413
+
414
+	/**
415
+	 * accounting.js for performing client-side calculations
416
+	 *
417
+	 * @since 4.9.62.p
418
+	 * @throws DuplicateCollectionIdentifierException
419
+	 * @throws InvalidDataTypeException
420
+	 * @throws InvalidEntityException
421
+	 */
422
+	private function loadAccountingJs()
423
+	{
424
+		//accounting.js library
425
+		// @link http://josscrowcroft.github.io/accounting.js/
426
+		$this->addJavascript(
427
+			CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
428
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
429
+			array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
430
+		)
431
+		->setVersion('0.3.2');
432
+
433
+		$this->addJavascript(
434
+			CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
435
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
436
+			array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
437
+		)
438
+		->setInlineDataCallback(
439
+			function () {
440
+				 wp_localize_script(
441
+					 CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
442
+					 'EE_ACCOUNTING_CFG',
443
+					 $this->getAccountingSettings()
444
+				 );
445
+			}
446
+		)
447
+		->setVersion();
448
+	}
449
+
450
+
451
+	/**
452
+	 * registers assets for cleaning your ears
453
+	 *
454
+	 * @param JavascriptAsset $script
455
+	 */
456
+	public function loadQtipJs(JavascriptAsset $script)
457
+	{
458
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
459
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
460
+		if (
461
+			$script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
462
+			&& apply_filters('FHEE_load_qtip', false)
463
+		) {
464
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
465
+		}
466
+	}
467
+
468
+
469
+	/**
470
+	 * assets that are used in the WordPress admin
471
+	 *
472
+	 * @since 4.9.62.p
473
+	 * @throws DuplicateCollectionIdentifierException
474
+	 * @throws InvalidDataTypeException
475
+	 * @throws InvalidEntityException
476
+	 */
477
+	private function registerAdminAssets()
478
+	{
479
+		$this->addJavascript(
480
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
481
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
482
+			array(
483
+				CoreAssetManager::JS_HANDLE_JQUERY,
484
+				CoreAssetManager::JS_HANDLE_EE_VENDOR,
485
+			)
486
+		)
487
+		->setRequiresTranslation();
488
+
489
+		$this->addStylesheet(
490
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
491
+			$this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
492
+		);
493
+	}
494 494
 }
Please login to merge, or discard this patch.
payment_methods/Aim/help_tabs/payment_methods_overview_aim.help_tab.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
         <?php _e('Change the image that is used for this payment gateway.', 'event_espresso'); ?>
76 76
     </li>
77 77
     <li>
78
-        <strong><?php esc_html_e('Note About Special Characters', 'event_espresso');?></strong>
79
-        <?php esc_html_e('If your event name, ticket name or ticket description contain special characters (eg emojis, foreign language characters, or curly quotes) they will be removed when sent to Authorize.net. This is because Authorize.net doesn\'t support them.', 'event_espresso');?></li>
78
+        <strong><?php esc_html_e('Note About Special Characters', 'event_espresso'); ?></strong>
79
+        <?php esc_html_e('If your event name, ticket name or ticket description contain special characters (eg emojis, foreign language characters, or curly quotes) they will be removed when sent to Authorize.net. This is because Authorize.net doesn\'t support them.', 'event_espresso'); ?></li>
80 80
     </li>
81 81
 </ul>
82 82
\ No newline at end of file
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_8_0.dms.php 1 patch
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 $stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*');
18 18
 $class_to_filepath = array();
19 19
 foreach ($stages as $filepath) {
20
-    $matches = array();
21
-    preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
-    $class_to_filepath[ $matches[1] ] = $filepath;
20
+	$matches = array();
21
+	preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
+	$class_to_filepath[ $matches[1] ] = $filepath;
23 23
 }
24 24
 // give addons a chance to autoload their stages too
25 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath);
@@ -38,71 +38,71 @@  discard block
 block discarded – undo
38 38
 class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base
39 39
 {
40 40
 
41
-    /**
42
-     * return EE_DMS_Core_4_8_0
43
-     *
44
-     * @param TableManager  $table_manager
45
-     * @param TableAnalysis $table_analysis
46
-     */
47
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
48
-    {
49
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso");
50
-        $this->_priority = 10;
51
-        $this->_migration_stages = array(
52
-            new EE_DMS_4_8_0_pretax_totals(),
53
-            new EE_DMS_4_8_0_event_subtotals(),
54
-        );
55
-        parent::__construct($table_manager, $table_analysis);
56
-    }
41
+	/**
42
+	 * return EE_DMS_Core_4_8_0
43
+	 *
44
+	 * @param TableManager  $table_manager
45
+	 * @param TableAnalysis $table_analysis
46
+	 */
47
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
48
+	{
49
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso");
50
+		$this->_priority = 10;
51
+		$this->_migration_stages = array(
52
+			new EE_DMS_4_8_0_pretax_totals(),
53
+			new EE_DMS_4_8_0_event_subtotals(),
54
+		);
55
+		parent::__construct($table_manager, $table_analysis);
56
+	}
57 57
 
58 58
 
59 59
 
60
-    /**
61
-     * Because this is being done at basically the same time as the MER-ready branch
62
-     * of core, it's possible people might have installed MEr-ready branch first,
63
-     * and then this one, in which case we still want to perform this migration,
64
-     * even though the version might not have increased
65
-     *
66
-     * @param array $version_array
67
-     * @return bool
68
-     */
69
-    public function can_migrate_from_version($version_array)
70
-    {
71
-        $version_string = $version_array['Core'];
72
-        if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) {
60
+	/**
61
+	 * Because this is being done at basically the same time as the MER-ready branch
62
+	 * of core, it's possible people might have installed MEr-ready branch first,
63
+	 * and then this one, in which case we still want to perform this migration,
64
+	 * even though the version might not have increased
65
+	 *
66
+	 * @param array $version_array
67
+	 * @return bool
68
+	 */
69
+	public function can_migrate_from_version($version_array)
70
+	{
71
+		$version_string = $version_array['Core'];
72
+		if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) {
73 73
 //          echo "$version_string can be migrated from";
74
-            return true;
75
-        } elseif (! $version_string) {
74
+			return true;
75
+		} elseif (! $version_string) {
76 76
 //          echo "no version string provided: $version_string";
77
-            // no version string provided... this must be pre 4.3
78
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
79
-        } else {
77
+			// no version string provided... this must be pre 4.3
78
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
79
+		} else {
80 80
 //          echo "$version_string doesnt apply";
81
-            return false;
82
-        }
83
-    }
81
+			return false;
82
+		}
83
+	}
84 84
 
85 85
 
86 86
 
87
-    /**
88
-     * @return bool
89
-     */
90
-    public function schema_changes_before_migration()
91
-    {
92
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
93
-        $now_in_mysql = current_time('mysql', true);
94
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
-        $table_name = 'esp_answer';
96
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
87
+	/**
88
+	 * @return bool
89
+	 */
90
+	public function schema_changes_before_migration()
91
+	{
92
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
93
+		$now_in_mysql = current_time('mysql', true);
94
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
+		$table_name = 'esp_answer';
96
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
97 97
 					REG_ID int(10) unsigned NOT NULL,
98 98
 					QST_ID int(10) unsigned NOT NULL,
99 99
 					ANS_value text NOT NULL,
100 100
 					PRIMARY KEY  (ANS_ID),
101 101
 					KEY REG_ID (REG_ID),
102 102
 					KEY QST_ID (QST_ID)";
103
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
104
-        $table_name = 'esp_attendee_meta';
105
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
103
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
104
+		$table_name = 'esp_attendee_meta';
105
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
106 106
 						ATT_ID bigint(20) unsigned NOT NULL,
107 107
 						ATT_fname varchar(45) NOT NULL,
108 108
 						ATT_lname varchar(45) NOT	NULL,
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 							PRIMARY KEY  (ATTM_ID),
118 118
 								KEY ATT_ID (ATT_ID),
119 119
 								KEY ATT_email (ATT_email(191))";
120
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
121
-        $table_name = 'esp_country';
122
-        $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL,
120
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
121
+		$table_name = 'esp_country';
122
+		$sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL,
123 123
 					  CNT_ISO3 varchar(3) collate utf8_bin NOT NULL,
124 124
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
125 125
 					  CNT_name varchar(45) collate utf8_bin NOT NULL,
@@ -135,25 +135,25 @@  discard block
 block discarded – undo
135 135
 					  CNT_is_EU tinyint(1) DEFAULT '0',
136 136
 					  CNT_active tinyint(1) DEFAULT '0',
137 137
 					  PRIMARY KEY  (CNT_ISO)";
138
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
139
-        $table_name = 'esp_currency';
140
-        $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
138
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
139
+		$table_name = 'esp_currency';
140
+		$sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
141 141
 				CUR_single varchar(45) collate utf8_bin DEFAULT 'dollar',
142 142
 				CUR_plural varchar(45) collate utf8_bin DEFAULT 'dollars',
143 143
 				CUR_sign varchar(45) collate utf8_bin DEFAULT '$',
144 144
 				CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2',
145 145
 				CUR_active tinyint(1) DEFAULT '0',
146 146
 				PRIMARY KEY  (CUR_code)";
147
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
148
-        $table_name = 'esp_currency_payment_method';
149
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
147
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
148
+		$table_name = 'esp_currency_payment_method';
149
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
150 150
 				CUR_code varchar(6) collate utf8_bin NOT NULL,
151 151
 				PMD_ID int(11) NOT NULL,
152 152
 				PRIMARY KEY  (CPM_ID),
153 153
 				KEY PMD_ID (PMD_ID)";
154
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
155
-        $table_name = 'esp_datetime';
156
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
154
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
155
+		$table_name = 'esp_datetime';
156
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
157 157
 				  EVT_ID bigint(20) unsigned NOT NULL,
158 158
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
159 159
 				  DTT_description text NOT NULL,
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 						KEY DTT_EVT_start (DTT_EVT_start),
170 170
 						KEY EVT_ID (EVT_ID),
171 171
 						KEY DTT_is_primary (DTT_is_primary)";
172
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
173
-        $table_name = 'esp_event_meta';
174
-        $sql = "
172
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
173
+		$table_name = 'esp_event_meta';
174
+		$sql = "
175 175
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
176 176
 			EVT_ID bigint(20) unsigned NOT NULL,
177 177
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -187,34 +187,34 @@  discard block
 block discarded – undo
187 187
 			EVT_donations tinyint(1) NULL,
188 188
 			PRIMARY KEY  (EVTM_ID),
189 189
 			KEY EVT_ID (EVT_ID)";
190
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
191
-        $table_name = 'esp_event_question_group';
192
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
190
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
191
+		$table_name = 'esp_event_question_group';
192
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
193 193
 					EVT_ID bigint(20) unsigned NOT NULL,
194 194
 					QSG_ID int(10) unsigned NOT NULL,
195 195
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
196 196
 					PRIMARY KEY  (EQG_ID),
197 197
 					KEY EVT_ID (EVT_ID),
198 198
 					KEY QSG_ID (QSG_ID)";
199
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
200
-        $table_name = 'esp_event_venue';
201
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
199
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
200
+		$table_name = 'esp_event_venue';
201
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
202 202
 				EVT_ID bigint(20) unsigned NOT NULL,
203 203
 				VNU_ID bigint(20) unsigned NOT NULL,
204 204
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
205 205
 				PRIMARY KEY  (EVV_ID)";
206
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
207
-        $table_name = 'esp_extra_meta';
208
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
206
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
207
+		$table_name = 'esp_extra_meta';
208
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
209 209
 				OBJ_ID int(11) DEFAULT NULL,
210 210
 				EXM_type varchar(45) DEFAULT NULL,
211 211
 				EXM_key varchar(45) DEFAULT NULL,
212 212
 				EXM_value text,
213 213
 				PRIMARY KEY  (EXM_ID),
214 214
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
215
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
216
-        $table_name = 'esp_extra_join';
217
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
215
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
216
+		$table_name = 'esp_extra_join';
217
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
218 218
 				EXJ_first_model_id varchar(6) NOT NULL,
219 219
 				EXJ_first_model_name varchar(20) NOT NULL,
220 220
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 				PRIMARY KEY  (EXJ_ID),
223 223
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
224 224
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
225
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
226
-        $table_name = 'esp_line_item';
227
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
225
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
226
+		$table_name = 'esp_line_item';
227
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
228 228
 				LIN_code varchar(245) NOT NULL DEFAULT '',
229 229
 				TXN_ID int(11) DEFAULT NULL,
230 230
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 				PRIMARY KEY  (LIN_ID),
244 244
 				KEY LIN_code (LIN_code(191)),
245 245
 				KEY TXN_ID (TXN_ID)";
246
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
-        $table_name = 'esp_log';
248
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
246
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
+		$table_name = 'esp_log';
248
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
249 249
 				LOG_time datetime DEFAULT NULL,
250 250
 				OBJ_ID varchar(45) DEFAULT NULL,
251 251
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -256,18 +256,18 @@  discard block
 block discarded – undo
256 256
 				KEY LOG_time (LOG_time),
257 257
 				KEY OBJ (OBJ_type,OBJ_ID),
258 258
 				KEY LOG_type (LOG_type)";
259
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
260
-        $table_name = 'esp_message_template';
261
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
259
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
260
+		$table_name = 'esp_message_template';
261
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
262 262
 					GRP_ID int(10) unsigned NOT NULL,
263 263
 					MTP_context varchar(50) NOT NULL,
264 264
 					MTP_template_field varchar(30) NOT NULL,
265 265
 					MTP_content text NOT NULL,
266 266
 					PRIMARY KEY  (MTP_ID),
267 267
 					KEY GRP_ID (GRP_ID)";
268
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
269
-        $table_name = 'esp_message_template_group';
270
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
268
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
269
+		$table_name = 'esp_message_template_group';
270
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
271 271
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
272 272
 					MTP_name varchar(245) NOT NULL DEFAULT '',
273 273
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
280 280
 					PRIMARY KEY  (GRP_ID),
281 281
 					KEY MTP_user_id (MTP_user_id)";
282
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
283
-        $table_name = 'esp_event_message_template';
284
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
282
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
283
+		$table_name = 'esp_event_message_template';
284
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
285 285
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
286 286
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
287 287
 					PRIMARY KEY  (EMT_ID),
288 288
 					KEY EVT_ID (EVT_ID),
289 289
 					KEY GRP_ID (GRP_ID)";
290
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
-        $table_name = 'esp_payment';
292
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
290
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
+		$table_name = 'esp_payment';
292
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
293 293
 					TXN_ID int(10) unsigned DEFAULT NULL,
294 294
 					STS_ID varchar(3) collate utf8_bin DEFAULT NULL,
295 295
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
 					PRIMARY KEY  (PAY_ID),
307 307
 					KEY PAY_timestamp (PAY_timestamp),
308 308
 					KEY TXN_ID (TXN_ID)";
309
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
310
-        $table_name = 'esp_payment_method';
311
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
309
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
310
+		$table_name = 'esp_payment_method';
311
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
312 312
 				PMD_type varchar(124) DEFAULT NULL,
313 313
 				PMD_name varchar(255) DEFAULT NULL,
314 314
 				PMD_desc text,
@@ -324,32 +324,32 @@  discard block
 block discarded – undo
324 324
 				PRIMARY KEY  (PMD_ID),
325 325
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
326 326
 				KEY PMD_type (PMD_type)";
327
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
328
-        $table_name = "esp_ticket_price";
329
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
327
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
328
+		$table_name = "esp_ticket_price";
329
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
330 330
 					  TKT_ID int(10) unsigned NOT NULL,
331 331
 					  PRC_ID int(10) unsigned NOT NULL,
332 332
 					  PRIMARY KEY  (TKP_ID),
333 333
 					  KEY TKT_ID (TKT_ID),
334 334
 					  KEY PRC_ID (PRC_ID)";
335
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
336
-        $table_name = "esp_datetime_ticket";
337
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
335
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
336
+		$table_name = "esp_datetime_ticket";
337
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
338 338
 					  DTT_ID int(10) unsigned NOT NULL,
339 339
 					  TKT_ID int(10) unsigned NOT NULL,
340 340
 					  PRIMARY KEY  (DTK_ID),
341 341
 					  KEY DTT_ID (DTT_ID),
342 342
 					  KEY TKT_ID (TKT_ID)";
343
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
344
-        $table_name = "esp_ticket_template";
345
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
344
+		$table_name = "esp_ticket_template";
345
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
346 346
 					  TTM_name varchar(45) NOT NULL,
347 347
 					  TTM_description text,
348 348
 					  TTM_file varchar(45),
349 349
 					  PRIMARY KEY  (TTM_ID)";
350
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
-        $table_name = 'esp_question';
352
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
+		$table_name = 'esp_question';
352
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
353 353
 					QST_display_text text NOT NULL,
354 354
 					QST_admin_label varchar(255) NOT NULL,
355 355
 					QST_system varchar(25) NOT NULL DEFAULT "",
@@ -363,18 +363,18 @@  discard block
 block discarded – undo
363 363
 					QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
364 364
 					PRIMARY KEY  (QST_ID),
365 365
 					KEY QST_order (QST_order)';
366
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
367
-        $table_name = 'esp_question_group_question';
368
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
366
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
367
+		$table_name = 'esp_question_group_question';
368
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
369 369
 					QSG_ID int(10) unsigned NOT NULL,
370 370
 					QST_ID int(10) unsigned NOT NULL,
371 371
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
372 372
 					PRIMARY KEY  (QGQ_ID),
373 373
 					KEY QST_ID (QST_ID),
374 374
 					KEY QSG_ID_order (QSG_ID,QGQ_order)";
375
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
-        $table_name = 'esp_question_option';
377
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
375
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
+		$table_name = 'esp_question_option';
377
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
378 378
 					QSO_value varchar(255) NOT NULL,
379 379
 					QSO_desc text NOT NULL,
380 380
 					QST_ID int(10) unsigned NOT NULL,
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 					PRIMARY KEY  (QSO_ID),
385 385
 					KEY QST_ID (QST_ID),
386 386
 					KEY QSO_order (QSO_order)";
387
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
388
-        $table_name = 'esp_registration';
389
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
387
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
388
+		$table_name = 'esp_registration';
389
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
390 390
 					  EVT_ID bigint(20) unsigned NOT NULL,
391 391
 					  ATT_ID bigint(20) unsigned NOT NULL,
392 392
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 					  KEY TKT_ID (TKT_ID),
411 411
 					  KEY EVT_ID (EVT_ID),
412 412
 					  KEY STS_ID (STS_ID)";
413
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
414
-        $table_name = 'esp_registration_payment';
415
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
413
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
414
+		$table_name = 'esp_registration_payment';
415
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
416 416
 					  REG_ID int(10) unsigned NOT NULL,
417 417
 					  PAY_ID int(10) unsigned NULL,
418 418
 					  RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00',
419 419
 					  PRIMARY KEY  (RPY_ID),
420 420
 					  KEY REG_ID (REG_ID),
421 421
 					  KEY PAY_ID (PAY_ID)";
422
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
423
-        $table_name = 'esp_checkin';
424
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
422
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
423
+		$table_name = 'esp_checkin';
424
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
425 425
 					REG_ID int(10) unsigned NOT NULL,
426 426
 					DTT_ID int(10) unsigned NOT NULL,
427 427
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
 					PRIMARY KEY  (CHK_ID),
430 430
 					KEY REG_ID (REG_ID),
431 431
 					KEY DTT_ID (DTT_ID)";
432
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
433
-        $table_name = 'esp_state';
434
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
432
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
433
+		$table_name = 'esp_state';
434
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
435 435
 					  CNT_ISO varchar(2) collate utf8_bin NOT NULL,
436 436
 					  STA_abbrev varchar(24) collate utf8_bin NOT NULL,
437 437
 					  STA_name varchar(100) collate utf8_bin NOT NULL,
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
 					  PRIMARY KEY  (STA_ID),
440 440
 					  KEY STA_abbrev (STA_abbrev),
441 441
 					  KEY CNT_ISO (CNT_ISO)";
442
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
443
-        $table_name = 'esp_status';
444
-        $sql = "STS_ID varchar(3) NOT NULL,
442
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
443
+		$table_name = 'esp_status';
444
+		$sql = "STS_ID varchar(3) NOT NULL,
445 445
 					  STS_code varchar(45) NOT NULL,
446 446
 					  STS_type varchar(45) NOT NULL,
447 447
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
450 450
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
451 451
 					  KEY STS_type (STS_type)";
452
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
453
-        $table_name = 'esp_transaction';
454
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
452
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
453
+		$table_name = 'esp_transaction';
454
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
455 455
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
456 456
 					  TXN_total decimal(10,3) DEFAULT '0.00',
457 457
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -463,9 +463,9 @@  discard block
 block discarded – undo
463 463
 					  PRIMARY KEY  (TXN_ID),
464 464
 					  KEY TXN_timestamp (TXN_timestamp),
465 465
 					  KEY STS_ID (STS_ID)";
466
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
467
-        $table_name = 'esp_venue_meta';
468
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
466
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
467
+		$table_name = 'esp_venue_meta';
468
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
469 469
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
470 470
 			VNU_address varchar(255) DEFAULT NULL,
471 471
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
 			KEY VNU_ID (VNU_ID),
485 485
 			KEY STA_ID (STA_ID),
486 486
 			KEY CNT_ISO (CNT_ISO)";
487
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
488
-        // modified tables
489
-        $table_name = "esp_price";
490
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
487
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
488
+		// modified tables
489
+		$table_name = "esp_price";
490
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
491 491
 					  PRT_ID tinyint(3) unsigned NOT NULL,
492 492
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
493 493
 					  PRC_name varchar(245) NOT NULL,
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 					  PRC_parent int(10) unsigned DEFAULT 0,
501 501
 					  PRIMARY KEY  (PRC_ID),
502 502
 					  KEY PRT_ID (PRT_ID)";
503
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
504
-        $table_name = "esp_price_type";
505
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
503
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
504
+		$table_name = "esp_price_type";
505
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
506 506
 				  PRT_name varchar(45) NOT NULL,
507 507
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
508 508
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -511,9 +511,9 @@  discard block
 block discarded – undo
511 511
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
512 512
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
513 513
 				  PRIMARY KEY  (PRT_ID)";
514
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
515
-        $table_name = "esp_ticket";
516
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
514
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
515
+		$table_name = "esp_ticket";
516
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
517 517
 					  TTM_ID int(10) unsigned NOT NULL,
518 518
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
519 519
 					  TKT_description text NOT NULL,
@@ -535,9 +535,9 @@  discard block
 block discarded – undo
535 535
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
536 536
 					  PRIMARY KEY  (TKT_ID),
537 537
 					  KEY TKT_start_date (TKT_start_date)";
538
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
539
-        $table_name = 'esp_question_group';
540
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
538
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
539
+		$table_name = 'esp_question_group';
540
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
541 541
 					QSG_name varchar(255) NOT NULL,
542 542
 					QSG_identifier varchar(100) NOT NULL,
543 543
 					QSG_desc text NULL,
@@ -550,223 +550,223 @@  discard block
 block discarded – undo
550 550
 					PRIMARY KEY  (QSG_ID),
551 551
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
552 552
 					KEY QSG_order (QSG_order)';
553
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
554
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
555
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
556
-        // (because many need to convert old string states to foreign keys into the states table)
557
-        $script_4_1_defaults->insert_default_states();
558
-        $script_4_1_defaults->insert_default_countries();
559
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
560
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
561
-        $script_4_5_defaults->insert_default_price_types();
562
-        $script_4_5_defaults->insert_default_prices();
563
-        $script_4_5_defaults->insert_default_tickets();
564
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
565
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
566
-        $script_4_6_defaults->add_default_admin_only_payments();
567
-        $script_4_6_defaults->insert_default_currencies();
568
-        $this->verify_new_countries();
569
-        $this->verify_new_currencies();
570
-        return true;
571
-    }
553
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
554
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
555
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
556
+		// (because many need to convert old string states to foreign keys into the states table)
557
+		$script_4_1_defaults->insert_default_states();
558
+		$script_4_1_defaults->insert_default_countries();
559
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
560
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
561
+		$script_4_5_defaults->insert_default_price_types();
562
+		$script_4_5_defaults->insert_default_prices();
563
+		$script_4_5_defaults->insert_default_tickets();
564
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
565
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
566
+		$script_4_6_defaults->add_default_admin_only_payments();
567
+		$script_4_6_defaults->insert_default_currencies();
568
+		$this->verify_new_countries();
569
+		$this->verify_new_currencies();
570
+		return true;
571
+	}
572 572
 
573 573
 
574 574
 
575
-    /**
576
-     * @return boolean
577
-     */
578
-    public function schema_changes_after_migration()
579
-    {
580
-        $this->fix_non_default_taxes();
581
-        // this is actually the same as the last DMS
582
-        /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */
583
-        $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0');
584
-        return $script_4_7_defaults->schema_changes_after_migration();
585
-    }
575
+	/**
576
+	 * @return boolean
577
+	 */
578
+	public function schema_changes_after_migration()
579
+	{
580
+		$this->fix_non_default_taxes();
581
+		// this is actually the same as the last DMS
582
+		/** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */
583
+		$script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0');
584
+		return $script_4_7_defaults->schema_changes_after_migration();
585
+	}
586 586
 
587 587
 
588 588
 
589
-    public function migration_page_hooks()
590
-    {
591
-    }
589
+	public function migration_page_hooks()
590
+	{
591
+	}
592 592
 
593 593
 
594 594
 
595
-    /**
596
-     * verifies each of the new countries exists that somehow we missed in 4.1
597
-     */
598
-    public function verify_new_countries()
599
-    {
600
-        // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
601
-        // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
602
-        // currency symbols: http://www.xe.com/symbols.php
603
-        // CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active
604
-        // ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
605
-        $newer_countries = array(
606
-            array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
607
-            array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
608
-            array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
609
-            array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
610
-            array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
611
-            array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
612
-            array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
613
-            array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
614
-            array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0),
615
-            array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
616
-            array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
617
-            array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0),
618
-            array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
619
-            array(
620
-                'BQ',
621
-                'BES',
622
-                0,
623
-                'Bonaire, Saint Eustatius and Saba',
624
-                'USD',
625
-                'Dollar',
626
-                'Dollars',
627
-                '$',
628
-                1,
629
-                2,
630
-                '+599',
631
-                0,
632
-                0,
633
-            ),
634
-            array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0),
635
-            array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0),
636
-            array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0),
637
-            array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
638
-            array(
639
-                'HM',
640
-                'HMD',
641
-                0,
642
-                'Heard Island and McDonald Islands',
643
-                'AUD',
644
-                'Dollar',
645
-                'Dollars',
646
-                '$',
647
-                1,
648
-                2,
649
-                '+891',
650
-                0,
651
-                0,
652
-            ),
653
-            array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0),
654
-            array(
655
-                'GS',
656
-                'SGS',
657
-                0,
658
-                'South Georgia and the South Sandwich Islands',
659
-                'GBP',
660
-                'Pound',
661
-                'Pounds',
662
-                '£',
663
-                1,
664
-                2,
665
-                '+500',
666
-                0,
667
-                0,
668
-            ),
669
-            array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0),
670
-            array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0),
671
-            array(
672
-                'UM',
673
-                'UMI',
674
-                0,
675
-                'United States Minor Outlying Islands',
676
-                'USD',
677
-                'Dollar',
678
-                'Dollars',
679
-                '$',
680
-                1,
681
-                2,
682
-                '+1',
683
-                0,
684
-                0,
685
-            ),
686
-        );
687
-        global $wpdb;
688
-        $country_table = $wpdb->prefix . "esp_country";
689
-        $country_format = array(
690
-            "CNT_ISO"         => '%s',
691
-            "CNT_ISO3"        => '%s',
692
-            "RGN_ID"          => '%d',
693
-            "CNT_name"        => '%s',
694
-            "CNT_cur_code"    => '%s',
695
-            "CNT_cur_single"  => '%s',
696
-            "CNT_cur_plural"  => '%s',
697
-            "CNT_cur_sign"    => '%s',
698
-            "CNT_cur_sign_b4" => '%d',
699
-            "CNT_cur_dec_plc" => '%d',
700
-            "CNT_tel_code"    => '%s',
701
-            "CNT_is_EU"       => '%d',
702
-            "CNT_active"      => '%d',
703
-        );
704
-        if ($this->_get_table_analysis()->tableExists($country_table)) {
705
-            foreach ($newer_countries as $country) {
706
-                $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
707
-                $countries = $wpdb->get_var($SQL);
708
-                if (! $countries) {
709
-                    $wpdb->insert(
710
-                        $country_table,
711
-                        array_combine(array_keys($country_format), $country),
712
-                        $country_format
713
-                    );
714
-                }
715
-            }
716
-        }
717
-    }
595
+	/**
596
+	 * verifies each of the new countries exists that somehow we missed in 4.1
597
+	 */
598
+	public function verify_new_countries()
599
+	{
600
+		// a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
601
+		// how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
602
+		// currency symbols: http://www.xe.com/symbols.php
603
+		// CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active
604
+		// ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
605
+		$newer_countries = array(
606
+			array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
607
+			array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
608
+			array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
609
+			array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
610
+			array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
611
+			array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
612
+			array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
613
+			array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
614
+			array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0),
615
+			array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
616
+			array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
617
+			array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0),
618
+			array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
619
+			array(
620
+				'BQ',
621
+				'BES',
622
+				0,
623
+				'Bonaire, Saint Eustatius and Saba',
624
+				'USD',
625
+				'Dollar',
626
+				'Dollars',
627
+				'$',
628
+				1,
629
+				2,
630
+				'+599',
631
+				0,
632
+				0,
633
+			),
634
+			array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0),
635
+			array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0),
636
+			array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0),
637
+			array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
638
+			array(
639
+				'HM',
640
+				'HMD',
641
+				0,
642
+				'Heard Island and McDonald Islands',
643
+				'AUD',
644
+				'Dollar',
645
+				'Dollars',
646
+				'$',
647
+				1,
648
+				2,
649
+				'+891',
650
+				0,
651
+				0,
652
+			),
653
+			array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0),
654
+			array(
655
+				'GS',
656
+				'SGS',
657
+				0,
658
+				'South Georgia and the South Sandwich Islands',
659
+				'GBP',
660
+				'Pound',
661
+				'Pounds',
662
+				'£',
663
+				1,
664
+				2,
665
+				'+500',
666
+				0,
667
+				0,
668
+			),
669
+			array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0),
670
+			array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0),
671
+			array(
672
+				'UM',
673
+				'UMI',
674
+				0,
675
+				'United States Minor Outlying Islands',
676
+				'USD',
677
+				'Dollar',
678
+				'Dollars',
679
+				'$',
680
+				1,
681
+				2,
682
+				'+1',
683
+				0,
684
+				0,
685
+			),
686
+		);
687
+		global $wpdb;
688
+		$country_table = $wpdb->prefix . "esp_country";
689
+		$country_format = array(
690
+			"CNT_ISO"         => '%s',
691
+			"CNT_ISO3"        => '%s',
692
+			"RGN_ID"          => '%d',
693
+			"CNT_name"        => '%s',
694
+			"CNT_cur_code"    => '%s',
695
+			"CNT_cur_single"  => '%s',
696
+			"CNT_cur_plural"  => '%s',
697
+			"CNT_cur_sign"    => '%s',
698
+			"CNT_cur_sign_b4" => '%d',
699
+			"CNT_cur_dec_plc" => '%d',
700
+			"CNT_tel_code"    => '%s',
701
+			"CNT_is_EU"       => '%d',
702
+			"CNT_active"      => '%d',
703
+		);
704
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
705
+			foreach ($newer_countries as $country) {
706
+				$SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
707
+				$countries = $wpdb->get_var($SQL);
708
+				if (! $countries) {
709
+					$wpdb->insert(
710
+						$country_table,
711
+						array_combine(array_keys($country_format), $country),
712
+						$country_format
713
+					);
714
+				}
715
+			}
716
+		}
717
+	}
718 718
 
719 719
 
720 720
 
721
-    /**
722
-     * verifies each of the new currencies exists that somehow we missed in 4.6
723
-     */
724
-    public function verify_new_currencies()
725
-    {
726
-        // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
727
-        // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
728
-        // currency symbols: http://www.xe.com/symbols.php
729
-        // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
730
-        // ( 'EUR',  'Euro',  'Euros',  '€',  2,1),
731
-        $newer_currencies = array(
732
-            array('RSD', 'Dinar', 'Dinars', '', 3, 1),
733
-        );
734
-        global $wpdb;
735
-        $currency_table = $wpdb->prefix . "esp_currency";
736
-        $currency_format = array(
737
-            "CUR_code"    => '%s',
738
-            "CUR_single"  => '%s',
739
-            "CUR_plural"  => '%s',
740
-            "CUR_sign"    => '%s',
741
-            "CUR_dec_plc" => '%d',
742
-            "CUR_active"  => '%d',
743
-        );
744
-        if ($this->_get_table_analysis()->tableExists($currency_table)) {
745
-            foreach ($newer_currencies as $currency) {
746
-                $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
747
-                $countries = $wpdb->get_var($SQL);
748
-                if (! $countries) {
749
-                    $wpdb->insert(
750
-                        $currency_table,
751
-                        array_combine(array_keys($currency_format), $currency),
752
-                        $currency_format
753
-                    );
754
-                }
755
-            }
756
-        }
757
-    }
721
+	/**
722
+	 * verifies each of the new currencies exists that somehow we missed in 4.6
723
+	 */
724
+	public function verify_new_currencies()
725
+	{
726
+		// a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
727
+		// how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
728
+		// currency symbols: http://www.xe.com/symbols.php
729
+		// CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
730
+		// ( 'EUR',  'Euro',  'Euros',  '€',  2,1),
731
+		$newer_currencies = array(
732
+			array('RSD', 'Dinar', 'Dinars', '', 3, 1),
733
+		);
734
+		global $wpdb;
735
+		$currency_table = $wpdb->prefix . "esp_currency";
736
+		$currency_format = array(
737
+			"CUR_code"    => '%s',
738
+			"CUR_single"  => '%s',
739
+			"CUR_plural"  => '%s',
740
+			"CUR_sign"    => '%s',
741
+			"CUR_dec_plc" => '%d',
742
+			"CUR_active"  => '%d',
743
+		);
744
+		if ($this->_get_table_analysis()->tableExists($currency_table)) {
745
+			foreach ($newer_currencies as $currency) {
746
+				$SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
747
+				$countries = $wpdb->get_var($SQL);
748
+				if (! $countries) {
749
+					$wpdb->insert(
750
+						$currency_table,
751
+						array_combine(array_keys($currency_format), $currency),
752
+						$currency_format
753
+					);
754
+				}
755
+			}
756
+		}
757
+	}
758 758
 
759 759
 
760 760
 
761
-    /**
762
-     * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731
763
-     * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
764
-     * we should be able to stop doing this in 4.9
765
-     */
766
-    public function fix_non_default_taxes()
767
-    {
768
-        global $wpdb;
769
-        $query = $wpdb->prepare("UPDATE
761
+	/**
762
+	 * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731
763
+	 * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
764
+	 * we should be able to stop doing this in 4.9
765
+	 */
766
+	public function fix_non_default_taxes()
767
+	{
768
+		global $wpdb;
769
+		$query = $wpdb->prepare("UPDATE
770 770
 				{$wpdb->prefix}esp_price p INNER JOIN
771 771
 				{$wpdb->prefix}esp_price_type pt ON p.PRT_ID = pt.PRT_ID
772 772
 			SET
@@ -775,6 +775,6 @@  discard block
 block discarded – undo
775 775
 				p.PRC_is_default = 0 AND
776 776
 				pt.PBT_ID = %d
777 777
 					", EEM_Price_Type::base_type_tax);
778
-        $wpdb->query($query);
779
-    }
778
+		$wpdb->query($query);
779
+	}
780 780
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/OrganizationSettings.php 1 patch
Indentation   +473 added lines, -473 removed lines patch added patch discarded remove patch
@@ -40,498 +40,498 @@
 block discarded – undo
40 40
 class OrganizationSettings extends FormHandler
41 41
 {
42 42
 
43
-    /**
44
-     * @var EE_Organization_Config
45
-     */
46
-    protected $organization_config;
43
+	/**
44
+	 * @var EE_Organization_Config
45
+	 */
46
+	protected $organization_config;
47 47
 
48
-    /**
49
-     * @var EE_Core_Config
50
-     */
51
-    protected $core_config;
48
+	/**
49
+	 * @var EE_Core_Config
50
+	 */
51
+	protected $core_config;
52 52
 
53 53
 
54
-    /**
55
-     * @var EE_Network_Core_Config
56
-     */
57
-    protected $network_core_config;
54
+	/**
55
+	 * @var EE_Network_Core_Config
56
+	 */
57
+	protected $network_core_config;
58 58
 
59
-    /**
60
-     * Form constructor.
61
-     *
62
-     * @param EE_Registry             $registry
63
-     * @param EE_Organization_Config  $organization_config
64
-     * @param EE_Core_Config          $core_config
65
-     * @param EE_Network_Core_Config $network_core_config
66
-     * @throws InvalidArgumentException
67
-     * @throws InvalidDataTypeException
68
-     * @throws DomainException
69
-     */
70
-    public function __construct(
71
-        EE_Registry $registry,
72
-        EE_Organization_Config $organization_config,
73
-        EE_Core_Config $core_config,
74
-        EE_Network_Core_Config $network_core_config
75
-    ) {
76
-        $this->organization_config = $organization_config;
77
-        $this->core_config = $core_config;
78
-        $this->network_core_config = $network_core_config;
79
-        parent::__construct(
80
-            esc_html__('Your Organization Settings', 'event_espresso'),
81
-            esc_html__('Your Organization Settings', 'event_espresso'),
82
-            'organization_settings',
83
-            '',
84
-            FormHandler::DO_NOT_SETUP_FORM,
85
-            $registry
86
-        );
87
-    }
59
+	/**
60
+	 * Form constructor.
61
+	 *
62
+	 * @param EE_Registry             $registry
63
+	 * @param EE_Organization_Config  $organization_config
64
+	 * @param EE_Core_Config          $core_config
65
+	 * @param EE_Network_Core_Config $network_core_config
66
+	 * @throws InvalidArgumentException
67
+	 * @throws InvalidDataTypeException
68
+	 * @throws DomainException
69
+	 */
70
+	public function __construct(
71
+		EE_Registry $registry,
72
+		EE_Organization_Config $organization_config,
73
+		EE_Core_Config $core_config,
74
+		EE_Network_Core_Config $network_core_config
75
+	) {
76
+		$this->organization_config = $organization_config;
77
+		$this->core_config = $core_config;
78
+		$this->network_core_config = $network_core_config;
79
+		parent::__construct(
80
+			esc_html__('Your Organization Settings', 'event_espresso'),
81
+			esc_html__('Your Organization Settings', 'event_espresso'),
82
+			'organization_settings',
83
+			'',
84
+			FormHandler::DO_NOT_SETUP_FORM,
85
+			$registry
86
+		);
87
+	}
88 88
 
89 89
 
90 90
 
91
-    /**
92
-     * creates and returns the actual form
93
-     *
94
-     * @return EE_Form_Section_Proper
95
-     * @throws EE_Error
96
-     */
97
-    public function generate()
98
-    {
99
-        $form = new EE_Form_Section_Proper(
100
-            array(
101
-                'name'            => 'organization_settings',
102
-                'html_id'         => 'organization_settings',
103
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
104
-                'subsections'     => array(
105
-                    'contact_information_hdr'        => new EE_Form_Section_HTML(
106
-                        EEH_HTML::h2(
107
-                            esc_html__('Contact Information', 'event_espresso')
108
-                            . ' '
109
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
110
-                            '',
111
-                            'contact-information-hdr'
112
-                        )
113
-                    ),
114
-                    'organization_name'      => new EE_Text_Input(
115
-                        array(
116
-                            'html_name' => 'organization_name',
117
-                            'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
118
-                            'html_help_text'  => esc_html__(
119
-                                'Displayed on all emails and invoices.',
120
-                                'event_espresso'
121
-                            ),
122
-                            'default'         => $this->organization_config->get_pretty('name'),
123
-                            'required'        => false,
124
-                        )
125
-                    ),
126
-                    'organization_address_1'      => new EE_Text_Input(
127
-                        array(
128
-                            'html_name' => 'organization_address_1',
129
-                            'html_label_text' => esc_html__('Street Address', 'event_espresso'),
130
-                            'default'         => $this->organization_config->get_pretty('address_1'),
131
-                            'required'        => false,
132
-                        )
133
-                    ),
134
-                    'organization_address_2'      => new EE_Text_Input(
135
-                        array(
136
-                            'html_name' => 'organization_address_2',
137
-                            'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
138
-                            'default'         => $this->organization_config->get_pretty('address_2'),
139
-                            'required'        => false,
140
-                        )
141
-                    ),
142
-                    'organization_city'      => new EE_Text_Input(
143
-                        array(
144
-                            'html_name' => 'organization_city',
145
-                            'html_label_text' => esc_html__('City', 'event_espresso'),
146
-                            'default'         => $this->organization_config->get_pretty('city'),
147
-                            'required'        => false,
148
-                        )
149
-                    ),
150
-                    'organization_state'      => new EE_State_Select_Input(
151
-                        null,
152
-                        array(
153
-                            'html_name' => 'organization_state',
154
-                            'html_label_text' => esc_html__('State/Province', 'event_espresso'),
155
-                            'default'         => $this->organization_config->STA_ID,
156
-                            'required'        => false,
157
-                        )
158
-                    ),
159
-                    'organization_country'      => new EE_Country_Select_Input(
160
-                        null,
161
-                        array(
162
-                            'html_name' => 'organization_country',
163
-                            'html_label_text' => esc_html__('Country', 'event_espresso'),
164
-                            'default'         => $this->organization_config->CNT_ISO,
165
-                            'required'        => false,
166
-                        )
167
-                    ),
168
-                    'organization_zip'      => new EE_Text_Input(
169
-                        array(
170
-                            'html_name' => 'organization_zip',
171
-                            'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
172
-                            'default'         => $this->organization_config->get_pretty('zip'),
173
-                            'required'        => false,
174
-                        )
175
-                    ),
176
-                    'organization_email'      => new EE_Text_Input(
177
-                        array(
178
-                            'html_name' => 'organization_email',
179
-                            'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
180
-                            'html_help_text'  => sprintf(
181
-                                esc_html__(
182
-                                    'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
183
-                                    'event_espresso'
184
-                                ),
185
-                                '<code>[CO_FORMATTED_EMAIL]</code>',
186
-                                '<code>[CO_EMAIL]</code>'
187
-                            ),
188
-                            'default'         => $this->organization_config->get_pretty('email'),
189
-                            'required'        => false,
190
-                        )
191
-                    ),
192
-                    'organization_phone'      => new EE_Text_Input(
193
-                        array(
194
-                            'html_name' => 'organization_phone',
195
-                            'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
196
-                            'html_help_text'  => esc_html__(
197
-                                'The phone number for your organization.',
198
-                                'event_espresso'
199
-                            ),
200
-                            'default'         => $this->organization_config->get_pretty('phone'),
201
-                            'required'        => false,
202
-                        )
203
-                    ),
204
-                    'organization_vat'      => new EE_Text_Input(
205
-                        array(
206
-                            'html_name' => 'organization_vat',
207
-                            'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
208
-                            'html_help_text'  => esc_html__(
209
-                                'The VAT/Tax Number may be displayed on invoices and receipts.',
210
-                                'event_espresso'
211
-                            ),
212
-                            'default'         => $this->organization_config->get_pretty('vat'),
213
-                            'required'        => false,
214
-                        )
215
-                    ),
216
-                    'company_logo_hdr'        => new EE_Form_Section_HTML(
217
-                        EEH_HTML::h2(
218
-                            esc_html__('Company Logo', 'event_espresso')
219
-                            . ' '
220
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
221
-                            '',
222
-                            'company-logo-hdr'
223
-                        )
224
-                    ),
225
-                    'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
226
-                        array(
227
-                            'html_name' => 'organization_logo_url',
228
-                            'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
229
-                            'html_help_text'  => esc_html__(
230
-                                'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
231
-                                'event_espresso'
232
-                            ),
233
-                            'default'         => $this->organization_config->get_pretty('logo_url'),
234
-                            'required'        => false,
235
-                        )
236
-                    ),
237
-                    'social_links_hdr'        => new EE_Form_Section_HTML(
238
-                        EEH_HTML::h2(
239
-                            esc_html__('Social Links', 'event_espresso')
240
-                            . ' '
241
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
242
-                            . EEH_HTML::br()
243
-                            . EEH_HTML::p(
244
-                                esc_html__(
245
-                                    'Enter any links to social accounts for your organization here',
246
-                                    'event_espresso'
247
-                                ),
248
-                                '',
249
-                                'description'
250
-                            ),
251
-                            '',
252
-                            'social-links-hdr'
253
-                        )
254
-                    ),
255
-                    'organization_facebook'      => new EE_Text_Input(
256
-                        array(
257
-                            'html_name' => 'organization_facebook',
258
-                            'html_label_text' => esc_html__('Facebook', 'event_espresso'),
259
-                            'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
260
-                            'default'         => $this->organization_config->get_pretty('facebook'),
261
-                            'required'        => false,
262
-                        )
263
-                    ),
264
-                    'organization_twitter'      => new EE_Text_Input(
265
-                        array(
266
-                            'html_name' => 'organization_twitter',
267
-                            'html_label_text' => esc_html__('Twitter', 'event_espresso'),
268
-                            'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
269
-                            'default'         => $this->organization_config->get_pretty('twitter'),
270
-                            'required'        => false,
271
-                        )
272
-                    ),
273
-                    'organization_linkedin'      => new EE_Text_Input(
274
-                        array(
275
-                            'html_name' => 'organization_linkedin',
276
-                            'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
277
-                            'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
278
-                            'default'         => $this->organization_config->get_pretty('linkedin'),
279
-                            'required'        => false,
280
-                        )
281
-                    ),
282
-                    'organization_pinterest'      => new EE_Text_Input(
283
-                        array(
284
-                            'html_name' => 'organization_pinterest',
285
-                            'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
286
-                            'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
287
-                            'default'         => $this->organization_config->get_pretty('pinterest'),
288
-                            'required'        => false,
289
-                        )
290
-                    ),
291
-                    'organization_google'      => new EE_Text_Input(
292
-                        array(
293
-                            'html_name' => 'organization_google',
294
-                            'html_label_text' => esc_html__('Google+', 'event_espresso'),
295
-                            'other_html_attributes' => ' placeholder="google.com/+profilename"',
296
-                            'default'         => $this->organization_config->get_pretty('google'),
297
-                            'required'        => false,
298
-                        )
299
-                    ),
300
-                    'organization_instagram'      => new EE_Text_Input(
301
-                        array(
302
-                            'html_name' => 'organization_instagram',
303
-                            'html_label_text' => esc_html__('Instagram', 'event_espresso'),
304
-                            'other_html_attributes' => ' placeholder="instagram.com/handle"',
305
-                            'default'         => $this->organization_config->get_pretty('instagram'),
306
-                            'required'        => false,
307
-                        )
308
-                    ),
309
-                ),
310
-            )
311
-        );
312
-        if (is_main_site()) {
313
-            $form->add_subsections(
314
-                array(
315
-                    'site_license_key_hdr' => new EE_Form_Section_HTML(
316
-                        EEH_HTML::h2(
317
-                            esc_html__('Your Event Espresso License Key', 'event_espresso')
318
-                            . ' '
319
-                            . EEH_HTML::span(
320
-                                EEH_Template::get_help_tab_link('site_license_key_info'),
321
-                                'help_tour_activation'
322
-                            ),
323
-                            '',
324
-                            'site-license-key-hdr'
325
-                        )
326
-                    ),
327
-                    'site_license_key' => $this->getSiteLicenseKeyField()
328
-                )
329
-            );
330
-            $form->add_subsections(
331
-                array(
332
-                    'uxip_optin_hdr' => new EE_Form_Section_HTML(
333
-                        $this->uxipOptinText()
334
-                    ),
335
-                    'ueip_optin' => new EE_Checkbox_Multi_Input(
336
-                        array(
337
-                            true => __('Yes! I want to help improve Event Espresso!', 'event_espresso')
338
-                        ),
339
-                        array(
340
-                            'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
341
-                            'html_label_text' => esc_html__(
342
-                                'UXIP Opt In?',
343
-                                'event_espresso'
344
-                            ),
345
-                            'default'         => isset($this->core_config->ee_ueip_optin)
346
-                                ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
347
-                                : false,
348
-                            'required'        => false,
349
-                        )
350
-                    ),
351
-                ),
352
-                'organization_instagram',
353
-                false
354
-            );
355
-        }
356
-        return $form;
357
-    }
91
+	/**
92
+	 * creates and returns the actual form
93
+	 *
94
+	 * @return EE_Form_Section_Proper
95
+	 * @throws EE_Error
96
+	 */
97
+	public function generate()
98
+	{
99
+		$form = new EE_Form_Section_Proper(
100
+			array(
101
+				'name'            => 'organization_settings',
102
+				'html_id'         => 'organization_settings',
103
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
104
+				'subsections'     => array(
105
+					'contact_information_hdr'        => new EE_Form_Section_HTML(
106
+						EEH_HTML::h2(
107
+							esc_html__('Contact Information', 'event_espresso')
108
+							. ' '
109
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
110
+							'',
111
+							'contact-information-hdr'
112
+						)
113
+					),
114
+					'organization_name'      => new EE_Text_Input(
115
+						array(
116
+							'html_name' => 'organization_name',
117
+							'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
118
+							'html_help_text'  => esc_html__(
119
+								'Displayed on all emails and invoices.',
120
+								'event_espresso'
121
+							),
122
+							'default'         => $this->organization_config->get_pretty('name'),
123
+							'required'        => false,
124
+						)
125
+					),
126
+					'organization_address_1'      => new EE_Text_Input(
127
+						array(
128
+							'html_name' => 'organization_address_1',
129
+							'html_label_text' => esc_html__('Street Address', 'event_espresso'),
130
+							'default'         => $this->organization_config->get_pretty('address_1'),
131
+							'required'        => false,
132
+						)
133
+					),
134
+					'organization_address_2'      => new EE_Text_Input(
135
+						array(
136
+							'html_name' => 'organization_address_2',
137
+							'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
138
+							'default'         => $this->organization_config->get_pretty('address_2'),
139
+							'required'        => false,
140
+						)
141
+					),
142
+					'organization_city'      => new EE_Text_Input(
143
+						array(
144
+							'html_name' => 'organization_city',
145
+							'html_label_text' => esc_html__('City', 'event_espresso'),
146
+							'default'         => $this->organization_config->get_pretty('city'),
147
+							'required'        => false,
148
+						)
149
+					),
150
+					'organization_state'      => new EE_State_Select_Input(
151
+						null,
152
+						array(
153
+							'html_name' => 'organization_state',
154
+							'html_label_text' => esc_html__('State/Province', 'event_espresso'),
155
+							'default'         => $this->organization_config->STA_ID,
156
+							'required'        => false,
157
+						)
158
+					),
159
+					'organization_country'      => new EE_Country_Select_Input(
160
+						null,
161
+						array(
162
+							'html_name' => 'organization_country',
163
+							'html_label_text' => esc_html__('Country', 'event_espresso'),
164
+							'default'         => $this->organization_config->CNT_ISO,
165
+							'required'        => false,
166
+						)
167
+					),
168
+					'organization_zip'      => new EE_Text_Input(
169
+						array(
170
+							'html_name' => 'organization_zip',
171
+							'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
172
+							'default'         => $this->organization_config->get_pretty('zip'),
173
+							'required'        => false,
174
+						)
175
+					),
176
+					'organization_email'      => new EE_Text_Input(
177
+						array(
178
+							'html_name' => 'organization_email',
179
+							'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
180
+							'html_help_text'  => sprintf(
181
+								esc_html__(
182
+									'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
183
+									'event_espresso'
184
+								),
185
+								'<code>[CO_FORMATTED_EMAIL]</code>',
186
+								'<code>[CO_EMAIL]</code>'
187
+							),
188
+							'default'         => $this->organization_config->get_pretty('email'),
189
+							'required'        => false,
190
+						)
191
+					),
192
+					'organization_phone'      => new EE_Text_Input(
193
+						array(
194
+							'html_name' => 'organization_phone',
195
+							'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
196
+							'html_help_text'  => esc_html__(
197
+								'The phone number for your organization.',
198
+								'event_espresso'
199
+							),
200
+							'default'         => $this->organization_config->get_pretty('phone'),
201
+							'required'        => false,
202
+						)
203
+					),
204
+					'organization_vat'      => new EE_Text_Input(
205
+						array(
206
+							'html_name' => 'organization_vat',
207
+							'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
208
+							'html_help_text'  => esc_html__(
209
+								'The VAT/Tax Number may be displayed on invoices and receipts.',
210
+								'event_espresso'
211
+							),
212
+							'default'         => $this->organization_config->get_pretty('vat'),
213
+							'required'        => false,
214
+						)
215
+					),
216
+					'company_logo_hdr'        => new EE_Form_Section_HTML(
217
+						EEH_HTML::h2(
218
+							esc_html__('Company Logo', 'event_espresso')
219
+							. ' '
220
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
221
+							'',
222
+							'company-logo-hdr'
223
+						)
224
+					),
225
+					'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
226
+						array(
227
+							'html_name' => 'organization_logo_url',
228
+							'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
229
+							'html_help_text'  => esc_html__(
230
+								'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
231
+								'event_espresso'
232
+							),
233
+							'default'         => $this->organization_config->get_pretty('logo_url'),
234
+							'required'        => false,
235
+						)
236
+					),
237
+					'social_links_hdr'        => new EE_Form_Section_HTML(
238
+						EEH_HTML::h2(
239
+							esc_html__('Social Links', 'event_espresso')
240
+							. ' '
241
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
242
+							. EEH_HTML::br()
243
+							. EEH_HTML::p(
244
+								esc_html__(
245
+									'Enter any links to social accounts for your organization here',
246
+									'event_espresso'
247
+								),
248
+								'',
249
+								'description'
250
+							),
251
+							'',
252
+							'social-links-hdr'
253
+						)
254
+					),
255
+					'organization_facebook'      => new EE_Text_Input(
256
+						array(
257
+							'html_name' => 'organization_facebook',
258
+							'html_label_text' => esc_html__('Facebook', 'event_espresso'),
259
+							'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
260
+							'default'         => $this->organization_config->get_pretty('facebook'),
261
+							'required'        => false,
262
+						)
263
+					),
264
+					'organization_twitter'      => new EE_Text_Input(
265
+						array(
266
+							'html_name' => 'organization_twitter',
267
+							'html_label_text' => esc_html__('Twitter', 'event_espresso'),
268
+							'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
269
+							'default'         => $this->organization_config->get_pretty('twitter'),
270
+							'required'        => false,
271
+						)
272
+					),
273
+					'organization_linkedin'      => new EE_Text_Input(
274
+						array(
275
+							'html_name' => 'organization_linkedin',
276
+							'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
277
+							'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
278
+							'default'         => $this->organization_config->get_pretty('linkedin'),
279
+							'required'        => false,
280
+						)
281
+					),
282
+					'organization_pinterest'      => new EE_Text_Input(
283
+						array(
284
+							'html_name' => 'organization_pinterest',
285
+							'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
286
+							'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
287
+							'default'         => $this->organization_config->get_pretty('pinterest'),
288
+							'required'        => false,
289
+						)
290
+					),
291
+					'organization_google'      => new EE_Text_Input(
292
+						array(
293
+							'html_name' => 'organization_google',
294
+							'html_label_text' => esc_html__('Google+', 'event_espresso'),
295
+							'other_html_attributes' => ' placeholder="google.com/+profilename"',
296
+							'default'         => $this->organization_config->get_pretty('google'),
297
+							'required'        => false,
298
+						)
299
+					),
300
+					'organization_instagram'      => new EE_Text_Input(
301
+						array(
302
+							'html_name' => 'organization_instagram',
303
+							'html_label_text' => esc_html__('Instagram', 'event_espresso'),
304
+							'other_html_attributes' => ' placeholder="instagram.com/handle"',
305
+							'default'         => $this->organization_config->get_pretty('instagram'),
306
+							'required'        => false,
307
+						)
308
+					),
309
+				),
310
+			)
311
+		);
312
+		if (is_main_site()) {
313
+			$form->add_subsections(
314
+				array(
315
+					'site_license_key_hdr' => new EE_Form_Section_HTML(
316
+						EEH_HTML::h2(
317
+							esc_html__('Your Event Espresso License Key', 'event_espresso')
318
+							. ' '
319
+							. EEH_HTML::span(
320
+								EEH_Template::get_help_tab_link('site_license_key_info'),
321
+								'help_tour_activation'
322
+							),
323
+							'',
324
+							'site-license-key-hdr'
325
+						)
326
+					),
327
+					'site_license_key' => $this->getSiteLicenseKeyField()
328
+				)
329
+			);
330
+			$form->add_subsections(
331
+				array(
332
+					'uxip_optin_hdr' => new EE_Form_Section_HTML(
333
+						$this->uxipOptinText()
334
+					),
335
+					'ueip_optin' => new EE_Checkbox_Multi_Input(
336
+						array(
337
+							true => __('Yes! I want to help improve Event Espresso!', 'event_espresso')
338
+						),
339
+						array(
340
+							'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
341
+							'html_label_text' => esc_html__(
342
+								'UXIP Opt In?',
343
+								'event_espresso'
344
+							),
345
+							'default'         => isset($this->core_config->ee_ueip_optin)
346
+								? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
347
+								: false,
348
+							'required'        => false,
349
+						)
350
+					),
351
+				),
352
+				'organization_instagram',
353
+				false
354
+			);
355
+		}
356
+		return $form;
357
+	}
358 358
 
359 359
 
360
-    /**
361
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
362
-     * returns a string of HTML that can be directly echoed in a template
363
-     *
364
-     * @return string
365
-     * @throws EE_Error
366
-     * @throws InvalidArgumentException
367
-     * @throws InvalidDataTypeException
368
-     * @throws InvalidInterfaceException
369
-     * @throws LogicException
370
-     */
371
-    public function display()
372
-    {
373
-        $this->form()->enqueue_js();
374
-        return parent::display();
375
-    }
360
+	/**
361
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
362
+	 * returns a string of HTML that can be directly echoed in a template
363
+	 *
364
+	 * @return string
365
+	 * @throws EE_Error
366
+	 * @throws InvalidArgumentException
367
+	 * @throws InvalidDataTypeException
368
+	 * @throws InvalidInterfaceException
369
+	 * @throws LogicException
370
+	 */
371
+	public function display()
372
+	{
373
+		$this->form()->enqueue_js();
374
+		return parent::display();
375
+	}
376 376
 
377 377
 
378
-    /**
379
-     * handles processing the form submission
380
-     * returns true or false depending on whether the form was processed successfully or not
381
-     *
382
-     * @param array $form_data
383
-     * @return bool
384
-     * @throws InvalidFormSubmissionException
385
-     * @throws EE_Error
386
-     * @throws LogicException
387
-     * @throws InvalidArgumentException
388
-     * @throws InvalidDataTypeException
389
-     */
390
-    public function process($form_data = array())
391
-    {
392
-        // process form
393
-        $valid_data = (array) parent::process($form_data);
394
-        if (empty($valid_data)) {
395
-            return false;
396
-        }
378
+	/**
379
+	 * handles processing the form submission
380
+	 * returns true or false depending on whether the form was processed successfully or not
381
+	 *
382
+	 * @param array $form_data
383
+	 * @return bool
384
+	 * @throws InvalidFormSubmissionException
385
+	 * @throws EE_Error
386
+	 * @throws LogicException
387
+	 * @throws InvalidArgumentException
388
+	 * @throws InvalidDataTypeException
389
+	 */
390
+	public function process($form_data = array())
391
+	{
392
+		// process form
393
+		$valid_data = (array) parent::process($form_data);
394
+		if (empty($valid_data)) {
395
+			return false;
396
+		}
397 397
 
398
-        if (is_main_site()) {
399
-            $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
400
-                ? sanitize_text_field($form_data['ee_site_license_key'])
401
-                : $this->network_core_config->site_license_key;
402
-        }
403
-        $this->organization_config->name = isset($form_data['organization_name'])
404
-            ? sanitize_text_field($form_data['organization_name'])
405
-            : $this->organization_config->name;
406
-        $this->organization_config->address_1 = isset($form_data['organization_address_1'])
407
-            ? sanitize_text_field($form_data['organization_address_1'])
408
-            : $this->organization_config->address_1;
409
-        $this->organization_config->address_2 = isset($form_data['organization_address_2'])
410
-            ? sanitize_text_field($form_data['organization_address_2'])
411
-            : $this->organization_config->address_2;
412
-        $this->organization_config->city = isset($form_data['organization_city'])
413
-            ? sanitize_text_field($form_data['organization_city'])
414
-            : $this->organization_config->city;
415
-        $this->organization_config->STA_ID = isset($form_data['organization_state'])
416
-            ? absint($form_data['organization_state'])
417
-            : $this->organization_config->STA_ID;
418
-        $this->organization_config->CNT_ISO = isset($form_data['organization_country'])
419
-            ? sanitize_text_field($form_data['organization_country'])
420
-            : $this->organization_config->CNT_ISO;
421
-        $this->organization_config->zip = isset($form_data['organization_zip'])
422
-            ? sanitize_text_field($form_data['organization_zip'])
423
-            : $this->organization_config->zip;
424
-        $this->organization_config->email = isset($form_data['organization_email'])
425
-            ? sanitize_email($form_data['organization_email'])
426
-            : $this->organization_config->email;
427
-        $this->organization_config->vat = isset($form_data['organization_vat'])
428
-            ? sanitize_text_field($form_data['organization_vat'])
429
-            : $this->organization_config->vat;
430
-        $this->organization_config->phone = isset($form_data['organization_phone'])
431
-            ? sanitize_text_field($form_data['organization_phone'])
432
-            : $this->organization_config->phone;
433
-        $this->organization_config->logo_url = isset($form_data['organization_logo_url'])
434
-            ? esc_url_raw($form_data['organization_logo_url'])
435
-            : $this->organization_config->logo_url;
436
-        $this->organization_config->facebook = isset($form_data['organization_facebook'])
437
-            ? esc_url_raw($form_data['organization_facebook'])
438
-            : $this->organization_config->facebook;
439
-        $this->organization_config->twitter = isset($form_data['organization_twitter'])
440
-            ? esc_url_raw($form_data['organization_twitter'])
441
-            : $this->organization_config->twitter;
442
-        $this->organization_config->linkedin = isset($form_data['organization_linkedin'])
443
-            ? esc_url_raw($form_data['organization_linkedin'])
444
-            : $this->organization_config->linkedin;
445
-        $this->organization_config->pinterest = isset($form_data['organization_pinterest'])
446
-            ? esc_url_raw($form_data['organization_pinterest'])
447
-            : $this->organization_config->pinterest;
448
-        $this->organization_config->google = isset($form_data['organization_google'])
449
-            ? esc_url_raw($form_data['organization_google'])
450
-            : $this->organization_config->google;
451
-        $this->organization_config->instagram = isset($form_data['organization_instagram'])
452
-            ? esc_url_raw($form_data['organization_instagram'])
453
-            : $this->organization_config->instagram;
454
-        $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
455
-            ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
456
-            : false;
457
-        $this->core_config->ee_ueip_has_notified = true;
398
+		if (is_main_site()) {
399
+			$this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
400
+				? sanitize_text_field($form_data['ee_site_license_key'])
401
+				: $this->network_core_config->site_license_key;
402
+		}
403
+		$this->organization_config->name = isset($form_data['organization_name'])
404
+			? sanitize_text_field($form_data['organization_name'])
405
+			: $this->organization_config->name;
406
+		$this->organization_config->address_1 = isset($form_data['organization_address_1'])
407
+			? sanitize_text_field($form_data['organization_address_1'])
408
+			: $this->organization_config->address_1;
409
+		$this->organization_config->address_2 = isset($form_data['organization_address_2'])
410
+			? sanitize_text_field($form_data['organization_address_2'])
411
+			: $this->organization_config->address_2;
412
+		$this->organization_config->city = isset($form_data['organization_city'])
413
+			? sanitize_text_field($form_data['organization_city'])
414
+			: $this->organization_config->city;
415
+		$this->organization_config->STA_ID = isset($form_data['organization_state'])
416
+			? absint($form_data['organization_state'])
417
+			: $this->organization_config->STA_ID;
418
+		$this->organization_config->CNT_ISO = isset($form_data['organization_country'])
419
+			? sanitize_text_field($form_data['organization_country'])
420
+			: $this->organization_config->CNT_ISO;
421
+		$this->organization_config->zip = isset($form_data['organization_zip'])
422
+			? sanitize_text_field($form_data['organization_zip'])
423
+			: $this->organization_config->zip;
424
+		$this->organization_config->email = isset($form_data['organization_email'])
425
+			? sanitize_email($form_data['organization_email'])
426
+			: $this->organization_config->email;
427
+		$this->organization_config->vat = isset($form_data['organization_vat'])
428
+			? sanitize_text_field($form_data['organization_vat'])
429
+			: $this->organization_config->vat;
430
+		$this->organization_config->phone = isset($form_data['organization_phone'])
431
+			? sanitize_text_field($form_data['organization_phone'])
432
+			: $this->organization_config->phone;
433
+		$this->organization_config->logo_url = isset($form_data['organization_logo_url'])
434
+			? esc_url_raw($form_data['organization_logo_url'])
435
+			: $this->organization_config->logo_url;
436
+		$this->organization_config->facebook = isset($form_data['organization_facebook'])
437
+			? esc_url_raw($form_data['organization_facebook'])
438
+			: $this->organization_config->facebook;
439
+		$this->organization_config->twitter = isset($form_data['organization_twitter'])
440
+			? esc_url_raw($form_data['organization_twitter'])
441
+			: $this->organization_config->twitter;
442
+		$this->organization_config->linkedin = isset($form_data['organization_linkedin'])
443
+			? esc_url_raw($form_data['organization_linkedin'])
444
+			: $this->organization_config->linkedin;
445
+		$this->organization_config->pinterest = isset($form_data['organization_pinterest'])
446
+			? esc_url_raw($form_data['organization_pinterest'])
447
+			: $this->organization_config->pinterest;
448
+		$this->organization_config->google = isset($form_data['organization_google'])
449
+			? esc_url_raw($form_data['organization_google'])
450
+			: $this->organization_config->google;
451
+		$this->organization_config->instagram = isset($form_data['organization_instagram'])
452
+			? esc_url_raw($form_data['organization_instagram'])
453
+			: $this->organization_config->instagram;
454
+		$this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
455
+			? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
456
+			: false;
457
+		$this->core_config->ee_ueip_has_notified = true;
458 458
 
459
-        $this->registry->CFG->currency = new EE_Currency_Config(
460
-            $this->organization_config->CNT_ISO
461
-        );
462
-        return true;
463
-    }
459
+		$this->registry->CFG->currency = new EE_Currency_Config(
460
+			$this->organization_config->CNT_ISO
461
+		);
462
+		return true;
463
+	}
464 464
 
465 465
 
466
-    /**
467
-     * @return string
468
-     */
469
-    private function uxipOptinText()
470
-    {
471
-        ob_start();
472
-        Stats::optinText(false);
473
-        return ob_get_clean();
474
-    }
466
+	/**
467
+	 * @return string
468
+	 */
469
+	private function uxipOptinText()
470
+	{
471
+		ob_start();
472
+		Stats::optinText(false);
473
+		return ob_get_clean();
474
+	}
475 475
 
476 476
 
477
-    /**
478
-     * Return whether the site license key has been verified or not.
479
-     * @return bool
480
-     */
481
-    private function licenseKeyVerified()
482
-    {
483
-        if (empty($this->network_core_config->site_license_key)) {
484
-            return false;
485
-        }
486
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
487
-        $verify_fail = get_option($ver_option_key, false);
488
-        return $verify_fail === false
489
-                  || (! empty($this->network_core_config->site_license_key)
490
-                        && $verify_fail === false
491
-                  );
492
-    }
477
+	/**
478
+	 * Return whether the site license key has been verified or not.
479
+	 * @return bool
480
+	 */
481
+	private function licenseKeyVerified()
482
+	{
483
+		if (empty($this->network_core_config->site_license_key)) {
484
+			return false;
485
+		}
486
+		$ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
487
+		$verify_fail = get_option($ver_option_key, false);
488
+		return $verify_fail === false
489
+				  || (! empty($this->network_core_config->site_license_key)
490
+						&& $verify_fail === false
491
+				  );
492
+	}
493 493
 
494 494
 
495
-    /**
496
-     * @return EE_Text_Input
497
-     */
498
-    private function getSiteLicenseKeyField()
499
-    {
500
-        $text_input = new EE_Text_Input(
501
-            array(
502
-                'html_name' => 'ee_site_license_key',
503
-                'html_id' => 'site_license_key',
504
-                'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
505
-                /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
506
-                'html_help_text'  => sprintf(
507
-                    esc_html__(
508
-                        'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
509
-                        'event_espresso'
510
-                    ),
511
-                    '<strong>',
512
-                    '</strong>'
513
-                ),
514
-                /** phpcs:enable */
515
-                'default'         => isset($this->network_core_config->site_license_key)
516
-                    ? $this->network_core_config->site_license_key
517
-                    : '',
518
-                'required'        => false,
519
-                'form_html_filter' => new VsprintfFilter(
520
-                    '%2$s %1$s',
521
-                    array($this->getValidationIndicator())
522
-                )
523
-            )
524
-        );
525
-        return $text_input;
526
-    }
495
+	/**
496
+	 * @return EE_Text_Input
497
+	 */
498
+	private function getSiteLicenseKeyField()
499
+	{
500
+		$text_input = new EE_Text_Input(
501
+			array(
502
+				'html_name' => 'ee_site_license_key',
503
+				'html_id' => 'site_license_key',
504
+				'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
505
+				/** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
506
+				'html_help_text'  => sprintf(
507
+					esc_html__(
508
+						'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
509
+						'event_espresso'
510
+					),
511
+					'<strong>',
512
+					'</strong>'
513
+				),
514
+				/** phpcs:enable */
515
+				'default'         => isset($this->network_core_config->site_license_key)
516
+					? $this->network_core_config->site_license_key
517
+					: '',
518
+				'required'        => false,
519
+				'form_html_filter' => new VsprintfFilter(
520
+					'%2$s %1$s',
521
+					array($this->getValidationIndicator())
522
+				)
523
+			)
524
+		);
525
+		return $text_input;
526
+	}
527 527
 
528 528
 
529
-    /**
530
-     * @return string
531
-     */
532
-    private function getValidationIndicator()
533
-    {
534
-        $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
535
-        return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
536
-    }
529
+	/**
530
+	 * @return string
531
+	 */
532
+	private function getValidationIndicator()
533
+	{
534
+		$verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
535
+		return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
536
+	}
537 537
 }
Please login to merge, or discard this patch.
modules/messages/EED_Messages.module.php 1 patch
Indentation   +1322 added lines, -1322 removed lines patch added patch discarded remove patch
@@ -16,1335 +16,1335 @@
 block discarded – undo
16 16
 class EED_Messages extends EED_Module
17 17
 {
18 18
 
19
-    /**
20
-     * This holds the EE_messages controller
21
-     *
22
-     * @deprecated 4.9.0
23
-     * @var EE_messages $_EEMSG
24
-     */
25
-    protected static $_EEMSG;
26
-
27
-    /**
28
-     * @type EE_Message_Resource_Manager $_message_resource_manager
29
-     */
30
-    protected static $_message_resource_manager;
31
-
32
-    /**
33
-     * This holds the EE_Messages_Processor business class.
34
-     *
35
-     * @type EE_Messages_Processor
36
-     */
37
-    protected static $_MSG_PROCESSOR;
38
-
39
-    /**
40
-     * holds all the paths for various messages components.
41
-     * Utilized by autoloader registry
42
-     *
43
-     * @var array
44
-     */
45
-    protected static $_MSG_PATHS;
46
-
47
-
48
-    /**
49
-     * This will hold an array of messages template packs that are registered in the messages system.
50
-     * Format is:
51
-     * array(
52
-     *    'template_pack_dbref' => EE_Messages_Template_Pack (instance)
53
-     * )
54
-     *
55
-     * @var EE_Messages_Template_Pack[]
56
-     */
57
-    protected static $_TMP_PACKS = array();
58
-
59
-
60
-    /**
61
-     * @return EED_Messages
62
-     */
63
-    public static function instance()
64
-    {
65
-        return parent::get_instance(__CLASS__);
66
-    }
67
-
68
-
69
-    /**
70
-     *  set_hooks - for hooking into EE Core, other modules, etc
71
-     *
72
-     * @since 4.5.0
73
-     * @return    void
74
-     */
75
-    public static function set_hooks()
76
-    {
77
-        // actions
78
-        add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
79
-        add_action(
80
-            'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
81
-            array('EED_Messages', 'maybe_registration'),
82
-            10,
83
-            2
84
-        );
85
-        // filters
86
-        add_filter(
87
-            'FHEE__EE_Registration__receipt_url__receipt_url',
88
-            array('EED_Messages', 'registration_message_trigger_url'),
89
-            10,
90
-            4
91
-        );
92
-        add_filter(
93
-            'FHEE__EE_Registration__invoice_url__invoice_url',
94
-            array('EED_Messages', 'registration_message_trigger_url'),
95
-            10,
96
-            4
97
-        );
98
-        // register routes
99
-        self::_register_routes();
100
-    }
101
-
102
-    /**
103
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
104
-     *
105
-     * @access    public
106
-     * @return    void
107
-     */
108
-    public static function set_hooks_admin()
109
-    {
110
-        // actions
111
-        add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
112
-        add_action(
113
-            'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
114
-            array('EED_Messages', 'payment_reminder'),
115
-            10
116
-        );
117
-        add_action(
118
-            'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
119
-            array('EED_Messages', 'maybe_registration'),
120
-            10,
121
-            3
122
-        );
123
-        add_action(
124
-            'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
125
-            array('EED_Messages', 'send_newsletter_message'),
126
-            10,
127
-            2
128
-        );
129
-        add_action(
130
-            'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction',
131
-            array('EED_Messages', 'cancelled_registration'),
132
-            10
133
-        );
134
-        add_action(
135
-            'AHEE__EE_Admin_Page___process_admin_payment_notification',
136
-            array('EED_Messages', 'process_admin_payment'),
137
-            10,
138
-            1
139
-        );
140
-        // filters
141
-        add_filter(
142
-            'FHEE__EE_Admin_Page___process_resend_registration__success',
143
-            array('EED_Messages', 'process_resend'),
144
-            10,
145
-            2
146
-        );
147
-        add_filter(
148
-            'FHEE__EE_Registration__receipt_url__receipt_url',
149
-            array('EED_Messages', 'registration_message_trigger_url'),
150
-            10,
151
-            4
152
-        );
153
-        add_filter(
154
-            'FHEE__EE_Registration__invoice_url__invoice_url',
155
-            array('EED_Messages', 'registration_message_trigger_url'),
156
-            10,
157
-            4
158
-        );
159
-    }
160
-
161
-
162
-    /**
163
-     * All the message triggers done by route go in here.
164
-     *
165
-     * @since 4.5.0
166
-     * @return void
167
-     */
168
-    protected static function _register_routes()
169
-    {
170
-        EE_Config::register_route('msg_url_trigger', 'Messages', 'run');
171
-        EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request');
172
-        EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger');
173
-        EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger');
174
-        do_action('AHEE__EED_Messages___register_routes');
175
-    }
176
-
177
-
178
-    /**
179
-     * This is called when a browser display trigger is executed.
180
-     * The browser display trigger is typically used when a already generated message is displayed directly in the
181
-     * browser.
182
-     *
183
-     * @since 4.9.0
184
-     * @param WP $WP
185
-     * @throws EE_Error
186
-     * @throws InvalidArgumentException
187
-     * @throws ReflectionException
188
-     * @throws InvalidDataTypeException
189
-     * @throws InvalidInterfaceException
190
-     */
191
-    public function browser_trigger($WP)
192
-    {
193
-        // ensure controller is loaded
194
-        self::_load_controller();
195
-        $token = EE_Registry::instance()->REQ->get('token');
196
-        try {
197
-            $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager);
198
-            self::$_MSG_PROCESSOR->generate_and_send_now($mtg);
199
-        } catch (EE_Error $e) {
200
-            $error_msg = __(
201
-                'Please note that a system message failed to send due to a technical issue.',
202
-                'event_espresso'
203
-            );
204
-            // add specific message for developers if WP_DEBUG in on
205
-            $error_msg .= '||' . $e->getMessage();
206
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
207
-        }
208
-    }
209
-
210
-
211
-    /**
212
-     * This is called when a browser error trigger is executed.
213
-     * When triggered this will grab the EE_Message matching the token in the request and use that to get the error
214
-     * message and display it.
215
-     *
216
-     * @since 4.9.0
217
-     * @param $WP
218
-     * @throws EE_Error
219
-     * @throws InvalidArgumentException
220
-     * @throws InvalidDataTypeException
221
-     * @throws InvalidInterfaceException
222
-     */
223
-    public function browser_error_trigger($WP)
224
-    {
225
-        $token = EE_Registry::instance()->REQ->get('token');
226
-        if ($token) {
227
-            $message = EEM_Message::instance()->get_one_by_token($token);
228
-            if ($message instanceof EE_Message) {
229
-                header('HTTP/1.1 200 OK');
230
-                $error_msg = nl2br($message->error_message());
231
-                ?>
19
+	/**
20
+	 * This holds the EE_messages controller
21
+	 *
22
+	 * @deprecated 4.9.0
23
+	 * @var EE_messages $_EEMSG
24
+	 */
25
+	protected static $_EEMSG;
26
+
27
+	/**
28
+	 * @type EE_Message_Resource_Manager $_message_resource_manager
29
+	 */
30
+	protected static $_message_resource_manager;
31
+
32
+	/**
33
+	 * This holds the EE_Messages_Processor business class.
34
+	 *
35
+	 * @type EE_Messages_Processor
36
+	 */
37
+	protected static $_MSG_PROCESSOR;
38
+
39
+	/**
40
+	 * holds all the paths for various messages components.
41
+	 * Utilized by autoloader registry
42
+	 *
43
+	 * @var array
44
+	 */
45
+	protected static $_MSG_PATHS;
46
+
47
+
48
+	/**
49
+	 * This will hold an array of messages template packs that are registered in the messages system.
50
+	 * Format is:
51
+	 * array(
52
+	 *    'template_pack_dbref' => EE_Messages_Template_Pack (instance)
53
+	 * )
54
+	 *
55
+	 * @var EE_Messages_Template_Pack[]
56
+	 */
57
+	protected static $_TMP_PACKS = array();
58
+
59
+
60
+	/**
61
+	 * @return EED_Messages
62
+	 */
63
+	public static function instance()
64
+	{
65
+		return parent::get_instance(__CLASS__);
66
+	}
67
+
68
+
69
+	/**
70
+	 *  set_hooks - for hooking into EE Core, other modules, etc
71
+	 *
72
+	 * @since 4.5.0
73
+	 * @return    void
74
+	 */
75
+	public static function set_hooks()
76
+	{
77
+		// actions
78
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
79
+		add_action(
80
+			'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
81
+			array('EED_Messages', 'maybe_registration'),
82
+			10,
83
+			2
84
+		);
85
+		// filters
86
+		add_filter(
87
+			'FHEE__EE_Registration__receipt_url__receipt_url',
88
+			array('EED_Messages', 'registration_message_trigger_url'),
89
+			10,
90
+			4
91
+		);
92
+		add_filter(
93
+			'FHEE__EE_Registration__invoice_url__invoice_url',
94
+			array('EED_Messages', 'registration_message_trigger_url'),
95
+			10,
96
+			4
97
+		);
98
+		// register routes
99
+		self::_register_routes();
100
+	}
101
+
102
+	/**
103
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
104
+	 *
105
+	 * @access    public
106
+	 * @return    void
107
+	 */
108
+	public static function set_hooks_admin()
109
+	{
110
+		// actions
111
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
112
+		add_action(
113
+			'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
114
+			array('EED_Messages', 'payment_reminder'),
115
+			10
116
+		);
117
+		add_action(
118
+			'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
119
+			array('EED_Messages', 'maybe_registration'),
120
+			10,
121
+			3
122
+		);
123
+		add_action(
124
+			'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
125
+			array('EED_Messages', 'send_newsletter_message'),
126
+			10,
127
+			2
128
+		);
129
+		add_action(
130
+			'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction',
131
+			array('EED_Messages', 'cancelled_registration'),
132
+			10
133
+		);
134
+		add_action(
135
+			'AHEE__EE_Admin_Page___process_admin_payment_notification',
136
+			array('EED_Messages', 'process_admin_payment'),
137
+			10,
138
+			1
139
+		);
140
+		// filters
141
+		add_filter(
142
+			'FHEE__EE_Admin_Page___process_resend_registration__success',
143
+			array('EED_Messages', 'process_resend'),
144
+			10,
145
+			2
146
+		);
147
+		add_filter(
148
+			'FHEE__EE_Registration__receipt_url__receipt_url',
149
+			array('EED_Messages', 'registration_message_trigger_url'),
150
+			10,
151
+			4
152
+		);
153
+		add_filter(
154
+			'FHEE__EE_Registration__invoice_url__invoice_url',
155
+			array('EED_Messages', 'registration_message_trigger_url'),
156
+			10,
157
+			4
158
+		);
159
+	}
160
+
161
+
162
+	/**
163
+	 * All the message triggers done by route go in here.
164
+	 *
165
+	 * @since 4.5.0
166
+	 * @return void
167
+	 */
168
+	protected static function _register_routes()
169
+	{
170
+		EE_Config::register_route('msg_url_trigger', 'Messages', 'run');
171
+		EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request');
172
+		EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger');
173
+		EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger');
174
+		do_action('AHEE__EED_Messages___register_routes');
175
+	}
176
+
177
+
178
+	/**
179
+	 * This is called when a browser display trigger is executed.
180
+	 * The browser display trigger is typically used when a already generated message is displayed directly in the
181
+	 * browser.
182
+	 *
183
+	 * @since 4.9.0
184
+	 * @param WP $WP
185
+	 * @throws EE_Error
186
+	 * @throws InvalidArgumentException
187
+	 * @throws ReflectionException
188
+	 * @throws InvalidDataTypeException
189
+	 * @throws InvalidInterfaceException
190
+	 */
191
+	public function browser_trigger($WP)
192
+	{
193
+		// ensure controller is loaded
194
+		self::_load_controller();
195
+		$token = EE_Registry::instance()->REQ->get('token');
196
+		try {
197
+			$mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager);
198
+			self::$_MSG_PROCESSOR->generate_and_send_now($mtg);
199
+		} catch (EE_Error $e) {
200
+			$error_msg = __(
201
+				'Please note that a system message failed to send due to a technical issue.',
202
+				'event_espresso'
203
+			);
204
+			// add specific message for developers if WP_DEBUG in on
205
+			$error_msg .= '||' . $e->getMessage();
206
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
207
+		}
208
+	}
209
+
210
+
211
+	/**
212
+	 * This is called when a browser error trigger is executed.
213
+	 * When triggered this will grab the EE_Message matching the token in the request and use that to get the error
214
+	 * message and display it.
215
+	 *
216
+	 * @since 4.9.0
217
+	 * @param $WP
218
+	 * @throws EE_Error
219
+	 * @throws InvalidArgumentException
220
+	 * @throws InvalidDataTypeException
221
+	 * @throws InvalidInterfaceException
222
+	 */
223
+	public function browser_error_trigger($WP)
224
+	{
225
+		$token = EE_Registry::instance()->REQ->get('token');
226
+		if ($token) {
227
+			$message = EEM_Message::instance()->get_one_by_token($token);
228
+			if ($message instanceof EE_Message) {
229
+				header('HTTP/1.1 200 OK');
230
+				$error_msg = nl2br($message->error_message());
231
+				?>
232 232
                 <!DOCTYPE html>
233 233
                 <html>
234 234
                 <head></head>
235 235
                 <body>
236 236
                 <?php echo empty($error_msg)
237
-                    ? esc_html__(
238
-                        'Unfortunately, we were unable to capture the error message for this message.',
239
-                        'event_espresso'
240
-                    )
241
-                    : wp_kses(
242
-                        $error_msg,
243
-                        array(
244
-                            'a'      => array(
245
-                                'href'  => array(),
246
-                                'title' => array(),
247
-                            ),
248
-                            'span'   => array(),
249
-                            'div'    => array(),
250
-                            'p'      => array(),
251
-                            'strong' => array(),
252
-                            'em'     => array(),
253
-                            'br'     => array(),
254
-                        )
255
-                    ); ?>
237
+					? esc_html__(
238
+						'Unfortunately, we were unable to capture the error message for this message.',
239
+						'event_espresso'
240
+					)
241
+					: wp_kses(
242
+						$error_msg,
243
+						array(
244
+							'a'      => array(
245
+								'href'  => array(),
246
+								'title' => array(),
247
+							),
248
+							'span'   => array(),
249
+							'div'    => array(),
250
+							'p'      => array(),
251
+							'strong' => array(),
252
+							'em'     => array(),
253
+							'br'     => array(),
254
+						)
255
+					); ?>
256 256
                 </body>
257 257
                 </html>
258 258
                 <?php
259
-                exit;
260
-            }
261
-        }
262
-        return;
263
-    }
264
-
265
-
266
-    /**
267
-     *  This runs when the msg_url_trigger route has initiated.
268
-     *
269
-     * @since 4.5.0
270
-     * @param WP $WP
271
-     * @throws EE_Error
272
-     * @throws InvalidArgumentException
273
-     * @throws ReflectionException
274
-     * @throws InvalidDataTypeException
275
-     * @throws InvalidInterfaceException
276
-     */
277
-    public function run($WP)
278
-    {
279
-        // ensure controller is loaded
280
-        self::_load_controller();
281
-        // attempt to process message
282
-        try {
283
-            /** @type EE_Message_To_Generate_From_Request $message_to_generate */
284
-            $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
285
-            self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate);
286
-        } catch (EE_Error $e) {
287
-            $error_msg = __(
288
-                'Please note that a system message failed to send due to a technical issue.',
289
-                'event_espresso'
290
-            );
291
-            // add specific message for developers if WP_DEBUG in on
292
-            $error_msg .= '||' . $e->getMessage();
293
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
294
-        }
295
-    }
296
-
297
-
298
-    /**
299
-     * This is triggered by the 'msg_cron_trigger' route.
300
-     *
301
-     * @param WP $WP
302
-     */
303
-    public function execute_batch_request($WP)
304
-    {
305
-        $this->run_cron();
306
-        header('HTTP/1.1 200 OK');
307
-        exit();
308
-    }
309
-
310
-
311
-    /**
312
-     * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp
313
-     * request.
314
-     */
315
-    public function run_cron()
316
-    {
317
-        self::_load_controller();
318
-        // get required vars
319
-        $cron_type = EE_Registry::instance()->REQ->get('type');
320
-        $transient_key = EE_Registry::instance()->REQ->get('key');
321
-
322
-        // now let's verify transient, if not valid exit immediately
323
-        if (! get_transient($transient_key)) {
324
-            /**
325
-             * trigger error so this gets in the error logs.  This is important because it happens on a non-user
326
-             * request.
327
-             */
328
-            trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso'));
329
-        }
330
-
331
-        // if made it here, lets' delete the transient to keep the db clean
332
-        delete_transient($transient_key);
333
-
334
-        if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) {
335
-            $method = 'batch_' . $cron_type . '_from_queue';
336
-            if (method_exists(self::$_MSG_PROCESSOR, $method)) {
337
-                self::$_MSG_PROCESSOR->$method();
338
-            } else {
339
-                // no matching task
340
-                /**
341
-                 * trigger error so this gets in the error logs.  This is important because it happens on a non user
342
-                 * request.
343
-                 */
344
-                trigger_error(
345
-                    esc_attr(
346
-                        sprintf(
347
-                            __('There is no task corresponding to this route %s', 'event_espresso'),
348
-                            $cron_type
349
-                        )
350
-                    )
351
-                );
352
-            }
353
-        }
354
-
355
-        do_action('FHEE__EED_Messages__run_cron__end');
356
-    }
357
-
358
-
359
-    /**
360
-     * This is used to retrieve the template pack for the given name.
361
-     * Retrieved packs are cached on the static $_TMP_PACKS array.  If there is no class matching the given name then
362
-     * the default template pack is returned.
363
-     *
364
-     * @deprecated 4.9.0  @see EEH_MSG_Template::get_template_pack()
365
-     * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used
366
-     *                                   in generating the Pack class name).
367
-     * @return EE_Messages_Template_Pack
368
-     * @throws EE_Error
369
-     * @throws InvalidArgumentException
370
-     * @throws ReflectionException
371
-     * @throws InvalidDataTypeException
372
-     * @throws InvalidInterfaceException
373
-     */
374
-    public static function get_template_pack($template_pack_name)
375
-    {
376
-        EE_Registry::instance()->load_helper('MSG_Template');
377
-        return EEH_MSG_Template::get_template_pack($template_pack_name);
378
-    }
379
-
380
-
381
-    /**
382
-     * Retrieves an array of all template packs.
383
-     * Array is in the format array( 'dbref' => EE_Messages_Template_Pack )
384
-     *
385
-     * @deprecated 4.9.0  @see EEH_MSG_Template_Pack::get_template_pack_collection
386
-     * @return EE_Messages_Template_Pack[]
387
-     * @throws EE_Error
388
-     * @throws InvalidArgumentException
389
-     * @throws ReflectionException
390
-     * @throws InvalidDataTypeException
391
-     * @throws InvalidInterfaceException
392
-     */
393
-    public static function get_template_packs()
394
-    {
395
-        EE_Registry::instance()->load_helper('MSG_Template');
396
-
397
-        // for backward compat, let's make sure this returns in the same format as originally.
398
-        $template_pack_collection = EEH_MSG_Template::get_template_pack_collection();
399
-        $template_pack_collection->rewind();
400
-        $template_packs = array();
401
-        while ($template_pack_collection->valid()) {
402
-            $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current();
403
-            $template_pack_collection->next();
404
-        }
405
-        return $template_packs;
406
-    }
407
-
408
-
409
-    /**
410
-     * This simply makes sure the autoloaders are registered for the EE_messages system.
411
-     *
412
-     * @since 4.5.0
413
-     * @return void
414
-     * @throws EE_Error
415
-     */
416
-    public static function set_autoloaders()
417
-    {
418
-        if (empty(self::$_MSG_PATHS)) {
419
-            self::_set_messages_paths();
420
-            foreach (self::$_MSG_PATHS as $path) {
421
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
422
-            }
423
-            // add aliases
424
-            EEH_Autoloader::add_alias('EE_messages', 'EE_messages');
425
-            EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger');
426
-        }
427
-    }
428
-
429
-
430
-    /**
431
-     * Take care of adding all the paths for the messages components to the $_MSG_PATHS property
432
-     * for use by the Messages Autoloaders
433
-     *
434
-     * @since 4.5.0
435
-     * @return void.
436
-     */
437
-    protected static function _set_messages_paths()
438
-    {
439
-        $dir_ref = array(
440
-            'messages/message_type',
441
-            'messages/messenger',
442
-            'messages/defaults',
443
-            'messages/defaults/email',
444
-            'messages/data_class',
445
-            'messages/validators',
446
-            'messages/validators/email',
447
-            'messages/validators/html',
448
-            'shortcodes',
449
-        );
450
-        $paths = array();
451
-        foreach ($dir_ref as $index => $dir) {
452
-            $paths[ $index ] = EE_LIBRARIES . $dir;
453
-        }
454
-        self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
455
-    }
456
-
457
-
458
-    /**
459
-     * Takes care of loading dependencies
460
-     *
461
-     * @since 4.5.0
462
-     * @return void
463
-     * @throws EE_Error
464
-     * @throws InvalidArgumentException
465
-     * @throws ReflectionException
466
-     * @throws InvalidDataTypeException
467
-     * @throws InvalidInterfaceException
468
-     */
469
-    protected static function _load_controller()
470
-    {
471
-        if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
472
-            EE_Registry::instance()->load_core('Request_Handler');
473
-            self::set_autoloaders();
474
-            self::$_EEMSG = EE_Registry::instance()->load_lib('messages');
475
-            self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor');
476
-            self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
477
-        }
478
-    }
479
-
480
-
481
-    /**
482
-     * @param EE_Transaction $transaction
483
-     * @throws EE_Error
484
-     * @throws InvalidArgumentException
485
-     * @throws InvalidDataTypeException
486
-     * @throws InvalidInterfaceException
487
-     * @throws ReflectionException
488
-     */
489
-    public static function payment_reminder(EE_Transaction $transaction)
490
-    {
491
-        self::_load_controller();
492
-        $data = array($transaction, null);
493
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data);
494
-    }
495
-
496
-
497
-    /**
498
-     * Any messages triggers for after successful gateway payments should go in here.
499
-     *
500
-     * @param EE_Transaction  $transaction object
501
-     * @param EE_Payment|null $payment     object
502
-     * @return void
503
-     * @throws EE_Error
504
-     * @throws InvalidArgumentException
505
-     * @throws ReflectionException
506
-     * @throws InvalidDataTypeException
507
-     * @throws InvalidInterfaceException
508
-     */
509
-    public static function payment(EE_Transaction $transaction, EE_Payment $payment = null)
510
-    {
511
-        // if there's no payment object, then we cannot do a payment type message!
512
-        if (! $payment instanceof EE_Payment) {
513
-            return;
514
-        }
515
-        self::_load_controller();
516
-        $data = array($transaction, $payment);
517
-        EE_Registry::instance()->load_helper('MSG_Template');
518
-        $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
519
-        // if payment amount is less than 0 then switch to payment_refund message type.
520
-        $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
521
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
522
-    }
523
-
524
-
525
-    /**
526
-     * @param EE_Transaction $transaction
527
-     * @throws EE_Error
528
-     * @throws InvalidArgumentException
529
-     * @throws InvalidDataTypeException
530
-     * @throws InvalidInterfaceException
531
-     * @throws ReflectionException
532
-     */
533
-    public static function cancelled_registration(EE_Transaction $transaction)
534
-    {
535
-        self::_load_controller();
536
-        $data = array($transaction, null);
537
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data);
538
-    }
539
-
540
-
541
-    /**
542
-     * Trigger for Registration messages
543
-     * Note that what registration message type is sent depends on what the reg status is for the registrations on the
544
-     * incoming transaction.
545
-     *
546
-     * @param EE_Registration $registration
547
-     * @param array           $extra_details
548
-     * @return void
549
-     * @throws EE_Error
550
-     * @throws InvalidArgumentException
551
-     * @throws InvalidDataTypeException
552
-     * @throws InvalidInterfaceException
553
-     * @throws ReflectionException
554
-     * @throws EntityNotFoundException
555
-     */
556
-    public static function maybe_registration(EE_Registration $registration, $extra_details = array())
557
-    {
558
-
559
-        if (! self::_verify_registration_notification_send($registration, $extra_details)) {
560
-            // no messages please
561
-            return;
562
-        }
563
-
564
-        // get all non-trashed registrations so we make sure we send messages for the right status.
565
-        $all_registrations = $registration->transaction()->registrations(
566
-            array(
567
-                array('REG_deleted' => false),
568
-                'order_by' => array(
569
-                    'Event.EVT_name'     => 'ASC',
570
-                    'Attendee.ATT_lname' => 'ASC',
571
-                    'Attendee.ATT_fname' => 'ASC',
572
-                ),
573
-            )
574
-        );
575
-        // cached array of statuses so we only trigger messages once per status.
576
-        $statuses_sent = array();
577
-        self::_load_controller();
578
-        $mtgs = array();
579
-
580
-        // loop through registrations and trigger messages once per status.
581
-        foreach ($all_registrations as $reg) {
582
-            // already triggered?
583
-            if (in_array($reg->status_ID(), $statuses_sent)) {
584
-                continue;
585
-            }
586
-
587
-            $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID());
588
-            $mtgs = array_merge(
589
-                $mtgs,
590
-                self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
591
-                    $message_type,
592
-                    array($registration->transaction(), null, $reg->status_ID())
593
-                )
594
-            );
595
-            $statuses_sent[] = $reg->status_ID();
596
-        }
597
-
598
-        if (count($statuses_sent) > 1) {
599
-            $mtgs = array_merge(
600
-                $mtgs,
601
-                self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
602
-                    'registration_summary',
603
-                    array($registration->transaction(), null)
604
-                )
605
-            );
606
-        }
607
-
608
-        // batch queue and initiate request
609
-        self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs);
610
-        self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
611
-    }
612
-
613
-
614
-    /**
615
-     * This is a helper method used to very whether a registration notification should be sent or
616
-     * not.  Prevents duplicate notifications going out for registration context notifications.
617
-     *
618
-     * @param EE_Registration $registration  [description]
619
-     * @param array           $extra_details [description]
620
-     * @return bool          true = send away, false = nope halt the presses.
621
-     */
622
-    protected static function _verify_registration_notification_send(
623
-        EE_Registration $registration,
624
-        $extra_details = array()
625
-    ) {
626
-        if (! $registration->is_primary_registrant()) {
627
-            return false;
628
-        }
629
-        // first we check if we're in admin and not doing front ajax
630
-        if (is_admin() && ! EE_FRONT_AJAX) {
631
-            // make sure appropriate admin params are set for sending messages
632
-            if (empty($_REQUEST['txn_reg_status_change']['send_notifications'])
633
-                || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])
634
-            ) {
635
-                // no messages sent please.
636
-                return false;
637
-            }
638
-        } else {
639
-            // frontend request (either regular or via AJAX)
640
-            // TXN is NOT finalized ?
641
-            if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
642
-                return false;
643
-            }
644
-            // return visit but nothing changed ???
645
-            if (isset($extra_details['revisit'], $extra_details['status_updates']) &&
646
-                $extra_details['revisit'] && ! $extra_details['status_updates']
647
-            ) {
648
-                return false;
649
-            }
650
-            // NOT sending messages && reg status is something other than "Not-Approved"
651
-            if (! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) &&
652
-                $registration->status_ID() !== EEM_Registration::status_id_not_approved
653
-            ) {
654
-                return false;
655
-            }
656
-        }
657
-        // release the kraken
658
-        return true;
659
-    }
660
-
661
-
662
-    /**
663
-     * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that
664
-     * status id.
665
-     *
666
-     * @deprecated 4.9.0  Use EEH_MSG_Template::reg_status_to_message_type_array()
667
-     *                    or EEH_MSG_Template::convert_reg_status_to_message_type
668
-     * @param string $reg_status
669
-     * @return array
670
-     * @throws EE_Error
671
-     * @throws InvalidArgumentException
672
-     * @throws ReflectionException
673
-     * @throws InvalidDataTypeException
674
-     * @throws InvalidInterfaceException
675
-     */
676
-    protected static function _get_reg_status_array($reg_status = '')
677
-    {
678
-        EE_Registry::instance()->load_helper('MSG_Template');
679
-        return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
680
-            ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
681
-            : EEH_MSG_Template::reg_status_to_message_type_array();
682
-    }
683
-
684
-
685
-    /**
686
-     * Simply returns the payment message type for the given payment status.
687
-     *
688
-     * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array
689
-     *                   or EEH_MSG_Template::convert_payment_status_to_message_type
690
-     * @param string $payment_status The payment status being matched.
691
-     * @return bool|string The payment message type slug matching the status or false if no match.
692
-     * @throws EE_Error
693
-     * @throws InvalidArgumentException
694
-     * @throws ReflectionException
695
-     * @throws InvalidDataTypeException
696
-     * @throws InvalidInterfaceException
697
-     */
698
-    protected static function _get_payment_message_type($payment_status)
699
-    {
700
-        EE_Registry::instance()->load_helper('MSG_Template');
701
-        return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
702
-            ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
703
-            : false;
704
-    }
705
-
706
-
707
-    /**
708
-     * Message triggers for a resending already sent message(s) (via EE_Message list table)
709
-     *
710
-     * @access public
711
-     * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages
712
-     * @return bool success/fail
713
-     * @throws EE_Error
714
-     * @throws InvalidArgumentException
715
-     * @throws InvalidDataTypeException
716
-     * @throws InvalidInterfaceException
717
-     * @throws ReflectionException
718
-     */
719
-    public static function process_resend($req_data)
720
-    {
721
-        self::_load_controller();
722
-
723
-        // if $msgID in this request then skip to the new resend_message
724
-        if (EE_Registry::instance()->REQ->get('MSG_ID')) {
725
-            return self::resend_message();
726
-        }
727
-
728
-        // make sure any incoming request data is set on the REQ so that it gets picked up later.
729
-        $req_data = (array) $req_data;
730
-        foreach ($req_data as $request_key => $request_value) {
731
-            EE_Registry::instance()->REQ->set($request_key, $request_value);
732
-        }
733
-
734
-        if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request(
735
-        )) {
736
-            return false;
737
-        }
738
-
739
-        try {
740
-            self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send);
741
-            self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
742
-        } catch (EE_Error $e) {
743
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
744
-            return false;
745
-        }
746
-        EE_Error::add_success(
747
-            __('Messages have been successfully queued for generation and sending.', 'event_espresso')
748
-        );
749
-        return true; // everything got queued.
750
-    }
751
-
752
-
753
-    /**
754
-     * Message triggers for a resending already sent message(s) (via EE_Message list table)
755
-     *
756
-     * @return bool
757
-     * @throws EE_Error
758
-     * @throws InvalidArgumentException
759
-     * @throws InvalidDataTypeException
760
-     * @throws InvalidInterfaceException
761
-     * @throws ReflectionException
762
-     */
763
-    public static function resend_message()
764
-    {
765
-        self::_load_controller();
766
-
767
-        $msgID = EE_Registry::instance()->REQ->get('MSG_ID');
768
-        if (! $msgID) {
769
-            EE_Error::add_error(
770
-                __(
771
-                    'Something went wrong because there is no "MSG_ID" value in the request',
772
-                    'event_espresso'
773
-                ),
774
-                __FILE__,
775
-                __FUNCTION__,
776
-                __LINE__
777
-            );
778
-            return false;
779
-        }
780
-
781
-        self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID);
782
-
783
-        // setup success message.
784
-        $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
785
-        EE_Error::add_success(
786
-            sprintf(
787
-                _n(
788
-                    'There was %d message queued for resending.',
789
-                    'There were %d messages queued for resending.',
790
-                    $count_ready_for_resend,
791
-                    'event_espresso'
792
-                ),
793
-                $count_ready_for_resend
794
-            )
795
-        );
796
-        return true;
797
-    }
798
-
799
-
800
-    /**
801
-     * Message triggers for manual payment applied by admin
802
-     *
803
-     * @param  EE_Payment $payment EE_payment object
804
-     * @return bool success/fail
805
-     * @throws EE_Error
806
-     * @throws InvalidArgumentException
807
-     * @throws ReflectionException
808
-     * @throws InvalidDataTypeException
809
-     * @throws InvalidInterfaceException
810
-     */
811
-    public static function process_admin_payment(EE_Payment $payment)
812
-    {
813
-        EE_Registry::instance()->load_helper('MSG_Template');
814
-        // we need to get the transaction object
815
-        $transaction = $payment->transaction();
816
-        if ($transaction instanceof EE_Transaction) {
817
-            $data = array($transaction, $payment);
818
-            $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
819
-
820
-            // if payment amount is less than 0 then switch to payment_refund message type.
821
-            $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
822
-
823
-            // if payment_refund is selected, but the status is NOT accepted.  Then change message type to false so NO message notification goes out.
824
-            $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved
825
-                ? false : $message_type;
826
-
827
-            self::_load_controller();
828
-
829
-            self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
830
-
831
-            // get count of queued for generation
832
-            $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(
833
-                array(
834
-                    EEM_Message::status_incomplete,
835
-                    EEM_Message::status_idle,
836
-                )
837
-            );
838
-
839
-            if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) {
840
-                add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
841
-                return true;
842
-            } else {
843
-                $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(
844
-                    EEM_Message::instance()->stati_indicating_failed_sending()
845
-                );
846
-                /**
847
-                 * Verify that there are actually errors.  If not then we return a success message because the queue might have been emptied due to successful
848
-                 * IMMEDIATE generation.
849
-                 */
850
-                if ($count_failed > 0) {
851
-                    EE_Error::add_error(
852
-                        sprintf(
853
-                            _n(
854
-                                'The payment notification generation failed.',
855
-                                '%d payment notifications failed being sent.',
856
-                                $count_failed,
857
-                                'event_espresso'
858
-                            ),
859
-                            $count_failed
860
-                        ),
861
-                        __FILE__,
862
-                        __FUNCTION__,
863
-                        __LINE__
864
-                    );
865
-
866
-                    return false;
867
-                } else {
868
-                    add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
869
-                    return true;
870
-                }
871
-            }
872
-        } else {
873
-            EE_Error::add_error(
874
-                'Unable to generate the payment notification because the given value for the transaction is invalid.',
875
-                'event_espresso'
876
-            );
877
-            return false;
878
-        }
879
-    }
880
-
881
-
882
-    /**
883
-     * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger
884
-     *
885
-     * @since   4.3.0
886
-     * @param  EE_Registration[] $registrations an array of EE_Registration objects
887
-     * @param  int               $grp_id        a specific message template group id.
888
-     * @return void
889
-     * @throws EE_Error
890
-     * @throws InvalidArgumentException
891
-     * @throws InvalidDataTypeException
892
-     * @throws InvalidInterfaceException
893
-     * @throws ReflectionException
894
-     */
895
-    public static function send_newsletter_message($registrations, $grp_id)
896
-    {
897
-        // make sure mtp is id and set it in the EE_Request Handler later messages setup.
898
-        EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id);
899
-        self::_load_controller();
900
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations);
901
-    }
902
-
903
-
904
-    /**
905
-     * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url
906
-     *
907
-     * @since   4.3.0
908
-     * @param    string          $registration_message_trigger_url
909
-     * @param    EE_Registration $registration
910
-     * @param string             $messenger
911
-     * @param string             $message_type
912
-     * @return string
913
-     * @throws EE_Error
914
-     * @throws InvalidArgumentException
915
-     * @throws InvalidDataTypeException
916
-     * @throws InvalidInterfaceException
917
-     */
918
-    public static function registration_message_trigger_url(
919
-        $registration_message_trigger_url,
920
-        EE_Registration $registration,
921
-        $messenger = 'html',
922
-        $message_type = 'invoice'
923
-    ) {
924
-        // whitelist $messenger
925
-        switch ($messenger) {
926
-            case 'pdf':
927
-                $sending_messenger = 'pdf';
928
-                $generating_messenger = 'html';
929
-                break;
930
-            case 'html':
931
-            default:
932
-                $sending_messenger = 'html';
933
-                $generating_messenger = 'html';
934
-                break;
935
-        }
936
-        // whitelist $message_type
937
-        switch ($message_type) {
938
-            case 'receipt':
939
-                $message_type = 'receipt';
940
-                break;
941
-            case 'invoice':
942
-            default:
943
-                $message_type = 'invoice';
944
-                break;
945
-        }
946
-        // verify that both the messenger AND the message type are active
947
-        if (EEH_MSG_Template::is_messenger_active($sending_messenger)
948
-            && EEH_MSG_Template::is_mt_active($message_type)
949
-        ) {
950
-            // need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?)
951
-            $template_query_params = array(
952
-                'MTP_is_active'    => true,
953
-                'MTP_messenger'    => $generating_messenger,
954
-                'MTP_message_type' => $message_type,
955
-                'Event.EVT_ID'     => $registration->event_ID(),
956
-            );
957
-            // get the message template group.
958
-            $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
959
-            // if we don't have an EE_Message_Template_Group then return
960
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
961
-                // remove EVT_ID from query params so that global templates get picked up
962
-                unset($template_query_params['Event.EVT_ID']);
963
-                // get global template as the fallback
964
-                $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
965
-            }
966
-            // if we don't have an EE_Message_Template_Group then return
967
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
968
-                return '';
969
-            }
970
-            // generate the URL
971
-            $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger(
972
-                $sending_messenger,
973
-                $generating_messenger,
974
-                'purchaser',
975
-                $message_type,
976
-                $registration,
977
-                $msg_template_group->ID(),
978
-                $registration->transaction_ID()
979
-            );
980
-        }
981
-        return $registration_message_trigger_url;
982
-    }
983
-
984
-
985
-    /**
986
-     * Use to generate and return a message preview!
987
-     *
988
-     * @param  string $type      This should correspond with a valid message type
989
-     * @param  string $context   This should correspond with a valid context for the message type
990
-     * @param  string $messenger This should correspond with a valid messenger.
991
-     * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
992
-     *                           preview
993
-     * @return bool|string The body of the message or if send is requested, sends.
994
-     * @throws EE_Error
995
-     * @throws InvalidArgumentException
996
-     * @throws InvalidDataTypeException
997
-     * @throws InvalidInterfaceException
998
-     * @throws ReflectionException
999
-     */
1000
-    public static function preview_message($type, $context, $messenger, $send = false)
1001
-    {
1002
-        self::_load_controller();
1003
-        $mtg = new EE_Message_To_Generate(
1004
-            $messenger,
1005
-            $type,
1006
-            array(),
1007
-            $context,
1008
-            true
1009
-        );
1010
-        $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send);
1011
-        if ($generated_preview_queue instanceof EE_Messages_Queue) {
1012
-            // loop through all content for the preview and remove any persisted records.
1013
-            $content = '';
1014
-            foreach ($generated_preview_queue->get_message_repository() as $message) {
1015
-                $content = $message->content();
1016
-                if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) {
1017
-                    $message->delete();
1018
-                }
1019
-            }
1020
-            return $content;
1021
-        } else {
1022
-            return $generated_preview_queue;
1023
-        }
1024
-    }
1025
-
1026
-
1027
-    /**
1028
-     * This is a method that allows for sending a message using a messenger matching the string given and the provided
1029
-     * EE_Message_Queue object.  The EE_Message_Queue object is used to create a single aggregate EE_Message via the
1030
-     * content found in the EE_Message objects in the queue.
1031
-     *
1032
-     * @since 4.9.0
1033
-     * @param string            $messenger            a string matching a valid active messenger in the system
1034
-     * @param string            $message_type         Although it seems contrary to the name of the method, a message
1035
-     *                                                type name is still required to send along the message type to the
1036
-     *                                                messenger because this is used for determining what specific
1037
-     *                                                variations might be loaded for the generated message.
1038
-     * @param EE_Messages_Queue $queue
1039
-     * @param string            $custom_subject       Can be used to set what the custom subject string will be on the
1040
-     *                                                aggregate EE_Message object.
1041
-     * @return bool success or fail.
1042
-     * @throws EE_Error
1043
-     * @throws InvalidArgumentException
1044
-     * @throws ReflectionException
1045
-     * @throws InvalidDataTypeException
1046
-     * @throws InvalidInterfaceException
1047
-     */
1048
-    public static function send_message_with_messenger_only(
1049
-        $messenger,
1050
-        $message_type,
1051
-        EE_Messages_Queue $queue,
1052
-        $custom_subject = ''
1053
-    ) {
1054
-        self::_load_controller();
1055
-        /** @type EE_Message_To_Generate_From_Queue $message_to_generate */
1056
-        $message_to_generate = EE_Registry::instance()->load_lib(
1057
-            'Message_To_Generate_From_Queue',
1058
-            array(
1059
-                $messenger,
1060
-                $message_type,
1061
-                $queue,
1062
-                $custom_subject,
1063
-            )
1064
-        );
1065
-        return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate);
1066
-    }
1067
-
1068
-
1069
-    /**
1070
-     * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation)
1071
-     *
1072
-     * @since 4.9.0
1073
-     * @param array $message_ids An array of message ids
1074
-     * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated
1075
-     *                           messages.
1076
-     * @throws EE_Error
1077
-     * @throws InvalidArgumentException
1078
-     * @throws InvalidDataTypeException
1079
-     * @throws InvalidInterfaceException
1080
-     * @throws ReflectionException
1081
-     */
1082
-    public static function generate_now($message_ids)
1083
-    {
1084
-        self::_load_controller();
1085
-        $messages = EEM_Message::instance()->get_all(
1086
-            array(
1087
-                0 => array(
1088
-                    'MSG_ID' => array('IN', $message_ids),
1089
-                    'STS_ID' => EEM_Message::status_incomplete,
1090
-                ),
1091
-            )
1092
-        );
1093
-        $generated_queue = false;
1094
-        if ($messages) {
1095
-            $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
1096
-        }
1097
-
1098
-        if (! $generated_queue instanceof EE_Messages_Queue) {
1099
-            EE_Error::add_error(
1100
-                __(
1101
-                    'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.',
1102
-                    'event_espresso'
1103
-                ),
1104
-                __FILE__,
1105
-                __FUNCTION__,
1106
-                __LINE__
1107
-            );
1108
-        }
1109
-        return $generated_queue;
1110
-    }
1111
-
1112
-
1113
-    /**
1114
-     * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or,
1115
-     * EEM_Message::status_idle
1116
-     *
1117
-     * @since 4.9.0
1118
-     * @param $message_ids
1119
-     * @return bool|EE_Messages_Queue false if no messages sent.
1120
-     * @throws EE_Error
1121
-     * @throws InvalidArgumentException
1122
-     * @throws InvalidDataTypeException
1123
-     * @throws InvalidInterfaceException
1124
-     * @throws ReflectionException
1125
-     */
1126
-    public static function send_now($message_ids)
1127
-    {
1128
-        self::_load_controller();
1129
-        $messages = EEM_Message::instance()->get_all(
1130
-            array(
1131
-                0 => array(
1132
-                    'MSG_ID' => array('IN', $message_ids),
1133
-                    'STS_ID' => array(
1134
-                        'IN',
1135
-                        array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry),
1136
-                    ),
1137
-                ),
1138
-            )
1139
-        );
1140
-        $sent_queue = false;
1141
-        if ($messages) {
1142
-            $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
1143
-        }
1144
-
1145
-        if (! $sent_queue instanceof EE_Messages_Queue) {
1146
-            EE_Error::add_error(
1147
-                __(
1148
-                    'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.',
1149
-                    'event_espresso'
1150
-                ),
1151
-                __FILE__,
1152
-                __FUNCTION__,
1153
-                __LINE__
1154
-            );
1155
-        } else {
1156
-            // can count how many sent by using the messages in the queue
1157
-            $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent());
1158
-            if ($sent_count > 0) {
1159
-                EE_Error::add_success(
1160
-                    sprintf(
1161
-                        _n(
1162
-                            'There was %d message successfully sent.',
1163
-                            'There were %d messages successfully sent.',
1164
-                            $sent_count,
1165
-                            'event_espresso'
1166
-                        ),
1167
-                        $sent_count
1168
-                    )
1169
-                );
1170
-            } else {
1171
-                EE_Error::overwrite_errors();
1172
-                EE_Error::add_error(
1173
-                    __(
1174
-                        'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error.
259
+				exit;
260
+			}
261
+		}
262
+		return;
263
+	}
264
+
265
+
266
+	/**
267
+	 *  This runs when the msg_url_trigger route has initiated.
268
+	 *
269
+	 * @since 4.5.0
270
+	 * @param WP $WP
271
+	 * @throws EE_Error
272
+	 * @throws InvalidArgumentException
273
+	 * @throws ReflectionException
274
+	 * @throws InvalidDataTypeException
275
+	 * @throws InvalidInterfaceException
276
+	 */
277
+	public function run($WP)
278
+	{
279
+		// ensure controller is loaded
280
+		self::_load_controller();
281
+		// attempt to process message
282
+		try {
283
+			/** @type EE_Message_To_Generate_From_Request $message_to_generate */
284
+			$message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
285
+			self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate);
286
+		} catch (EE_Error $e) {
287
+			$error_msg = __(
288
+				'Please note that a system message failed to send due to a technical issue.',
289
+				'event_espresso'
290
+			);
291
+			// add specific message for developers if WP_DEBUG in on
292
+			$error_msg .= '||' . $e->getMessage();
293
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
294
+		}
295
+	}
296
+
297
+
298
+	/**
299
+	 * This is triggered by the 'msg_cron_trigger' route.
300
+	 *
301
+	 * @param WP $WP
302
+	 */
303
+	public function execute_batch_request($WP)
304
+	{
305
+		$this->run_cron();
306
+		header('HTTP/1.1 200 OK');
307
+		exit();
308
+	}
309
+
310
+
311
+	/**
312
+	 * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp
313
+	 * request.
314
+	 */
315
+	public function run_cron()
316
+	{
317
+		self::_load_controller();
318
+		// get required vars
319
+		$cron_type = EE_Registry::instance()->REQ->get('type');
320
+		$transient_key = EE_Registry::instance()->REQ->get('key');
321
+
322
+		// now let's verify transient, if not valid exit immediately
323
+		if (! get_transient($transient_key)) {
324
+			/**
325
+			 * trigger error so this gets in the error logs.  This is important because it happens on a non-user
326
+			 * request.
327
+			 */
328
+			trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso'));
329
+		}
330
+
331
+		// if made it here, lets' delete the transient to keep the db clean
332
+		delete_transient($transient_key);
333
+
334
+		if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) {
335
+			$method = 'batch_' . $cron_type . '_from_queue';
336
+			if (method_exists(self::$_MSG_PROCESSOR, $method)) {
337
+				self::$_MSG_PROCESSOR->$method();
338
+			} else {
339
+				// no matching task
340
+				/**
341
+				 * trigger error so this gets in the error logs.  This is important because it happens on a non user
342
+				 * request.
343
+				 */
344
+				trigger_error(
345
+					esc_attr(
346
+						sprintf(
347
+							__('There is no task corresponding to this route %s', 'event_espresso'),
348
+							$cron_type
349
+						)
350
+					)
351
+				);
352
+			}
353
+		}
354
+
355
+		do_action('FHEE__EED_Messages__run_cron__end');
356
+	}
357
+
358
+
359
+	/**
360
+	 * This is used to retrieve the template pack for the given name.
361
+	 * Retrieved packs are cached on the static $_TMP_PACKS array.  If there is no class matching the given name then
362
+	 * the default template pack is returned.
363
+	 *
364
+	 * @deprecated 4.9.0  @see EEH_MSG_Template::get_template_pack()
365
+	 * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used
366
+	 *                                   in generating the Pack class name).
367
+	 * @return EE_Messages_Template_Pack
368
+	 * @throws EE_Error
369
+	 * @throws InvalidArgumentException
370
+	 * @throws ReflectionException
371
+	 * @throws InvalidDataTypeException
372
+	 * @throws InvalidInterfaceException
373
+	 */
374
+	public static function get_template_pack($template_pack_name)
375
+	{
376
+		EE_Registry::instance()->load_helper('MSG_Template');
377
+		return EEH_MSG_Template::get_template_pack($template_pack_name);
378
+	}
379
+
380
+
381
+	/**
382
+	 * Retrieves an array of all template packs.
383
+	 * Array is in the format array( 'dbref' => EE_Messages_Template_Pack )
384
+	 *
385
+	 * @deprecated 4.9.0  @see EEH_MSG_Template_Pack::get_template_pack_collection
386
+	 * @return EE_Messages_Template_Pack[]
387
+	 * @throws EE_Error
388
+	 * @throws InvalidArgumentException
389
+	 * @throws ReflectionException
390
+	 * @throws InvalidDataTypeException
391
+	 * @throws InvalidInterfaceException
392
+	 */
393
+	public static function get_template_packs()
394
+	{
395
+		EE_Registry::instance()->load_helper('MSG_Template');
396
+
397
+		// for backward compat, let's make sure this returns in the same format as originally.
398
+		$template_pack_collection = EEH_MSG_Template::get_template_pack_collection();
399
+		$template_pack_collection->rewind();
400
+		$template_packs = array();
401
+		while ($template_pack_collection->valid()) {
402
+			$template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current();
403
+			$template_pack_collection->next();
404
+		}
405
+		return $template_packs;
406
+	}
407
+
408
+
409
+	/**
410
+	 * This simply makes sure the autoloaders are registered for the EE_messages system.
411
+	 *
412
+	 * @since 4.5.0
413
+	 * @return void
414
+	 * @throws EE_Error
415
+	 */
416
+	public static function set_autoloaders()
417
+	{
418
+		if (empty(self::$_MSG_PATHS)) {
419
+			self::_set_messages_paths();
420
+			foreach (self::$_MSG_PATHS as $path) {
421
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
422
+			}
423
+			// add aliases
424
+			EEH_Autoloader::add_alias('EE_messages', 'EE_messages');
425
+			EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger');
426
+		}
427
+	}
428
+
429
+
430
+	/**
431
+	 * Take care of adding all the paths for the messages components to the $_MSG_PATHS property
432
+	 * for use by the Messages Autoloaders
433
+	 *
434
+	 * @since 4.5.0
435
+	 * @return void.
436
+	 */
437
+	protected static function _set_messages_paths()
438
+	{
439
+		$dir_ref = array(
440
+			'messages/message_type',
441
+			'messages/messenger',
442
+			'messages/defaults',
443
+			'messages/defaults/email',
444
+			'messages/data_class',
445
+			'messages/validators',
446
+			'messages/validators/email',
447
+			'messages/validators/html',
448
+			'shortcodes',
449
+		);
450
+		$paths = array();
451
+		foreach ($dir_ref as $index => $dir) {
452
+			$paths[ $index ] = EE_LIBRARIES . $dir;
453
+		}
454
+		self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
455
+	}
456
+
457
+
458
+	/**
459
+	 * Takes care of loading dependencies
460
+	 *
461
+	 * @since 4.5.0
462
+	 * @return void
463
+	 * @throws EE_Error
464
+	 * @throws InvalidArgumentException
465
+	 * @throws ReflectionException
466
+	 * @throws InvalidDataTypeException
467
+	 * @throws InvalidInterfaceException
468
+	 */
469
+	protected static function _load_controller()
470
+	{
471
+		if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
472
+			EE_Registry::instance()->load_core('Request_Handler');
473
+			self::set_autoloaders();
474
+			self::$_EEMSG = EE_Registry::instance()->load_lib('messages');
475
+			self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor');
476
+			self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
477
+		}
478
+	}
479
+
480
+
481
+	/**
482
+	 * @param EE_Transaction $transaction
483
+	 * @throws EE_Error
484
+	 * @throws InvalidArgumentException
485
+	 * @throws InvalidDataTypeException
486
+	 * @throws InvalidInterfaceException
487
+	 * @throws ReflectionException
488
+	 */
489
+	public static function payment_reminder(EE_Transaction $transaction)
490
+	{
491
+		self::_load_controller();
492
+		$data = array($transaction, null);
493
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data);
494
+	}
495
+
496
+
497
+	/**
498
+	 * Any messages triggers for after successful gateway payments should go in here.
499
+	 *
500
+	 * @param EE_Transaction  $transaction object
501
+	 * @param EE_Payment|null $payment     object
502
+	 * @return void
503
+	 * @throws EE_Error
504
+	 * @throws InvalidArgumentException
505
+	 * @throws ReflectionException
506
+	 * @throws InvalidDataTypeException
507
+	 * @throws InvalidInterfaceException
508
+	 */
509
+	public static function payment(EE_Transaction $transaction, EE_Payment $payment = null)
510
+	{
511
+		// if there's no payment object, then we cannot do a payment type message!
512
+		if (! $payment instanceof EE_Payment) {
513
+			return;
514
+		}
515
+		self::_load_controller();
516
+		$data = array($transaction, $payment);
517
+		EE_Registry::instance()->load_helper('MSG_Template');
518
+		$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
519
+		// if payment amount is less than 0 then switch to payment_refund message type.
520
+		$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
521
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
522
+	}
523
+
524
+
525
+	/**
526
+	 * @param EE_Transaction $transaction
527
+	 * @throws EE_Error
528
+	 * @throws InvalidArgumentException
529
+	 * @throws InvalidDataTypeException
530
+	 * @throws InvalidInterfaceException
531
+	 * @throws ReflectionException
532
+	 */
533
+	public static function cancelled_registration(EE_Transaction $transaction)
534
+	{
535
+		self::_load_controller();
536
+		$data = array($transaction, null);
537
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data);
538
+	}
539
+
540
+
541
+	/**
542
+	 * Trigger for Registration messages
543
+	 * Note that what registration message type is sent depends on what the reg status is for the registrations on the
544
+	 * incoming transaction.
545
+	 *
546
+	 * @param EE_Registration $registration
547
+	 * @param array           $extra_details
548
+	 * @return void
549
+	 * @throws EE_Error
550
+	 * @throws InvalidArgumentException
551
+	 * @throws InvalidDataTypeException
552
+	 * @throws InvalidInterfaceException
553
+	 * @throws ReflectionException
554
+	 * @throws EntityNotFoundException
555
+	 */
556
+	public static function maybe_registration(EE_Registration $registration, $extra_details = array())
557
+	{
558
+
559
+		if (! self::_verify_registration_notification_send($registration, $extra_details)) {
560
+			// no messages please
561
+			return;
562
+		}
563
+
564
+		// get all non-trashed registrations so we make sure we send messages for the right status.
565
+		$all_registrations = $registration->transaction()->registrations(
566
+			array(
567
+				array('REG_deleted' => false),
568
+				'order_by' => array(
569
+					'Event.EVT_name'     => 'ASC',
570
+					'Attendee.ATT_lname' => 'ASC',
571
+					'Attendee.ATT_fname' => 'ASC',
572
+				),
573
+			)
574
+		);
575
+		// cached array of statuses so we only trigger messages once per status.
576
+		$statuses_sent = array();
577
+		self::_load_controller();
578
+		$mtgs = array();
579
+
580
+		// loop through registrations and trigger messages once per status.
581
+		foreach ($all_registrations as $reg) {
582
+			// already triggered?
583
+			if (in_array($reg->status_ID(), $statuses_sent)) {
584
+				continue;
585
+			}
586
+
587
+			$message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID());
588
+			$mtgs = array_merge(
589
+				$mtgs,
590
+				self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
591
+					$message_type,
592
+					array($registration->transaction(), null, $reg->status_ID())
593
+				)
594
+			);
595
+			$statuses_sent[] = $reg->status_ID();
596
+		}
597
+
598
+		if (count($statuses_sent) > 1) {
599
+			$mtgs = array_merge(
600
+				$mtgs,
601
+				self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
602
+					'registration_summary',
603
+					array($registration->transaction(), null)
604
+				)
605
+			);
606
+		}
607
+
608
+		// batch queue and initiate request
609
+		self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs);
610
+		self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
611
+	}
612
+
613
+
614
+	/**
615
+	 * This is a helper method used to very whether a registration notification should be sent or
616
+	 * not.  Prevents duplicate notifications going out for registration context notifications.
617
+	 *
618
+	 * @param EE_Registration $registration  [description]
619
+	 * @param array           $extra_details [description]
620
+	 * @return bool          true = send away, false = nope halt the presses.
621
+	 */
622
+	protected static function _verify_registration_notification_send(
623
+		EE_Registration $registration,
624
+		$extra_details = array()
625
+	) {
626
+		if (! $registration->is_primary_registrant()) {
627
+			return false;
628
+		}
629
+		// first we check if we're in admin and not doing front ajax
630
+		if (is_admin() && ! EE_FRONT_AJAX) {
631
+			// make sure appropriate admin params are set for sending messages
632
+			if (empty($_REQUEST['txn_reg_status_change']['send_notifications'])
633
+				|| ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])
634
+			) {
635
+				// no messages sent please.
636
+				return false;
637
+			}
638
+		} else {
639
+			// frontend request (either regular or via AJAX)
640
+			// TXN is NOT finalized ?
641
+			if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
642
+				return false;
643
+			}
644
+			// return visit but nothing changed ???
645
+			if (isset($extra_details['revisit'], $extra_details['status_updates']) &&
646
+				$extra_details['revisit'] && ! $extra_details['status_updates']
647
+			) {
648
+				return false;
649
+			}
650
+			// NOT sending messages && reg status is something other than "Not-Approved"
651
+			if (! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) &&
652
+				$registration->status_ID() !== EEM_Registration::status_id_not_approved
653
+			) {
654
+				return false;
655
+			}
656
+		}
657
+		// release the kraken
658
+		return true;
659
+	}
660
+
661
+
662
+	/**
663
+	 * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that
664
+	 * status id.
665
+	 *
666
+	 * @deprecated 4.9.0  Use EEH_MSG_Template::reg_status_to_message_type_array()
667
+	 *                    or EEH_MSG_Template::convert_reg_status_to_message_type
668
+	 * @param string $reg_status
669
+	 * @return array
670
+	 * @throws EE_Error
671
+	 * @throws InvalidArgumentException
672
+	 * @throws ReflectionException
673
+	 * @throws InvalidDataTypeException
674
+	 * @throws InvalidInterfaceException
675
+	 */
676
+	protected static function _get_reg_status_array($reg_status = '')
677
+	{
678
+		EE_Registry::instance()->load_helper('MSG_Template');
679
+		return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
680
+			? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
681
+			: EEH_MSG_Template::reg_status_to_message_type_array();
682
+	}
683
+
684
+
685
+	/**
686
+	 * Simply returns the payment message type for the given payment status.
687
+	 *
688
+	 * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array
689
+	 *                   or EEH_MSG_Template::convert_payment_status_to_message_type
690
+	 * @param string $payment_status The payment status being matched.
691
+	 * @return bool|string The payment message type slug matching the status or false if no match.
692
+	 * @throws EE_Error
693
+	 * @throws InvalidArgumentException
694
+	 * @throws ReflectionException
695
+	 * @throws InvalidDataTypeException
696
+	 * @throws InvalidInterfaceException
697
+	 */
698
+	protected static function _get_payment_message_type($payment_status)
699
+	{
700
+		EE_Registry::instance()->load_helper('MSG_Template');
701
+		return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
702
+			? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
703
+			: false;
704
+	}
705
+
706
+
707
+	/**
708
+	 * Message triggers for a resending already sent message(s) (via EE_Message list table)
709
+	 *
710
+	 * @access public
711
+	 * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages
712
+	 * @return bool success/fail
713
+	 * @throws EE_Error
714
+	 * @throws InvalidArgumentException
715
+	 * @throws InvalidDataTypeException
716
+	 * @throws InvalidInterfaceException
717
+	 * @throws ReflectionException
718
+	 */
719
+	public static function process_resend($req_data)
720
+	{
721
+		self::_load_controller();
722
+
723
+		// if $msgID in this request then skip to the new resend_message
724
+		if (EE_Registry::instance()->REQ->get('MSG_ID')) {
725
+			return self::resend_message();
726
+		}
727
+
728
+		// make sure any incoming request data is set on the REQ so that it gets picked up later.
729
+		$req_data = (array) $req_data;
730
+		foreach ($req_data as $request_key => $request_value) {
731
+			EE_Registry::instance()->REQ->set($request_key, $request_value);
732
+		}
733
+
734
+		if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request(
735
+		)) {
736
+			return false;
737
+		}
738
+
739
+		try {
740
+			self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send);
741
+			self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
742
+		} catch (EE_Error $e) {
743
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
744
+			return false;
745
+		}
746
+		EE_Error::add_success(
747
+			__('Messages have been successfully queued for generation and sending.', 'event_espresso')
748
+		);
749
+		return true; // everything got queued.
750
+	}
751
+
752
+
753
+	/**
754
+	 * Message triggers for a resending already sent message(s) (via EE_Message list table)
755
+	 *
756
+	 * @return bool
757
+	 * @throws EE_Error
758
+	 * @throws InvalidArgumentException
759
+	 * @throws InvalidDataTypeException
760
+	 * @throws InvalidInterfaceException
761
+	 * @throws ReflectionException
762
+	 */
763
+	public static function resend_message()
764
+	{
765
+		self::_load_controller();
766
+
767
+		$msgID = EE_Registry::instance()->REQ->get('MSG_ID');
768
+		if (! $msgID) {
769
+			EE_Error::add_error(
770
+				__(
771
+					'Something went wrong because there is no "MSG_ID" value in the request',
772
+					'event_espresso'
773
+				),
774
+				__FILE__,
775
+				__FUNCTION__,
776
+				__LINE__
777
+			);
778
+			return false;
779
+		}
780
+
781
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID);
782
+
783
+		// setup success message.
784
+		$count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
785
+		EE_Error::add_success(
786
+			sprintf(
787
+				_n(
788
+					'There was %d message queued for resending.',
789
+					'There were %d messages queued for resending.',
790
+					$count_ready_for_resend,
791
+					'event_espresso'
792
+				),
793
+				$count_ready_for_resend
794
+			)
795
+		);
796
+		return true;
797
+	}
798
+
799
+
800
+	/**
801
+	 * Message triggers for manual payment applied by admin
802
+	 *
803
+	 * @param  EE_Payment $payment EE_payment object
804
+	 * @return bool success/fail
805
+	 * @throws EE_Error
806
+	 * @throws InvalidArgumentException
807
+	 * @throws ReflectionException
808
+	 * @throws InvalidDataTypeException
809
+	 * @throws InvalidInterfaceException
810
+	 */
811
+	public static function process_admin_payment(EE_Payment $payment)
812
+	{
813
+		EE_Registry::instance()->load_helper('MSG_Template');
814
+		// we need to get the transaction object
815
+		$transaction = $payment->transaction();
816
+		if ($transaction instanceof EE_Transaction) {
817
+			$data = array($transaction, $payment);
818
+			$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
819
+
820
+			// if payment amount is less than 0 then switch to payment_refund message type.
821
+			$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
822
+
823
+			// if payment_refund is selected, but the status is NOT accepted.  Then change message type to false so NO message notification goes out.
824
+			$message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved
825
+				? false : $message_type;
826
+
827
+			self::_load_controller();
828
+
829
+			self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
830
+
831
+			// get count of queued for generation
832
+			$count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(
833
+				array(
834
+					EEM_Message::status_incomplete,
835
+					EEM_Message::status_idle,
836
+				)
837
+			);
838
+
839
+			if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) {
840
+				add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
841
+				return true;
842
+			} else {
843
+				$count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(
844
+					EEM_Message::instance()->stati_indicating_failed_sending()
845
+				);
846
+				/**
847
+				 * Verify that there are actually errors.  If not then we return a success message because the queue might have been emptied due to successful
848
+				 * IMMEDIATE generation.
849
+				 */
850
+				if ($count_failed > 0) {
851
+					EE_Error::add_error(
852
+						sprintf(
853
+							_n(
854
+								'The payment notification generation failed.',
855
+								'%d payment notifications failed being sent.',
856
+								$count_failed,
857
+								'event_espresso'
858
+							),
859
+							$count_failed
860
+						),
861
+						__FILE__,
862
+						__FUNCTION__,
863
+						__LINE__
864
+					);
865
+
866
+					return false;
867
+				} else {
868
+					add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
869
+					return true;
870
+				}
871
+			}
872
+		} else {
873
+			EE_Error::add_error(
874
+				'Unable to generate the payment notification because the given value for the transaction is invalid.',
875
+				'event_espresso'
876
+			);
877
+			return false;
878
+		}
879
+	}
880
+
881
+
882
+	/**
883
+	 * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger
884
+	 *
885
+	 * @since   4.3.0
886
+	 * @param  EE_Registration[] $registrations an array of EE_Registration objects
887
+	 * @param  int               $grp_id        a specific message template group id.
888
+	 * @return void
889
+	 * @throws EE_Error
890
+	 * @throws InvalidArgumentException
891
+	 * @throws InvalidDataTypeException
892
+	 * @throws InvalidInterfaceException
893
+	 * @throws ReflectionException
894
+	 */
895
+	public static function send_newsletter_message($registrations, $grp_id)
896
+	{
897
+		// make sure mtp is id and set it in the EE_Request Handler later messages setup.
898
+		EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id);
899
+		self::_load_controller();
900
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations);
901
+	}
902
+
903
+
904
+	/**
905
+	 * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url
906
+	 *
907
+	 * @since   4.3.0
908
+	 * @param    string          $registration_message_trigger_url
909
+	 * @param    EE_Registration $registration
910
+	 * @param string             $messenger
911
+	 * @param string             $message_type
912
+	 * @return string
913
+	 * @throws EE_Error
914
+	 * @throws InvalidArgumentException
915
+	 * @throws InvalidDataTypeException
916
+	 * @throws InvalidInterfaceException
917
+	 */
918
+	public static function registration_message_trigger_url(
919
+		$registration_message_trigger_url,
920
+		EE_Registration $registration,
921
+		$messenger = 'html',
922
+		$message_type = 'invoice'
923
+	) {
924
+		// whitelist $messenger
925
+		switch ($messenger) {
926
+			case 'pdf':
927
+				$sending_messenger = 'pdf';
928
+				$generating_messenger = 'html';
929
+				break;
930
+			case 'html':
931
+			default:
932
+				$sending_messenger = 'html';
933
+				$generating_messenger = 'html';
934
+				break;
935
+		}
936
+		// whitelist $message_type
937
+		switch ($message_type) {
938
+			case 'receipt':
939
+				$message_type = 'receipt';
940
+				break;
941
+			case 'invoice':
942
+			default:
943
+				$message_type = 'invoice';
944
+				break;
945
+		}
946
+		// verify that both the messenger AND the message type are active
947
+		if (EEH_MSG_Template::is_messenger_active($sending_messenger)
948
+			&& EEH_MSG_Template::is_mt_active($message_type)
949
+		) {
950
+			// need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?)
951
+			$template_query_params = array(
952
+				'MTP_is_active'    => true,
953
+				'MTP_messenger'    => $generating_messenger,
954
+				'MTP_message_type' => $message_type,
955
+				'Event.EVT_ID'     => $registration->event_ID(),
956
+			);
957
+			// get the message template group.
958
+			$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
959
+			// if we don't have an EE_Message_Template_Group then return
960
+			if (! $msg_template_group instanceof EE_Message_Template_Group) {
961
+				// remove EVT_ID from query params so that global templates get picked up
962
+				unset($template_query_params['Event.EVT_ID']);
963
+				// get global template as the fallback
964
+				$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
965
+			}
966
+			// if we don't have an EE_Message_Template_Group then return
967
+			if (! $msg_template_group instanceof EE_Message_Template_Group) {
968
+				return '';
969
+			}
970
+			// generate the URL
971
+			$registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger(
972
+				$sending_messenger,
973
+				$generating_messenger,
974
+				'purchaser',
975
+				$message_type,
976
+				$registration,
977
+				$msg_template_group->ID(),
978
+				$registration->transaction_ID()
979
+			);
980
+		}
981
+		return $registration_message_trigger_url;
982
+	}
983
+
984
+
985
+	/**
986
+	 * Use to generate and return a message preview!
987
+	 *
988
+	 * @param  string $type      This should correspond with a valid message type
989
+	 * @param  string $context   This should correspond with a valid context for the message type
990
+	 * @param  string $messenger This should correspond with a valid messenger.
991
+	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
992
+	 *                           preview
993
+	 * @return bool|string The body of the message or if send is requested, sends.
994
+	 * @throws EE_Error
995
+	 * @throws InvalidArgumentException
996
+	 * @throws InvalidDataTypeException
997
+	 * @throws InvalidInterfaceException
998
+	 * @throws ReflectionException
999
+	 */
1000
+	public static function preview_message($type, $context, $messenger, $send = false)
1001
+	{
1002
+		self::_load_controller();
1003
+		$mtg = new EE_Message_To_Generate(
1004
+			$messenger,
1005
+			$type,
1006
+			array(),
1007
+			$context,
1008
+			true
1009
+		);
1010
+		$generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send);
1011
+		if ($generated_preview_queue instanceof EE_Messages_Queue) {
1012
+			// loop through all content for the preview and remove any persisted records.
1013
+			$content = '';
1014
+			foreach ($generated_preview_queue->get_message_repository() as $message) {
1015
+				$content = $message->content();
1016
+				if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) {
1017
+					$message->delete();
1018
+				}
1019
+			}
1020
+			return $content;
1021
+		} else {
1022
+			return $generated_preview_queue;
1023
+		}
1024
+	}
1025
+
1026
+
1027
+	/**
1028
+	 * This is a method that allows for sending a message using a messenger matching the string given and the provided
1029
+	 * EE_Message_Queue object.  The EE_Message_Queue object is used to create a single aggregate EE_Message via the
1030
+	 * content found in the EE_Message objects in the queue.
1031
+	 *
1032
+	 * @since 4.9.0
1033
+	 * @param string            $messenger            a string matching a valid active messenger in the system
1034
+	 * @param string            $message_type         Although it seems contrary to the name of the method, a message
1035
+	 *                                                type name is still required to send along the message type to the
1036
+	 *                                                messenger because this is used for determining what specific
1037
+	 *                                                variations might be loaded for the generated message.
1038
+	 * @param EE_Messages_Queue $queue
1039
+	 * @param string            $custom_subject       Can be used to set what the custom subject string will be on the
1040
+	 *                                                aggregate EE_Message object.
1041
+	 * @return bool success or fail.
1042
+	 * @throws EE_Error
1043
+	 * @throws InvalidArgumentException
1044
+	 * @throws ReflectionException
1045
+	 * @throws InvalidDataTypeException
1046
+	 * @throws InvalidInterfaceException
1047
+	 */
1048
+	public static function send_message_with_messenger_only(
1049
+		$messenger,
1050
+		$message_type,
1051
+		EE_Messages_Queue $queue,
1052
+		$custom_subject = ''
1053
+	) {
1054
+		self::_load_controller();
1055
+		/** @type EE_Message_To_Generate_From_Queue $message_to_generate */
1056
+		$message_to_generate = EE_Registry::instance()->load_lib(
1057
+			'Message_To_Generate_From_Queue',
1058
+			array(
1059
+				$messenger,
1060
+				$message_type,
1061
+				$queue,
1062
+				$custom_subject,
1063
+			)
1064
+		);
1065
+		return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate);
1066
+	}
1067
+
1068
+
1069
+	/**
1070
+	 * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation)
1071
+	 *
1072
+	 * @since 4.9.0
1073
+	 * @param array $message_ids An array of message ids
1074
+	 * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated
1075
+	 *                           messages.
1076
+	 * @throws EE_Error
1077
+	 * @throws InvalidArgumentException
1078
+	 * @throws InvalidDataTypeException
1079
+	 * @throws InvalidInterfaceException
1080
+	 * @throws ReflectionException
1081
+	 */
1082
+	public static function generate_now($message_ids)
1083
+	{
1084
+		self::_load_controller();
1085
+		$messages = EEM_Message::instance()->get_all(
1086
+			array(
1087
+				0 => array(
1088
+					'MSG_ID' => array('IN', $message_ids),
1089
+					'STS_ID' => EEM_Message::status_incomplete,
1090
+				),
1091
+			)
1092
+		);
1093
+		$generated_queue = false;
1094
+		if ($messages) {
1095
+			$generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
1096
+		}
1097
+
1098
+		if (! $generated_queue instanceof EE_Messages_Queue) {
1099
+			EE_Error::add_error(
1100
+				__(
1101
+					'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.',
1102
+					'event_espresso'
1103
+				),
1104
+				__FILE__,
1105
+				__FUNCTION__,
1106
+				__LINE__
1107
+			);
1108
+		}
1109
+		return $generated_queue;
1110
+	}
1111
+
1112
+
1113
+	/**
1114
+	 * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or,
1115
+	 * EEM_Message::status_idle
1116
+	 *
1117
+	 * @since 4.9.0
1118
+	 * @param $message_ids
1119
+	 * @return bool|EE_Messages_Queue false if no messages sent.
1120
+	 * @throws EE_Error
1121
+	 * @throws InvalidArgumentException
1122
+	 * @throws InvalidDataTypeException
1123
+	 * @throws InvalidInterfaceException
1124
+	 * @throws ReflectionException
1125
+	 */
1126
+	public static function send_now($message_ids)
1127
+	{
1128
+		self::_load_controller();
1129
+		$messages = EEM_Message::instance()->get_all(
1130
+			array(
1131
+				0 => array(
1132
+					'MSG_ID' => array('IN', $message_ids),
1133
+					'STS_ID' => array(
1134
+						'IN',
1135
+						array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry),
1136
+					),
1137
+				),
1138
+			)
1139
+		);
1140
+		$sent_queue = false;
1141
+		if ($messages) {
1142
+			$sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
1143
+		}
1144
+
1145
+		if (! $sent_queue instanceof EE_Messages_Queue) {
1146
+			EE_Error::add_error(
1147
+				__(
1148
+					'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.',
1149
+					'event_espresso'
1150
+				),
1151
+				__FILE__,
1152
+				__FUNCTION__,
1153
+				__LINE__
1154
+			);
1155
+		} else {
1156
+			// can count how many sent by using the messages in the queue
1157
+			$sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent());
1158
+			if ($sent_count > 0) {
1159
+				EE_Error::add_success(
1160
+					sprintf(
1161
+						_n(
1162
+							'There was %d message successfully sent.',
1163
+							'There were %d messages successfully sent.',
1164
+							$sent_count,
1165
+							'event_espresso'
1166
+						),
1167
+						$sent_count
1168
+					)
1169
+				);
1170
+			} else {
1171
+				EE_Error::overwrite_errors();
1172
+				EE_Error::add_error(
1173
+					__(
1174
+						'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error.
1175 1175
 					If there was an error, you can look at the messages in the message activity list table for any error messages.',
1176
-                        'event_espresso'
1177
-                    ),
1178
-                    __FILE__,
1179
-                    __FUNCTION__,
1180
-                    __LINE__
1181
-                );
1182
-            }
1183
-        }
1184
-        return $sent_queue;
1185
-    }
1186
-
1187
-
1188
-    /**
1189
-     * Generate and send immediately from the given $message_ids
1190
-     *
1191
-     * @param array $message_ids EE_Message entity ids.
1192
-     * @throws EE_Error
1193
-     * @throws InvalidArgumentException
1194
-     * @throws InvalidDataTypeException
1195
-     * @throws InvalidInterfaceException
1196
-     * @throws ReflectionException
1197
-     */
1198
-    public static function generate_and_send_now(array $message_ids)
1199
-    {
1200
-        $generated_queue = self::generate_now($message_ids);
1201
-        // now let's just trigger sending immediately from this queue.
1202
-        $messages_sent = $generated_queue instanceof EE_Messages_Queue
1203
-            ? $generated_queue->execute()
1204
-            : 0;
1205
-        if ($messages_sent) {
1206
-            EE_Error::add_success(
1207
-                esc_html(
1208
-                    sprintf(
1209
-                        _n(
1210
-                            'There was %d message successfully generated and sent.',
1211
-                            'There were %d messages successfully generated and sent.',
1212
-                            $messages_sent,
1213
-                            'event_espresso'
1214
-                        ),
1215
-                        $messages_sent
1216
-                    )
1217
-                )
1218
-            );
1219
-            // errors would be added via the generate_now method.
1220
-        }
1221
-    }
1222
-
1223
-
1224
-    /**
1225
-     * This will queue the incoming message ids for resending.
1226
-     * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued.
1227
-     *
1228
-     * @since 4.9.0
1229
-     * @param array $message_ids An array of EE_Message IDs
1230
-     * @return bool true means messages were successfully queued for resending, false means none were queued for
1231
-     *                           resending.
1232
-     * @throws EE_Error
1233
-     * @throws InvalidArgumentException
1234
-     * @throws InvalidDataTypeException
1235
-     * @throws InvalidInterfaceException
1236
-     * @throws ReflectionException
1237
-     */
1238
-    public static function queue_for_resending($message_ids)
1239
-    {
1240
-        self::_load_controller();
1241
-        self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids);
1242
-
1243
-        // get queue and count
1244
-        $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
1245
-
1246
-        if ($queue_count > 0
1247
-        ) {
1248
-            EE_Error::add_success(
1249
-                sprintf(
1250
-                    _n(
1251
-                        '%d message successfully queued for resending.',
1252
-                        '%d messages successfully queued for resending.',
1253
-                        $queue_count,
1254
-                        'event_espresso'
1255
-                    ),
1256
-                    $queue_count
1257
-                )
1258
-            );
1259
-            /**
1260
-             * @see filter usage in EE_Messages_Queue::initiate_request_by_priority
1261
-             */
1262
-        } elseif (apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true)
1263
-            || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
1264
-        ) {
1265
-            $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent);
1266
-            if ($queue_count > 0) {
1267
-                EE_Error::add_success(
1268
-                    sprintf(
1269
-                        _n(
1270
-                            '%d message successfully sent.',
1271
-                            '%d messages successfully sent.',
1272
-                            $queue_count,
1273
-                            'event_espresso'
1274
-                        ),
1275
-                        $queue_count
1276
-                    )
1277
-                );
1278
-            } else {
1279
-                EE_Error::add_error(
1280
-                    __(
1281
-                        'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1282
-                        'event_espresso'
1283
-                    ),
1284
-                    __FILE__,
1285
-                    __FUNCTION__,
1286
-                    __LINE__
1287
-                );
1288
-            }
1289
-        } else {
1290
-            EE_Error::add_error(
1291
-                __(
1292
-                    'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1293
-                    'event_espresso'
1294
-                ),
1295
-                __FILE__,
1296
-                __FUNCTION__,
1297
-                __LINE__
1298
-            );
1299
-        }
1300
-        return (bool) $queue_count;
1301
-    }
1302
-
1303
-
1304
-    /**
1305
-     * debug
1306
-     *
1307
-     * @param string          $class
1308
-     * @param string          $func
1309
-     * @param string          $line
1310
-     * @param \EE_Transaction $transaction
1311
-     * @param array           $info
1312
-     * @param bool            $display_request
1313
-     * @throws EE_Error
1314
-     * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
1315
-     */
1316
-    protected static function log(
1317
-        $class = '',
1318
-        $func = '',
1319
-        $line = '',
1320
-        EE_Transaction $transaction,
1321
-        $info = array(),
1322
-        $display_request = false
1323
-    ) {
1324
-        if (defined('EE_DEBUG') && EE_DEBUG) {
1325
-            if ($transaction instanceof EE_Transaction) {
1326
-                // don't serialize objects
1327
-                $info = EEH_Debug_Tools::strip_objects($info);
1328
-                $info['TXN_status'] = $transaction->status_ID();
1329
-                $info['TXN_reg_steps'] = $transaction->reg_steps();
1330
-                if ($transaction->ID()) {
1331
-                    $index = 'EE_Transaction: ' . $transaction->ID();
1332
-                    EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
1333
-                }
1334
-            }
1335
-        }
1336
-    }
1337
-
1338
-
1339
-    /**
1340
-     *  Resets all the static properties in this class when called.
1341
-     */
1342
-    public static function reset()
1343
-    {
1344
-        self::$_EEMSG = null;
1345
-        self::$_message_resource_manager = null;
1346
-        self::$_MSG_PROCESSOR = null;
1347
-        self::$_MSG_PATHS = null;
1348
-        self::$_TMP_PACKS = array();
1349
-    }
1176
+						'event_espresso'
1177
+					),
1178
+					__FILE__,
1179
+					__FUNCTION__,
1180
+					__LINE__
1181
+				);
1182
+			}
1183
+		}
1184
+		return $sent_queue;
1185
+	}
1186
+
1187
+
1188
+	/**
1189
+	 * Generate and send immediately from the given $message_ids
1190
+	 *
1191
+	 * @param array $message_ids EE_Message entity ids.
1192
+	 * @throws EE_Error
1193
+	 * @throws InvalidArgumentException
1194
+	 * @throws InvalidDataTypeException
1195
+	 * @throws InvalidInterfaceException
1196
+	 * @throws ReflectionException
1197
+	 */
1198
+	public static function generate_and_send_now(array $message_ids)
1199
+	{
1200
+		$generated_queue = self::generate_now($message_ids);
1201
+		// now let's just trigger sending immediately from this queue.
1202
+		$messages_sent = $generated_queue instanceof EE_Messages_Queue
1203
+			? $generated_queue->execute()
1204
+			: 0;
1205
+		if ($messages_sent) {
1206
+			EE_Error::add_success(
1207
+				esc_html(
1208
+					sprintf(
1209
+						_n(
1210
+							'There was %d message successfully generated and sent.',
1211
+							'There were %d messages successfully generated and sent.',
1212
+							$messages_sent,
1213
+							'event_espresso'
1214
+						),
1215
+						$messages_sent
1216
+					)
1217
+				)
1218
+			);
1219
+			// errors would be added via the generate_now method.
1220
+		}
1221
+	}
1222
+
1223
+
1224
+	/**
1225
+	 * This will queue the incoming message ids for resending.
1226
+	 * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued.
1227
+	 *
1228
+	 * @since 4.9.0
1229
+	 * @param array $message_ids An array of EE_Message IDs
1230
+	 * @return bool true means messages were successfully queued for resending, false means none were queued for
1231
+	 *                           resending.
1232
+	 * @throws EE_Error
1233
+	 * @throws InvalidArgumentException
1234
+	 * @throws InvalidDataTypeException
1235
+	 * @throws InvalidInterfaceException
1236
+	 * @throws ReflectionException
1237
+	 */
1238
+	public static function queue_for_resending($message_ids)
1239
+	{
1240
+		self::_load_controller();
1241
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids);
1242
+
1243
+		// get queue and count
1244
+		$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
1245
+
1246
+		if ($queue_count > 0
1247
+		) {
1248
+			EE_Error::add_success(
1249
+				sprintf(
1250
+					_n(
1251
+						'%d message successfully queued for resending.',
1252
+						'%d messages successfully queued for resending.',
1253
+						$queue_count,
1254
+						'event_espresso'
1255
+					),
1256
+					$queue_count
1257
+				)
1258
+			);
1259
+			/**
1260
+			 * @see filter usage in EE_Messages_Queue::initiate_request_by_priority
1261
+			 */
1262
+		} elseif (apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true)
1263
+			|| EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
1264
+		) {
1265
+			$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent);
1266
+			if ($queue_count > 0) {
1267
+				EE_Error::add_success(
1268
+					sprintf(
1269
+						_n(
1270
+							'%d message successfully sent.',
1271
+							'%d messages successfully sent.',
1272
+							$queue_count,
1273
+							'event_espresso'
1274
+						),
1275
+						$queue_count
1276
+					)
1277
+				);
1278
+			} else {
1279
+				EE_Error::add_error(
1280
+					__(
1281
+						'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1282
+						'event_espresso'
1283
+					),
1284
+					__FILE__,
1285
+					__FUNCTION__,
1286
+					__LINE__
1287
+				);
1288
+			}
1289
+		} else {
1290
+			EE_Error::add_error(
1291
+				__(
1292
+					'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1293
+					'event_espresso'
1294
+				),
1295
+				__FILE__,
1296
+				__FUNCTION__,
1297
+				__LINE__
1298
+			);
1299
+		}
1300
+		return (bool) $queue_count;
1301
+	}
1302
+
1303
+
1304
+	/**
1305
+	 * debug
1306
+	 *
1307
+	 * @param string          $class
1308
+	 * @param string          $func
1309
+	 * @param string          $line
1310
+	 * @param \EE_Transaction $transaction
1311
+	 * @param array           $info
1312
+	 * @param bool            $display_request
1313
+	 * @throws EE_Error
1314
+	 * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
1315
+	 */
1316
+	protected static function log(
1317
+		$class = '',
1318
+		$func = '',
1319
+		$line = '',
1320
+		EE_Transaction $transaction,
1321
+		$info = array(),
1322
+		$display_request = false
1323
+	) {
1324
+		if (defined('EE_DEBUG') && EE_DEBUG) {
1325
+			if ($transaction instanceof EE_Transaction) {
1326
+				// don't serialize objects
1327
+				$info = EEH_Debug_Tools::strip_objects($info);
1328
+				$info['TXN_status'] = $transaction->status_ID();
1329
+				$info['TXN_reg_steps'] = $transaction->reg_steps();
1330
+				if ($transaction->ID()) {
1331
+					$index = 'EE_Transaction: ' . $transaction->ID();
1332
+					EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
1333
+				}
1334
+			}
1335
+		}
1336
+	}
1337
+
1338
+
1339
+	/**
1340
+	 *  Resets all the static properties in this class when called.
1341
+	 */
1342
+	public static function reset()
1343
+	{
1344
+		self::$_EEMSG = null;
1345
+		self::$_message_resource_manager = null;
1346
+		self::$_MSG_PROCESSOR = null;
1347
+		self::$_MSG_PATHS = null;
1348
+		self::$_TMP_PACKS = array();
1349
+	}
1350 1350
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.68.rc.006');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.68.rc.006');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.