@@ -29,21 +29,21 @@ discard block |
||
29 | 29 | $has_answers = $question->has_answers(); |
30 | 30 | |
31 | 31 | if ($QST_system === 'country') { |
32 | - // already escaped |
|
33 | - echo EEH_HTML::div( |
|
34 | - EEH_HTML::h4( |
|
35 | - '<span class="dashicons dashicons-info"></span>' |
|
36 | - . esc_html__('Did you know...', 'event_espresso') |
|
37 | - ) . |
|
38 | - EEH_HTML::p( |
|
39 | - esc_html__( |
|
40 | - 'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.', |
|
41 | - 'event_espresso' |
|
42 | - ) |
|
43 | - ), |
|
44 | - '', |
|
45 | - 'ee-info-box' |
|
46 | - ); |
|
32 | + // already escaped |
|
33 | + echo EEH_HTML::div( |
|
34 | + EEH_HTML::h4( |
|
35 | + '<span class="dashicons dashicons-info"></span>' |
|
36 | + . esc_html__('Did you know...', 'event_espresso') |
|
37 | + ) . |
|
38 | + EEH_HTML::p( |
|
39 | + esc_html__( |
|
40 | + 'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.', |
|
41 | + 'event_espresso' |
|
42 | + ) |
|
43 | + ), |
|
44 | + '', |
|
45 | + 'ee-info-box' |
|
46 | + ); |
|
47 | 47 | } |
48 | 48 | ?> |
49 | 49 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | </th> |
80 | 80 | <td> |
81 | 81 | <?php |
82 | - $id = ! empty($QST_system) ? '_disabled' : ''; |
|
83 | - $disabled_attr = ! empty($QST_system) ? 'disabled' : ''; |
|
84 | - ?> |
|
82 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
83 | + $disabled_attr = ! empty($QST_system) ? 'disabled' : ''; |
|
84 | + ?> |
|
85 | 85 | <input class='regular-text' |
86 | 86 | id="QST_admin_label<?php echo esc_attr($id); ?>" |
87 | 87 | name="QST_admin_label<?php echo esc_attr($id); ?>" |
@@ -123,30 +123,30 @@ discard block |
||
123 | 123 | </th> |
124 | 124 | <td> |
125 | 125 | <?php |
126 | - $id = ! empty($QST_system) ? '_disabled' : ''; |
|
127 | - $disabled_attr = ! empty($QST_system) ? 'disabled' : ''; |
|
128 | - $admin_only = $question->get('QST_admin_only'); |
|
129 | - $checked = ! empty($admin_only) ? ' checked' : ''; |
|
130 | - ?> |
|
126 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
127 | + $disabled_attr = ! empty($QST_system) ? 'disabled' : ''; |
|
128 | + $admin_only = $question->get('QST_admin_only'); |
|
129 | + $checked = ! empty($admin_only) ? ' checked' : ''; |
|
130 | + ?> |
|
131 | 131 | <input class="QST_admin_only" |
132 | 132 | id="QST_admin_only<?php echo esc_attr($id); ?>" |
133 | 133 | name="QST_admin_only<?php echo esc_attr($id); ?>" |
134 | 134 | type="checkbox" |
135 | 135 | value="1" |
136 | 136 | <?php |
137 | - echo esc_attr($disabled_attr); |
|
138 | - echo esc_attr($checked); |
|
139 | - ?> |
|
137 | + echo esc_attr($disabled_attr); |
|
138 | + echo esc_attr($checked); |
|
139 | + ?> |
|
140 | 140 | /> |
141 | 141 | <br /> |
142 | 142 | <p class="description"> |
143 | 143 | <?php |
144 | - if (! empty($QST_system)) { ?> |
|
144 | + if (! empty($QST_system)) { ?> |
|
145 | 145 | <span class="description" style="color:#D54E21;"> |
146 | 146 | <?php esc_html_e( |
147 | - 'System question! This field cannot be changed.', |
|
148 | - 'event_espresso' |
|
149 | - ); ?> |
|
147 | + 'System question! This field cannot be changed.', |
|
148 | + 'event_espresso' |
|
149 | + ); ?> |
|
150 | 150 | </span> |
151 | 151 | <?php } ?> |
152 | 152 | </p> |
@@ -162,44 +162,44 @@ discard block |
||
162 | 162 | </th> |
163 | 163 | <td> |
164 | 164 | <?php |
165 | - $disabled = ! empty($QST_system) && $QST_system !== EEM_Attendee::system_question_phone; |
|
166 | - if ($disabled) { |
|
167 | - $disabled_attr = 'disabled="disabled"'; |
|
168 | - $id = '_disabled'; |
|
169 | - } else { |
|
170 | - $disabled_attr = ''; |
|
171 | - $id = ''; |
|
172 | - } |
|
165 | + $disabled = ! empty($QST_system) && $QST_system !== EEM_Attendee::system_question_phone; |
|
166 | + if ($disabled) { |
|
167 | + $disabled_attr = 'disabled="disabled"'; |
|
168 | + $id = '_disabled'; |
|
169 | + } else { |
|
170 | + $disabled_attr = ''; |
|
171 | + $id = ''; |
|
172 | + } |
|
173 | 173 | |
174 | - // Only display Confirm email for |
|
175 | - if (empty($QST_system) || $QST_system !== EEM_Attendee::system_question_email_confirm) { |
|
176 | - unset($question_types[ EEM_Question::QST_type_email_confirm ]); |
|
177 | - } |
|
174 | + // Only display Confirm email for |
|
175 | + if (empty($QST_system) || $QST_system !== EEM_Attendee::system_question_email_confirm) { |
|
176 | + unset($question_types[ EEM_Question::QST_type_email_confirm ]); |
|
177 | + } |
|
178 | 178 | |
179 | - echo EEH_Form_Fields::select_input( |
|
180 | - 'QST_type' . $id, |
|
181 | - $question_types, |
|
182 | - $question->type(), |
|
183 | - 'id="QST_type' . $id . '"' . $disabled_attr |
|
184 | - ); // already escaped |
|
185 | - if ($disabled) { ?> |
|
179 | + echo EEH_Form_Fields::select_input( |
|
180 | + 'QST_type' . $id, |
|
181 | + $question_types, |
|
182 | + $question->type(), |
|
183 | + 'id="QST_type' . $id . '"' . $disabled_attr |
|
184 | + ); // already escaped |
|
185 | + if ($disabled) { ?> |
|
186 | 186 | <input id='QST_type' |
187 | 187 | name="QST_type" |
188 | 188 | type="hidden" |
189 | 189 | value="<?php echo esc_attr($question->type()); ?>" |
190 | 190 | /> |
191 | 191 | <?php |
192 | - $explanatory_text = esc_html__( |
|
193 | - 'System question! This field cannot be changed.', |
|
194 | - 'event_espresso' |
|
195 | - ); |
|
196 | - } else { |
|
197 | - $explanatory_text = esc_html__( |
|
198 | - 'Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.', |
|
199 | - 'event_espresso' |
|
200 | - ); |
|
201 | - } |
|
202 | - if ($disabled || $has_answers) { ?> |
|
192 | + $explanatory_text = esc_html__( |
|
193 | + 'System question! This field cannot be changed.', |
|
194 | + 'event_espresso' |
|
195 | + ); |
|
196 | + } else { |
|
197 | + $explanatory_text = esc_html__( |
|
198 | + 'Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.', |
|
199 | + 'event_espresso' |
|
200 | + ); |
|
201 | + } |
|
202 | + if ($disabled || $has_answers) { ?> |
|
203 | 203 | <p> |
204 | 204 | <span class="description" style="color:#D54E21;"> |
205 | 205 | <?php echo esc_html($explanatory_text); ?> |
@@ -228,21 +228,21 @@ discard block |
||
228 | 228 | <p> |
229 | 229 | <span class="description"> |
230 | 230 | <?php esc_html_e( |
231 | - 'Maximum number of characters allowed when answering this question', |
|
232 | - 'event_espresso' |
|
233 | - ); ?> |
|
231 | + 'Maximum number of characters allowed when answering this question', |
|
232 | + 'event_espresso' |
|
233 | + ); ?> |
|
234 | 234 | </span> |
235 | 235 | </p> |
236 | 236 | <?php if ($QST_system) { ?> |
237 | 237 | <p> |
238 | 238 | <span class="description" style="color:#D54E21;"> |
239 | 239 | <?php printf( |
240 | - esc_html__( |
|
241 | - 'System question! The maximum number of characters that can be used for this question is %1$s', |
|
242 | - 'event_espresso' |
|
243 | - ), |
|
244 | - $max_max |
|
245 | - ); ?> |
|
240 | + esc_html__( |
|
241 | + 'System question! The maximum number of characters that can be used for this question is %1$s', |
|
242 | + 'event_espresso' |
|
243 | + ), |
|
244 | + $max_max |
|
245 | + ); ?> |
|
246 | 246 | </span> |
247 | 247 | </p> |
248 | 248 | <?php } ?> |
@@ -264,9 +264,9 @@ discard block |
||
264 | 264 | </th> |
265 | 265 | <th class="option-desc-header"> |
266 | 266 | <?php esc_html_e( |
267 | - 'Description (optional, only shown on registration form)', |
|
268 | - 'event_espresso' |
|
269 | - ) ?> |
|
267 | + 'Description (optional, only shown on registration form)', |
|
268 | + 'event_espresso' |
|
269 | + ) ?> |
|
270 | 270 | </th> |
271 | 271 | <th> |
272 | 272 | </th> |
@@ -301,14 +301,14 @@ discard block |
||
301 | 301 | </tr> |
302 | 302 | |
303 | 303 | <?php |
304 | - $count = 0; |
|
305 | - $question_options = $question->options(); |
|
306 | - if (! empty($question_options)) { |
|
307 | - foreach ($question_options as $option_id => $option) { |
|
308 | - $disabled_attr = $has_answers || $option->get('QSO_system') |
|
309 | - ? 'disabled' |
|
310 | - : ''; |
|
311 | - ?> |
|
304 | + $count = 0; |
|
305 | + $question_options = $question->options(); |
|
306 | + if (! empty($question_options)) { |
|
307 | + foreach ($question_options as $option_id => $option) { |
|
308 | + $disabled_attr = $has_answers || $option->get('QSO_system') |
|
309 | + ? 'disabled' |
|
310 | + : ''; |
|
311 | + ?> |
|
312 | 312 | <tr class="question-option ee-options-sortable"> |
313 | 313 | <td class="option-value-cell"> |
314 | 314 | <input type="hidden" |
@@ -345,21 +345,21 @@ discard block |
||
345 | 345 | </span> |
346 | 346 | </td> |
347 | 347 | <?php |
348 | - echo EEH_Form_Fields::hidden_input( |
|
349 | - "question_options[{$count}][QST_ID])", |
|
350 | - $option->question_ID() |
|
351 | - ); // already escaped |
|
352 | - echo EEH_Form_Fields::hidden_input( |
|
353 | - "question_options[{$count}][QSO_ID])", |
|
354 | - $option->ID() |
|
355 | - ); // already escaped |
|
356 | - $count++; |
|
357 | - ?> |
|
348 | + echo EEH_Form_Fields::hidden_input( |
|
349 | + "question_options[{$count}][QST_ID])", |
|
350 | + $option->question_ID() |
|
351 | + ); // already escaped |
|
352 | + echo EEH_Form_Fields::hidden_input( |
|
353 | + "question_options[{$count}][QSO_ID])", |
|
354 | + $option->ID() |
|
355 | + ); // already escaped |
|
356 | + $count++; |
|
357 | + ?> |
|
358 | 358 | </tr> |
359 | 359 | <?php |
360 | - } |
|
361 | - } else { |
|
362 | - ?> |
|
360 | + } |
|
361 | + } else { |
|
362 | + ?> |
|
363 | 363 | <tr class="question-option ee-options-sortable"> |
364 | 364 | <td class="option-value-cell"> |
365 | 365 | <input type="hidden" |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | </td> |
384 | 384 | </tr> |
385 | 385 | <?php |
386 | - } |
|
387 | - ?> |
|
386 | + } |
|
387 | + ?> |
|
388 | 388 | <tr style="display:none"> |
389 | 389 | <td colspan="3"> |
390 | 390 | <?php echo EEH_Form_Fields::hidden_input("question_options_count", $count); // already escaped ?> |
@@ -403,16 +403,16 @@ discard block |
||
403 | 403 | |
404 | 404 | <p class="description"> |
405 | 405 | <?php esc_html_e( |
406 | - 'Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.', |
|
407 | - 'event_espresso' |
|
408 | - ) ?> |
|
406 | + 'Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.', |
|
407 | + 'event_espresso' |
|
408 | + ) ?> |
|
409 | 409 | </p> |
410 | 410 | <?php if ($has_answers) : ?> |
411 | 411 | <p class="description" style="color:#D54E21;"> |
412 | 412 | <?php esc_html_e( |
413 | - 'Answer values that are uneditable are this way because there are registrations in the database that have answers for this question. If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes. This will ensure that the existing registrations that chose the original answer will preserve that answer.', |
|
414 | - 'event_espresso' |
|
415 | - ); ?> |
|
413 | + 'Answer values that are uneditable are this way because there are registrations in the database that have answers for this question. If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes. This will ensure that the existing registrations that chose the original answer will preserve that answer.', |
|
414 | + 'event_espresso' |
|
415 | + ); ?> |
|
416 | 416 | </p> |
417 | 417 | |
418 | 418 | <?php endif; ?> |
@@ -428,40 +428,40 @@ discard block |
||
428 | 428 | </th> |
429 | 429 | <td> |
430 | 430 | <?php |
431 | - $system_required = ['fname', 'email']; |
|
432 | - $disabled_attr = in_array($QST_system, $system_required) ? ' disabled="disabled"' : ''; |
|
433 | - $required_on = $question->get('QST_admin_only'); |
|
434 | - $show_required_msg = $required_on ? '' : ' display:none;'; |
|
435 | - $disabled_attr = $required_on || ! empty($disabled_attr) ? ' disabled="disabled"' : ''; |
|
436 | - $id = |
|
437 | - ! empty($disabled_attr) && in_array($QST_system, $system_required) ? '_disabled' : ''; |
|
438 | - $requiredOptions = [ |
|
439 | - ['text' => esc_html__('Optional', 'event_espresso'), 'id' => 0], |
|
440 | - ['text' => esc_html__('Required', 'event_espresso'), 'id' => 1], |
|
441 | - ]; |
|
442 | - echo EEH_Form_Fields::select_input( |
|
443 | - 'QST_required' . $id, |
|
444 | - $requiredOptions, |
|
445 | - $question->required(), |
|
446 | - 'id="QST_required' . $id . '"' . $disabled_attr |
|
447 | - ); // already escaped |
|
448 | - ?> |
|
431 | + $system_required = ['fname', 'email']; |
|
432 | + $disabled_attr = in_array($QST_system, $system_required) ? ' disabled="disabled"' : ''; |
|
433 | + $required_on = $question->get('QST_admin_only'); |
|
434 | + $show_required_msg = $required_on ? '' : ' display:none;'; |
|
435 | + $disabled_attr = $required_on || ! empty($disabled_attr) ? ' disabled="disabled"' : ''; |
|
436 | + $id = |
|
437 | + ! empty($disabled_attr) && in_array($QST_system, $system_required) ? '_disabled' : ''; |
|
438 | + $requiredOptions = [ |
|
439 | + ['text' => esc_html__('Optional', 'event_espresso'), 'id' => 0], |
|
440 | + ['text' => esc_html__('Required', 'event_espresso'), 'id' => 1], |
|
441 | + ]; |
|
442 | + echo EEH_Form_Fields::select_input( |
|
443 | + 'QST_required' . $id, |
|
444 | + $requiredOptions, |
|
445 | + $question->required(), |
|
446 | + 'id="QST_required' . $id . '"' . $disabled_attr |
|
447 | + ); // already escaped |
|
448 | + ?> |
|
449 | 449 | <p> |
450 | 450 | <span id="required_toggled_on" class="description" |
451 | 451 | style="color:#D54E21;<?php echo esc_attr($show_required_msg); ?>" |
452 | 452 | > |
453 | 453 | <?php esc_html_e( |
454 | - 'Required is set to optional, and this field is disabled, because the question is Admin-Only.', |
|
455 | - 'event_espresso' |
|
456 | - ) ?> |
|
454 | + 'Required is set to optional, and this field is disabled, because the question is Admin-Only.', |
|
455 | + 'event_espresso' |
|
456 | + ) ?> |
|
457 | 457 | </span |
458 | 458 | </p> |
459 | 459 | <p> |
460 | 460 | <span id="required_toggled_off" class="description" style="color:#D54E21; display: none;"> |
461 | 461 | <?php esc_html_e( |
462 | - 'Required option field is no longer disabled because the question is not Admin-Only', |
|
463 | - 'event_espresso' |
|
464 | - ) ?> |
|
462 | + 'Required option field is no longer disabled because the question is not Admin-Only', |
|
463 | + 'event_espresso' |
|
464 | + ) ?> |
|
465 | 465 | </span> |
466 | 466 | </p> |
467 | 467 | <?php if (! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?> |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | </td> |
495 | 495 | </tr> |
496 | 496 | <?php |
497 | - do_action('AHEE__questions_main_meta_box__template__after_table_form_table', $question); |
|
498 | - ?> |
|
497 | + do_action('AHEE__questions_main_meta_box__template__after_table_form_table', $question); |
|
498 | + ?> |
|
499 | 499 | </tbody> |
500 | 500 | </table> |
501 | 501 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | assert($question_group); |
12 | 12 | assert($question_group instanceof EE_Question_Group); |
13 | 13 | /* @var EE_Question[] $all_questions */ |
14 | -assert(isset($all_questions) && (empty($all_questions) || is_array($all_questions)));// list of unused questions |
|
14 | +assert(isset($all_questions) && (empty($all_questions) || is_array($all_questions))); // list of unused questions |
|
15 | 15 | foreach ($all_questions as $unused_question) { |
16 | 16 | assert($unused_question); |
17 | 17 | assert($unused_question instanceof EE_Question); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | <input id="QSG_identifier" name="QSG_identifier<?php echo esc_attr($id); ?>" |
57 | 57 | value="<?php echo esc_attr($question_group->get_f('QSG_identifier')); ?>" type="text" |
58 | 58 | class="regular-text" <?php echo esc_attr($disabled); ?>> |
59 | - <?php if (! empty($QSG_system)) { ?> |
|
59 | + <?php if ( ! empty($QSG_system)) { ?> |
|
60 | 60 | <p><span class="description" style="color:#D54E21;"> |
61 | 61 | <?php esc_html_e('System question group! This field cannot be changed.', 'event_espresso') ?> |
62 | 62 | </span><br/></p> |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | foreach ($all_questions as $question_ID => $question) { |
158 | 158 | if ($question instanceof EE_Question) { |
159 | 159 | /*@var $question EE_Question*/ |
160 | - $checked = isset($question_group_questions[ $question_ID ]) ? 'checked' : ''; |
|
160 | + $checked = isset($question_group_questions[$question_ID]) ? 'checked' : ''; |
|
161 | 161 | // disable questions from the personal information question group |
162 | 162 | // is it required in the current question group? if so don't allow admins to remove it |
163 | 163 | $disabled = in_array( |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | ); |
210 | 210 | $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL); |
211 | 211 | |
212 | - echo '<a href="' . $edit_link . '" target="_blank" title="' . |
|
212 | + echo '<a href="'.$edit_link.'" target="_blank" title="'. |
|
213 | 213 | sprintf( |
214 | 214 | esc_attr__('Edit %s', 'event_espresso'), |
215 | 215 | $question->admin_label() |
@@ -15,1442 +15,1442 @@ |
||
15 | 15 | class Extend_Registration_Form_Admin_Page extends Registration_Form_Admin_Page |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
20 | - */ |
|
21 | - public function __construct($routing = true) |
|
22 | - { |
|
23 | - define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/'); |
|
24 | - define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/'); |
|
25 | - define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
26 | - define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/'); |
|
27 | - define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
28 | - parent::__construct($routing); |
|
29 | - } |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @return void |
|
34 | - */ |
|
35 | - protected function _extend_page_config() |
|
36 | - { |
|
37 | - $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
38 | - $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) |
|
39 | - ? $this->_req_data['QST_ID'] : 0; |
|
40 | - $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) |
|
41 | - ? $this->_req_data['QSG_ID'] : 0; |
|
42 | - |
|
43 | - $new_page_routes = array( |
|
44 | - 'question_groups' => array( |
|
45 | - 'func' => '_question_groups_overview_list_table', |
|
46 | - 'capability' => 'ee_read_question_groups', |
|
47 | - ), |
|
48 | - 'add_question' => array( |
|
49 | - 'func' => '_edit_question', |
|
50 | - 'capability' => 'ee_edit_questions', |
|
51 | - ), |
|
52 | - 'insert_question' => array( |
|
53 | - 'func' => '_insert_or_update_question', |
|
54 | - 'args' => array('new_question' => true), |
|
55 | - 'capability' => 'ee_edit_questions', |
|
56 | - 'noheader' => true, |
|
57 | - ), |
|
58 | - 'duplicate_question' => array( |
|
59 | - 'func' => '_duplicate_question', |
|
60 | - 'capability' => 'ee_edit_questions', |
|
61 | - 'noheader' => true, |
|
62 | - ), |
|
63 | - 'trash_question' => array( |
|
64 | - 'func' => '_trash_question', |
|
65 | - 'capability' => 'ee_delete_question', |
|
66 | - 'obj_id' => $qst_id, |
|
67 | - 'noheader' => true, |
|
68 | - ), |
|
69 | - |
|
70 | - 'restore_question' => array( |
|
71 | - 'func' => '_trash_or_restore_questions', |
|
72 | - 'capability' => 'ee_delete_question', |
|
73 | - 'obj_id' => $qst_id, |
|
74 | - 'args' => array('trash' => false), |
|
75 | - 'noheader' => true, |
|
76 | - ), |
|
77 | - |
|
78 | - 'delete_question' => array( |
|
79 | - 'func' => '_delete_question', |
|
80 | - 'capability' => 'ee_delete_question', |
|
81 | - 'obj_id' => $qst_id, |
|
82 | - 'noheader' => true, |
|
83 | - ), |
|
84 | - |
|
85 | - 'trash_questions' => array( |
|
86 | - 'func' => '_trash_or_restore_questions', |
|
87 | - 'capability' => 'ee_delete_questions', |
|
88 | - 'args' => array('trash' => true), |
|
89 | - 'noheader' => true, |
|
90 | - ), |
|
91 | - |
|
92 | - 'restore_questions' => array( |
|
93 | - 'func' => '_trash_or_restore_questions', |
|
94 | - 'capability' => 'ee_delete_questions', |
|
95 | - 'args' => array('trash' => false), |
|
96 | - 'noheader' => true, |
|
97 | - ), |
|
98 | - |
|
99 | - 'delete_questions' => array( |
|
100 | - 'func' => '_delete_questions', |
|
101 | - 'args' => array(), |
|
102 | - 'capability' => 'ee_delete_questions', |
|
103 | - 'noheader' => true, |
|
104 | - ), |
|
105 | - |
|
106 | - 'add_question_group' => array( |
|
107 | - 'func' => '_edit_question_group', |
|
108 | - 'capability' => 'ee_edit_question_groups', |
|
109 | - ), |
|
110 | - |
|
111 | - 'edit_question_group' => array( |
|
112 | - 'func' => '_edit_question_group', |
|
113 | - 'capability' => 'ee_edit_question_group', |
|
114 | - 'obj_id' => $qsg_id, |
|
115 | - 'args' => array('edit'), |
|
116 | - ), |
|
117 | - |
|
118 | - 'delete_question_groups' => array( |
|
119 | - 'func' => '_delete_question_groups', |
|
120 | - 'capability' => 'ee_delete_question_groups', |
|
121 | - 'noheader' => true, |
|
122 | - ), |
|
123 | - |
|
124 | - 'delete_question_group' => array( |
|
125 | - 'func' => '_delete_question_groups', |
|
126 | - 'capability' => 'ee_delete_question_group', |
|
127 | - 'obj_id' => $qsg_id, |
|
128 | - 'noheader' => true, |
|
129 | - ), |
|
130 | - |
|
131 | - 'trash_question_group' => array( |
|
132 | - 'func' => '_trash_or_restore_question_groups', |
|
133 | - 'args' => array('trash' => true), |
|
134 | - 'capability' => 'ee_delete_question_group', |
|
135 | - 'obj_id' => $qsg_id, |
|
136 | - 'noheader' => true, |
|
137 | - ), |
|
138 | - |
|
139 | - 'restore_question_group' => array( |
|
140 | - 'func' => '_trash_or_restore_question_groups', |
|
141 | - 'args' => array('trash' => false), |
|
142 | - 'capability' => 'ee_delete_question_group', |
|
143 | - 'obj_id' => $qsg_id, |
|
144 | - 'noheader' => true, |
|
145 | - ), |
|
146 | - |
|
147 | - 'insert_question_group' => array( |
|
148 | - 'func' => '_insert_or_update_question_group', |
|
149 | - 'args' => array('new_question_group' => true), |
|
150 | - 'capability' => 'ee_edit_question_groups', |
|
151 | - 'noheader' => true, |
|
152 | - ), |
|
153 | - |
|
154 | - 'update_question_group' => array( |
|
155 | - 'func' => '_insert_or_update_question_group', |
|
156 | - 'args' => array('new_question_group' => false), |
|
157 | - 'capability' => 'ee_edit_question_group', |
|
158 | - 'obj_id' => $qsg_id, |
|
159 | - 'noheader' => true, |
|
160 | - ), |
|
161 | - |
|
162 | - 'trash_question_groups' => array( |
|
163 | - 'func' => '_trash_or_restore_question_groups', |
|
164 | - 'args' => array('trash' => true), |
|
165 | - 'capability' => 'ee_delete_question_groups', |
|
166 | - 'noheader' => array('trash' => false), |
|
167 | - ), |
|
168 | - |
|
169 | - 'restore_question_groups' => array( |
|
170 | - 'func' => '_trash_or_restore_question_groups', |
|
171 | - 'args' => array('trash' => false), |
|
172 | - 'capability' => 'ee_delete_question_groups', |
|
173 | - 'noheader' => true, |
|
174 | - ), |
|
175 | - |
|
176 | - |
|
177 | - 'espresso_update_question_group_order' => array( |
|
178 | - 'func' => 'update_question_group_order', |
|
179 | - 'capability' => 'ee_edit_question_groups', |
|
180 | - 'noheader' => true, |
|
181 | - ), |
|
182 | - |
|
183 | - 'view_reg_form_settings' => array( |
|
184 | - 'func' => '_reg_form_settings', |
|
185 | - 'capability' => 'manage_options', |
|
186 | - ), |
|
187 | - |
|
188 | - 'update_reg_form_settings' => array( |
|
189 | - 'func' => '_update_reg_form_settings', |
|
190 | - 'capability' => 'manage_options', |
|
191 | - 'noheader' => true, |
|
192 | - ), |
|
193 | - ); |
|
194 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
195 | - |
|
196 | - $new_page_config = array( |
|
197 | - |
|
198 | - 'question_groups' => array( |
|
199 | - 'nav' => array( |
|
200 | - 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
201 | - 'order' => 20, |
|
202 | - ), |
|
203 | - 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
204 | - 'help_tabs' => array( |
|
205 | - 'registration_form_question_groups_help_tab' => array( |
|
206 | - 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
207 | - 'filename' => 'registration_form_question_groups', |
|
208 | - ), |
|
209 | - 'registration_form_question_groups_table_column_headings_help_tab' => array( |
|
210 | - 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
211 | - 'filename' => 'registration_form_question_groups_table_column_headings', |
|
212 | - ), |
|
213 | - 'registration_form_question_groups_views_bulk_actions_search_help_tab' => array( |
|
214 | - 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
215 | - 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
216 | - ), |
|
217 | - ), |
|
218 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
219 | - 'require_nonce' => false, |
|
220 | - 'qtips' => array( |
|
221 | - 'EE_Registration_Form_Tips', |
|
222 | - ), |
|
223 | - ), |
|
224 | - |
|
225 | - 'add_question' => array( |
|
226 | - 'nav' => array( |
|
227 | - 'label' => esc_html__('Add Question', 'event_espresso'), |
|
228 | - 'order' => 5, |
|
229 | - 'persistent' => false, |
|
230 | - ), |
|
231 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
232 | - 'help_tabs' => array( |
|
233 | - 'registration_form_add_question_help_tab' => array( |
|
234 | - 'title' => esc_html__('Add Question', 'event_espresso'), |
|
235 | - 'filename' => 'registration_form_add_question', |
|
236 | - ), |
|
237 | - ), |
|
238 | - 'require_nonce' => false, |
|
239 | - ), |
|
240 | - |
|
241 | - 'add_question_group' => array( |
|
242 | - 'nav' => array( |
|
243 | - 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
244 | - 'order' => 5, |
|
245 | - 'persistent' => false, |
|
246 | - ), |
|
247 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
248 | - 'help_tabs' => array( |
|
249 | - 'registration_form_add_question_group_help_tab' => array( |
|
250 | - 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
251 | - 'filename' => 'registration_form_add_question_group', |
|
252 | - ), |
|
253 | - ), |
|
254 | - 'require_nonce' => false, |
|
255 | - ), |
|
256 | - |
|
257 | - 'edit_question_group' => array( |
|
258 | - 'nav' => array( |
|
259 | - 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
260 | - 'order' => 5, |
|
261 | - 'persistent' => false, |
|
262 | - 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg( |
|
263 | - array('question_group_id' => $this->_req_data['question_group_id']), |
|
264 | - $this->_current_page_view_url |
|
265 | - ) : $this->_admin_base_url, |
|
266 | - ), |
|
267 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
268 | - 'help_tabs' => array( |
|
269 | - 'registration_form_edit_question_group_help_tab' => array( |
|
270 | - 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
271 | - 'filename' => 'registration_form_edit_question_group', |
|
272 | - ), |
|
273 | - ), |
|
274 | - 'require_nonce' => false, |
|
275 | - ), |
|
276 | - |
|
277 | - 'view_reg_form_settings' => array( |
|
278 | - 'nav' => array( |
|
279 | - 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
280 | - 'order' => 40, |
|
281 | - ), |
|
282 | - 'labels' => array( |
|
283 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
284 | - ), |
|
285 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
286 | - 'help_tabs' => array( |
|
287 | - 'registration_form_reg_form_settings_help_tab' => array( |
|
288 | - 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
289 | - 'filename' => 'registration_form_reg_form_settings', |
|
290 | - ), |
|
291 | - ), |
|
292 | - 'require_nonce' => false, |
|
293 | - ), |
|
294 | - |
|
295 | - ); |
|
296 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
297 | - |
|
298 | - // change the list table we're going to use so it's the NEW list table! |
|
299 | - $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
300 | - |
|
301 | - |
|
302 | - // additional labels |
|
303 | - $new_labels = array( |
|
304 | - 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
305 | - 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
306 | - 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
307 | - 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
308 | - 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
309 | - ); |
|
310 | - $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - /** |
|
315 | - * @return void |
|
316 | - */ |
|
317 | - protected function _ajax_hooks() |
|
318 | - { |
|
319 | - add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * @return void |
|
325 | - */ |
|
326 | - public function load_scripts_styles_question_groups() |
|
327 | - { |
|
328 | - wp_enqueue_script('espresso_ajax_table_sorting'); |
|
329 | - } |
|
330 | - |
|
331 | - |
|
332 | - /** |
|
333 | - * @return void |
|
334 | - */ |
|
335 | - public function load_scripts_styles_add_question_group() |
|
336 | - { |
|
337 | - $this->load_scripts_styles_forms(); |
|
338 | - $this->load_sortable_question_script(); |
|
339 | - } |
|
340 | - |
|
341 | - |
|
342 | - /** |
|
343 | - * @return void |
|
344 | - */ |
|
345 | - public function load_scripts_styles_edit_question_group() |
|
346 | - { |
|
347 | - $this->load_scripts_styles_forms(); |
|
348 | - $this->load_sortable_question_script(); |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * registers and enqueues script for questions |
|
354 | - * |
|
355 | - * @return void |
|
356 | - */ |
|
357 | - public function load_sortable_question_script() |
|
358 | - { |
|
359 | - wp_register_script( |
|
360 | - 'ee-question-sortable', |
|
361 | - REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
362 | - array('jquery-ui-sortable'), |
|
363 | - EVENT_ESPRESSO_VERSION, |
|
364 | - true |
|
365 | - ); |
|
366 | - wp_enqueue_script('ee-question-sortable'); |
|
367 | - } |
|
368 | - |
|
369 | - |
|
370 | - /** |
|
371 | - * @return void |
|
372 | - */ |
|
373 | - protected function _set_list_table_views_default() |
|
374 | - { |
|
375 | - $this->_views = array( |
|
376 | - 'all' => array( |
|
377 | - 'slug' => 'all', |
|
378 | - 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
379 | - 'count' => 0, |
|
380 | - 'bulk_action' => array( |
|
381 | - 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
382 | - ), |
|
383 | - ), |
|
384 | - ); |
|
385 | - |
|
386 | - if ( |
|
387 | - EE_Registry::instance()->CAP->current_user_can( |
|
388 | - 'ee_delete_questions', |
|
389 | - 'espresso_registration_form_trash_questions' |
|
390 | - ) |
|
391 | - ) { |
|
392 | - $this->_views['trash'] = array( |
|
393 | - 'slug' => 'trash', |
|
394 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
395 | - 'count' => 0, |
|
396 | - 'bulk_action' => array( |
|
397 | - 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
398 | - 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
399 | - ), |
|
400 | - ); |
|
401 | - } |
|
402 | - } |
|
403 | - |
|
404 | - |
|
405 | - /** |
|
406 | - * @return void |
|
407 | - */ |
|
408 | - protected function _set_list_table_views_question_groups() |
|
409 | - { |
|
410 | - $this->_views = array( |
|
411 | - 'all' => array( |
|
412 | - 'slug' => 'all', |
|
413 | - 'label' => esc_html__('All', 'event_espresso'), |
|
414 | - 'count' => 0, |
|
415 | - 'bulk_action' => array( |
|
416 | - 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
417 | - ), |
|
418 | - ), |
|
419 | - ); |
|
420 | - |
|
421 | - if ( |
|
422 | - EE_Registry::instance()->CAP->current_user_can( |
|
423 | - 'ee_delete_question_groups', |
|
424 | - 'espresso_registration_form_trash_question_groups' |
|
425 | - ) |
|
426 | - ) { |
|
427 | - $this->_views['trash'] = array( |
|
428 | - 'slug' => 'trash', |
|
429 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
430 | - 'count' => 0, |
|
431 | - 'bulk_action' => array( |
|
432 | - 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
433 | - 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
434 | - ), |
|
435 | - ); |
|
436 | - } |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * @return void |
|
442 | - * @throws EE_Error |
|
443 | - * @throws InvalidArgumentException |
|
444 | - * @throws InvalidDataTypeException |
|
445 | - * @throws InvalidInterfaceException |
|
446 | - */ |
|
447 | - protected function _questions_overview_list_table() |
|
448 | - { |
|
449 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
450 | - 'add_question', |
|
451 | - 'add_question', |
|
452 | - array(), |
|
453 | - 'add-new-h2' |
|
454 | - ); |
|
455 | - parent::_questions_overview_list_table(); |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - /** |
|
460 | - * @return void |
|
461 | - * @throws DomainException |
|
462 | - * @throws EE_Error |
|
463 | - * @throws InvalidArgumentException |
|
464 | - * @throws InvalidDataTypeException |
|
465 | - * @throws InvalidInterfaceException |
|
466 | - */ |
|
467 | - protected function _question_groups_overview_list_table() |
|
468 | - { |
|
469 | - $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
470 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
471 | - 'add_question_group', |
|
472 | - 'add_question_group', |
|
473 | - array(), |
|
474 | - 'add-new-h2' |
|
475 | - ); |
|
476 | - $this->display_admin_list_table_page_with_sidebar(); |
|
477 | - } |
|
478 | - |
|
479 | - |
|
480 | - /** |
|
481 | - * @return void |
|
482 | - * @throws EE_Error |
|
483 | - * @throws InvalidArgumentException |
|
484 | - * @throws InvalidDataTypeException |
|
485 | - * @throws InvalidInterfaceException |
|
486 | - */ |
|
487 | - protected function _delete_question() |
|
488 | - { |
|
489 | - $success = $this->_delete_items($this->_question_model); |
|
490 | - $this->_redirect_after_action( |
|
491 | - $success, |
|
492 | - $this->_question_model->item_name($success), |
|
493 | - 'deleted', |
|
494 | - array('action' => 'default', 'status' => 'all') |
|
495 | - ); |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - /** |
|
500 | - * @return void |
|
501 | - * @throws EE_Error |
|
502 | - * @throws InvalidArgumentException |
|
503 | - * @throws InvalidDataTypeException |
|
504 | - * @throws InvalidInterfaceException |
|
505 | - */ |
|
506 | - protected function _delete_questions() |
|
507 | - { |
|
508 | - $success = $this->_delete_items($this->_question_model); |
|
509 | - $this->_redirect_after_action( |
|
510 | - $success, |
|
511 | - $this->_question_model->item_name($success), |
|
512 | - 'deleted permanently', |
|
513 | - array('action' => 'default', 'status' => 'trash') |
|
514 | - ); |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /** |
|
519 | - * Performs the deletion of a single or multiple questions or question groups. |
|
520 | - * |
|
521 | - * @param EEM_Soft_Delete_Base $model |
|
522 | - * @return int number of items deleted permanently |
|
523 | - * @throws EE_Error |
|
524 | - * @throws InvalidArgumentException |
|
525 | - * @throws InvalidDataTypeException |
|
526 | - * @throws InvalidInterfaceException |
|
527 | - */ |
|
528 | - private function _delete_items(EEM_Soft_Delete_Base $model) |
|
529 | - { |
|
530 | - $success = 0; |
|
531 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
532 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
533 | - // if array has more than one element than success message should be plural |
|
534 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
535 | - // cycle thru bulk action checkboxes |
|
536 | - while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
537 | - if (! $this->_delete_item($ID, $model)) { |
|
538 | - $success = 0; |
|
539 | - } |
|
540 | - } |
|
541 | - } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
542 | - $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
543 | - } elseif (! empty($this->_req_data['QST_ID'])) { |
|
544 | - $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
545 | - } else { |
|
546 | - EE_Error::add_error( |
|
547 | - sprintf( |
|
548 | - esc_html__( |
|
549 | - "No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", |
|
550 | - "event_espresso" |
|
551 | - ) |
|
552 | - ), |
|
553 | - __FILE__, |
|
554 | - __FUNCTION__, |
|
555 | - __LINE__ |
|
556 | - ); |
|
557 | - } |
|
558 | - return $success; |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - /** |
|
563 | - * Deletes the specified question (and its associated question options) or question group |
|
564 | - * |
|
565 | - * @param int $id |
|
566 | - * @param EEM_Soft_Delete_Base $model |
|
567 | - * @return boolean |
|
568 | - * @throws EE_Error |
|
569 | - * @throws InvalidArgumentException |
|
570 | - * @throws InvalidDataTypeException |
|
571 | - * @throws InvalidInterfaceException |
|
572 | - */ |
|
573 | - protected function _delete_item($id, $model) |
|
574 | - { |
|
575 | - if ($model instanceof EEM_Question) { |
|
576 | - EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
577 | - } |
|
578 | - return $model->delete_permanently_by_ID(absint($id)); |
|
579 | - } |
|
580 | - |
|
581 | - |
|
582 | - /****************************** QUESTION GROUPS ******************************/ |
|
583 | - |
|
584 | - |
|
585 | - /** |
|
586 | - * @param string $type |
|
587 | - * @return void |
|
588 | - * @throws DomainException |
|
589 | - * @throws EE_Error |
|
590 | - * @throws InvalidArgumentException |
|
591 | - * @throws InvalidDataTypeException |
|
592 | - * @throws InvalidInterfaceException |
|
593 | - */ |
|
594 | - protected function _edit_question_group($type = 'add') |
|
595 | - { |
|
596 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
597 | - $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) |
|
598 | - ? absint($this->_req_data['QSG_ID']) |
|
599 | - : false; |
|
600 | - |
|
601 | - switch ($this->_req_action) { |
|
602 | - case 'add_question_group': |
|
603 | - $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
604 | - break; |
|
605 | - case 'edit_question_group': |
|
606 | - $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
607 | - break; |
|
608 | - default: |
|
609 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
610 | - } |
|
611 | - // add ID to title if editing |
|
612 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
613 | - if ($ID) { |
|
614 | - /** @var EE_Question_Group $questionGroup */ |
|
615 | - $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
616 | - $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
617 | - $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
618 | - } else { |
|
619 | - /** @var EE_Question_Group $questionGroup */ |
|
620 | - $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
621 | - $questionGroup->set_order_to_latest(); |
|
622 | - $this->_set_add_edit_form_tags('insert_question_group'); |
|
623 | - } |
|
624 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
625 | - $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
626 | - $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
627 | - $this->_template_args['question_group'] = $questionGroup; |
|
628 | - |
|
629 | - $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
630 | - $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
|
631 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
632 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
633 | - $this->_template_args, |
|
634 | - true |
|
635 | - ); |
|
636 | - |
|
637 | - // the details template wrapper |
|
638 | - $this->display_admin_page_with_sidebar(); |
|
639 | - } |
|
640 | - |
|
641 | - |
|
642 | - /** |
|
643 | - * @return void |
|
644 | - * @throws EE_Error |
|
645 | - * @throws InvalidArgumentException |
|
646 | - * @throws InvalidDataTypeException |
|
647 | - * @throws InvalidInterfaceException |
|
648 | - */ |
|
649 | - protected function _delete_question_groups() |
|
650 | - { |
|
651 | - $success = $this->_delete_items($this->_question_group_model); |
|
652 | - $this->_redirect_after_action( |
|
653 | - $success, |
|
654 | - $this->_question_group_model->item_name($success), |
|
655 | - 'deleted permanently', |
|
656 | - array('action' => 'question_groups', 'status' => 'trash') |
|
657 | - ); |
|
658 | - } |
|
659 | - |
|
660 | - |
|
661 | - /** |
|
662 | - * @param bool $new_question_group |
|
663 | - * @throws EE_Error |
|
664 | - * @throws InvalidArgumentException |
|
665 | - * @throws InvalidDataTypeException |
|
666 | - * @throws InvalidInterfaceException |
|
667 | - */ |
|
668 | - protected function _insert_or_update_question_group($new_question_group = true) |
|
669 | - { |
|
670 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
671 | - $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
672 | - |
|
673 | - // make sure identifier is unique |
|
674 | - $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : ''; |
|
675 | - $where_values = ['QSG_identifier' => $set_column_values['QSG_identifier']]; |
|
676 | - if (! $new_question_group && isset($set_column_values['QSG_ID'])) { |
|
677 | - $where_values['QSG_ID'] = ['!=', $set_column_values['QSG_ID']]; |
|
678 | - } |
|
679 | - $identifier_exists = ! empty($identifier_value) |
|
680 | - ? $this->_question_group_model->count([$where_values]) > 0 |
|
681 | - : false; |
|
682 | - if ($identifier_exists) { |
|
683 | - $set_column_values['QSG_identifier'] .= uniqid('id', true); |
|
684 | - } |
|
685 | - |
|
686 | - if ($new_question_group) { |
|
687 | - $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
688 | - $success = $QSG_ID ? 1 : 0; |
|
689 | - if ($success === 0) { |
|
690 | - EE_Error::add_error( |
|
691 | - esc_html__('Something went wrong saving the question group.', 'event_espresso'), |
|
692 | - __FILE__, |
|
693 | - __FUNCTION__, |
|
694 | - __LINE__ |
|
695 | - ); |
|
696 | - $this->_redirect_after_action( |
|
697 | - false, |
|
698 | - '', |
|
699 | - '', |
|
700 | - array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
701 | - true |
|
702 | - ); |
|
703 | - } |
|
704 | - } else { |
|
705 | - $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
706 | - unset($set_column_values['QSG_ID']); |
|
707 | - $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
708 | - } |
|
709 | - |
|
710 | - $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( |
|
711 | - EEM_Attendee::system_question_phone |
|
712 | - ); |
|
713 | - // update the existing related questions |
|
714 | - // BUT FIRST... delete the phone question from the Question_Group_Question |
|
715 | - // if it is being added to this question group (therefore removed from the existing group) |
|
716 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
717 | - // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
718 | - EEM_Question_Group_Question::instance()->delete( |
|
719 | - array( |
|
720 | - array( |
|
721 | - 'QST_ID' => $phone_question_id, |
|
722 | - 'QSG_ID' => array('!=', $QSG_ID), |
|
723 | - ), |
|
724 | - ) |
|
725 | - ); |
|
726 | - } |
|
727 | - /** @type EE_Question_Group $question_group */ |
|
728 | - $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
729 | - $questions = $question_group->questions(); |
|
730 | - // make sure system phone question is added to list of questions for this group |
|
731 | - if (! isset($questions[ $phone_question_id ])) { |
|
732 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
733 | - } |
|
734 | - |
|
735 | - foreach ($questions as $question_ID => $question) { |
|
736 | - // first we always check for order. |
|
737 | - if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
738 | - // update question order |
|
739 | - $question_group->update_question_order( |
|
740 | - $question_ID, |
|
741 | - $this->_req_data['question_orders'][ $question_ID ] |
|
742 | - ); |
|
743 | - } |
|
744 | - |
|
745 | - // then we always check if adding or removing. |
|
746 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
747 | - $question_group->add_question($question_ID); |
|
748 | - } else { |
|
749 | - // not found, remove it (but only if not a system question for the personal group |
|
750 | - // with the exception of lname system question - we allow removal of it) |
|
751 | - if ( |
|
752 | - in_array( |
|
753 | - $question->system_ID(), |
|
754 | - EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
755 | - $question_group->system_group() |
|
756 | - ) |
|
757 | - ) |
|
758 | - ) { |
|
759 | - continue; |
|
760 | - } else { |
|
761 | - $question_group->remove_question($question_ID); |
|
762 | - } |
|
763 | - } |
|
764 | - } |
|
765 | - // save new related questions |
|
766 | - if (isset($this->_req_data['questions'])) { |
|
767 | - foreach ($this->_req_data['questions'] as $QST_ID) { |
|
768 | - $question_group->add_question($QST_ID); |
|
769 | - if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
770 | - $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
771 | - } |
|
772 | - } |
|
773 | - } |
|
774 | - |
|
775 | - if ($success !== false) { |
|
776 | - $msg = $new_question_group |
|
777 | - ? sprintf( |
|
778 | - esc_html__('The %s has been created', 'event_espresso'), |
|
779 | - $this->_question_group_model->item_name() |
|
780 | - ) |
|
781 | - : sprintf( |
|
782 | - esc_html__( |
|
783 | - 'The %s has been updated', |
|
784 | - 'event_espresso' |
|
785 | - ), |
|
786 | - $this->_question_group_model->item_name() |
|
787 | - ); |
|
788 | - EE_Error::add_success($msg); |
|
789 | - } |
|
790 | - $this->_redirect_after_action( |
|
791 | - false, |
|
792 | - '', |
|
793 | - '', |
|
794 | - array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
795 | - true |
|
796 | - ); |
|
797 | - } |
|
798 | - |
|
799 | - |
|
800 | - /** |
|
801 | - * duplicates a question and all its question options and redirects to the new question. |
|
802 | - * |
|
803 | - * @return void |
|
804 | - * @throws EE_Error |
|
805 | - * @throws InvalidArgumentException |
|
806 | - * @throws ReflectionException |
|
807 | - * @throws InvalidDataTypeException |
|
808 | - * @throws InvalidInterfaceException |
|
809 | - */ |
|
810 | - public function _duplicate_question() |
|
811 | - { |
|
812 | - $question_ID = (int) $this->_req_data['QST_ID']; |
|
813 | - $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
814 | - if ($question instanceof EE_Question) { |
|
815 | - $new_question = $question->duplicate(); |
|
816 | - if ($new_question instanceof EE_Question) { |
|
817 | - $this->_redirect_after_action( |
|
818 | - true, |
|
819 | - esc_html__('Question', 'event_espresso'), |
|
820 | - esc_html__('Duplicated', 'event_espresso'), |
|
821 | - array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), |
|
822 | - true |
|
823 | - ); |
|
824 | - } else { |
|
825 | - global $wpdb; |
|
826 | - EE_Error::add_error( |
|
827 | - sprintf( |
|
828 | - esc_html__( |
|
829 | - 'Could not duplicate question with ID %1$d because: %2$s', |
|
830 | - 'event_espresso' |
|
831 | - ), |
|
832 | - $question_ID, |
|
833 | - $wpdb->last_error |
|
834 | - ), |
|
835 | - __FILE__, |
|
836 | - __FUNCTION__, |
|
837 | - __LINE__ |
|
838 | - ); |
|
839 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
840 | - } |
|
841 | - } else { |
|
842 | - EE_Error::add_error( |
|
843 | - sprintf( |
|
844 | - esc_html__( |
|
845 | - 'Could not duplicate question with ID %d because it didn\'t exist!', |
|
846 | - 'event_espresso' |
|
847 | - ), |
|
848 | - $question_ID |
|
849 | - ), |
|
850 | - __FILE__, |
|
851 | - __FUNCTION__, |
|
852 | - __LINE__ |
|
853 | - ); |
|
854 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
855 | - } |
|
856 | - } |
|
857 | - |
|
858 | - |
|
859 | - /** |
|
860 | - * @param bool $trash |
|
861 | - * @throws EE_Error |
|
862 | - */ |
|
863 | - protected function _trash_or_restore_question_groups($trash = true) |
|
864 | - { |
|
865 | - $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
866 | - } |
|
867 | - |
|
868 | - |
|
869 | - /** |
|
870 | - *_trash_question |
|
871 | - * |
|
872 | - * @return void |
|
873 | - * @throws EE_Error |
|
874 | - */ |
|
875 | - protected function _trash_question() |
|
876 | - { |
|
877 | - $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
878 | - $query_args = array('action' => 'default', 'status' => 'all'); |
|
879 | - $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
880 | - } |
|
881 | - |
|
882 | - |
|
883 | - /** |
|
884 | - * @param bool $trash |
|
885 | - * @throws EE_Error |
|
886 | - */ |
|
887 | - protected function _trash_or_restore_questions($trash = true) |
|
888 | - { |
|
889 | - $this->_trash_or_restore_items($this->_question_model, $trash); |
|
890 | - } |
|
891 | - |
|
892 | - |
|
893 | - /** |
|
894 | - * Internally used to delete or restore items, using the request data. Meant to be |
|
895 | - * flexible between question or question groups |
|
896 | - * |
|
897 | - * @param EEM_Soft_Delete_Base $model |
|
898 | - * @param boolean $trash whether to trash or restore |
|
899 | - * @throws EE_Error |
|
900 | - */ |
|
901 | - private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
902 | - { |
|
903 | - |
|
904 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
905 | - |
|
906 | - $success = 1; |
|
907 | - // Checkboxes |
|
908 | - // echo "trash $trash"; |
|
909 | - // var_dump($this->_req_data['checkbox']);die; |
|
910 | - if (isset($this->_req_data['checkbox'])) { |
|
911 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
912 | - // if array has more than one element than success message should be plural |
|
913 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
914 | - // cycle thru bulk action checkboxes |
|
915 | - while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
916 | - if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
917 | - $success = 0; |
|
918 | - } |
|
919 | - } |
|
920 | - } else { |
|
921 | - // grab single id and delete |
|
922 | - $ID = absint($this->_req_data['checkbox']); |
|
923 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
924 | - $success = 0; |
|
925 | - } |
|
926 | - } |
|
927 | - } else { |
|
928 | - // delete via trash link |
|
929 | - // grab single id and delete |
|
930 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
931 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
932 | - $success = 0; |
|
933 | - } |
|
934 | - } |
|
935 | - |
|
936 | - |
|
937 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
938 | - // echo "action :$action"; |
|
939 | - // $action = 'questions' ? 'default' : $action; |
|
940 | - if ($trash) { |
|
941 | - $action_desc = 'trashed'; |
|
942 | - $status = 'trash'; |
|
943 | - } else { |
|
944 | - $action_desc = 'restored'; |
|
945 | - $status = 'all'; |
|
946 | - } |
|
947 | - $this->_redirect_after_action( |
|
948 | - $success, |
|
949 | - $model->item_name($success), |
|
950 | - $action_desc, |
|
951 | - array('action' => $action, 'status' => $status) |
|
952 | - ); |
|
953 | - } |
|
954 | - |
|
955 | - |
|
956 | - /** |
|
957 | - * @param $per_page |
|
958 | - * @param int $current_page |
|
959 | - * @param bool|false $count |
|
960 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
961 | - * @throws EE_Error |
|
962 | - * @throws InvalidArgumentException |
|
963 | - * @throws InvalidDataTypeException |
|
964 | - * @throws InvalidInterfaceException |
|
965 | - */ |
|
966 | - public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
967 | - { |
|
968 | - $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
969 | - |
|
970 | - if ($count) { |
|
971 | - // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
972 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
973 | - $results = $this->_question_model->count_deleted($where); |
|
974 | - } else { |
|
975 | - // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
976 | - $results = $this->_question_model->get_all_deleted($query_params); |
|
977 | - } |
|
978 | - return $results; |
|
979 | - } |
|
980 | - |
|
981 | - |
|
982 | - /** |
|
983 | - * @param $per_page |
|
984 | - * @param int $current_page |
|
985 | - * @param bool|false $count |
|
986 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
987 | - * @throws EE_Error |
|
988 | - * @throws InvalidArgumentException |
|
989 | - * @throws InvalidDataTypeException |
|
990 | - * @throws InvalidInterfaceException |
|
991 | - */ |
|
992 | - public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
993 | - { |
|
994 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
995 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
996 | - if ($count) { |
|
997 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
998 | - $results = $questionGroupModel->count($where); |
|
999 | - } else { |
|
1000 | - $results = $questionGroupModel->get_all($query_params); |
|
1001 | - } |
|
1002 | - return $results; |
|
1003 | - } |
|
1004 | - |
|
1005 | - |
|
1006 | - /** |
|
1007 | - * @param $per_page |
|
1008 | - * @param int $current_page |
|
1009 | - * @param bool $count |
|
1010 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
1011 | - * @throws EE_Error |
|
1012 | - * @throws InvalidArgumentException |
|
1013 | - * @throws InvalidDataTypeException |
|
1014 | - * @throws InvalidInterfaceException |
|
1015 | - */ |
|
1016 | - public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
1017 | - { |
|
1018 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
1019 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1020 | - if ($count) { |
|
1021 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
1022 | - $query_params['limit'] = null; |
|
1023 | - $results = $questionGroupModel->count_deleted($where); |
|
1024 | - } else { |
|
1025 | - $results = $questionGroupModel->get_all_deleted($query_params); |
|
1026 | - } |
|
1027 | - return $results; |
|
1028 | - } |
|
1029 | - |
|
1030 | - |
|
1031 | - /** |
|
1032 | - * method for performing updates to question order |
|
1033 | - * |
|
1034 | - * @return void results array |
|
1035 | - * @throws EE_Error |
|
1036 | - * @throws InvalidArgumentException |
|
1037 | - * @throws InvalidDataTypeException |
|
1038 | - * @throws InvalidInterfaceException |
|
1039 | - */ |
|
1040 | - public function update_question_group_order() |
|
1041 | - { |
|
1042 | - |
|
1043 | - $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
1044 | - |
|
1045 | - // grab our row IDs |
|
1046 | - $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
1047 | - ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
1048 | - : array(); |
|
1049 | - |
|
1050 | - $perpage = ! empty($this->_req_data['perpage']) |
|
1051 | - ? (int) $this->_req_data['perpage'] |
|
1052 | - : null; |
|
1053 | - $curpage = ! empty($this->_req_data['curpage']) |
|
1054 | - ? (int) $this->_req_data['curpage'] |
|
1055 | - : null; |
|
1056 | - |
|
1057 | - if (! empty($row_ids)) { |
|
1058 | - // figure out where we start the row_id count at for the current page. |
|
1059 | - $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
1060 | - |
|
1061 | - $row_count = count($row_ids); |
|
1062 | - for ($i = 0; $i < $row_count; $i++) { |
|
1063 | - // Update the questions when re-ordering |
|
1064 | - $updated = EEM_Question_Group::instance()->update( |
|
1065 | - array('QSG_order' => $qsgcount), |
|
1066 | - array(array('QSG_ID' => $row_ids[ $i ])) |
|
1067 | - ); |
|
1068 | - if ($updated === false) { |
|
1069 | - $success = false; |
|
1070 | - } |
|
1071 | - $qsgcount++; |
|
1072 | - } |
|
1073 | - } else { |
|
1074 | - $success = false; |
|
1075 | - } |
|
1076 | - |
|
1077 | - $errors = ! $success |
|
1078 | - ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
1079 | - : false; |
|
1080 | - |
|
1081 | - echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
1082 | - die(); |
|
1083 | - } |
|
1084 | - |
|
1085 | - |
|
1086 | - |
|
1087 | - /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
1088 | - |
|
1089 | - |
|
1090 | - /** |
|
1091 | - * @throws DomainException |
|
1092 | - * @throws EE_Error |
|
1093 | - * @throws InvalidArgumentException |
|
1094 | - * @throws InvalidDataTypeException |
|
1095 | - * @throws InvalidInterfaceException |
|
1096 | - */ |
|
1097 | - protected function _reg_form_settings() |
|
1098 | - { |
|
1099 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
1100 | - add_action( |
|
1101 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1102 | - array($this, 'email_validation_settings_form'), |
|
1103 | - 2 |
|
1104 | - ); |
|
1105 | - add_action( |
|
1106 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1107 | - array($this, 'copy_attendee_info_settings_form'), |
|
1108 | - 4 |
|
1109 | - ); |
|
1110 | - $this->_template_args = (array) apply_filters( |
|
1111 | - 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
1112 | - $this->_template_args |
|
1113 | - ); |
|
1114 | - $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
1115 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1116 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1117 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1118 | - $this->_template_args, |
|
1119 | - true |
|
1120 | - ); |
|
1121 | - $this->display_admin_page_with_sidebar(); |
|
1122 | - } |
|
1123 | - |
|
1124 | - |
|
1125 | - /** |
|
1126 | - * @return void |
|
1127 | - * @throws EE_Error |
|
1128 | - * @throws InvalidArgumentException |
|
1129 | - * @throws ReflectionException |
|
1130 | - * @throws InvalidDataTypeException |
|
1131 | - * @throws InvalidInterfaceException |
|
1132 | - */ |
|
1133 | - protected function _update_reg_form_settings() |
|
1134 | - { |
|
1135 | - EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
1136 | - EE_Registry::instance()->CFG->registration |
|
1137 | - ); |
|
1138 | - EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form( |
|
1139 | - EE_Registry::instance()->CFG->registration |
|
1140 | - ); |
|
1141 | - EE_Registry::instance()->CFG->registration = apply_filters( |
|
1142 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
1143 | - EE_Registry::instance()->CFG->registration |
|
1144 | - ); |
|
1145 | - $success = $this->_update_espresso_configuration( |
|
1146 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1147 | - EE_Registry::instance()->CFG, |
|
1148 | - __FILE__, |
|
1149 | - __FUNCTION__, |
|
1150 | - __LINE__ |
|
1151 | - ); |
|
1152 | - $this->_redirect_after_action( |
|
1153 | - $success, |
|
1154 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1155 | - 'updated', |
|
1156 | - array('action' => 'view_reg_form_settings') |
|
1157 | - ); |
|
1158 | - } |
|
1159 | - |
|
1160 | - |
|
1161 | - /** |
|
1162 | - * @return void |
|
1163 | - * @throws EE_Error |
|
1164 | - * @throws InvalidArgumentException |
|
1165 | - * @throws InvalidDataTypeException |
|
1166 | - * @throws InvalidInterfaceException |
|
1167 | - */ |
|
1168 | - public function copy_attendee_info_settings_form() |
|
1169 | - { |
|
1170 | - echo wp_kses($this->_copy_attendee_info_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1171 | - } |
|
1172 | - |
|
1173 | - /** |
|
1174 | - * _copy_attendee_info_settings_form |
|
1175 | - * |
|
1176 | - * @access protected |
|
1177 | - * @return EE_Form_Section_Proper |
|
1178 | - * @throws \EE_Error |
|
1179 | - */ |
|
1180 | - protected function _copy_attendee_info_settings_form() |
|
1181 | - { |
|
1182 | - return new EE_Form_Section_Proper( |
|
1183 | - array( |
|
1184 | - 'name' => 'copy_attendee_info_settings', |
|
1185 | - 'html_id' => 'copy_attendee_info_settings', |
|
1186 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1187 | - 'subsections' => apply_filters( |
|
1188 | - 'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections', |
|
1189 | - array( |
|
1190 | - 'copy_attendee_info_hdr' => new EE_Form_Section_HTML( |
|
1191 | - EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso')) |
|
1192 | - ), |
|
1193 | - 'copy_attendee_info' => new EE_Yes_No_Input( |
|
1194 | - array( |
|
1195 | - 'html_label_text' => esc_html__( |
|
1196 | - 'Allow copy #1 attendee info to extra attendees?', |
|
1197 | - 'event_espresso' |
|
1198 | - ), |
|
1199 | - 'html_help_text' => esc_html__( |
|
1200 | - 'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.', |
|
1201 | - 'event_espresso' |
|
1202 | - ), |
|
1203 | - 'default' => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(), |
|
1204 | - 'required' => false, |
|
1205 | - 'display_html_label_text' => false, |
|
1206 | - ) |
|
1207 | - ), |
|
1208 | - ) |
|
1209 | - ), |
|
1210 | - ) |
|
1211 | - ); |
|
1212 | - } |
|
1213 | - |
|
1214 | - /** |
|
1215 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1216 | - * @return EE_Registration_Config |
|
1217 | - * @throws EE_Error |
|
1218 | - * @throws InvalidArgumentException |
|
1219 | - * @throws ReflectionException |
|
1220 | - * @throws InvalidDataTypeException |
|
1221 | - * @throws InvalidInterfaceException |
|
1222 | - */ |
|
1223 | - public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1224 | - { |
|
1225 | - $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo(); |
|
1226 | - try { |
|
1227 | - $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form(); |
|
1228 | - // if not displaying a form, then check for form submission |
|
1229 | - if ($copy_attendee_info_settings_form->was_submitted()) { |
|
1230 | - // capture form data |
|
1231 | - $copy_attendee_info_settings_form->receive_form_submission(); |
|
1232 | - // validate form data |
|
1233 | - if ($copy_attendee_info_settings_form->is_valid()) { |
|
1234 | - // grab validated data from form |
|
1235 | - $valid_data = $copy_attendee_info_settings_form->valid_data(); |
|
1236 | - if (isset($valid_data['copy_attendee_info'])) { |
|
1237 | - $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']); |
|
1238 | - } else { |
|
1239 | - EE_Error::add_error( |
|
1240 | - esc_html__( |
|
1241 | - 'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.', |
|
1242 | - 'event_espresso' |
|
1243 | - ), |
|
1244 | - __FILE__, |
|
1245 | - __FUNCTION__, |
|
1246 | - __LINE__ |
|
1247 | - ); |
|
1248 | - } |
|
1249 | - } else { |
|
1250 | - if ($copy_attendee_info_settings_form->submission_error_message() !== '') { |
|
1251 | - EE_Error::add_error( |
|
1252 | - $copy_attendee_info_settings_form->submission_error_message(), |
|
1253 | - __FILE__, |
|
1254 | - __FUNCTION__, |
|
1255 | - __LINE__ |
|
1256 | - ); |
|
1257 | - } |
|
1258 | - } |
|
1259 | - } |
|
1260 | - } catch (EE_Error $e) { |
|
1261 | - $e->get_error(); |
|
1262 | - } |
|
1263 | - return $EE_Registration_Config; |
|
1264 | - } |
|
1265 | - |
|
1266 | - |
|
1267 | - /** |
|
1268 | - * @return void |
|
1269 | - * @throws EE_Error |
|
1270 | - * @throws InvalidArgumentException |
|
1271 | - * @throws InvalidDataTypeException |
|
1272 | - * @throws InvalidInterfaceException |
|
1273 | - */ |
|
1274 | - public function email_validation_settings_form() |
|
1275 | - { |
|
1276 | - echo wp_kses($this->_email_validation_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1277 | - } |
|
1278 | - |
|
1279 | - |
|
1280 | - /** |
|
1281 | - * _email_validation_settings_form |
|
1282 | - * |
|
1283 | - * @access protected |
|
1284 | - * @return EE_Form_Section_Proper |
|
1285 | - * @throws \EE_Error |
|
1286 | - */ |
|
1287 | - protected function _email_validation_settings_form() |
|
1288 | - { |
|
1289 | - return new EE_Form_Section_Proper( |
|
1290 | - array( |
|
1291 | - 'name' => 'email_validation_settings', |
|
1292 | - 'html_id' => 'email_validation_settings', |
|
1293 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1294 | - 'subsections' => apply_filters( |
|
1295 | - 'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections', |
|
1296 | - array( |
|
1297 | - 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
1298 | - EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
1299 | - ), |
|
1300 | - 'email_validation_level' => new EE_Select_Input( |
|
1301 | - array( |
|
1302 | - 'basic' => esc_html__('Basic', 'event_espresso'), |
|
1303 | - 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
1304 | - 'i18n' => esc_html__('International', 'event_espresso'), |
|
1305 | - 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
1306 | - ), |
|
1307 | - array( |
|
1308 | - 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
1309 | - . EEH_Template::get_help_tab_link('email_validation_info'), |
|
1310 | - 'html_help_text' => esc_html__( |
|
1311 | - 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', |
|
1312 | - 'event_espresso' |
|
1313 | - ), |
|
1314 | - 'default' => isset( |
|
1315 | - EE_Registry::instance()->CFG->registration->email_validation_level |
|
1316 | - ) |
|
1317 | - ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
1318 | - : 'wp_default', |
|
1319 | - 'required' => false, |
|
1320 | - ) |
|
1321 | - ), |
|
1322 | - ) |
|
1323 | - ), |
|
1324 | - ) |
|
1325 | - ); |
|
1326 | - } |
|
1327 | - |
|
1328 | - |
|
1329 | - /** |
|
1330 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1331 | - * @return EE_Registration_Config |
|
1332 | - * @throws EE_Error |
|
1333 | - * @throws InvalidArgumentException |
|
1334 | - * @throws ReflectionException |
|
1335 | - * @throws InvalidDataTypeException |
|
1336 | - * @throws InvalidInterfaceException |
|
1337 | - */ |
|
1338 | - public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1339 | - { |
|
1340 | - $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1341 | - try { |
|
1342 | - $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1343 | - // if not displaying a form, then check for form submission |
|
1344 | - if ($email_validation_settings_form->was_submitted()) { |
|
1345 | - // capture form data |
|
1346 | - $email_validation_settings_form->receive_form_submission(); |
|
1347 | - // validate form data |
|
1348 | - if ($email_validation_settings_form->is_valid()) { |
|
1349 | - // grab validated data from form |
|
1350 | - $valid_data = $email_validation_settings_form->valid_data(); |
|
1351 | - if (isset($valid_data['email_validation_level'])) { |
|
1352 | - $email_validation_level = $valid_data['email_validation_level']; |
|
1353 | - // now if they want to use international email addresses |
|
1354 | - if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1355 | - // in case we need to reset their email validation level, |
|
1356 | - // make sure that the previous value wasn't already set to one of the i18n options. |
|
1357 | - if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1358 | - // if so, then reset it back to "basic" since that is the only other option that, |
|
1359 | - // despite offering poor validation, supports i18n email addresses |
|
1360 | - $prev_email_validation_level = 'basic'; |
|
1361 | - } |
|
1362 | - // confirm our i18n email validation will work on the server |
|
1363 | - if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1364 | - // or reset email validation level to previous value |
|
1365 | - $email_validation_level = $prev_email_validation_level; |
|
1366 | - } |
|
1367 | - } |
|
1368 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1369 | - } else { |
|
1370 | - EE_Error::add_error( |
|
1371 | - esc_html__( |
|
1372 | - 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1373 | - 'event_espresso' |
|
1374 | - ), |
|
1375 | - __FILE__, |
|
1376 | - __FUNCTION__, |
|
1377 | - __LINE__ |
|
1378 | - ); |
|
1379 | - } |
|
1380 | - } else { |
|
1381 | - if ($email_validation_settings_form->submission_error_message() !== '') { |
|
1382 | - EE_Error::add_error( |
|
1383 | - $email_validation_settings_form->submission_error_message(), |
|
1384 | - __FILE__, |
|
1385 | - __FUNCTION__, |
|
1386 | - __LINE__ |
|
1387 | - ); |
|
1388 | - } |
|
1389 | - } |
|
1390 | - } |
|
1391 | - } catch (EE_Error $e) { |
|
1392 | - $e->get_error(); |
|
1393 | - } |
|
1394 | - return $EE_Registration_Config; |
|
1395 | - } |
|
1396 | - |
|
1397 | - |
|
1398 | - /** |
|
1399 | - * confirms that the server's PHP version has the PCRE module enabled, |
|
1400 | - * and that the PCRE version works with our i18n email validation |
|
1401 | - * |
|
1402 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1403 | - * @param string $email_validation_level |
|
1404 | - * @return bool |
|
1405 | - */ |
|
1406 | - private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1407 | - { |
|
1408 | - // first check that PCRE is enabled |
|
1409 | - if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1410 | - EE_Error::add_error( |
|
1411 | - sprintf( |
|
1412 | - esc_html__( |
|
1413 | - 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1414 | - 'event_espresso' |
|
1415 | - ), |
|
1416 | - '<br />' |
|
1417 | - ), |
|
1418 | - __FILE__, |
|
1419 | - __FUNCTION__, |
|
1420 | - __LINE__ |
|
1421 | - ); |
|
1422 | - return false; |
|
1423 | - } else { |
|
1424 | - // PCRE support is enabled, but let's still |
|
1425 | - // perform a test to see if the server will support it. |
|
1426 | - // but first, save the updated validation level to the config, |
|
1427 | - // so that the validation strategy picks it up. |
|
1428 | - // this will get bumped back down if it doesn't work |
|
1429 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1430 | - try { |
|
1431 | - $email_validator = new EE_Email_Validation_Strategy(); |
|
1432 | - $i18n_email_address = apply_filters( |
|
1433 | - 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1434 | - 'jägerjü[email protected]' |
|
1435 | - ); |
|
1436 | - $email_validator->validate($i18n_email_address); |
|
1437 | - } catch (Exception $e) { |
|
1438 | - EE_Error::add_error( |
|
1439 | - sprintf( |
|
1440 | - esc_html__( |
|
1441 | - 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1442 | - 'event_espresso' |
|
1443 | - ), |
|
1444 | - '<br />', |
|
1445 | - '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>' |
|
1446 | - ), |
|
1447 | - __FILE__, |
|
1448 | - __FUNCTION__, |
|
1449 | - __LINE__ |
|
1450 | - ); |
|
1451 | - return false; |
|
1452 | - } |
|
1453 | - } |
|
1454 | - return true; |
|
1455 | - } |
|
18 | + /** |
|
19 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
20 | + */ |
|
21 | + public function __construct($routing = true) |
|
22 | + { |
|
23 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/'); |
|
24 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/'); |
|
25 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
26 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/'); |
|
27 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
28 | + parent::__construct($routing); |
|
29 | + } |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @return void |
|
34 | + */ |
|
35 | + protected function _extend_page_config() |
|
36 | + { |
|
37 | + $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
38 | + $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) |
|
39 | + ? $this->_req_data['QST_ID'] : 0; |
|
40 | + $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) |
|
41 | + ? $this->_req_data['QSG_ID'] : 0; |
|
42 | + |
|
43 | + $new_page_routes = array( |
|
44 | + 'question_groups' => array( |
|
45 | + 'func' => '_question_groups_overview_list_table', |
|
46 | + 'capability' => 'ee_read_question_groups', |
|
47 | + ), |
|
48 | + 'add_question' => array( |
|
49 | + 'func' => '_edit_question', |
|
50 | + 'capability' => 'ee_edit_questions', |
|
51 | + ), |
|
52 | + 'insert_question' => array( |
|
53 | + 'func' => '_insert_or_update_question', |
|
54 | + 'args' => array('new_question' => true), |
|
55 | + 'capability' => 'ee_edit_questions', |
|
56 | + 'noheader' => true, |
|
57 | + ), |
|
58 | + 'duplicate_question' => array( |
|
59 | + 'func' => '_duplicate_question', |
|
60 | + 'capability' => 'ee_edit_questions', |
|
61 | + 'noheader' => true, |
|
62 | + ), |
|
63 | + 'trash_question' => array( |
|
64 | + 'func' => '_trash_question', |
|
65 | + 'capability' => 'ee_delete_question', |
|
66 | + 'obj_id' => $qst_id, |
|
67 | + 'noheader' => true, |
|
68 | + ), |
|
69 | + |
|
70 | + 'restore_question' => array( |
|
71 | + 'func' => '_trash_or_restore_questions', |
|
72 | + 'capability' => 'ee_delete_question', |
|
73 | + 'obj_id' => $qst_id, |
|
74 | + 'args' => array('trash' => false), |
|
75 | + 'noheader' => true, |
|
76 | + ), |
|
77 | + |
|
78 | + 'delete_question' => array( |
|
79 | + 'func' => '_delete_question', |
|
80 | + 'capability' => 'ee_delete_question', |
|
81 | + 'obj_id' => $qst_id, |
|
82 | + 'noheader' => true, |
|
83 | + ), |
|
84 | + |
|
85 | + 'trash_questions' => array( |
|
86 | + 'func' => '_trash_or_restore_questions', |
|
87 | + 'capability' => 'ee_delete_questions', |
|
88 | + 'args' => array('trash' => true), |
|
89 | + 'noheader' => true, |
|
90 | + ), |
|
91 | + |
|
92 | + 'restore_questions' => array( |
|
93 | + 'func' => '_trash_or_restore_questions', |
|
94 | + 'capability' => 'ee_delete_questions', |
|
95 | + 'args' => array('trash' => false), |
|
96 | + 'noheader' => true, |
|
97 | + ), |
|
98 | + |
|
99 | + 'delete_questions' => array( |
|
100 | + 'func' => '_delete_questions', |
|
101 | + 'args' => array(), |
|
102 | + 'capability' => 'ee_delete_questions', |
|
103 | + 'noheader' => true, |
|
104 | + ), |
|
105 | + |
|
106 | + 'add_question_group' => array( |
|
107 | + 'func' => '_edit_question_group', |
|
108 | + 'capability' => 'ee_edit_question_groups', |
|
109 | + ), |
|
110 | + |
|
111 | + 'edit_question_group' => array( |
|
112 | + 'func' => '_edit_question_group', |
|
113 | + 'capability' => 'ee_edit_question_group', |
|
114 | + 'obj_id' => $qsg_id, |
|
115 | + 'args' => array('edit'), |
|
116 | + ), |
|
117 | + |
|
118 | + 'delete_question_groups' => array( |
|
119 | + 'func' => '_delete_question_groups', |
|
120 | + 'capability' => 'ee_delete_question_groups', |
|
121 | + 'noheader' => true, |
|
122 | + ), |
|
123 | + |
|
124 | + 'delete_question_group' => array( |
|
125 | + 'func' => '_delete_question_groups', |
|
126 | + 'capability' => 'ee_delete_question_group', |
|
127 | + 'obj_id' => $qsg_id, |
|
128 | + 'noheader' => true, |
|
129 | + ), |
|
130 | + |
|
131 | + 'trash_question_group' => array( |
|
132 | + 'func' => '_trash_or_restore_question_groups', |
|
133 | + 'args' => array('trash' => true), |
|
134 | + 'capability' => 'ee_delete_question_group', |
|
135 | + 'obj_id' => $qsg_id, |
|
136 | + 'noheader' => true, |
|
137 | + ), |
|
138 | + |
|
139 | + 'restore_question_group' => array( |
|
140 | + 'func' => '_trash_or_restore_question_groups', |
|
141 | + 'args' => array('trash' => false), |
|
142 | + 'capability' => 'ee_delete_question_group', |
|
143 | + 'obj_id' => $qsg_id, |
|
144 | + 'noheader' => true, |
|
145 | + ), |
|
146 | + |
|
147 | + 'insert_question_group' => array( |
|
148 | + 'func' => '_insert_or_update_question_group', |
|
149 | + 'args' => array('new_question_group' => true), |
|
150 | + 'capability' => 'ee_edit_question_groups', |
|
151 | + 'noheader' => true, |
|
152 | + ), |
|
153 | + |
|
154 | + 'update_question_group' => array( |
|
155 | + 'func' => '_insert_or_update_question_group', |
|
156 | + 'args' => array('new_question_group' => false), |
|
157 | + 'capability' => 'ee_edit_question_group', |
|
158 | + 'obj_id' => $qsg_id, |
|
159 | + 'noheader' => true, |
|
160 | + ), |
|
161 | + |
|
162 | + 'trash_question_groups' => array( |
|
163 | + 'func' => '_trash_or_restore_question_groups', |
|
164 | + 'args' => array('trash' => true), |
|
165 | + 'capability' => 'ee_delete_question_groups', |
|
166 | + 'noheader' => array('trash' => false), |
|
167 | + ), |
|
168 | + |
|
169 | + 'restore_question_groups' => array( |
|
170 | + 'func' => '_trash_or_restore_question_groups', |
|
171 | + 'args' => array('trash' => false), |
|
172 | + 'capability' => 'ee_delete_question_groups', |
|
173 | + 'noheader' => true, |
|
174 | + ), |
|
175 | + |
|
176 | + |
|
177 | + 'espresso_update_question_group_order' => array( |
|
178 | + 'func' => 'update_question_group_order', |
|
179 | + 'capability' => 'ee_edit_question_groups', |
|
180 | + 'noheader' => true, |
|
181 | + ), |
|
182 | + |
|
183 | + 'view_reg_form_settings' => array( |
|
184 | + 'func' => '_reg_form_settings', |
|
185 | + 'capability' => 'manage_options', |
|
186 | + ), |
|
187 | + |
|
188 | + 'update_reg_form_settings' => array( |
|
189 | + 'func' => '_update_reg_form_settings', |
|
190 | + 'capability' => 'manage_options', |
|
191 | + 'noheader' => true, |
|
192 | + ), |
|
193 | + ); |
|
194 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
195 | + |
|
196 | + $new_page_config = array( |
|
197 | + |
|
198 | + 'question_groups' => array( |
|
199 | + 'nav' => array( |
|
200 | + 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
201 | + 'order' => 20, |
|
202 | + ), |
|
203 | + 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
204 | + 'help_tabs' => array( |
|
205 | + 'registration_form_question_groups_help_tab' => array( |
|
206 | + 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
207 | + 'filename' => 'registration_form_question_groups', |
|
208 | + ), |
|
209 | + 'registration_form_question_groups_table_column_headings_help_tab' => array( |
|
210 | + 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
211 | + 'filename' => 'registration_form_question_groups_table_column_headings', |
|
212 | + ), |
|
213 | + 'registration_form_question_groups_views_bulk_actions_search_help_tab' => array( |
|
214 | + 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
215 | + 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
216 | + ), |
|
217 | + ), |
|
218 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
219 | + 'require_nonce' => false, |
|
220 | + 'qtips' => array( |
|
221 | + 'EE_Registration_Form_Tips', |
|
222 | + ), |
|
223 | + ), |
|
224 | + |
|
225 | + 'add_question' => array( |
|
226 | + 'nav' => array( |
|
227 | + 'label' => esc_html__('Add Question', 'event_espresso'), |
|
228 | + 'order' => 5, |
|
229 | + 'persistent' => false, |
|
230 | + ), |
|
231 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
232 | + 'help_tabs' => array( |
|
233 | + 'registration_form_add_question_help_tab' => array( |
|
234 | + 'title' => esc_html__('Add Question', 'event_espresso'), |
|
235 | + 'filename' => 'registration_form_add_question', |
|
236 | + ), |
|
237 | + ), |
|
238 | + 'require_nonce' => false, |
|
239 | + ), |
|
240 | + |
|
241 | + 'add_question_group' => array( |
|
242 | + 'nav' => array( |
|
243 | + 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
244 | + 'order' => 5, |
|
245 | + 'persistent' => false, |
|
246 | + ), |
|
247 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
248 | + 'help_tabs' => array( |
|
249 | + 'registration_form_add_question_group_help_tab' => array( |
|
250 | + 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
251 | + 'filename' => 'registration_form_add_question_group', |
|
252 | + ), |
|
253 | + ), |
|
254 | + 'require_nonce' => false, |
|
255 | + ), |
|
256 | + |
|
257 | + 'edit_question_group' => array( |
|
258 | + 'nav' => array( |
|
259 | + 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
260 | + 'order' => 5, |
|
261 | + 'persistent' => false, |
|
262 | + 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg( |
|
263 | + array('question_group_id' => $this->_req_data['question_group_id']), |
|
264 | + $this->_current_page_view_url |
|
265 | + ) : $this->_admin_base_url, |
|
266 | + ), |
|
267 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
268 | + 'help_tabs' => array( |
|
269 | + 'registration_form_edit_question_group_help_tab' => array( |
|
270 | + 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
271 | + 'filename' => 'registration_form_edit_question_group', |
|
272 | + ), |
|
273 | + ), |
|
274 | + 'require_nonce' => false, |
|
275 | + ), |
|
276 | + |
|
277 | + 'view_reg_form_settings' => array( |
|
278 | + 'nav' => array( |
|
279 | + 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
280 | + 'order' => 40, |
|
281 | + ), |
|
282 | + 'labels' => array( |
|
283 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
284 | + ), |
|
285 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
286 | + 'help_tabs' => array( |
|
287 | + 'registration_form_reg_form_settings_help_tab' => array( |
|
288 | + 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
289 | + 'filename' => 'registration_form_reg_form_settings', |
|
290 | + ), |
|
291 | + ), |
|
292 | + 'require_nonce' => false, |
|
293 | + ), |
|
294 | + |
|
295 | + ); |
|
296 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
297 | + |
|
298 | + // change the list table we're going to use so it's the NEW list table! |
|
299 | + $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
300 | + |
|
301 | + |
|
302 | + // additional labels |
|
303 | + $new_labels = array( |
|
304 | + 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
305 | + 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
306 | + 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
307 | + 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
308 | + 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
309 | + ); |
|
310 | + $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + /** |
|
315 | + * @return void |
|
316 | + */ |
|
317 | + protected function _ajax_hooks() |
|
318 | + { |
|
319 | + add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * @return void |
|
325 | + */ |
|
326 | + public function load_scripts_styles_question_groups() |
|
327 | + { |
|
328 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
329 | + } |
|
330 | + |
|
331 | + |
|
332 | + /** |
|
333 | + * @return void |
|
334 | + */ |
|
335 | + public function load_scripts_styles_add_question_group() |
|
336 | + { |
|
337 | + $this->load_scripts_styles_forms(); |
|
338 | + $this->load_sortable_question_script(); |
|
339 | + } |
|
340 | + |
|
341 | + |
|
342 | + /** |
|
343 | + * @return void |
|
344 | + */ |
|
345 | + public function load_scripts_styles_edit_question_group() |
|
346 | + { |
|
347 | + $this->load_scripts_styles_forms(); |
|
348 | + $this->load_sortable_question_script(); |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * registers and enqueues script for questions |
|
354 | + * |
|
355 | + * @return void |
|
356 | + */ |
|
357 | + public function load_sortable_question_script() |
|
358 | + { |
|
359 | + wp_register_script( |
|
360 | + 'ee-question-sortable', |
|
361 | + REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
362 | + array('jquery-ui-sortable'), |
|
363 | + EVENT_ESPRESSO_VERSION, |
|
364 | + true |
|
365 | + ); |
|
366 | + wp_enqueue_script('ee-question-sortable'); |
|
367 | + } |
|
368 | + |
|
369 | + |
|
370 | + /** |
|
371 | + * @return void |
|
372 | + */ |
|
373 | + protected function _set_list_table_views_default() |
|
374 | + { |
|
375 | + $this->_views = array( |
|
376 | + 'all' => array( |
|
377 | + 'slug' => 'all', |
|
378 | + 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
379 | + 'count' => 0, |
|
380 | + 'bulk_action' => array( |
|
381 | + 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
382 | + ), |
|
383 | + ), |
|
384 | + ); |
|
385 | + |
|
386 | + if ( |
|
387 | + EE_Registry::instance()->CAP->current_user_can( |
|
388 | + 'ee_delete_questions', |
|
389 | + 'espresso_registration_form_trash_questions' |
|
390 | + ) |
|
391 | + ) { |
|
392 | + $this->_views['trash'] = array( |
|
393 | + 'slug' => 'trash', |
|
394 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
395 | + 'count' => 0, |
|
396 | + 'bulk_action' => array( |
|
397 | + 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
398 | + 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
399 | + ), |
|
400 | + ); |
|
401 | + } |
|
402 | + } |
|
403 | + |
|
404 | + |
|
405 | + /** |
|
406 | + * @return void |
|
407 | + */ |
|
408 | + protected function _set_list_table_views_question_groups() |
|
409 | + { |
|
410 | + $this->_views = array( |
|
411 | + 'all' => array( |
|
412 | + 'slug' => 'all', |
|
413 | + 'label' => esc_html__('All', 'event_espresso'), |
|
414 | + 'count' => 0, |
|
415 | + 'bulk_action' => array( |
|
416 | + 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
417 | + ), |
|
418 | + ), |
|
419 | + ); |
|
420 | + |
|
421 | + if ( |
|
422 | + EE_Registry::instance()->CAP->current_user_can( |
|
423 | + 'ee_delete_question_groups', |
|
424 | + 'espresso_registration_form_trash_question_groups' |
|
425 | + ) |
|
426 | + ) { |
|
427 | + $this->_views['trash'] = array( |
|
428 | + 'slug' => 'trash', |
|
429 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
430 | + 'count' => 0, |
|
431 | + 'bulk_action' => array( |
|
432 | + 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
433 | + 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
434 | + ), |
|
435 | + ); |
|
436 | + } |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * @return void |
|
442 | + * @throws EE_Error |
|
443 | + * @throws InvalidArgumentException |
|
444 | + * @throws InvalidDataTypeException |
|
445 | + * @throws InvalidInterfaceException |
|
446 | + */ |
|
447 | + protected function _questions_overview_list_table() |
|
448 | + { |
|
449 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
450 | + 'add_question', |
|
451 | + 'add_question', |
|
452 | + array(), |
|
453 | + 'add-new-h2' |
|
454 | + ); |
|
455 | + parent::_questions_overview_list_table(); |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + /** |
|
460 | + * @return void |
|
461 | + * @throws DomainException |
|
462 | + * @throws EE_Error |
|
463 | + * @throws InvalidArgumentException |
|
464 | + * @throws InvalidDataTypeException |
|
465 | + * @throws InvalidInterfaceException |
|
466 | + */ |
|
467 | + protected function _question_groups_overview_list_table() |
|
468 | + { |
|
469 | + $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
470 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
471 | + 'add_question_group', |
|
472 | + 'add_question_group', |
|
473 | + array(), |
|
474 | + 'add-new-h2' |
|
475 | + ); |
|
476 | + $this->display_admin_list_table_page_with_sidebar(); |
|
477 | + } |
|
478 | + |
|
479 | + |
|
480 | + /** |
|
481 | + * @return void |
|
482 | + * @throws EE_Error |
|
483 | + * @throws InvalidArgumentException |
|
484 | + * @throws InvalidDataTypeException |
|
485 | + * @throws InvalidInterfaceException |
|
486 | + */ |
|
487 | + protected function _delete_question() |
|
488 | + { |
|
489 | + $success = $this->_delete_items($this->_question_model); |
|
490 | + $this->_redirect_after_action( |
|
491 | + $success, |
|
492 | + $this->_question_model->item_name($success), |
|
493 | + 'deleted', |
|
494 | + array('action' => 'default', 'status' => 'all') |
|
495 | + ); |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + /** |
|
500 | + * @return void |
|
501 | + * @throws EE_Error |
|
502 | + * @throws InvalidArgumentException |
|
503 | + * @throws InvalidDataTypeException |
|
504 | + * @throws InvalidInterfaceException |
|
505 | + */ |
|
506 | + protected function _delete_questions() |
|
507 | + { |
|
508 | + $success = $this->_delete_items($this->_question_model); |
|
509 | + $this->_redirect_after_action( |
|
510 | + $success, |
|
511 | + $this->_question_model->item_name($success), |
|
512 | + 'deleted permanently', |
|
513 | + array('action' => 'default', 'status' => 'trash') |
|
514 | + ); |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /** |
|
519 | + * Performs the deletion of a single or multiple questions or question groups. |
|
520 | + * |
|
521 | + * @param EEM_Soft_Delete_Base $model |
|
522 | + * @return int number of items deleted permanently |
|
523 | + * @throws EE_Error |
|
524 | + * @throws InvalidArgumentException |
|
525 | + * @throws InvalidDataTypeException |
|
526 | + * @throws InvalidInterfaceException |
|
527 | + */ |
|
528 | + private function _delete_items(EEM_Soft_Delete_Base $model) |
|
529 | + { |
|
530 | + $success = 0; |
|
531 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
532 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
533 | + // if array has more than one element than success message should be plural |
|
534 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
535 | + // cycle thru bulk action checkboxes |
|
536 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
537 | + if (! $this->_delete_item($ID, $model)) { |
|
538 | + $success = 0; |
|
539 | + } |
|
540 | + } |
|
541 | + } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
542 | + $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
543 | + } elseif (! empty($this->_req_data['QST_ID'])) { |
|
544 | + $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
545 | + } else { |
|
546 | + EE_Error::add_error( |
|
547 | + sprintf( |
|
548 | + esc_html__( |
|
549 | + "No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", |
|
550 | + "event_espresso" |
|
551 | + ) |
|
552 | + ), |
|
553 | + __FILE__, |
|
554 | + __FUNCTION__, |
|
555 | + __LINE__ |
|
556 | + ); |
|
557 | + } |
|
558 | + return $success; |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + /** |
|
563 | + * Deletes the specified question (and its associated question options) or question group |
|
564 | + * |
|
565 | + * @param int $id |
|
566 | + * @param EEM_Soft_Delete_Base $model |
|
567 | + * @return boolean |
|
568 | + * @throws EE_Error |
|
569 | + * @throws InvalidArgumentException |
|
570 | + * @throws InvalidDataTypeException |
|
571 | + * @throws InvalidInterfaceException |
|
572 | + */ |
|
573 | + protected function _delete_item($id, $model) |
|
574 | + { |
|
575 | + if ($model instanceof EEM_Question) { |
|
576 | + EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
577 | + } |
|
578 | + return $model->delete_permanently_by_ID(absint($id)); |
|
579 | + } |
|
580 | + |
|
581 | + |
|
582 | + /****************************** QUESTION GROUPS ******************************/ |
|
583 | + |
|
584 | + |
|
585 | + /** |
|
586 | + * @param string $type |
|
587 | + * @return void |
|
588 | + * @throws DomainException |
|
589 | + * @throws EE_Error |
|
590 | + * @throws InvalidArgumentException |
|
591 | + * @throws InvalidDataTypeException |
|
592 | + * @throws InvalidInterfaceException |
|
593 | + */ |
|
594 | + protected function _edit_question_group($type = 'add') |
|
595 | + { |
|
596 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
597 | + $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) |
|
598 | + ? absint($this->_req_data['QSG_ID']) |
|
599 | + : false; |
|
600 | + |
|
601 | + switch ($this->_req_action) { |
|
602 | + case 'add_question_group': |
|
603 | + $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
604 | + break; |
|
605 | + case 'edit_question_group': |
|
606 | + $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
607 | + break; |
|
608 | + default: |
|
609 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
610 | + } |
|
611 | + // add ID to title if editing |
|
612 | + $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
613 | + if ($ID) { |
|
614 | + /** @var EE_Question_Group $questionGroup */ |
|
615 | + $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
616 | + $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
617 | + $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
618 | + } else { |
|
619 | + /** @var EE_Question_Group $questionGroup */ |
|
620 | + $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
621 | + $questionGroup->set_order_to_latest(); |
|
622 | + $this->_set_add_edit_form_tags('insert_question_group'); |
|
623 | + } |
|
624 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
625 | + $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
626 | + $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
627 | + $this->_template_args['question_group'] = $questionGroup; |
|
628 | + |
|
629 | + $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
630 | + $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
|
631 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
632 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
633 | + $this->_template_args, |
|
634 | + true |
|
635 | + ); |
|
636 | + |
|
637 | + // the details template wrapper |
|
638 | + $this->display_admin_page_with_sidebar(); |
|
639 | + } |
|
640 | + |
|
641 | + |
|
642 | + /** |
|
643 | + * @return void |
|
644 | + * @throws EE_Error |
|
645 | + * @throws InvalidArgumentException |
|
646 | + * @throws InvalidDataTypeException |
|
647 | + * @throws InvalidInterfaceException |
|
648 | + */ |
|
649 | + protected function _delete_question_groups() |
|
650 | + { |
|
651 | + $success = $this->_delete_items($this->_question_group_model); |
|
652 | + $this->_redirect_after_action( |
|
653 | + $success, |
|
654 | + $this->_question_group_model->item_name($success), |
|
655 | + 'deleted permanently', |
|
656 | + array('action' => 'question_groups', 'status' => 'trash') |
|
657 | + ); |
|
658 | + } |
|
659 | + |
|
660 | + |
|
661 | + /** |
|
662 | + * @param bool $new_question_group |
|
663 | + * @throws EE_Error |
|
664 | + * @throws InvalidArgumentException |
|
665 | + * @throws InvalidDataTypeException |
|
666 | + * @throws InvalidInterfaceException |
|
667 | + */ |
|
668 | + protected function _insert_or_update_question_group($new_question_group = true) |
|
669 | + { |
|
670 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
671 | + $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
672 | + |
|
673 | + // make sure identifier is unique |
|
674 | + $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : ''; |
|
675 | + $where_values = ['QSG_identifier' => $set_column_values['QSG_identifier']]; |
|
676 | + if (! $new_question_group && isset($set_column_values['QSG_ID'])) { |
|
677 | + $where_values['QSG_ID'] = ['!=', $set_column_values['QSG_ID']]; |
|
678 | + } |
|
679 | + $identifier_exists = ! empty($identifier_value) |
|
680 | + ? $this->_question_group_model->count([$where_values]) > 0 |
|
681 | + : false; |
|
682 | + if ($identifier_exists) { |
|
683 | + $set_column_values['QSG_identifier'] .= uniqid('id', true); |
|
684 | + } |
|
685 | + |
|
686 | + if ($new_question_group) { |
|
687 | + $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
688 | + $success = $QSG_ID ? 1 : 0; |
|
689 | + if ($success === 0) { |
|
690 | + EE_Error::add_error( |
|
691 | + esc_html__('Something went wrong saving the question group.', 'event_espresso'), |
|
692 | + __FILE__, |
|
693 | + __FUNCTION__, |
|
694 | + __LINE__ |
|
695 | + ); |
|
696 | + $this->_redirect_after_action( |
|
697 | + false, |
|
698 | + '', |
|
699 | + '', |
|
700 | + array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
701 | + true |
|
702 | + ); |
|
703 | + } |
|
704 | + } else { |
|
705 | + $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
706 | + unset($set_column_values['QSG_ID']); |
|
707 | + $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
708 | + } |
|
709 | + |
|
710 | + $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( |
|
711 | + EEM_Attendee::system_question_phone |
|
712 | + ); |
|
713 | + // update the existing related questions |
|
714 | + // BUT FIRST... delete the phone question from the Question_Group_Question |
|
715 | + // if it is being added to this question group (therefore removed from the existing group) |
|
716 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
717 | + // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
718 | + EEM_Question_Group_Question::instance()->delete( |
|
719 | + array( |
|
720 | + array( |
|
721 | + 'QST_ID' => $phone_question_id, |
|
722 | + 'QSG_ID' => array('!=', $QSG_ID), |
|
723 | + ), |
|
724 | + ) |
|
725 | + ); |
|
726 | + } |
|
727 | + /** @type EE_Question_Group $question_group */ |
|
728 | + $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
729 | + $questions = $question_group->questions(); |
|
730 | + // make sure system phone question is added to list of questions for this group |
|
731 | + if (! isset($questions[ $phone_question_id ])) { |
|
732 | + $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
733 | + } |
|
734 | + |
|
735 | + foreach ($questions as $question_ID => $question) { |
|
736 | + // first we always check for order. |
|
737 | + if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
738 | + // update question order |
|
739 | + $question_group->update_question_order( |
|
740 | + $question_ID, |
|
741 | + $this->_req_data['question_orders'][ $question_ID ] |
|
742 | + ); |
|
743 | + } |
|
744 | + |
|
745 | + // then we always check if adding or removing. |
|
746 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
747 | + $question_group->add_question($question_ID); |
|
748 | + } else { |
|
749 | + // not found, remove it (but only if not a system question for the personal group |
|
750 | + // with the exception of lname system question - we allow removal of it) |
|
751 | + if ( |
|
752 | + in_array( |
|
753 | + $question->system_ID(), |
|
754 | + EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
755 | + $question_group->system_group() |
|
756 | + ) |
|
757 | + ) |
|
758 | + ) { |
|
759 | + continue; |
|
760 | + } else { |
|
761 | + $question_group->remove_question($question_ID); |
|
762 | + } |
|
763 | + } |
|
764 | + } |
|
765 | + // save new related questions |
|
766 | + if (isset($this->_req_data['questions'])) { |
|
767 | + foreach ($this->_req_data['questions'] as $QST_ID) { |
|
768 | + $question_group->add_question($QST_ID); |
|
769 | + if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
770 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
771 | + } |
|
772 | + } |
|
773 | + } |
|
774 | + |
|
775 | + if ($success !== false) { |
|
776 | + $msg = $new_question_group |
|
777 | + ? sprintf( |
|
778 | + esc_html__('The %s has been created', 'event_espresso'), |
|
779 | + $this->_question_group_model->item_name() |
|
780 | + ) |
|
781 | + : sprintf( |
|
782 | + esc_html__( |
|
783 | + 'The %s has been updated', |
|
784 | + 'event_espresso' |
|
785 | + ), |
|
786 | + $this->_question_group_model->item_name() |
|
787 | + ); |
|
788 | + EE_Error::add_success($msg); |
|
789 | + } |
|
790 | + $this->_redirect_after_action( |
|
791 | + false, |
|
792 | + '', |
|
793 | + '', |
|
794 | + array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
795 | + true |
|
796 | + ); |
|
797 | + } |
|
798 | + |
|
799 | + |
|
800 | + /** |
|
801 | + * duplicates a question and all its question options and redirects to the new question. |
|
802 | + * |
|
803 | + * @return void |
|
804 | + * @throws EE_Error |
|
805 | + * @throws InvalidArgumentException |
|
806 | + * @throws ReflectionException |
|
807 | + * @throws InvalidDataTypeException |
|
808 | + * @throws InvalidInterfaceException |
|
809 | + */ |
|
810 | + public function _duplicate_question() |
|
811 | + { |
|
812 | + $question_ID = (int) $this->_req_data['QST_ID']; |
|
813 | + $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
814 | + if ($question instanceof EE_Question) { |
|
815 | + $new_question = $question->duplicate(); |
|
816 | + if ($new_question instanceof EE_Question) { |
|
817 | + $this->_redirect_after_action( |
|
818 | + true, |
|
819 | + esc_html__('Question', 'event_espresso'), |
|
820 | + esc_html__('Duplicated', 'event_espresso'), |
|
821 | + array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), |
|
822 | + true |
|
823 | + ); |
|
824 | + } else { |
|
825 | + global $wpdb; |
|
826 | + EE_Error::add_error( |
|
827 | + sprintf( |
|
828 | + esc_html__( |
|
829 | + 'Could not duplicate question with ID %1$d because: %2$s', |
|
830 | + 'event_espresso' |
|
831 | + ), |
|
832 | + $question_ID, |
|
833 | + $wpdb->last_error |
|
834 | + ), |
|
835 | + __FILE__, |
|
836 | + __FUNCTION__, |
|
837 | + __LINE__ |
|
838 | + ); |
|
839 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
840 | + } |
|
841 | + } else { |
|
842 | + EE_Error::add_error( |
|
843 | + sprintf( |
|
844 | + esc_html__( |
|
845 | + 'Could not duplicate question with ID %d because it didn\'t exist!', |
|
846 | + 'event_espresso' |
|
847 | + ), |
|
848 | + $question_ID |
|
849 | + ), |
|
850 | + __FILE__, |
|
851 | + __FUNCTION__, |
|
852 | + __LINE__ |
|
853 | + ); |
|
854 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
855 | + } |
|
856 | + } |
|
857 | + |
|
858 | + |
|
859 | + /** |
|
860 | + * @param bool $trash |
|
861 | + * @throws EE_Error |
|
862 | + */ |
|
863 | + protected function _trash_or_restore_question_groups($trash = true) |
|
864 | + { |
|
865 | + $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
866 | + } |
|
867 | + |
|
868 | + |
|
869 | + /** |
|
870 | + *_trash_question |
|
871 | + * |
|
872 | + * @return void |
|
873 | + * @throws EE_Error |
|
874 | + */ |
|
875 | + protected function _trash_question() |
|
876 | + { |
|
877 | + $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
878 | + $query_args = array('action' => 'default', 'status' => 'all'); |
|
879 | + $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
880 | + } |
|
881 | + |
|
882 | + |
|
883 | + /** |
|
884 | + * @param bool $trash |
|
885 | + * @throws EE_Error |
|
886 | + */ |
|
887 | + protected function _trash_or_restore_questions($trash = true) |
|
888 | + { |
|
889 | + $this->_trash_or_restore_items($this->_question_model, $trash); |
|
890 | + } |
|
891 | + |
|
892 | + |
|
893 | + /** |
|
894 | + * Internally used to delete or restore items, using the request data. Meant to be |
|
895 | + * flexible between question or question groups |
|
896 | + * |
|
897 | + * @param EEM_Soft_Delete_Base $model |
|
898 | + * @param boolean $trash whether to trash or restore |
|
899 | + * @throws EE_Error |
|
900 | + */ |
|
901 | + private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
902 | + { |
|
903 | + |
|
904 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
905 | + |
|
906 | + $success = 1; |
|
907 | + // Checkboxes |
|
908 | + // echo "trash $trash"; |
|
909 | + // var_dump($this->_req_data['checkbox']);die; |
|
910 | + if (isset($this->_req_data['checkbox'])) { |
|
911 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
912 | + // if array has more than one element than success message should be plural |
|
913 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
914 | + // cycle thru bulk action checkboxes |
|
915 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
916 | + if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
917 | + $success = 0; |
|
918 | + } |
|
919 | + } |
|
920 | + } else { |
|
921 | + // grab single id and delete |
|
922 | + $ID = absint($this->_req_data['checkbox']); |
|
923 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
924 | + $success = 0; |
|
925 | + } |
|
926 | + } |
|
927 | + } else { |
|
928 | + // delete via trash link |
|
929 | + // grab single id and delete |
|
930 | + $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
931 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
932 | + $success = 0; |
|
933 | + } |
|
934 | + } |
|
935 | + |
|
936 | + |
|
937 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
938 | + // echo "action :$action"; |
|
939 | + // $action = 'questions' ? 'default' : $action; |
|
940 | + if ($trash) { |
|
941 | + $action_desc = 'trashed'; |
|
942 | + $status = 'trash'; |
|
943 | + } else { |
|
944 | + $action_desc = 'restored'; |
|
945 | + $status = 'all'; |
|
946 | + } |
|
947 | + $this->_redirect_after_action( |
|
948 | + $success, |
|
949 | + $model->item_name($success), |
|
950 | + $action_desc, |
|
951 | + array('action' => $action, 'status' => $status) |
|
952 | + ); |
|
953 | + } |
|
954 | + |
|
955 | + |
|
956 | + /** |
|
957 | + * @param $per_page |
|
958 | + * @param int $current_page |
|
959 | + * @param bool|false $count |
|
960 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
961 | + * @throws EE_Error |
|
962 | + * @throws InvalidArgumentException |
|
963 | + * @throws InvalidDataTypeException |
|
964 | + * @throws InvalidInterfaceException |
|
965 | + */ |
|
966 | + public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
967 | + { |
|
968 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
969 | + |
|
970 | + if ($count) { |
|
971 | + // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
972 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
973 | + $results = $this->_question_model->count_deleted($where); |
|
974 | + } else { |
|
975 | + // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
976 | + $results = $this->_question_model->get_all_deleted($query_params); |
|
977 | + } |
|
978 | + return $results; |
|
979 | + } |
|
980 | + |
|
981 | + |
|
982 | + /** |
|
983 | + * @param $per_page |
|
984 | + * @param int $current_page |
|
985 | + * @param bool|false $count |
|
986 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
987 | + * @throws EE_Error |
|
988 | + * @throws InvalidArgumentException |
|
989 | + * @throws InvalidDataTypeException |
|
990 | + * @throws InvalidInterfaceException |
|
991 | + */ |
|
992 | + public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
993 | + { |
|
994 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
995 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
996 | + if ($count) { |
|
997 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
998 | + $results = $questionGroupModel->count($where); |
|
999 | + } else { |
|
1000 | + $results = $questionGroupModel->get_all($query_params); |
|
1001 | + } |
|
1002 | + return $results; |
|
1003 | + } |
|
1004 | + |
|
1005 | + |
|
1006 | + /** |
|
1007 | + * @param $per_page |
|
1008 | + * @param int $current_page |
|
1009 | + * @param bool $count |
|
1010 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
1011 | + * @throws EE_Error |
|
1012 | + * @throws InvalidArgumentException |
|
1013 | + * @throws InvalidDataTypeException |
|
1014 | + * @throws InvalidInterfaceException |
|
1015 | + */ |
|
1016 | + public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
1017 | + { |
|
1018 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
1019 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1020 | + if ($count) { |
|
1021 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
1022 | + $query_params['limit'] = null; |
|
1023 | + $results = $questionGroupModel->count_deleted($where); |
|
1024 | + } else { |
|
1025 | + $results = $questionGroupModel->get_all_deleted($query_params); |
|
1026 | + } |
|
1027 | + return $results; |
|
1028 | + } |
|
1029 | + |
|
1030 | + |
|
1031 | + /** |
|
1032 | + * method for performing updates to question order |
|
1033 | + * |
|
1034 | + * @return void results array |
|
1035 | + * @throws EE_Error |
|
1036 | + * @throws InvalidArgumentException |
|
1037 | + * @throws InvalidDataTypeException |
|
1038 | + * @throws InvalidInterfaceException |
|
1039 | + */ |
|
1040 | + public function update_question_group_order() |
|
1041 | + { |
|
1042 | + |
|
1043 | + $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
1044 | + |
|
1045 | + // grab our row IDs |
|
1046 | + $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
1047 | + ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
1048 | + : array(); |
|
1049 | + |
|
1050 | + $perpage = ! empty($this->_req_data['perpage']) |
|
1051 | + ? (int) $this->_req_data['perpage'] |
|
1052 | + : null; |
|
1053 | + $curpage = ! empty($this->_req_data['curpage']) |
|
1054 | + ? (int) $this->_req_data['curpage'] |
|
1055 | + : null; |
|
1056 | + |
|
1057 | + if (! empty($row_ids)) { |
|
1058 | + // figure out where we start the row_id count at for the current page. |
|
1059 | + $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
1060 | + |
|
1061 | + $row_count = count($row_ids); |
|
1062 | + for ($i = 0; $i < $row_count; $i++) { |
|
1063 | + // Update the questions when re-ordering |
|
1064 | + $updated = EEM_Question_Group::instance()->update( |
|
1065 | + array('QSG_order' => $qsgcount), |
|
1066 | + array(array('QSG_ID' => $row_ids[ $i ])) |
|
1067 | + ); |
|
1068 | + if ($updated === false) { |
|
1069 | + $success = false; |
|
1070 | + } |
|
1071 | + $qsgcount++; |
|
1072 | + } |
|
1073 | + } else { |
|
1074 | + $success = false; |
|
1075 | + } |
|
1076 | + |
|
1077 | + $errors = ! $success |
|
1078 | + ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
1079 | + : false; |
|
1080 | + |
|
1081 | + echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
1082 | + die(); |
|
1083 | + } |
|
1084 | + |
|
1085 | + |
|
1086 | + |
|
1087 | + /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
1088 | + |
|
1089 | + |
|
1090 | + /** |
|
1091 | + * @throws DomainException |
|
1092 | + * @throws EE_Error |
|
1093 | + * @throws InvalidArgumentException |
|
1094 | + * @throws InvalidDataTypeException |
|
1095 | + * @throws InvalidInterfaceException |
|
1096 | + */ |
|
1097 | + protected function _reg_form_settings() |
|
1098 | + { |
|
1099 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
1100 | + add_action( |
|
1101 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1102 | + array($this, 'email_validation_settings_form'), |
|
1103 | + 2 |
|
1104 | + ); |
|
1105 | + add_action( |
|
1106 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1107 | + array($this, 'copy_attendee_info_settings_form'), |
|
1108 | + 4 |
|
1109 | + ); |
|
1110 | + $this->_template_args = (array) apply_filters( |
|
1111 | + 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
1112 | + $this->_template_args |
|
1113 | + ); |
|
1114 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
1115 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1116 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1117 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1118 | + $this->_template_args, |
|
1119 | + true |
|
1120 | + ); |
|
1121 | + $this->display_admin_page_with_sidebar(); |
|
1122 | + } |
|
1123 | + |
|
1124 | + |
|
1125 | + /** |
|
1126 | + * @return void |
|
1127 | + * @throws EE_Error |
|
1128 | + * @throws InvalidArgumentException |
|
1129 | + * @throws ReflectionException |
|
1130 | + * @throws InvalidDataTypeException |
|
1131 | + * @throws InvalidInterfaceException |
|
1132 | + */ |
|
1133 | + protected function _update_reg_form_settings() |
|
1134 | + { |
|
1135 | + EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
1136 | + EE_Registry::instance()->CFG->registration |
|
1137 | + ); |
|
1138 | + EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form( |
|
1139 | + EE_Registry::instance()->CFG->registration |
|
1140 | + ); |
|
1141 | + EE_Registry::instance()->CFG->registration = apply_filters( |
|
1142 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
1143 | + EE_Registry::instance()->CFG->registration |
|
1144 | + ); |
|
1145 | + $success = $this->_update_espresso_configuration( |
|
1146 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1147 | + EE_Registry::instance()->CFG, |
|
1148 | + __FILE__, |
|
1149 | + __FUNCTION__, |
|
1150 | + __LINE__ |
|
1151 | + ); |
|
1152 | + $this->_redirect_after_action( |
|
1153 | + $success, |
|
1154 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1155 | + 'updated', |
|
1156 | + array('action' => 'view_reg_form_settings') |
|
1157 | + ); |
|
1158 | + } |
|
1159 | + |
|
1160 | + |
|
1161 | + /** |
|
1162 | + * @return void |
|
1163 | + * @throws EE_Error |
|
1164 | + * @throws InvalidArgumentException |
|
1165 | + * @throws InvalidDataTypeException |
|
1166 | + * @throws InvalidInterfaceException |
|
1167 | + */ |
|
1168 | + public function copy_attendee_info_settings_form() |
|
1169 | + { |
|
1170 | + echo wp_kses($this->_copy_attendee_info_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1171 | + } |
|
1172 | + |
|
1173 | + /** |
|
1174 | + * _copy_attendee_info_settings_form |
|
1175 | + * |
|
1176 | + * @access protected |
|
1177 | + * @return EE_Form_Section_Proper |
|
1178 | + * @throws \EE_Error |
|
1179 | + */ |
|
1180 | + protected function _copy_attendee_info_settings_form() |
|
1181 | + { |
|
1182 | + return new EE_Form_Section_Proper( |
|
1183 | + array( |
|
1184 | + 'name' => 'copy_attendee_info_settings', |
|
1185 | + 'html_id' => 'copy_attendee_info_settings', |
|
1186 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1187 | + 'subsections' => apply_filters( |
|
1188 | + 'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections', |
|
1189 | + array( |
|
1190 | + 'copy_attendee_info_hdr' => new EE_Form_Section_HTML( |
|
1191 | + EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso')) |
|
1192 | + ), |
|
1193 | + 'copy_attendee_info' => new EE_Yes_No_Input( |
|
1194 | + array( |
|
1195 | + 'html_label_text' => esc_html__( |
|
1196 | + 'Allow copy #1 attendee info to extra attendees?', |
|
1197 | + 'event_espresso' |
|
1198 | + ), |
|
1199 | + 'html_help_text' => esc_html__( |
|
1200 | + 'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.', |
|
1201 | + 'event_espresso' |
|
1202 | + ), |
|
1203 | + 'default' => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(), |
|
1204 | + 'required' => false, |
|
1205 | + 'display_html_label_text' => false, |
|
1206 | + ) |
|
1207 | + ), |
|
1208 | + ) |
|
1209 | + ), |
|
1210 | + ) |
|
1211 | + ); |
|
1212 | + } |
|
1213 | + |
|
1214 | + /** |
|
1215 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1216 | + * @return EE_Registration_Config |
|
1217 | + * @throws EE_Error |
|
1218 | + * @throws InvalidArgumentException |
|
1219 | + * @throws ReflectionException |
|
1220 | + * @throws InvalidDataTypeException |
|
1221 | + * @throws InvalidInterfaceException |
|
1222 | + */ |
|
1223 | + public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1224 | + { |
|
1225 | + $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo(); |
|
1226 | + try { |
|
1227 | + $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form(); |
|
1228 | + // if not displaying a form, then check for form submission |
|
1229 | + if ($copy_attendee_info_settings_form->was_submitted()) { |
|
1230 | + // capture form data |
|
1231 | + $copy_attendee_info_settings_form->receive_form_submission(); |
|
1232 | + // validate form data |
|
1233 | + if ($copy_attendee_info_settings_form->is_valid()) { |
|
1234 | + // grab validated data from form |
|
1235 | + $valid_data = $copy_attendee_info_settings_form->valid_data(); |
|
1236 | + if (isset($valid_data['copy_attendee_info'])) { |
|
1237 | + $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']); |
|
1238 | + } else { |
|
1239 | + EE_Error::add_error( |
|
1240 | + esc_html__( |
|
1241 | + 'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.', |
|
1242 | + 'event_espresso' |
|
1243 | + ), |
|
1244 | + __FILE__, |
|
1245 | + __FUNCTION__, |
|
1246 | + __LINE__ |
|
1247 | + ); |
|
1248 | + } |
|
1249 | + } else { |
|
1250 | + if ($copy_attendee_info_settings_form->submission_error_message() !== '') { |
|
1251 | + EE_Error::add_error( |
|
1252 | + $copy_attendee_info_settings_form->submission_error_message(), |
|
1253 | + __FILE__, |
|
1254 | + __FUNCTION__, |
|
1255 | + __LINE__ |
|
1256 | + ); |
|
1257 | + } |
|
1258 | + } |
|
1259 | + } |
|
1260 | + } catch (EE_Error $e) { |
|
1261 | + $e->get_error(); |
|
1262 | + } |
|
1263 | + return $EE_Registration_Config; |
|
1264 | + } |
|
1265 | + |
|
1266 | + |
|
1267 | + /** |
|
1268 | + * @return void |
|
1269 | + * @throws EE_Error |
|
1270 | + * @throws InvalidArgumentException |
|
1271 | + * @throws InvalidDataTypeException |
|
1272 | + * @throws InvalidInterfaceException |
|
1273 | + */ |
|
1274 | + public function email_validation_settings_form() |
|
1275 | + { |
|
1276 | + echo wp_kses($this->_email_validation_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1277 | + } |
|
1278 | + |
|
1279 | + |
|
1280 | + /** |
|
1281 | + * _email_validation_settings_form |
|
1282 | + * |
|
1283 | + * @access protected |
|
1284 | + * @return EE_Form_Section_Proper |
|
1285 | + * @throws \EE_Error |
|
1286 | + */ |
|
1287 | + protected function _email_validation_settings_form() |
|
1288 | + { |
|
1289 | + return new EE_Form_Section_Proper( |
|
1290 | + array( |
|
1291 | + 'name' => 'email_validation_settings', |
|
1292 | + 'html_id' => 'email_validation_settings', |
|
1293 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1294 | + 'subsections' => apply_filters( |
|
1295 | + 'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections', |
|
1296 | + array( |
|
1297 | + 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
1298 | + EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
1299 | + ), |
|
1300 | + 'email_validation_level' => new EE_Select_Input( |
|
1301 | + array( |
|
1302 | + 'basic' => esc_html__('Basic', 'event_espresso'), |
|
1303 | + 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
1304 | + 'i18n' => esc_html__('International', 'event_espresso'), |
|
1305 | + 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
1306 | + ), |
|
1307 | + array( |
|
1308 | + 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
1309 | + . EEH_Template::get_help_tab_link('email_validation_info'), |
|
1310 | + 'html_help_text' => esc_html__( |
|
1311 | + 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', |
|
1312 | + 'event_espresso' |
|
1313 | + ), |
|
1314 | + 'default' => isset( |
|
1315 | + EE_Registry::instance()->CFG->registration->email_validation_level |
|
1316 | + ) |
|
1317 | + ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
1318 | + : 'wp_default', |
|
1319 | + 'required' => false, |
|
1320 | + ) |
|
1321 | + ), |
|
1322 | + ) |
|
1323 | + ), |
|
1324 | + ) |
|
1325 | + ); |
|
1326 | + } |
|
1327 | + |
|
1328 | + |
|
1329 | + /** |
|
1330 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1331 | + * @return EE_Registration_Config |
|
1332 | + * @throws EE_Error |
|
1333 | + * @throws InvalidArgumentException |
|
1334 | + * @throws ReflectionException |
|
1335 | + * @throws InvalidDataTypeException |
|
1336 | + * @throws InvalidInterfaceException |
|
1337 | + */ |
|
1338 | + public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1339 | + { |
|
1340 | + $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1341 | + try { |
|
1342 | + $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1343 | + // if not displaying a form, then check for form submission |
|
1344 | + if ($email_validation_settings_form->was_submitted()) { |
|
1345 | + // capture form data |
|
1346 | + $email_validation_settings_form->receive_form_submission(); |
|
1347 | + // validate form data |
|
1348 | + if ($email_validation_settings_form->is_valid()) { |
|
1349 | + // grab validated data from form |
|
1350 | + $valid_data = $email_validation_settings_form->valid_data(); |
|
1351 | + if (isset($valid_data['email_validation_level'])) { |
|
1352 | + $email_validation_level = $valid_data['email_validation_level']; |
|
1353 | + // now if they want to use international email addresses |
|
1354 | + if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1355 | + // in case we need to reset their email validation level, |
|
1356 | + // make sure that the previous value wasn't already set to one of the i18n options. |
|
1357 | + if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1358 | + // if so, then reset it back to "basic" since that is the only other option that, |
|
1359 | + // despite offering poor validation, supports i18n email addresses |
|
1360 | + $prev_email_validation_level = 'basic'; |
|
1361 | + } |
|
1362 | + // confirm our i18n email validation will work on the server |
|
1363 | + if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1364 | + // or reset email validation level to previous value |
|
1365 | + $email_validation_level = $prev_email_validation_level; |
|
1366 | + } |
|
1367 | + } |
|
1368 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1369 | + } else { |
|
1370 | + EE_Error::add_error( |
|
1371 | + esc_html__( |
|
1372 | + 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1373 | + 'event_espresso' |
|
1374 | + ), |
|
1375 | + __FILE__, |
|
1376 | + __FUNCTION__, |
|
1377 | + __LINE__ |
|
1378 | + ); |
|
1379 | + } |
|
1380 | + } else { |
|
1381 | + if ($email_validation_settings_form->submission_error_message() !== '') { |
|
1382 | + EE_Error::add_error( |
|
1383 | + $email_validation_settings_form->submission_error_message(), |
|
1384 | + __FILE__, |
|
1385 | + __FUNCTION__, |
|
1386 | + __LINE__ |
|
1387 | + ); |
|
1388 | + } |
|
1389 | + } |
|
1390 | + } |
|
1391 | + } catch (EE_Error $e) { |
|
1392 | + $e->get_error(); |
|
1393 | + } |
|
1394 | + return $EE_Registration_Config; |
|
1395 | + } |
|
1396 | + |
|
1397 | + |
|
1398 | + /** |
|
1399 | + * confirms that the server's PHP version has the PCRE module enabled, |
|
1400 | + * and that the PCRE version works with our i18n email validation |
|
1401 | + * |
|
1402 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1403 | + * @param string $email_validation_level |
|
1404 | + * @return bool |
|
1405 | + */ |
|
1406 | + private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1407 | + { |
|
1408 | + // first check that PCRE is enabled |
|
1409 | + if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1410 | + EE_Error::add_error( |
|
1411 | + sprintf( |
|
1412 | + esc_html__( |
|
1413 | + 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1414 | + 'event_espresso' |
|
1415 | + ), |
|
1416 | + '<br />' |
|
1417 | + ), |
|
1418 | + __FILE__, |
|
1419 | + __FUNCTION__, |
|
1420 | + __LINE__ |
|
1421 | + ); |
|
1422 | + return false; |
|
1423 | + } else { |
|
1424 | + // PCRE support is enabled, but let's still |
|
1425 | + // perform a test to see if the server will support it. |
|
1426 | + // but first, save the updated validation level to the config, |
|
1427 | + // so that the validation strategy picks it up. |
|
1428 | + // this will get bumped back down if it doesn't work |
|
1429 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1430 | + try { |
|
1431 | + $email_validator = new EE_Email_Validation_Strategy(); |
|
1432 | + $i18n_email_address = apply_filters( |
|
1433 | + 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1434 | + 'jägerjü[email protected]' |
|
1435 | + ); |
|
1436 | + $email_validator->validate($i18n_email_address); |
|
1437 | + } catch (Exception $e) { |
|
1438 | + EE_Error::add_error( |
|
1439 | + sprintf( |
|
1440 | + esc_html__( |
|
1441 | + 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1442 | + 'event_espresso' |
|
1443 | + ), |
|
1444 | + '<br />', |
|
1445 | + '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>' |
|
1446 | + ), |
|
1447 | + __FILE__, |
|
1448 | + __FUNCTION__, |
|
1449 | + __LINE__ |
|
1450 | + ); |
|
1451 | + return false; |
|
1452 | + } |
|
1453 | + } |
|
1454 | + return true; |
|
1455 | + } |
|
1456 | 1456 | } |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __construct($routing = true) |
22 | 22 | { |
23 | - define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/'); |
|
24 | - define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/'); |
|
25 | - define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
26 | - define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/'); |
|
27 | - define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
23 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form/'); |
|
24 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets/'); |
|
25 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/'); |
|
26 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates/'); |
|
27 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/'); |
|
28 | 28 | parent::__construct($routing); |
29 | 29 | } |
30 | 30 | |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | { |
359 | 359 | wp_register_script( |
360 | 360 | 'ee-question-sortable', |
361 | - REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
361 | + REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js', |
|
362 | 362 | array('jquery-ui-sortable'), |
363 | 363 | EVENT_ESPRESSO_VERSION, |
364 | 364 | true |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | */ |
447 | 447 | protected function _questions_overview_list_table() |
448 | 448 | { |
449 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
449 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
450 | 450 | 'add_question', |
451 | 451 | 'add_question', |
452 | 452 | array(), |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | protected function _question_groups_overview_list_table() |
468 | 468 | { |
469 | 469 | $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
470 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
470 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
471 | 471 | 'add_question_group', |
472 | 472 | 'add_question_group', |
473 | 473 | array(), |
@@ -529,18 +529,18 @@ discard block |
||
529 | 529 | { |
530 | 530 | $success = 0; |
531 | 531 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
532 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
532 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
533 | 533 | // if array has more than one element than success message should be plural |
534 | 534 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
535 | 535 | // cycle thru bulk action checkboxes |
536 | 536 | while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
537 | - if (! $this->_delete_item($ID, $model)) { |
|
537 | + if ( ! $this->_delete_item($ID, $model)) { |
|
538 | 538 | $success = 0; |
539 | 539 | } |
540 | 540 | } |
541 | - } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
541 | + } elseif ( ! empty($this->_req_data['QSG_ID'])) { |
|
542 | 542 | $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
543 | - } elseif (! empty($this->_req_data['QST_ID'])) { |
|
543 | + } elseif ( ! empty($this->_req_data['QST_ID'])) { |
|
544 | 544 | $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
545 | 545 | } else { |
546 | 546 | EE_Error::add_error( |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
610 | 610 | } |
611 | 611 | // add ID to title if editing |
612 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
612 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
613 | 613 | if ($ID) { |
614 | 614 | /** @var EE_Question_Group $questionGroup */ |
615 | 615 | $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
630 | 630 | $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
631 | 631 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
632 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
632 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php', |
|
633 | 633 | $this->_template_args, |
634 | 634 | true |
635 | 635 | ); |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | // make sure identifier is unique |
674 | 674 | $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : ''; |
675 | 675 | $where_values = ['QSG_identifier' => $set_column_values['QSG_identifier']]; |
676 | - if (! $new_question_group && isset($set_column_values['QSG_ID'])) { |
|
676 | + if ( ! $new_question_group && isset($set_column_values['QSG_ID'])) { |
|
677 | 677 | $where_values['QSG_ID'] = ['!=', $set_column_values['QSG_ID']]; |
678 | 678 | } |
679 | 679 | $identifier_exists = ! empty($identifier_value) |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | // update the existing related questions |
714 | 714 | // BUT FIRST... delete the phone question from the Question_Group_Question |
715 | 715 | // if it is being added to this question group (therefore removed from the existing group) |
716 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
716 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) { |
|
717 | 717 | // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
718 | 718 | EEM_Question_Group_Question::instance()->delete( |
719 | 719 | array( |
@@ -728,22 +728,22 @@ discard block |
||
728 | 728 | $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
729 | 729 | $questions = $question_group->questions(); |
730 | 730 | // make sure system phone question is added to list of questions for this group |
731 | - if (! isset($questions[ $phone_question_id ])) { |
|
732 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
731 | + if ( ! isset($questions[$phone_question_id])) { |
|
732 | + $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | foreach ($questions as $question_ID => $question) { |
736 | 736 | // first we always check for order. |
737 | - if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
737 | + if ( ! empty($this->_req_data['question_orders'][$question_ID])) { |
|
738 | 738 | // update question order |
739 | 739 | $question_group->update_question_order( |
740 | 740 | $question_ID, |
741 | - $this->_req_data['question_orders'][ $question_ID ] |
|
741 | + $this->_req_data['question_orders'][$question_ID] |
|
742 | 742 | ); |
743 | 743 | } |
744 | 744 | |
745 | 745 | // then we always check if adding or removing. |
746 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
746 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) { |
|
747 | 747 | $question_group->add_question($question_ID); |
748 | 748 | } else { |
749 | 749 | // not found, remove it (but only if not a system question for the personal group |
@@ -766,8 +766,8 @@ discard block |
||
766 | 766 | if (isset($this->_req_data['questions'])) { |
767 | 767 | foreach ($this->_req_data['questions'] as $QST_ID) { |
768 | 768 | $question_group->add_question($QST_ID); |
769 | - if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
770 | - $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
769 | + if (isset($this->_req_data['question_orders'][$QST_ID])) { |
|
770 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]); |
|
771 | 771 | } |
772 | 772 | } |
773 | 773 | } |
@@ -908,33 +908,33 @@ discard block |
||
908 | 908 | // echo "trash $trash"; |
909 | 909 | // var_dump($this->_req_data['checkbox']);die; |
910 | 910 | if (isset($this->_req_data['checkbox'])) { |
911 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
911 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
912 | 912 | // if array has more than one element than success message should be plural |
913 | 913 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
914 | 914 | // cycle thru bulk action checkboxes |
915 | 915 | while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
916 | - if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
916 | + if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
917 | 917 | $success = 0; |
918 | 918 | } |
919 | 919 | } |
920 | 920 | } else { |
921 | 921 | // grab single id and delete |
922 | 922 | $ID = absint($this->_req_data['checkbox']); |
923 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
923 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
924 | 924 | $success = 0; |
925 | 925 | } |
926 | 926 | } |
927 | 927 | } else { |
928 | 928 | // delete via trash link |
929 | 929 | // grab single id and delete |
930 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
931 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
930 | + $ID = absint($this->_req_data[$model->primary_key_name()]); |
|
931 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
932 | 932 | $success = 0; |
933 | 933 | } |
934 | 934 | } |
935 | 935 | |
936 | 936 | |
937 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
937 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; // strtolower( $model->item_name(2) ); |
|
938 | 938 | // echo "action :$action"; |
939 | 939 | // $action = 'questions' ? 'default' : $action; |
940 | 940 | if ($trash) { |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | ? (int) $this->_req_data['curpage'] |
1055 | 1055 | : null; |
1056 | 1056 | |
1057 | - if (! empty($row_ids)) { |
|
1057 | + if ( ! empty($row_ids)) { |
|
1058 | 1058 | // figure out where we start the row_id count at for the current page. |
1059 | 1059 | $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
1060 | 1060 | |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | // Update the questions when re-ordering |
1064 | 1064 | $updated = EEM_Question_Group::instance()->update( |
1065 | 1065 | array('QSG_order' => $qsgcount), |
1066 | - array(array('QSG_ID' => $row_ids[ $i ])) |
|
1066 | + array(array('QSG_ID' => $row_ids[$i])) |
|
1067 | 1067 | ); |
1068 | 1068 | if ($updated === false) { |
1069 | 1069 | $success = false; |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | $this->_set_add_edit_form_tags('update_reg_form_settings'); |
1115 | 1115 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
1116 | 1116 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
1117 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1117 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php', |
|
1118 | 1118 | $this->_template_args, |
1119 | 1119 | true |
1120 | 1120 | ); |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | $prev_email_validation_level = 'basic'; |
1361 | 1361 | } |
1362 | 1362 | // confirm our i18n email validation will work on the server |
1363 | - if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1363 | + if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1364 | 1364 | // or reset email validation level to previous value |
1365 | 1365 | $email_validation_level = $prev_email_validation_level; |
1366 | 1366 | } |
@@ -1406,7 +1406,7 @@ discard block |
||
1406 | 1406 | private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
1407 | 1407 | { |
1408 | 1408 | // first check that PCRE is enabled |
1409 | - if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1409 | + if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
1410 | 1410 | EE_Error::add_error( |
1411 | 1411 | sprintf( |
1412 | 1412 | esc_html__( |
@@ -38,103 +38,103 @@ |
||
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.6.2'); |
|
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.6.2'); |
|
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.10.30.rc.015'); |
|
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.10.30.rc.015'); |
|
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 | } |
141 | 141 | \ No newline at end of file |