@@ -17,178 +17,178 @@ |
||
17 | 17 | */ |
18 | 18 | class FeatureFlagsConfig extends JsonDataWordpressOption |
19 | 19 | { |
20 | - /** |
|
21 | - * WP option name for saving the Feature Flags configuration |
|
22 | - */ |
|
23 | - private const OPTION_NAME = 'ee_feature_flags'; |
|
24 | - |
|
25 | - /** |
|
26 | - * use FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT instead |
|
27 | - * this hasn't been deleted because it's used in the REM add-on |
|
28 | - * |
|
29 | - * @deprecated 5.0.18.p |
|
30 | - */ |
|
31 | - public const USE_EVENT_EDITOR_BULK_EDIT = FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT; |
|
32 | - |
|
33 | - private static array $removed = [ |
|
34 | - FeatureFlag::USE_ADVANCED_EVENT_EDITOR, |
|
35 | - ]; |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - protected Domain $domain; |
|
40 | - |
|
41 | - private ?stdClass $feature_flags = null; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @var array|null |
|
46 | - * @since 5.0.30.p |
|
47 | - */ |
|
48 | - private ?array $feature_flags_form_options = null; |
|
49 | - |
|
50 | - |
|
51 | - public function __construct(Domain $domain, JsonDataHandler $json_data_handler) |
|
52 | - { |
|
53 | - $this->domain = $domain; |
|
54 | - parent::__construct($json_data_handler, FeatureFlagsConfig::OPTION_NAME, $this->getDefaultFeatureFlagOptions()); |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * see the FeatureFlag::USE_* constants for descriptions of each feature flag and their default values |
|
60 | - * |
|
61 | - * @return stdClass |
|
62 | - */ |
|
63 | - public function getDefaultFeatureFlagOptions(): stdClass |
|
64 | - { |
|
65 | - return (object) [ |
|
66 | - FeatureFlag::USE_DATETIME_STATUS_CONTROLS => false, |
|
67 | - FeatureFlag::USE_DEFAULT_TICKET_MANAGER => true, |
|
68 | - FeatureFlag::USE_EDD_PLUGIN_LICENSING => defined('EE_USE_EDD_PLUGIN_LICENSING') |
|
69 | - && EE_USE_EDD_PLUGIN_LICENSING, |
|
70 | - FeatureFlag::USE_EVENT_DESCRIPTION_RTE => false, |
|
71 | - FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT => $this->domain->isCaffeinated() |
|
72 | - && ! $this->domain->isMultiSite(), |
|
73 | - FeatureFlag::USE_EXPERIMENTAL_RTE => false, |
|
74 | - FeatureFlag::USE_PAYMENT_PROCESSOR_FEES => true, |
|
75 | - FeatureFlag::USE_REG_FORM_BUILDER => false, |
|
76 | - FeatureFlag::USE_REG_FORM_TICKET_QUESTIONS => false, |
|
77 | - FeatureFlag::USE_REG_OPTIONS_META_BOX => false, |
|
78 | - FeatureFlag::USE_SPCO_FORM_REFACTOR => false, |
|
79 | - ]; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * feature flags that absolutely must be enabled/disabled based on hard-coded conditions |
|
85 | - * |
|
86 | - * @return stdClass |
|
87 | - * @since 5.0.20.p |
|
88 | - */ |
|
89 | - public function getOverrides(): stdClass |
|
90 | - { |
|
91 | - $overrides = []; |
|
92 | - if (defined('EE_USE_EDD_PLUGIN_LICENSING')) { |
|
93 | - $overrides[ FeatureFlag::USE_EDD_PLUGIN_LICENSING ] = EE_USE_EDD_PLUGIN_LICENSING; |
|
94 | - } |
|
95 | - return (object) $overrides; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @return stdClass |
|
101 | - */ |
|
102 | - public function getFeatureFlags(): stdClass |
|
103 | - { |
|
104 | - if ($this->feature_flags) { |
|
105 | - return $this->feature_flags; |
|
106 | - } |
|
107 | - $default_options = $this->getDefaultFeatureFlagOptions(); |
|
108 | - $this->feature_flags = $this->getAll(); |
|
109 | - $overrides = $this->getOverrides(); |
|
110 | - // ensure that all feature flags are set |
|
111 | - foreach ($default_options as $key => $value) { |
|
112 | - // if the feature flag is not set, use the default value |
|
113 | - if (! isset($this->feature_flags->$key)) { |
|
114 | - $this->feature_flags->$key = $value; |
|
115 | - } |
|
116 | - // ensure that all overrides are set |
|
117 | - if (isset($overrides->$key)) { |
|
118 | - $this->feature_flags->$key = $overrides->$key; |
|
119 | - } |
|
120 | - } |
|
121 | - return $this->feature_flags; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - public function saveFeatureFlagsConfig(?stdClass $feature_flags = null): int |
|
126 | - { |
|
127 | - $feature_flags = $feature_flags ?? $this->feature_flags; |
|
128 | - foreach (FeatureFlagsConfig::$removed as $feature_flag) { |
|
129 | - unset($feature_flags->{$feature_flag}); |
|
130 | - } |
|
131 | - $this->feature_flags = $feature_flags; |
|
132 | - return $this->updateOption($feature_flags); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * enables a feature flag, ex: |
|
138 | - * $this->enableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR); |
|
139 | - * |
|
140 | - * @param string $feature_flag the feature flag to enable. One of the FeatureFlag::USE_* constants |
|
141 | - * @param bool $add_if_missing |
|
142 | - * @param bool $save |
|
143 | - * @return int |
|
144 | - */ |
|
145 | - public function enableFeatureFlag(string $feature_flag, bool $add_if_missing = false, bool $save = true): int |
|
146 | - { |
|
147 | - if (! $this->feature_flags) { |
|
148 | - $this->getFeatureFlags(); |
|
149 | - } |
|
150 | - if (! property_exists($this->feature_flags, $feature_flag) && ! $add_if_missing) { |
|
151 | - return WordPressOption::UPDATE_ERROR; |
|
152 | - } |
|
153 | - $this->feature_flags->{$feature_flag} = true; |
|
154 | - // if feature flag is the advanced event editor bulk edit options |
|
155 | - // then only enabled if the site is Caffeinated and not MultiSite |
|
156 | - if ($feature_flag === FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT) { |
|
157 | - $this->feature_flags->{$feature_flag} = $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(); |
|
158 | - } |
|
159 | - if ($save) { |
|
160 | - return $this->saveFeatureFlagsConfig($this->feature_flags); |
|
161 | - } |
|
162 | - return WordPressOption::UPDATE_NONE; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * disables a feature flag, ex: |
|
168 | - * $this->disableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR); |
|
169 | - * |
|
170 | - * @param string $feature_flag the feature flag to disable. One of the FeatureFlag::USE_* constants |
|
171 | - * @param bool $save |
|
172 | - * @return int |
|
173 | - */ |
|
174 | - public function disableFeatureFlag(string $feature_flag, bool $save = true): int |
|
175 | - { |
|
176 | - if (! $this->feature_flags) { |
|
177 | - $this->getFeatureFlags(); |
|
178 | - } |
|
179 | - if (! property_exists($this->feature_flags, $feature_flag)) { |
|
180 | - return WordPressOption::UPDATE_ERROR; |
|
181 | - } |
|
182 | - $this->feature_flags->{$feature_flag} = false; |
|
183 | - if ($save) { |
|
184 | - return $this->saveFeatureFlagsConfig($this->feature_flags); |
|
185 | - } |
|
186 | - return WordPressOption::UPDATE_NONE; |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - public function getFeatureFlagsFormOptions(): ?array |
|
191 | - { |
|
192 | - return FeatureFlag::getFormOptions(); |
|
193 | - } |
|
20 | + /** |
|
21 | + * WP option name for saving the Feature Flags configuration |
|
22 | + */ |
|
23 | + private const OPTION_NAME = 'ee_feature_flags'; |
|
24 | + |
|
25 | + /** |
|
26 | + * use FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT instead |
|
27 | + * this hasn't been deleted because it's used in the REM add-on |
|
28 | + * |
|
29 | + * @deprecated 5.0.18.p |
|
30 | + */ |
|
31 | + public const USE_EVENT_EDITOR_BULK_EDIT = FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT; |
|
32 | + |
|
33 | + private static array $removed = [ |
|
34 | + FeatureFlag::USE_ADVANCED_EVENT_EDITOR, |
|
35 | + ]; |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + protected Domain $domain; |
|
40 | + |
|
41 | + private ?stdClass $feature_flags = null; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @var array|null |
|
46 | + * @since 5.0.30.p |
|
47 | + */ |
|
48 | + private ?array $feature_flags_form_options = null; |
|
49 | + |
|
50 | + |
|
51 | + public function __construct(Domain $domain, JsonDataHandler $json_data_handler) |
|
52 | + { |
|
53 | + $this->domain = $domain; |
|
54 | + parent::__construct($json_data_handler, FeatureFlagsConfig::OPTION_NAME, $this->getDefaultFeatureFlagOptions()); |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * see the FeatureFlag::USE_* constants for descriptions of each feature flag and their default values |
|
60 | + * |
|
61 | + * @return stdClass |
|
62 | + */ |
|
63 | + public function getDefaultFeatureFlagOptions(): stdClass |
|
64 | + { |
|
65 | + return (object) [ |
|
66 | + FeatureFlag::USE_DATETIME_STATUS_CONTROLS => false, |
|
67 | + FeatureFlag::USE_DEFAULT_TICKET_MANAGER => true, |
|
68 | + FeatureFlag::USE_EDD_PLUGIN_LICENSING => defined('EE_USE_EDD_PLUGIN_LICENSING') |
|
69 | + && EE_USE_EDD_PLUGIN_LICENSING, |
|
70 | + FeatureFlag::USE_EVENT_DESCRIPTION_RTE => false, |
|
71 | + FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT => $this->domain->isCaffeinated() |
|
72 | + && ! $this->domain->isMultiSite(), |
|
73 | + FeatureFlag::USE_EXPERIMENTAL_RTE => false, |
|
74 | + FeatureFlag::USE_PAYMENT_PROCESSOR_FEES => true, |
|
75 | + FeatureFlag::USE_REG_FORM_BUILDER => false, |
|
76 | + FeatureFlag::USE_REG_FORM_TICKET_QUESTIONS => false, |
|
77 | + FeatureFlag::USE_REG_OPTIONS_META_BOX => false, |
|
78 | + FeatureFlag::USE_SPCO_FORM_REFACTOR => false, |
|
79 | + ]; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * feature flags that absolutely must be enabled/disabled based on hard-coded conditions |
|
85 | + * |
|
86 | + * @return stdClass |
|
87 | + * @since 5.0.20.p |
|
88 | + */ |
|
89 | + public function getOverrides(): stdClass |
|
90 | + { |
|
91 | + $overrides = []; |
|
92 | + if (defined('EE_USE_EDD_PLUGIN_LICENSING')) { |
|
93 | + $overrides[ FeatureFlag::USE_EDD_PLUGIN_LICENSING ] = EE_USE_EDD_PLUGIN_LICENSING; |
|
94 | + } |
|
95 | + return (object) $overrides; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @return stdClass |
|
101 | + */ |
|
102 | + public function getFeatureFlags(): stdClass |
|
103 | + { |
|
104 | + if ($this->feature_flags) { |
|
105 | + return $this->feature_flags; |
|
106 | + } |
|
107 | + $default_options = $this->getDefaultFeatureFlagOptions(); |
|
108 | + $this->feature_flags = $this->getAll(); |
|
109 | + $overrides = $this->getOverrides(); |
|
110 | + // ensure that all feature flags are set |
|
111 | + foreach ($default_options as $key => $value) { |
|
112 | + // if the feature flag is not set, use the default value |
|
113 | + if (! isset($this->feature_flags->$key)) { |
|
114 | + $this->feature_flags->$key = $value; |
|
115 | + } |
|
116 | + // ensure that all overrides are set |
|
117 | + if (isset($overrides->$key)) { |
|
118 | + $this->feature_flags->$key = $overrides->$key; |
|
119 | + } |
|
120 | + } |
|
121 | + return $this->feature_flags; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + public function saveFeatureFlagsConfig(?stdClass $feature_flags = null): int |
|
126 | + { |
|
127 | + $feature_flags = $feature_flags ?? $this->feature_flags; |
|
128 | + foreach (FeatureFlagsConfig::$removed as $feature_flag) { |
|
129 | + unset($feature_flags->{$feature_flag}); |
|
130 | + } |
|
131 | + $this->feature_flags = $feature_flags; |
|
132 | + return $this->updateOption($feature_flags); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * enables a feature flag, ex: |
|
138 | + * $this->enableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR); |
|
139 | + * |
|
140 | + * @param string $feature_flag the feature flag to enable. One of the FeatureFlag::USE_* constants |
|
141 | + * @param bool $add_if_missing |
|
142 | + * @param bool $save |
|
143 | + * @return int |
|
144 | + */ |
|
145 | + public function enableFeatureFlag(string $feature_flag, bool $add_if_missing = false, bool $save = true): int |
|
146 | + { |
|
147 | + if (! $this->feature_flags) { |
|
148 | + $this->getFeatureFlags(); |
|
149 | + } |
|
150 | + if (! property_exists($this->feature_flags, $feature_flag) && ! $add_if_missing) { |
|
151 | + return WordPressOption::UPDATE_ERROR; |
|
152 | + } |
|
153 | + $this->feature_flags->{$feature_flag} = true; |
|
154 | + // if feature flag is the advanced event editor bulk edit options |
|
155 | + // then only enabled if the site is Caffeinated and not MultiSite |
|
156 | + if ($feature_flag === FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT) { |
|
157 | + $this->feature_flags->{$feature_flag} = $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(); |
|
158 | + } |
|
159 | + if ($save) { |
|
160 | + return $this->saveFeatureFlagsConfig($this->feature_flags); |
|
161 | + } |
|
162 | + return WordPressOption::UPDATE_NONE; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * disables a feature flag, ex: |
|
168 | + * $this->disableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR); |
|
169 | + * |
|
170 | + * @param string $feature_flag the feature flag to disable. One of the FeatureFlag::USE_* constants |
|
171 | + * @param bool $save |
|
172 | + * @return int |
|
173 | + */ |
|
174 | + public function disableFeatureFlag(string $feature_flag, bool $save = true): int |
|
175 | + { |
|
176 | + if (! $this->feature_flags) { |
|
177 | + $this->getFeatureFlags(); |
|
178 | + } |
|
179 | + if (! property_exists($this->feature_flags, $feature_flag)) { |
|
180 | + return WordPressOption::UPDATE_ERROR; |
|
181 | + } |
|
182 | + $this->feature_flags->{$feature_flag} = false; |
|
183 | + if ($save) { |
|
184 | + return $this->saveFeatureFlagsConfig($this->feature_flags); |
|
185 | + } |
|
186 | + return WordPressOption::UPDATE_NONE; |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + public function getFeatureFlagsFormOptions(): ?array |
|
191 | + { |
|
192 | + return FeatureFlag::getFormOptions(); |
|
193 | + } |
|
194 | 194 | } |
@@ -16,57 +16,57 @@ |
||
16 | 16 | */ |
17 | 17 | class CheckinsCSV |
18 | 18 | { |
19 | - /** |
|
20 | - * Returns datetime label |
|
21 | - * |
|
22 | - * @param EE_Datetime $datetime |
|
23 | - * @return string |
|
24 | - * @throws EE_Error |
|
25 | - * @throws ReflectionException |
|
26 | - */ |
|
27 | - public static function getDatetimeLabel(EE_Datetime $datetime): string |
|
28 | - { |
|
29 | - if (trim($datetime->get('DTT_name'))) { |
|
30 | - /* translators: 1: datetime name, 2: datetime ID */ |
|
31 | - return sprintf( |
|
32 | - esc_html__('Check-ins for %1$s - ID: %2$s', 'event_espresso'), |
|
33 | - esc_html($datetime->get('DTT_name')), |
|
34 | - esc_html($datetime->get('DTT_ID')) |
|
35 | - ); |
|
36 | - } |
|
19 | + /** |
|
20 | + * Returns datetime label |
|
21 | + * |
|
22 | + * @param EE_Datetime $datetime |
|
23 | + * @return string |
|
24 | + * @throws EE_Error |
|
25 | + * @throws ReflectionException |
|
26 | + */ |
|
27 | + public static function getDatetimeLabel(EE_Datetime $datetime): string |
|
28 | + { |
|
29 | + if (trim($datetime->get('DTT_name'))) { |
|
30 | + /* translators: 1: datetime name, 2: datetime ID */ |
|
31 | + return sprintf( |
|
32 | + esc_html__('Check-ins for %1$s - ID: %2$s', 'event_espresso'), |
|
33 | + esc_html($datetime->get('DTT_name')), |
|
34 | + esc_html($datetime->get('DTT_ID')) |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | |
38 | - /* translators: %s: datetime ID */ |
|
39 | - return sprintf( |
|
40 | - esc_html__('CHK-IN DTT-ID: %1$s', 'event_espresso'), |
|
41 | - esc_html($datetime->get('DTT_ID')) |
|
42 | - ); |
|
43 | - } |
|
38 | + /* translators: %s: datetime ID */ |
|
39 | + return sprintf( |
|
40 | + esc_html__('CHK-IN DTT-ID: %1$s', 'event_espresso'), |
|
41 | + esc_html($datetime->get('DTT_ID')) |
|
42 | + ); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * Returns checkin value using checkin status and datetime |
|
48 | - * |
|
49 | - * @param EE_Checkin|null $checkin |
|
50 | - * @return string|null |
|
51 | - * @throws EE_Error |
|
52 | - * @throws ReflectionException |
|
53 | - */ |
|
54 | - public static function getCheckinValue(?EE_Checkin $checkin): ?string |
|
55 | - { |
|
56 | - if ($checkin instanceof EE_Checkin && $checkin->get('CHK_in') === true) { |
|
57 | - /* translators: 1: check-in timestamp */ |
|
58 | - return sprintf( |
|
59 | - esc_html__('IN: %1$s', 'event_espresso'), |
|
60 | - $checkin->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
61 | - ); |
|
62 | - } elseif ($checkin instanceof EE_Checkin && $checkin->get('CHK_in') === false) { |
|
63 | - /* translators: 1: check-in timestamp */ |
|
64 | - return sprintf( |
|
65 | - esc_html__('OUT: %1$s', 'event_espresso'), |
|
66 | - $checkin->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
67 | - ); |
|
68 | - } |
|
46 | + /** |
|
47 | + * Returns checkin value using checkin status and datetime |
|
48 | + * |
|
49 | + * @param EE_Checkin|null $checkin |
|
50 | + * @return string|null |
|
51 | + * @throws EE_Error |
|
52 | + * @throws ReflectionException |
|
53 | + */ |
|
54 | + public static function getCheckinValue(?EE_Checkin $checkin): ?string |
|
55 | + { |
|
56 | + if ($checkin instanceof EE_Checkin && $checkin->get('CHK_in') === true) { |
|
57 | + /* translators: 1: check-in timestamp */ |
|
58 | + return sprintf( |
|
59 | + esc_html__('IN: %1$s', 'event_espresso'), |
|
60 | + $checkin->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
61 | + ); |
|
62 | + } elseif ($checkin instanceof EE_Checkin && $checkin->get('CHK_in') === false) { |
|
63 | + /* translators: 1: check-in timestamp */ |
|
64 | + return sprintf( |
|
65 | + esc_html__('OUT: %1$s', 'event_espresso'), |
|
66 | + $checkin->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | |
70 | - return ''; |
|
71 | - } |
|
70 | + return ''; |
|
71 | + } |
|
72 | 72 | } |
@@ -18,65 +18,65 @@ |
||
18 | 18 | */ |
19 | 19 | class AnswersCSV |
20 | 20 | { |
21 | - /** |
|
22 | - * Add question / answer columns to the CSV row |
|
23 | - * |
|
24 | - * @param array $reg_row |
|
25 | - * @param array $data |
|
26 | - * @param array $question_labels |
|
27 | - * @return array |
|
28 | - * @throws EE_Error |
|
29 | - * @throws ReflectionException |
|
30 | - */ |
|
31 | - public static function addAnswerColumns(array $reg_row, array $data, array $question_labels): array |
|
32 | - { |
|
33 | - $answer_model = EEM_Answer::instance(); |
|
34 | - $qst_model = EEM_Question::instance(); |
|
35 | - $state_model = EEM_State::instance(); |
|
36 | - // make sure each registration has the same questions in the same order |
|
37 | - foreach ($question_labels as $question_label) { |
|
38 | - if (! isset($data[ $question_label ])) { |
|
39 | - $data[ $question_label ] = null; |
|
40 | - } |
|
41 | - } |
|
42 | - $answers = $answer_model->get_all_wpdb_results([ |
|
43 | - ['REG_ID' => $reg_row['Registration.REG_ID']], |
|
44 | - 'force_join' => ['Question'], |
|
45 | - ]); |
|
46 | - // now fill out the questions THEY answered |
|
47 | - foreach ($answers as $answer_row) { |
|
48 | - if ($answer_row['Question.QST_system']) { |
|
49 | - // it's an answer to a system question. That was already displayed as part of the attendee |
|
50 | - // fields, so don't write it out again thanks. |
|
51 | - continue; |
|
52 | - } |
|
21 | + /** |
|
22 | + * Add question / answer columns to the CSV row |
|
23 | + * |
|
24 | + * @param array $reg_row |
|
25 | + * @param array $data |
|
26 | + * @param array $question_labels |
|
27 | + * @return array |
|
28 | + * @throws EE_Error |
|
29 | + * @throws ReflectionException |
|
30 | + */ |
|
31 | + public static function addAnswerColumns(array $reg_row, array $data, array $question_labels): array |
|
32 | + { |
|
33 | + $answer_model = EEM_Answer::instance(); |
|
34 | + $qst_model = EEM_Question::instance(); |
|
35 | + $state_model = EEM_State::instance(); |
|
36 | + // make sure each registration has the same questions in the same order |
|
37 | + foreach ($question_labels as $question_label) { |
|
38 | + if (! isset($data[ $question_label ])) { |
|
39 | + $data[ $question_label ] = null; |
|
40 | + } |
|
41 | + } |
|
42 | + $answers = $answer_model->get_all_wpdb_results([ |
|
43 | + ['REG_ID' => $reg_row['Registration.REG_ID']], |
|
44 | + 'force_join' => ['Question'], |
|
45 | + ]); |
|
46 | + // now fill out the questions THEY answered |
|
47 | + foreach ($answers as $answer_row) { |
|
48 | + if ($answer_row['Question.QST_system']) { |
|
49 | + // it's an answer to a system question. That was already displayed as part of the attendee |
|
50 | + // fields, so don't write it out again thanks. |
|
51 | + continue; |
|
52 | + } |
|
53 | 53 | |
54 | - $question_label = $answer_row['Question.QST_ID'] |
|
55 | - ? EEH_Export::prepare_value_from_db_for_display( |
|
56 | - $qst_model, |
|
57 | - 'QST_admin_label', |
|
58 | - $answer_row['Question.QST_admin_label'] |
|
59 | - ) |
|
60 | - : sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
54 | + $question_label = $answer_row['Question.QST_ID'] |
|
55 | + ? EEH_Export::prepare_value_from_db_for_display( |
|
56 | + $qst_model, |
|
57 | + 'QST_admin_label', |
|
58 | + $answer_row['Question.QST_admin_label'] |
|
59 | + ) |
|
60 | + : sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
61 | 61 | |
62 | - if (! array_key_exists($question_label, $data)) { |
|
63 | - // We don't need an answer for this specific question in the current dataset |
|
64 | - // so skip adding this value to $data. |
|
65 | - continue; |
|
66 | - } |
|
62 | + if (! array_key_exists($question_label, $data)) { |
|
63 | + // We don't need an answer for this specific question in the current dataset |
|
64 | + // so skip adding this value to $data. |
|
65 | + continue; |
|
66 | + } |
|
67 | 67 | |
68 | - $data[ $question_label ] = isset($answer_row['Question.QST_type']) |
|
69 | - && $answer_row['Question.QST_type'] === EEM_Question::QST_type_state |
|
70 | - ? $state_model->get_state_name_by_ID((int) $answer_row['Answer.ANS_value']) |
|
71 | - // this isn't for html, so don't show html entities |
|
72 | - : html_entity_decode( |
|
73 | - EEH_Export::prepare_value_from_db_for_display( |
|
74 | - $answer_model, |
|
75 | - 'ANS_value', |
|
76 | - $answer_row['Answer.ANS_value'] |
|
77 | - ) |
|
78 | - ); |
|
79 | - } |
|
80 | - return $data; |
|
81 | - } |
|
68 | + $data[ $question_label ] = isset($answer_row['Question.QST_type']) |
|
69 | + && $answer_row['Question.QST_type'] === EEM_Question::QST_type_state |
|
70 | + ? $state_model->get_state_name_by_ID((int) $answer_row['Answer.ANS_value']) |
|
71 | + // this isn't for html, so don't show html entities |
|
72 | + : html_entity_decode( |
|
73 | + EEH_Export::prepare_value_from_db_for_display( |
|
74 | + $answer_model, |
|
75 | + 'ANS_value', |
|
76 | + $answer_row['Answer.ANS_value'] |
|
77 | + ) |
|
78 | + ); |
|
79 | + } |
|
80 | + return $data; |
|
81 | + } |
|
82 | 82 | } |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | $state_model = EEM_State::instance(); |
36 | 36 | // make sure each registration has the same questions in the same order |
37 | 37 | foreach ($question_labels as $question_label) { |
38 | - if (! isset($data[ $question_label ])) { |
|
39 | - $data[ $question_label ] = null; |
|
38 | + if ( ! isset($data[$question_label])) { |
|
39 | + $data[$question_label] = null; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | $answers = $answer_model->get_all_wpdb_results([ |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | ) |
60 | 60 | : sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
61 | 61 | |
62 | - if (! array_key_exists($question_label, $data)) { |
|
62 | + if ( ! array_key_exists($question_label, $data)) { |
|
63 | 63 | // We don't need an answer for this specific question in the current dataset |
64 | 64 | // so skip adding this value to $data. |
65 | 65 | continue; |
66 | 66 | } |
67 | 67 | |
68 | - $data[ $question_label ] = isset($answer_row['Question.QST_type']) |
|
68 | + $data[$question_label] = isset($answer_row['Question.QST_type']) |
|
69 | 69 | && $answer_row['Question.QST_type'] === EEM_Question::QST_type_state |
70 | 70 | ? $state_model->get_state_name_by_ID((int) $answer_row['Answer.ANS_value']) |
71 | 71 | // this isn't for html, so don't show html entities |
@@ -6,74 +6,74 @@ |
||
6 | 6 | |
7 | 7 | class JqueryAssetManager extends AssetManager |
8 | 8 | { |
9 | - const JS_HANDLE_JQUERY = 'jquery'; |
|
9 | + const JS_HANDLE_JQUERY = 'jquery'; |
|
10 | 10 | |
11 | - const JS_HANDLE_JQUERY_COOKIE = 'jquery-cookie'; |
|
11 | + const JS_HANDLE_JQUERY_COOKIE = 'jquery-cookie'; |
|
12 | 12 | |
13 | - const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
13 | + const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
14 | 14 | |
15 | - const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
15 | + const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
16 | 16 | |
17 | - const JS_HANDLE_JQUERY_UI_CORE = 'jquery-ui-core'; |
|
17 | + const JS_HANDLE_JQUERY_UI_CORE = 'jquery-ui-core'; |
|
18 | 18 | |
19 | - const JS_HANDLE_JQUERY_UI_DATEPICKER = 'jquery-ui-datepicker'; |
|
19 | + const JS_HANDLE_JQUERY_UI_DATEPICKER = 'jquery-ui-datepicker'; |
|
20 | 20 | |
21 | - const JS_HANDLE_JQUERY_UI_DRAGGABLE = 'jquery-ui-draggable'; |
|
21 | + const JS_HANDLE_JQUERY_UI_DRAGGABLE = 'jquery-ui-draggable'; |
|
22 | 22 | |
23 | - const JS_HANDLE_JQUERY_UI_SLIDER = 'jquery-ui-slider'; |
|
23 | + const JS_HANDLE_JQUERY_UI_SLIDER = 'jquery-ui-slider'; |
|
24 | 24 | |
25 | - const JS_HANDLE_JQUERY_UI_SORTABLE = 'jquery-ui-sortable'; |
|
25 | + const JS_HANDLE_JQUERY_UI_SORTABLE = 'jquery-ui-sortable'; |
|
26 | 26 | |
27 | - const JS_HANDLE_JQUERY_UI_TIMEPICKER_ADDON = 'jquery-ui-timepicker-addon'; |
|
27 | + const JS_HANDLE_JQUERY_UI_TIMEPICKER_ADDON = 'jquery-ui-timepicker-addon'; |
|
28 | 28 | |
29 | - const JS_HANDLE_JQUERY_UI_TOUCH_PUNCH = 'jquery.ui.touch-punch'; |
|
29 | + const JS_HANDLE_JQUERY_UI_TOUCH_PUNCH = 'jquery.ui.touch-punch'; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - /** |
|
33 | + /** |
|
34 | 34 | * @inheritDoc |
35 | 35 | */ |
36 | 36 | public function addAssets() |
37 | 37 | { |
38 | - // register cookie script for future dependencies |
|
39 | - $this->addJavascript( |
|
40 | - JqueryAssetManager::JS_HANDLE_JQUERY_COOKIE, |
|
41 | - EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
42 | - ['jquery'], |
|
43 | - true, |
|
44 | - '2.1' |
|
45 | - ); |
|
46 | - |
|
47 | - $this->addJavascript( |
|
48 | - JqueryAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
49 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
50 | - array(JqueryAssetManager::JS_HANDLE_JQUERY), |
|
51 | - true, |
|
52 | - '1.19.5' |
|
53 | - )->setEnqueueImmediately(); |
|
54 | - |
|
55 | - $this->addJavascript( |
|
56 | - JqueryAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
57 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
58 | - array(JqueryAssetManager::JS_HANDLE_JQUERY_VALIDATE), |
|
59 | - true, |
|
60 | - '1.19.5' |
|
61 | - ); |
|
62 | - |
|
63 | - $this->addJavascript( |
|
64 | - JqueryAssetManager::JS_HANDLE_JQUERY_UI_TIMEPICKER_ADDON, |
|
65 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', |
|
66 | - [ |
|
67 | - JqueryAssetManager::JS_HANDLE_JQUERY_UI_DATEPICKER, |
|
68 | - JqueryAssetManager::JS_HANDLE_JQUERY_UI_SLIDER |
|
69 | - ] |
|
70 | - ); |
|
71 | - $this->addJavascript( |
|
72 | - JqueryAssetManager::JS_HANDLE_JQUERY_UI_TOUCH_PUNCH, |
|
73 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.ui.touch-punch.min.js', |
|
74 | - [ |
|
75 | - JqueryAssetManager::JS_HANDLE_JQUERY_UI_CORE |
|
76 | - ] |
|
77 | - ); |
|
38 | + // register cookie script for future dependencies |
|
39 | + $this->addJavascript( |
|
40 | + JqueryAssetManager::JS_HANDLE_JQUERY_COOKIE, |
|
41 | + EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
42 | + ['jquery'], |
|
43 | + true, |
|
44 | + '2.1' |
|
45 | + ); |
|
46 | + |
|
47 | + $this->addJavascript( |
|
48 | + JqueryAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
49 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
50 | + array(JqueryAssetManager::JS_HANDLE_JQUERY), |
|
51 | + true, |
|
52 | + '1.19.5' |
|
53 | + )->setEnqueueImmediately(); |
|
54 | + |
|
55 | + $this->addJavascript( |
|
56 | + JqueryAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
57 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
58 | + array(JqueryAssetManager::JS_HANDLE_JQUERY_VALIDATE), |
|
59 | + true, |
|
60 | + '1.19.5' |
|
61 | + ); |
|
62 | + |
|
63 | + $this->addJavascript( |
|
64 | + JqueryAssetManager::JS_HANDLE_JQUERY_UI_TIMEPICKER_ADDON, |
|
65 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', |
|
66 | + [ |
|
67 | + JqueryAssetManager::JS_HANDLE_JQUERY_UI_DATEPICKER, |
|
68 | + JqueryAssetManager::JS_HANDLE_JQUERY_UI_SLIDER |
|
69 | + ] |
|
70 | + ); |
|
71 | + $this->addJavascript( |
|
72 | + JqueryAssetManager::JS_HANDLE_JQUERY_UI_TOUCH_PUNCH, |
|
73 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.ui.touch-punch.min.js', |
|
74 | + [ |
|
75 | + JqueryAssetManager::JS_HANDLE_JQUERY_UI_CORE |
|
76 | + ] |
|
77 | + ); |
|
78 | 78 | } |
79 | 79 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | // register cookie script for future dependencies |
39 | 39 | $this->addJavascript( |
40 | 40 | JqueryAssetManager::JS_HANDLE_JQUERY_COOKIE, |
41 | - EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
41 | + EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', |
|
42 | 42 | ['jquery'], |
43 | 43 | true, |
44 | 44 | '2.1' |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | $this->addJavascript( |
48 | 48 | JqueryAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
49 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
49 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
50 | 50 | array(JqueryAssetManager::JS_HANDLE_JQUERY), |
51 | 51 | true, |
52 | 52 | '1.19.5' |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | $this->addJavascript( |
56 | 56 | JqueryAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
57 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
57 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
58 | 58 | array(JqueryAssetManager::JS_HANDLE_JQUERY_VALIDATE), |
59 | 59 | true, |
60 | 60 | '1.19.5' |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | $this->addJavascript( |
64 | 64 | JqueryAssetManager::JS_HANDLE_JQUERY_UI_TIMEPICKER_ADDON, |
65 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', |
|
65 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', |
|
66 | 66 | [ |
67 | 67 | JqueryAssetManager::JS_HANDLE_JQUERY_UI_DATEPICKER, |
68 | 68 | JqueryAssetManager::JS_HANDLE_JQUERY_UI_SLIDER |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | ); |
71 | 71 | $this->addJavascript( |
72 | 72 | JqueryAssetManager::JS_HANDLE_JQUERY_UI_TOUCH_PUNCH, |
73 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.ui.touch-punch.min.js', |
|
73 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.ui.touch-punch.min.js', |
|
74 | 74 | [ |
75 | 75 | JqueryAssetManager::JS_HANDLE_JQUERY_UI_CORE |
76 | 76 | ] |
@@ -13,211 +13,211 @@ |
||
13 | 13 | |
14 | 14 | class RegFormInputHandler |
15 | 15 | { |
16 | - private EEM_Attendee $attendee_model; |
|
17 | - |
|
18 | - private string $checkout_reg_url_link; |
|
19 | - |
|
20 | - private RegistrantData $registrant_data; |
|
21 | - |
|
22 | - private array $required_questions; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * RegFormHandler constructor. |
|
27 | - */ |
|
28 | - public function __construct( |
|
29 | - string $checkout_reg_url_link, |
|
30 | - array $required_questions, |
|
31 | - EEM_Attendee $attendee_model, |
|
32 | - RegistrantData $registrant_data |
|
33 | - ) { |
|
34 | - $this->attendee_model = $attendee_model; |
|
35 | - $this->checkout_reg_url_link = $checkout_reg_url_link; |
|
36 | - $this->registrant_data = $registrant_data; |
|
37 | - $this->required_questions = $required_questions; |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * @param EE_Registration $registration |
|
43 | - * @param string $reg_url_link |
|
44 | - * @param int|string $form_input |
|
45 | - * @param float|int|string $input_value |
|
46 | - * @return bool |
|
47 | - * @throws EE_Error |
|
48 | - * @throws ReflectionException |
|
49 | - */ |
|
50 | - public function processFormInput( |
|
51 | - EE_Registration $registration, |
|
52 | - string $reg_url_link, |
|
53 | - $form_input, |
|
54 | - $input_value |
|
55 | - ): bool { |
|
56 | - // check for critical inputs |
|
57 | - if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) { |
|
58 | - return false; |
|
59 | - } |
|
60 | - $input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData( |
|
61 | - $reg_url_link, |
|
62 | - $form_input, |
|
63 | - $input_value |
|
64 | - ); |
|
65 | - if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) { |
|
66 | - EE_Error::add_error( |
|
67 | - sprintf( |
|
68 | - esc_html_x( |
|
69 | - 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
70 | - 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
71 | - 'event_espresso' |
|
72 | - ), |
|
73 | - $form_input, |
|
74 | - $input_value |
|
75 | - ), |
|
76 | - __FILE__, |
|
77 | - __FUNCTION__, |
|
78 | - __LINE__ |
|
79 | - ); |
|
80 | - return false; |
|
81 | - } |
|
82 | - return true; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @param EE_Registration $registration |
|
88 | - * @param string $reg_url_link |
|
89 | - * @param int|string $form_input |
|
90 | - * @param float|int|string $input_value |
|
91 | - * @return bool |
|
92 | - * @throws EE_Error |
|
93 | - * @throws InvalidArgumentException |
|
94 | - * @throws InvalidDataTypeException |
|
95 | - * @throws InvalidInterfaceException |
|
96 | - * @throws ReflectionException |
|
97 | - */ |
|
98 | - private function saveRegistrationFormInput( |
|
99 | - EE_Registration $registration, |
|
100 | - string $reg_url_link, |
|
101 | - $form_input = '', |
|
102 | - $input_value = '' |
|
103 | - ): bool { |
|
104 | - // If email_confirm is sent it's not saved |
|
105 | - if ((string) $form_input === 'email_confirm') { |
|
106 | - return true; |
|
107 | - } |
|
108 | - // allow for plugins to hook in and do their own processing of the form input. |
|
109 | - // For plugins to bypass normal processing here, they just need to return a truthy value. |
|
110 | - if ( |
|
111 | - apply_filters( |
|
112 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput', |
|
113 | - false, |
|
114 | - $registration, |
|
115 | - $form_input, |
|
116 | - $input_value, |
|
117 | - $this |
|
118 | - ) |
|
119 | - ) { |
|
120 | - return true; |
|
121 | - } |
|
122 | - /* |
|
16 | + private EEM_Attendee $attendee_model; |
|
17 | + |
|
18 | + private string $checkout_reg_url_link; |
|
19 | + |
|
20 | + private RegistrantData $registrant_data; |
|
21 | + |
|
22 | + private array $required_questions; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * RegFormHandler constructor. |
|
27 | + */ |
|
28 | + public function __construct( |
|
29 | + string $checkout_reg_url_link, |
|
30 | + array $required_questions, |
|
31 | + EEM_Attendee $attendee_model, |
|
32 | + RegistrantData $registrant_data |
|
33 | + ) { |
|
34 | + $this->attendee_model = $attendee_model; |
|
35 | + $this->checkout_reg_url_link = $checkout_reg_url_link; |
|
36 | + $this->registrant_data = $registrant_data; |
|
37 | + $this->required_questions = $required_questions; |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * @param EE_Registration $registration |
|
43 | + * @param string $reg_url_link |
|
44 | + * @param int|string $form_input |
|
45 | + * @param float|int|string $input_value |
|
46 | + * @return bool |
|
47 | + * @throws EE_Error |
|
48 | + * @throws ReflectionException |
|
49 | + */ |
|
50 | + public function processFormInput( |
|
51 | + EE_Registration $registration, |
|
52 | + string $reg_url_link, |
|
53 | + $form_input, |
|
54 | + $input_value |
|
55 | + ): bool { |
|
56 | + // check for critical inputs |
|
57 | + if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) { |
|
58 | + return false; |
|
59 | + } |
|
60 | + $input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData( |
|
61 | + $reg_url_link, |
|
62 | + $form_input, |
|
63 | + $input_value |
|
64 | + ); |
|
65 | + if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) { |
|
66 | + EE_Error::add_error( |
|
67 | + sprintf( |
|
68 | + esc_html_x( |
|
69 | + 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
70 | + 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
71 | + 'event_espresso' |
|
72 | + ), |
|
73 | + $form_input, |
|
74 | + $input_value |
|
75 | + ), |
|
76 | + __FILE__, |
|
77 | + __FUNCTION__, |
|
78 | + __LINE__ |
|
79 | + ); |
|
80 | + return false; |
|
81 | + } |
|
82 | + return true; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @param EE_Registration $registration |
|
88 | + * @param string $reg_url_link |
|
89 | + * @param int|string $form_input |
|
90 | + * @param float|int|string $input_value |
|
91 | + * @return bool |
|
92 | + * @throws EE_Error |
|
93 | + * @throws InvalidArgumentException |
|
94 | + * @throws InvalidDataTypeException |
|
95 | + * @throws InvalidInterfaceException |
|
96 | + * @throws ReflectionException |
|
97 | + */ |
|
98 | + private function saveRegistrationFormInput( |
|
99 | + EE_Registration $registration, |
|
100 | + string $reg_url_link, |
|
101 | + $form_input = '', |
|
102 | + $input_value = '' |
|
103 | + ): bool { |
|
104 | + // If email_confirm is sent it's not saved |
|
105 | + if ((string) $form_input === 'email_confirm') { |
|
106 | + return true; |
|
107 | + } |
|
108 | + // allow for plugins to hook in and do their own processing of the form input. |
|
109 | + // For plugins to bypass normal processing here, they just need to return a truthy value. |
|
110 | + if ( |
|
111 | + apply_filters( |
|
112 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput', |
|
113 | + false, |
|
114 | + $registration, |
|
115 | + $form_input, |
|
116 | + $input_value, |
|
117 | + $this |
|
118 | + ) |
|
119 | + ) { |
|
120 | + return true; |
|
121 | + } |
|
122 | + /* |
|
123 | 123 | * $answer_cache_id is the key used to find the EE_Answer we want |
124 | 124 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
125 | 125 | */ |
126 | - $answer_cache_id = $this->checkout_reg_url_link |
|
127 | - ? $form_input . '-' . $reg_url_link |
|
128 | - : $form_input; |
|
129 | - $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id); |
|
130 | - $answer_is_obj = $registrant_answer instanceof EE_Answer; |
|
131 | - // rename form_inputs if they are EE_Attendee properties |
|
132 | - switch ((string) $form_input) { |
|
133 | - case 'state': |
|
134 | - case 'STA_ID': |
|
135 | - $attendee_property = true; |
|
136 | - $form_input = 'STA_ID'; |
|
137 | - break; |
|
138 | - |
|
139 | - case 'country': |
|
140 | - case 'CNT_ISO': |
|
141 | - $attendee_property = true; |
|
142 | - $form_input = 'CNT_ISO'; |
|
143 | - break; |
|
144 | - |
|
145 | - default: |
|
146 | - $ATT_input = 'ATT_' . $form_input; |
|
147 | - $attendee_property = $this->attendee_model->has_field($ATT_input); |
|
148 | - $form_input = $attendee_property |
|
149 | - ? 'ATT_' . $form_input |
|
150 | - : $form_input; |
|
151 | - } |
|
152 | - |
|
153 | - // if this form input has a corresponding attendee property |
|
154 | - if ($attendee_property) { |
|
155 | - $this->registrant_data->addRegistrantDataValue($reg_url_link, $form_input, $input_value); |
|
156 | - if ($answer_is_obj) { |
|
157 | - // and delete the corresponding answer since we won't be storing this data in that object |
|
158 | - $registration->_remove_relation_to($registrant_answer, 'Answer'); |
|
159 | - $registrant_answer->delete_permanently(); |
|
160 | - } |
|
161 | - return true; |
|
162 | - } |
|
163 | - if ($answer_is_obj) { |
|
164 | - // save this data to the answer object |
|
165 | - $registrant_answer->set_value($input_value); |
|
166 | - $result = $registrant_answer->save(); |
|
167 | - return $result !== false; |
|
168 | - } |
|
169 | - foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) { |
|
170 | - if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
171 | - $answer->set_value($input_value); |
|
172 | - $result = $answer->save(); |
|
173 | - return $result !== false; |
|
174 | - } |
|
175 | - } |
|
176 | - return false; |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * @param int|string $form_input |
|
182 | - * @param float|int|string $input_value |
|
183 | - * @return boolean |
|
184 | - */ |
|
185 | - private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail( |
|
186 | - $form_input = '', |
|
187 | - $input_value = '' |
|
188 | - ): bool { |
|
189 | - if (empty($input_value)) { |
|
190 | - // if the form input isn't marked as being required, then just return |
|
191 | - if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) { |
|
192 | - return true; |
|
193 | - } |
|
194 | - switch ($form_input) { |
|
195 | - case 'fname': |
|
196 | - EE_Error::add_error( |
|
197 | - esc_html__('First Name is a required value.', 'event_espresso'), |
|
198 | - __FILE__, |
|
199 | - __FUNCTION__, |
|
200 | - __LINE__ |
|
201 | - ); |
|
202 | - return false; |
|
203 | - case 'lname': |
|
204 | - EE_Error::add_error( |
|
205 | - esc_html__('Last Name is a required value.', 'event_espresso'), |
|
206 | - __FILE__, |
|
207 | - __FUNCTION__, |
|
208 | - __LINE__ |
|
209 | - ); |
|
210 | - return false; |
|
211 | - case 'email': |
|
212 | - EE_Error::add_error( |
|
213 | - esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
214 | - __FILE__, |
|
215 | - __FUNCTION__, |
|
216 | - __LINE__ |
|
217 | - ); |
|
218 | - return false; |
|
219 | - } |
|
220 | - } |
|
221 | - return true; |
|
222 | - } |
|
126 | + $answer_cache_id = $this->checkout_reg_url_link |
|
127 | + ? $form_input . '-' . $reg_url_link |
|
128 | + : $form_input; |
|
129 | + $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id); |
|
130 | + $answer_is_obj = $registrant_answer instanceof EE_Answer; |
|
131 | + // rename form_inputs if they are EE_Attendee properties |
|
132 | + switch ((string) $form_input) { |
|
133 | + case 'state': |
|
134 | + case 'STA_ID': |
|
135 | + $attendee_property = true; |
|
136 | + $form_input = 'STA_ID'; |
|
137 | + break; |
|
138 | + |
|
139 | + case 'country': |
|
140 | + case 'CNT_ISO': |
|
141 | + $attendee_property = true; |
|
142 | + $form_input = 'CNT_ISO'; |
|
143 | + break; |
|
144 | + |
|
145 | + default: |
|
146 | + $ATT_input = 'ATT_' . $form_input; |
|
147 | + $attendee_property = $this->attendee_model->has_field($ATT_input); |
|
148 | + $form_input = $attendee_property |
|
149 | + ? 'ATT_' . $form_input |
|
150 | + : $form_input; |
|
151 | + } |
|
152 | + |
|
153 | + // if this form input has a corresponding attendee property |
|
154 | + if ($attendee_property) { |
|
155 | + $this->registrant_data->addRegistrantDataValue($reg_url_link, $form_input, $input_value); |
|
156 | + if ($answer_is_obj) { |
|
157 | + // and delete the corresponding answer since we won't be storing this data in that object |
|
158 | + $registration->_remove_relation_to($registrant_answer, 'Answer'); |
|
159 | + $registrant_answer->delete_permanently(); |
|
160 | + } |
|
161 | + return true; |
|
162 | + } |
|
163 | + if ($answer_is_obj) { |
|
164 | + // save this data to the answer object |
|
165 | + $registrant_answer->set_value($input_value); |
|
166 | + $result = $registrant_answer->save(); |
|
167 | + return $result !== false; |
|
168 | + } |
|
169 | + foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) { |
|
170 | + if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
171 | + $answer->set_value($input_value); |
|
172 | + $result = $answer->save(); |
|
173 | + return $result !== false; |
|
174 | + } |
|
175 | + } |
|
176 | + return false; |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * @param int|string $form_input |
|
182 | + * @param float|int|string $input_value |
|
183 | + * @return boolean |
|
184 | + */ |
|
185 | + private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail( |
|
186 | + $form_input = '', |
|
187 | + $input_value = '' |
|
188 | + ): bool { |
|
189 | + if (empty($input_value)) { |
|
190 | + // if the form input isn't marked as being required, then just return |
|
191 | + if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) { |
|
192 | + return true; |
|
193 | + } |
|
194 | + switch ($form_input) { |
|
195 | + case 'fname': |
|
196 | + EE_Error::add_error( |
|
197 | + esc_html__('First Name is a required value.', 'event_espresso'), |
|
198 | + __FILE__, |
|
199 | + __FUNCTION__, |
|
200 | + __LINE__ |
|
201 | + ); |
|
202 | + return false; |
|
203 | + case 'lname': |
|
204 | + EE_Error::add_error( |
|
205 | + esc_html__('Last Name is a required value.', 'event_espresso'), |
|
206 | + __FILE__, |
|
207 | + __FUNCTION__, |
|
208 | + __LINE__ |
|
209 | + ); |
|
210 | + return false; |
|
211 | + case 'email': |
|
212 | + EE_Error::add_error( |
|
213 | + esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
214 | + __FILE__, |
|
215 | + __FUNCTION__, |
|
216 | + __LINE__ |
|
217 | + ); |
|
218 | + return false; |
|
219 | + } |
|
220 | + } |
|
221 | + return true; |
|
222 | + } |
|
223 | 223 | } |
@@ -13,58 +13,58 @@ |
||
13 | 13 | |
14 | 14 | class TicketDetailsTable extends EE_Form_Section_HTML |
15 | 15 | { |
16 | - private EE_Line_Item $cart_grand_total; |
|
17 | - private EE_Line_Item_Display $line_item_display; |
|
16 | + private EE_Line_Item $cart_grand_total; |
|
17 | + private EE_Line_Item_Display $line_item_display; |
|
18 | 18 | |
19 | - private static int $prev_ticket_id = 0; |
|
19 | + private static int $prev_ticket_id = 0; |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @param EE_Line_Item $cart_grand_total |
|
24 | - * @param EE_Line_Item_Display $line_item_display |
|
25 | - * @param EE_Ticket $ticket |
|
26 | - * @param bool $revisit |
|
27 | - * @throws EE_Error |
|
28 | - * @throws ReflectionException |
|
29 | - */ |
|
30 | - public function __construct(EE_Line_Item $cart_grand_total, EE_Line_Item_Display $line_item_display, EE_Ticket $ticket, bool $revisit) |
|
31 | - { |
|
32 | - $this->cart_grand_total = $cart_grand_total; |
|
33 | - $this->line_item_display = $line_item_display; |
|
34 | - parent::__construct( |
|
35 | - ! $revisit && $ticket->ID() !== TicketDetailsTable::$prev_ticket_id |
|
36 | - ? $this->generateTicketDetailsTable($ticket) |
|
37 | - : '' |
|
38 | - ); |
|
39 | - TicketDetailsTable::$prev_ticket_id = $ticket->ID(); |
|
40 | - } |
|
22 | + /** |
|
23 | + * @param EE_Line_Item $cart_grand_total |
|
24 | + * @param EE_Line_Item_Display $line_item_display |
|
25 | + * @param EE_Ticket $ticket |
|
26 | + * @param bool $revisit |
|
27 | + * @throws EE_Error |
|
28 | + * @throws ReflectionException |
|
29 | + */ |
|
30 | + public function __construct(EE_Line_Item $cart_grand_total, EE_Line_Item_Display $line_item_display, EE_Ticket $ticket, bool $revisit) |
|
31 | + { |
|
32 | + $this->cart_grand_total = $cart_grand_total; |
|
33 | + $this->line_item_display = $line_item_display; |
|
34 | + parent::__construct( |
|
35 | + ! $revisit && $ticket->ID() !== TicketDetailsTable::$prev_ticket_id |
|
36 | + ? $this->generateTicketDetailsTable($ticket) |
|
37 | + : '' |
|
38 | + ); |
|
39 | + TicketDetailsTable::$prev_ticket_id = $ticket->ID(); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - private function generateTicketDetailsTable(EE_Ticket $ticket): string |
|
44 | - { |
|
45 | - $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
46 | - $this->cart_grand_total, |
|
47 | - 'Ticket', |
|
48 | - [$ticket->ID()] |
|
49 | - ); |
|
50 | - $ticket_line_item = ! empty($ticket_line_item) ? reset($ticket_line_item) : $ticket_line_item; |
|
43 | + private function generateTicketDetailsTable(EE_Ticket $ticket): string |
|
44 | + { |
|
45 | + $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
46 | + $this->cart_grand_total, |
|
47 | + 'Ticket', |
|
48 | + [$ticket->ID()] |
|
49 | + ); |
|
50 | + $ticket_line_item = ! empty($ticket_line_item) ? reset($ticket_line_item) : $ticket_line_item; |
|
51 | 51 | |
52 | - return EEH_HTML::div( |
|
53 | - EEH_HTML::table( |
|
54 | - EEH_HTML::thead( |
|
55 | - EEH_HTML::tr( |
|
56 | - EEH_HTML::th('', '', 'jst-left') |
|
57 | - . EEH_HTML::th(esc_html__('Qty', 'event_espresso'), '', 'jst-rght') |
|
58 | - . EEH_HTML::th(esc_html__('Price', 'event_espresso'), '', 'jst-rght') |
|
59 | - . EEH_HTML::th(esc_html__('Total', 'event_espresso'), '', 'jst-rght'), |
|
60 | - ) |
|
61 | - ) |
|
62 | - . EEH_HTML::tbody($this->line_item_display->display_line_item($ticket_line_item)), |
|
63 | - '', |
|
64 | - 'spco-ticket-details' |
|
65 | - ), |
|
66 | - '', |
|
67 | - 'spco-ticket-info-dv' |
|
68 | - ); |
|
69 | - } |
|
52 | + return EEH_HTML::div( |
|
53 | + EEH_HTML::table( |
|
54 | + EEH_HTML::thead( |
|
55 | + EEH_HTML::tr( |
|
56 | + EEH_HTML::th('', '', 'jst-left') |
|
57 | + . EEH_HTML::th(esc_html__('Qty', 'event_espresso'), '', 'jst-rght') |
|
58 | + . EEH_HTML::th(esc_html__('Price', 'event_espresso'), '', 'jst-rght') |
|
59 | + . EEH_HTML::th(esc_html__('Total', 'event_espresso'), '', 'jst-rght'), |
|
60 | + ) |
|
61 | + ) |
|
62 | + . EEH_HTML::tbody($this->line_item_display->display_line_item($ticket_line_item)), |
|
63 | + '', |
|
64 | + 'spco-ticket-details' |
|
65 | + ), |
|
66 | + '', |
|
67 | + 'spco-ticket-info-dv' |
|
68 | + ); |
|
69 | + } |
|
70 | 70 | } |
@@ -10,23 +10,23 @@ |
||
10 | 10 | |
11 | 11 | class EventHeader extends EE_Form_Section_HTML |
12 | 12 | { |
13 | - private static int $prev_event_id = 0; |
|
13 | + private static int $prev_event_id = 0; |
|
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @param EE_Event $event |
|
18 | - * @throws EE_Error |
|
19 | - * @throws ReflectionException |
|
20 | - */ |
|
21 | - public function __construct(EE_Event $event) |
|
22 | - { |
|
23 | - parent::__construct( |
|
24 | - // only show event title if not admin and event id is not the same as the previous event id |
|
25 | - ! is_admin() && $event->ID() !== EventHeader::$prev_event_id |
|
26 | - ? EEH_HTML::h4(esc_html($event->name()), "event_title-{$event->ID()}", 'big-event-title-hdr') |
|
27 | - : '' |
|
28 | - ); |
|
29 | - // update prev event id after generating header html |
|
30 | - EventHeader::$prev_event_id = $event->ID(); |
|
31 | - } |
|
16 | + /** |
|
17 | + * @param EE_Event $event |
|
18 | + * @throws EE_Error |
|
19 | + * @throws ReflectionException |
|
20 | + */ |
|
21 | + public function __construct(EE_Event $event) |
|
22 | + { |
|
23 | + parent::__construct( |
|
24 | + // only show event title if not admin and event id is not the same as the previous event id |
|
25 | + ! is_admin() && $event->ID() !== EventHeader::$prev_event_id |
|
26 | + ? EEH_HTML::h4(esc_html($event->name()), "event_title-{$event->ID()}", 'big-event-title-hdr') |
|
27 | + : '' |
|
28 | + ); |
|
29 | + // update prev event id after generating header html |
|
30 | + EventHeader::$prev_event_id = $event->ID(); |
|
31 | + } |
|
32 | 32 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | class EventHeader extends EE_Form_Section_HTML |
12 | 12 | { |
13 | - private static int $prev_event_id = 0; |
|
13 | + private static int $prev_event_id = 0; |
|
14 | 14 | |
15 | 15 | |
16 | 16 | /** |
@@ -7,24 +7,24 @@ |
||
7 | 7 | |
8 | 8 | class AttendeeInformationNotice extends EE_Form_Section_HTML |
9 | 9 | { |
10 | - public function __construct() |
|
11 | - { |
|
12 | - parent::__construct( |
|
13 | - EEH_HTML::p( |
|
14 | - apply_filters( |
|
15 | - 'FHEE__registration_page_attendee_information__attendee_information_pg', |
|
16 | - sprintf( |
|
17 | - esc_html__( |
|
18 | - 'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', |
|
19 | - 'event_espresso' |
|
20 | - ), |
|
21 | - '<br />', |
|
22 | - '<span class="asterisk">*</span>' |
|
23 | - ) |
|
24 | - ), |
|
25 | - 'spco-attendee_information-pg', |
|
26 | - 'spco-steps-pg small-text drk-grey-text' |
|
27 | - ) |
|
28 | - ); |
|
29 | - } |
|
10 | + public function __construct() |
|
11 | + { |
|
12 | + parent::__construct( |
|
13 | + EEH_HTML::p( |
|
14 | + apply_filters( |
|
15 | + 'FHEE__registration_page_attendee_information__attendee_information_pg', |
|
16 | + sprintf( |
|
17 | + esc_html__( |
|
18 | + 'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', |
|
19 | + 'event_espresso' |
|
20 | + ), |
|
21 | + '<br />', |
|
22 | + '<span class="asterisk">*</span>' |
|
23 | + ) |
|
24 | + ), |
|
25 | + 'spco-attendee_information-pg', |
|
26 | + 'spco-steps-pg small-text drk-grey-text' |
|
27 | + ) |
|
28 | + ); |
|
29 | + } |
|
30 | 30 | } |
@@ -40,275 +40,275 @@ |
||
40 | 40 | */ |
41 | 41 | class RegForm extends EE_Form_Section_Proper |
42 | 42 | { |
43 | - private EE_Line_Item_Display $line_item_display; |
|
44 | - |
|
45 | - private string $primary_registrant = ''; |
|
46 | - |
|
47 | - private array $required_questions = []; |
|
48 | - |
|
49 | - private array $subsections = []; |
|
50 | - |
|
51 | - |
|
52 | - private bool $print_copy_info = false; |
|
53 | - |
|
54 | - protected int $reg_form_count = 0; |
|
55 | - |
|
56 | - public EE_Registration_Config $reg_config; |
|
57 | - |
|
58 | - public EE_SPCO_Reg_Step_Attendee_Information $reg_step; |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * RegForm constructor. |
|
63 | - * |
|
64 | - * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
65 | - * @param EE_Registration_Config $reg_config |
|
66 | - * @throws ReflectionException |
|
67 | - * @throws EE_Error |
|
68 | - */ |
|
69 | - public function __construct( |
|
70 | - EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
71 | - EE_Registration_Config $reg_config |
|
72 | - ) { |
|
73 | - $this->reg_step = $reg_step; |
|
74 | - $this->reg_config = $reg_config; |
|
75 | - // setup some classes so that they are ready for loading during construction of other classes |
|
76 | - LoaderFactory::getShared(CountryOptions::class, [$this->reg_step->checkout->action]); |
|
77 | - LoaderFactory::getShared(StateOptions::class, [$this->reg_step->checkout->action]); |
|
78 | - LoaderFactory::getShared(RegFormQuestionFactory::class, [[$this, 'addRequiredQuestion']]); |
|
79 | - parent::__construct( |
|
80 | - [ |
|
81 | - 'name' => $this->reg_step->reg_form_name(), |
|
82 | - 'html_id' => $this->reg_step->reg_form_name(), |
|
83 | - 'layout_strategy' => new EE_No_Layout(), |
|
84 | - 'subsections' => $this->generateSubsections(), |
|
85 | - ] |
|
86 | - ); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @return void |
|
92 | - */ |
|
93 | - public function enablePrintCopyInfo(): void |
|
94 | - { |
|
95 | - $this->print_copy_info = true; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @return bool |
|
101 | - */ |
|
102 | - public function printCopyInfo(): bool |
|
103 | - { |
|
104 | - return $this->print_copy_info; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @return int |
|
110 | - */ |
|
111 | - public function regFormCount(): int |
|
112 | - { |
|
113 | - return $this->reg_form_count; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - public function requiredQuestions(): array |
|
121 | - { |
|
122 | - return $this->required_questions; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @param string $identifier |
|
128 | - * @param string $required_question |
|
129 | - */ |
|
130 | - public function addRequiredQuestion(string $identifier, string $required_question): void |
|
131 | - { |
|
132 | - $this->required_questions[ $identifier ] = $required_question; |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * @return EE_Form_Section_Proper[] |
|
138 | - * @throws DomainException |
|
139 | - * @throws EE_Error |
|
140 | - * @throws InvalidArgumentException |
|
141 | - * @throws ReflectionException |
|
142 | - * @throws EntityNotFoundException |
|
143 | - * @throws InvalidDataTypeException |
|
144 | - * @throws InvalidInterfaceException |
|
145 | - */ |
|
146 | - private function generateSubsections(): array |
|
147 | - { |
|
148 | - $this->configureLineItemDisplay(); |
|
149 | - $this->addAttendeeInformationNotice(); |
|
150 | - |
|
151 | - // grab the saved registrations from the transaction |
|
152 | - $registrations = $this->reg_step->checkout->transaction->registrations( |
|
153 | - $this->reg_step->checkout->reg_cache_where_params |
|
154 | - ); |
|
155 | - if ($registrations) { |
|
156 | - foreach ($registrations as $registration) { |
|
157 | - if (! $registration instanceof EE_Registration) { |
|
158 | - continue; |
|
159 | - } |
|
160 | - $this->addAttendeeRegForm($registration); |
|
161 | - } |
|
162 | - $this->addCopyAttendeeInfoForm($registrations); |
|
163 | - } |
|
164 | - $this->addPrivacyConsentCheckbox(); |
|
165 | - $this->displayEventQuestionsLink(); |
|
166 | - $this->subsections['default_hidden_inputs'] = $this->reg_step->reg_step_hidden_inputs(); |
|
167 | - |
|
168 | - return (array) apply_filters( |
|
169 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegForm__generateSubsections__subsections', |
|
170 | - $this->subsections, |
|
171 | - $this |
|
172 | - ); |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * @throws EE_Error |
|
178 | - * @throws ReflectionException |
|
179 | - */ |
|
180 | - private function configureLineItemDisplay() |
|
181 | - { |
|
182 | - // autoload Line_Item_Display classes |
|
183 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
184 | - $this->line_item_display = new EE_Line_Item_Display(); |
|
185 | - // calculate taxes |
|
186 | - $this->line_item_display->display_line_item( |
|
187 | - $this->reg_step->checkout->cart->get_grand_total(), |
|
188 | - ['set_tax_rate' => true] |
|
189 | - ); |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - private function addAttendeeInformationNotice(): void |
|
194 | - { |
|
195 | - if (is_admin()) { |
|
196 | - return; |
|
197 | - } |
|
198 | - $this->subsections['attendee_information_notice'] = new AttendeeInformationNotice(); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * @param EE_Registration $registration |
|
204 | - * @throws EE_Error |
|
205 | - * @throws ReflectionException |
|
206 | - */ |
|
207 | - private function addAttendeeRegForm(EE_Registration $registration): void |
|
208 | - { |
|
209 | - // can this registration be processed during this visit ? |
|
210 | - if (! $this->reg_step->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
211 | - return; |
|
212 | - } |
|
213 | - $reg_url_link = $registration->reg_url_link(); |
|
214 | - if ($registration->is_primary_registrant()) { |
|
215 | - $this->primary_registrant = $reg_url_link; |
|
216 | - } |
|
217 | - |
|
218 | - /** @var AttendeeRegForm $registrant_form */ |
|
219 | - $registrant_form = LoaderFactory::getNew( |
|
220 | - AttendeeRegForm::class, |
|
221 | - [ |
|
222 | - $registration, |
|
223 | - $this->reg_config->copyAttendeeInfo(), |
|
224 | - [$this, 'enablePrintCopyInfo'], |
|
225 | - $this->reg_step, |
|
226 | - ] |
|
227 | - ); |
|
228 | - |
|
229 | - // skip section if there are no questions |
|
230 | - if (! $registrant_form->hasQuestions()) { |
|
231 | - return; |
|
232 | - } |
|
233 | - |
|
234 | - // but increment the reg form count if form is valid. |
|
235 | - $this->reg_form_count++; |
|
236 | - $this->subsections["panel-div-open-$reg_url_link"] = new EE_Form_Section_HTML( |
|
237 | - EEH_HTML::div( |
|
238 | - '', |
|
239 | - "spco-attendee-panel-dv-$reg_url_link", |
|
240 | - "spco-attendee-panel-dv spco-attendee-ticket-$reg_url_link" |
|
241 | - ) |
|
242 | - ); |
|
243 | - $this->subsections["event-header-$reg_url_link"] = new EventHeader($registration->event()); |
|
244 | - $this->subsections["ticket-details-$reg_url_link"] = new TicketDetailsTable( |
|
245 | - $this->reg_step->checkout->cart->get_grand_total(), |
|
246 | - $this->line_item_display, |
|
247 | - $registration->ticket(), |
|
248 | - $this->reg_step->checkout->revisit |
|
249 | - ); |
|
250 | - $this->subsections[ $reg_url_link ] = $registrant_form; |
|
251 | - $this->subsections["panel-div-close-$reg_url_link"] = new EE_Form_Section_HTML( |
|
252 | - EEH_HTML::divx("spco-attendee-panel-dv-$reg_url_link") |
|
253 | - ); |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * @throws ReflectionException |
|
259 | - * @throws EE_Error |
|
260 | - */ |
|
261 | - private function addCopyAttendeeInfoForm(array $registrations) |
|
262 | - { |
|
263 | - if ( |
|
264 | - $this->primary_registrant |
|
265 | - && count($registrations) > 1 |
|
266 | - && isset($this->subsections[ $this->primary_registrant ]) |
|
267 | - && $this->subsections[ $this->primary_registrant ] instanceof EE_Form_Section_Proper |
|
268 | - ) { |
|
269 | - $this->subsections[ $this->primary_registrant ]->add_subsections( |
|
270 | - [ |
|
271 | - 'spco_copy_attendee_chk' => $this->print_copy_info |
|
272 | - ? new CopyAttendeeInfoForm($registrations, $this->reg_step->slug()) |
|
273 | - : new AutoCopyAttendeeInfoForm($this->reg_step->slug()), |
|
274 | - ], |
|
275 | - 'primary_registrant', |
|
276 | - false |
|
277 | - ); |
|
278 | - } |
|
279 | - } |
|
280 | - |
|
281 | - |
|
282 | - /** |
|
283 | - * @return void |
|
284 | - * @throws EE_Error |
|
285 | - */ |
|
286 | - private function addPrivacyConsentCheckbox(): void |
|
287 | - { |
|
288 | - // if this isn't a revisit, and they have the privacy consent box enabled, add it |
|
289 | - if (! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
290 | - $this->subsections['consent_box'] = new PrivacyConsentCheckboxForm( |
|
291 | - $this->reg_step->slug(), |
|
292 | - $this->reg_config->getConsentCheckboxLabelText() |
|
293 | - ); |
|
294 | - } |
|
295 | - } |
|
296 | - |
|
297 | - |
|
298 | - private function displayEventQuestionsLink() |
|
299 | - { |
|
300 | - $this->subsections['event_questions_link'] = new EE_Form_Section_HTML( |
|
301 | - EEH_HTML::div( |
|
302 | - EEH_HTML::link( |
|
303 | - '', |
|
304 | - esc_html__('show event questions', 'event_espresso'), |
|
305 | - esc_html__('show event questions', 'event_espresso'), |
|
306 | - 'spco-display-event-questions-lnk', |
|
307 | - 'act-like-link smaller-text hidden hide-if-no-js float-right' |
|
308 | - ), |
|
309 | - '', |
|
310 | - 'clearfix' |
|
311 | - ) |
|
312 | - ); |
|
313 | - } |
|
43 | + private EE_Line_Item_Display $line_item_display; |
|
44 | + |
|
45 | + private string $primary_registrant = ''; |
|
46 | + |
|
47 | + private array $required_questions = []; |
|
48 | + |
|
49 | + private array $subsections = []; |
|
50 | + |
|
51 | + |
|
52 | + private bool $print_copy_info = false; |
|
53 | + |
|
54 | + protected int $reg_form_count = 0; |
|
55 | + |
|
56 | + public EE_Registration_Config $reg_config; |
|
57 | + |
|
58 | + public EE_SPCO_Reg_Step_Attendee_Information $reg_step; |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * RegForm constructor. |
|
63 | + * |
|
64 | + * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
65 | + * @param EE_Registration_Config $reg_config |
|
66 | + * @throws ReflectionException |
|
67 | + * @throws EE_Error |
|
68 | + */ |
|
69 | + public function __construct( |
|
70 | + EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
71 | + EE_Registration_Config $reg_config |
|
72 | + ) { |
|
73 | + $this->reg_step = $reg_step; |
|
74 | + $this->reg_config = $reg_config; |
|
75 | + // setup some classes so that they are ready for loading during construction of other classes |
|
76 | + LoaderFactory::getShared(CountryOptions::class, [$this->reg_step->checkout->action]); |
|
77 | + LoaderFactory::getShared(StateOptions::class, [$this->reg_step->checkout->action]); |
|
78 | + LoaderFactory::getShared(RegFormQuestionFactory::class, [[$this, 'addRequiredQuestion']]); |
|
79 | + parent::__construct( |
|
80 | + [ |
|
81 | + 'name' => $this->reg_step->reg_form_name(), |
|
82 | + 'html_id' => $this->reg_step->reg_form_name(), |
|
83 | + 'layout_strategy' => new EE_No_Layout(), |
|
84 | + 'subsections' => $this->generateSubsections(), |
|
85 | + ] |
|
86 | + ); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @return void |
|
92 | + */ |
|
93 | + public function enablePrintCopyInfo(): void |
|
94 | + { |
|
95 | + $this->print_copy_info = true; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @return bool |
|
101 | + */ |
|
102 | + public function printCopyInfo(): bool |
|
103 | + { |
|
104 | + return $this->print_copy_info; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @return int |
|
110 | + */ |
|
111 | + public function regFormCount(): int |
|
112 | + { |
|
113 | + return $this->reg_form_count; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + public function requiredQuestions(): array |
|
121 | + { |
|
122 | + return $this->required_questions; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @param string $identifier |
|
128 | + * @param string $required_question |
|
129 | + */ |
|
130 | + public function addRequiredQuestion(string $identifier, string $required_question): void |
|
131 | + { |
|
132 | + $this->required_questions[ $identifier ] = $required_question; |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * @return EE_Form_Section_Proper[] |
|
138 | + * @throws DomainException |
|
139 | + * @throws EE_Error |
|
140 | + * @throws InvalidArgumentException |
|
141 | + * @throws ReflectionException |
|
142 | + * @throws EntityNotFoundException |
|
143 | + * @throws InvalidDataTypeException |
|
144 | + * @throws InvalidInterfaceException |
|
145 | + */ |
|
146 | + private function generateSubsections(): array |
|
147 | + { |
|
148 | + $this->configureLineItemDisplay(); |
|
149 | + $this->addAttendeeInformationNotice(); |
|
150 | + |
|
151 | + // grab the saved registrations from the transaction |
|
152 | + $registrations = $this->reg_step->checkout->transaction->registrations( |
|
153 | + $this->reg_step->checkout->reg_cache_where_params |
|
154 | + ); |
|
155 | + if ($registrations) { |
|
156 | + foreach ($registrations as $registration) { |
|
157 | + if (! $registration instanceof EE_Registration) { |
|
158 | + continue; |
|
159 | + } |
|
160 | + $this->addAttendeeRegForm($registration); |
|
161 | + } |
|
162 | + $this->addCopyAttendeeInfoForm($registrations); |
|
163 | + } |
|
164 | + $this->addPrivacyConsentCheckbox(); |
|
165 | + $this->displayEventQuestionsLink(); |
|
166 | + $this->subsections['default_hidden_inputs'] = $this->reg_step->reg_step_hidden_inputs(); |
|
167 | + |
|
168 | + return (array) apply_filters( |
|
169 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegForm__generateSubsections__subsections', |
|
170 | + $this->subsections, |
|
171 | + $this |
|
172 | + ); |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * @throws EE_Error |
|
178 | + * @throws ReflectionException |
|
179 | + */ |
|
180 | + private function configureLineItemDisplay() |
|
181 | + { |
|
182 | + // autoload Line_Item_Display classes |
|
183 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
184 | + $this->line_item_display = new EE_Line_Item_Display(); |
|
185 | + // calculate taxes |
|
186 | + $this->line_item_display->display_line_item( |
|
187 | + $this->reg_step->checkout->cart->get_grand_total(), |
|
188 | + ['set_tax_rate' => true] |
|
189 | + ); |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + private function addAttendeeInformationNotice(): void |
|
194 | + { |
|
195 | + if (is_admin()) { |
|
196 | + return; |
|
197 | + } |
|
198 | + $this->subsections['attendee_information_notice'] = new AttendeeInformationNotice(); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * @param EE_Registration $registration |
|
204 | + * @throws EE_Error |
|
205 | + * @throws ReflectionException |
|
206 | + */ |
|
207 | + private function addAttendeeRegForm(EE_Registration $registration): void |
|
208 | + { |
|
209 | + // can this registration be processed during this visit ? |
|
210 | + if (! $this->reg_step->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
211 | + return; |
|
212 | + } |
|
213 | + $reg_url_link = $registration->reg_url_link(); |
|
214 | + if ($registration->is_primary_registrant()) { |
|
215 | + $this->primary_registrant = $reg_url_link; |
|
216 | + } |
|
217 | + |
|
218 | + /** @var AttendeeRegForm $registrant_form */ |
|
219 | + $registrant_form = LoaderFactory::getNew( |
|
220 | + AttendeeRegForm::class, |
|
221 | + [ |
|
222 | + $registration, |
|
223 | + $this->reg_config->copyAttendeeInfo(), |
|
224 | + [$this, 'enablePrintCopyInfo'], |
|
225 | + $this->reg_step, |
|
226 | + ] |
|
227 | + ); |
|
228 | + |
|
229 | + // skip section if there are no questions |
|
230 | + if (! $registrant_form->hasQuestions()) { |
|
231 | + return; |
|
232 | + } |
|
233 | + |
|
234 | + // but increment the reg form count if form is valid. |
|
235 | + $this->reg_form_count++; |
|
236 | + $this->subsections["panel-div-open-$reg_url_link"] = new EE_Form_Section_HTML( |
|
237 | + EEH_HTML::div( |
|
238 | + '', |
|
239 | + "spco-attendee-panel-dv-$reg_url_link", |
|
240 | + "spco-attendee-panel-dv spco-attendee-ticket-$reg_url_link" |
|
241 | + ) |
|
242 | + ); |
|
243 | + $this->subsections["event-header-$reg_url_link"] = new EventHeader($registration->event()); |
|
244 | + $this->subsections["ticket-details-$reg_url_link"] = new TicketDetailsTable( |
|
245 | + $this->reg_step->checkout->cart->get_grand_total(), |
|
246 | + $this->line_item_display, |
|
247 | + $registration->ticket(), |
|
248 | + $this->reg_step->checkout->revisit |
|
249 | + ); |
|
250 | + $this->subsections[ $reg_url_link ] = $registrant_form; |
|
251 | + $this->subsections["panel-div-close-$reg_url_link"] = new EE_Form_Section_HTML( |
|
252 | + EEH_HTML::divx("spco-attendee-panel-dv-$reg_url_link") |
|
253 | + ); |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * @throws ReflectionException |
|
259 | + * @throws EE_Error |
|
260 | + */ |
|
261 | + private function addCopyAttendeeInfoForm(array $registrations) |
|
262 | + { |
|
263 | + if ( |
|
264 | + $this->primary_registrant |
|
265 | + && count($registrations) > 1 |
|
266 | + && isset($this->subsections[ $this->primary_registrant ]) |
|
267 | + && $this->subsections[ $this->primary_registrant ] instanceof EE_Form_Section_Proper |
|
268 | + ) { |
|
269 | + $this->subsections[ $this->primary_registrant ]->add_subsections( |
|
270 | + [ |
|
271 | + 'spco_copy_attendee_chk' => $this->print_copy_info |
|
272 | + ? new CopyAttendeeInfoForm($registrations, $this->reg_step->slug()) |
|
273 | + : new AutoCopyAttendeeInfoForm($this->reg_step->slug()), |
|
274 | + ], |
|
275 | + 'primary_registrant', |
|
276 | + false |
|
277 | + ); |
|
278 | + } |
|
279 | + } |
|
280 | + |
|
281 | + |
|
282 | + /** |
|
283 | + * @return void |
|
284 | + * @throws EE_Error |
|
285 | + */ |
|
286 | + private function addPrivacyConsentCheckbox(): void |
|
287 | + { |
|
288 | + // if this isn't a revisit, and they have the privacy consent box enabled, add it |
|
289 | + if (! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
290 | + $this->subsections['consent_box'] = new PrivacyConsentCheckboxForm( |
|
291 | + $this->reg_step->slug(), |
|
292 | + $this->reg_config->getConsentCheckboxLabelText() |
|
293 | + ); |
|
294 | + } |
|
295 | + } |
|
296 | + |
|
297 | + |
|
298 | + private function displayEventQuestionsLink() |
|
299 | + { |
|
300 | + $this->subsections['event_questions_link'] = new EE_Form_Section_HTML( |
|
301 | + EEH_HTML::div( |
|
302 | + EEH_HTML::link( |
|
303 | + '', |
|
304 | + esc_html__('show event questions', 'event_espresso'), |
|
305 | + esc_html__('show event questions', 'event_espresso'), |
|
306 | + 'spco-display-event-questions-lnk', |
|
307 | + 'act-like-link smaller-text hidden hide-if-no-js float-right' |
|
308 | + ), |
|
309 | + '', |
|
310 | + 'clearfix' |
|
311 | + ) |
|
312 | + ); |
|
313 | + } |
|
314 | 314 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function addRequiredQuestion(string $identifier, string $required_question): void |
131 | 131 | { |
132 | - $this->required_questions[ $identifier ] = $required_question; |
|
132 | + $this->required_questions[$identifier] = $required_question; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | ); |
155 | 155 | if ($registrations) { |
156 | 156 | foreach ($registrations as $registration) { |
157 | - if (! $registration instanceof EE_Registration) { |
|
157 | + if ( ! $registration instanceof EE_Registration) { |
|
158 | 158 | continue; |
159 | 159 | } |
160 | 160 | $this->addAttendeeRegForm($registration); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | $this->addPrivacyConsentCheckbox(); |
165 | 165 | $this->displayEventQuestionsLink(); |
166 | - $this->subsections['default_hidden_inputs'] = $this->reg_step->reg_step_hidden_inputs(); |
|
166 | + $this->subsections['default_hidden_inputs'] = $this->reg_step->reg_step_hidden_inputs(); |
|
167 | 167 | |
168 | 168 | return (array) apply_filters( |
169 | 169 | 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegForm__generateSubsections__subsections', |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | private function addAttendeeRegForm(EE_Registration $registration): void |
208 | 208 | { |
209 | 209 | // can this registration be processed during this visit ? |
210 | - if (! $this->reg_step->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
210 | + if ( ! $this->reg_step->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
211 | 211 | return; |
212 | 212 | } |
213 | 213 | $reg_url_link = $registration->reg_url_link(); |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | ); |
228 | 228 | |
229 | 229 | // skip section if there are no questions |
230 | - if (! $registrant_form->hasQuestions()) { |
|
230 | + if ( ! $registrant_form->hasQuestions()) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | 234 | // but increment the reg form count if form is valid. |
235 | 235 | $this->reg_form_count++; |
236 | - $this->subsections["panel-div-open-$reg_url_link"] = new EE_Form_Section_HTML( |
|
236 | + $this->subsections["panel-div-open-$reg_url_link"] = new EE_Form_Section_HTML( |
|
237 | 237 | EEH_HTML::div( |
238 | 238 | '', |
239 | 239 | "spco-attendee-panel-dv-$reg_url_link", |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $registration->ticket(), |
248 | 248 | $this->reg_step->checkout->revisit |
249 | 249 | ); |
250 | - $this->subsections[ $reg_url_link ] = $registrant_form; |
|
250 | + $this->subsections[$reg_url_link] = $registrant_form; |
|
251 | 251 | $this->subsections["panel-div-close-$reg_url_link"] = new EE_Form_Section_HTML( |
252 | 252 | EEH_HTML::divx("spco-attendee-panel-dv-$reg_url_link") |
253 | 253 | ); |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | if ( |
264 | 264 | $this->primary_registrant |
265 | 265 | && count($registrations) > 1 |
266 | - && isset($this->subsections[ $this->primary_registrant ]) |
|
267 | - && $this->subsections[ $this->primary_registrant ] instanceof EE_Form_Section_Proper |
|
266 | + && isset($this->subsections[$this->primary_registrant]) |
|
267 | + && $this->subsections[$this->primary_registrant] instanceof EE_Form_Section_Proper |
|
268 | 268 | ) { |
269 | - $this->subsections[ $this->primary_registrant ]->add_subsections( |
|
269 | + $this->subsections[$this->primary_registrant]->add_subsections( |
|
270 | 270 | [ |
271 | 271 | 'spco_copy_attendee_chk' => $this->print_copy_info |
272 | 272 | ? new CopyAttendeeInfoForm($registrations, $this->reg_step->slug()) |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | private function addPrivacyConsentCheckbox(): void |
287 | 287 | { |
288 | 288 | // if this isn't a revisit, and they have the privacy consent box enabled, add it |
289 | - if (! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
289 | + if ( ! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
290 | 290 | $this->subsections['consent_box'] = new PrivacyConsentCheckboxForm( |
291 | 291 | $this->reg_step->slug(), |
292 | 292 | $this->reg_config->getConsentCheckboxLabelText() |