@@ -18,197 +18,197 @@ |
||
18 | 18 | */ |
19 | 19 | class Extend_About_Admin_Page extends About_Admin_Page |
20 | 20 | { |
21 | - public function __construct($routing = true) |
|
22 | - { |
|
23 | - parent::__construct($routing); |
|
24 | - define('EE_ABOUT_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'about/templates/'); |
|
25 | - } |
|
26 | - |
|
27 | - |
|
28 | - protected function _set_page_routes() |
|
29 | - { |
|
30 | - $this->_page_routes = [ |
|
31 | - 'default' => [ |
|
32 | - 'func' => '_whats_new', |
|
33 | - 'capability' => 'manage_options', |
|
34 | - ], |
|
35 | - 'overview' => [ |
|
36 | - 'func' => '_overview', |
|
37 | - 'capability' => 'manage_options', |
|
38 | - ], |
|
39 | - 'credits' => [ |
|
40 | - 'func' => '_credits', |
|
41 | - 'capability' => 'manage_options', |
|
42 | - ], |
|
43 | - /*'decafvpro' => array( |
|
21 | + public function __construct($routing = true) |
|
22 | + { |
|
23 | + parent::__construct($routing); |
|
24 | + define('EE_ABOUT_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'about/templates/'); |
|
25 | + } |
|
26 | + |
|
27 | + |
|
28 | + protected function _set_page_routes() |
|
29 | + { |
|
30 | + $this->_page_routes = [ |
|
31 | + 'default' => [ |
|
32 | + 'func' => '_whats_new', |
|
33 | + 'capability' => 'manage_options', |
|
34 | + ], |
|
35 | + 'overview' => [ |
|
36 | + 'func' => '_overview', |
|
37 | + 'capability' => 'manage_options', |
|
38 | + ], |
|
39 | + 'credits' => [ |
|
40 | + 'func' => '_credits', |
|
41 | + 'capability' => 'manage_options', |
|
42 | + ], |
|
43 | + /*'decafvpro' => array( |
|
44 | 44 | 'func' => '_decafvpro', |
45 | 45 | 'capability' => 'manage_options' |
46 | 46 | ),*/ |
47 | - 'reviews' => [ |
|
48 | - 'func' => '_reviews', |
|
49 | - 'capability' => 'manage_options', |
|
50 | - ], |
|
51 | - |
|
52 | - |
|
53 | - ]; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - protected function _set_page_config() |
|
58 | - { |
|
59 | - parent::_set_page_config(); |
|
60 | - |
|
61 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'about'; |
|
62 | - $this->_page_config = [ |
|
63 | - 'default' => [ |
|
64 | - 'nav' => [ |
|
65 | - 'label' => esc_html__('What\'s New', 'event_espresso'), |
|
66 | - 'icon' => 'dashicons-bell', |
|
67 | - 'order' => 10, |
|
68 | - ], |
|
69 | - 'require_nonce' => false, |
|
70 | - ], |
|
71 | - 'overview' => [ |
|
72 | - 'nav' => [ |
|
73 | - 'label' => esc_html__('About', 'event_espresso'), |
|
74 | - 'icon' => 'dashicons-info', |
|
75 | - 'order' => 20, |
|
76 | - ], |
|
77 | - 'require_nonce' => false, |
|
78 | - ], |
|
79 | - 'credits' => [ |
|
80 | - 'nav' => [ |
|
81 | - 'label' => esc_html__('Credits', 'event_espresso'), |
|
82 | - 'icon' => 'dashicons-thumbs-up', |
|
83 | - 'order' => 30, |
|
84 | - ], |
|
85 | - 'require_nonce' => false, |
|
86 | - ], |
|
87 | - /*'decafvpro' => array( |
|
47 | + 'reviews' => [ |
|
48 | + 'func' => '_reviews', |
|
49 | + 'capability' => 'manage_options', |
|
50 | + ], |
|
51 | + |
|
52 | + |
|
53 | + ]; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + protected function _set_page_config() |
|
58 | + { |
|
59 | + parent::_set_page_config(); |
|
60 | + |
|
61 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'about'; |
|
62 | + $this->_page_config = [ |
|
63 | + 'default' => [ |
|
64 | + 'nav' => [ |
|
65 | + 'label' => esc_html__('What\'s New', 'event_espresso'), |
|
66 | + 'icon' => 'dashicons-bell', |
|
67 | + 'order' => 10, |
|
68 | + ], |
|
69 | + 'require_nonce' => false, |
|
70 | + ], |
|
71 | + 'overview' => [ |
|
72 | + 'nav' => [ |
|
73 | + 'label' => esc_html__('About', 'event_espresso'), |
|
74 | + 'icon' => 'dashicons-info', |
|
75 | + 'order' => 20, |
|
76 | + ], |
|
77 | + 'require_nonce' => false, |
|
78 | + ], |
|
79 | + 'credits' => [ |
|
80 | + 'nav' => [ |
|
81 | + 'label' => esc_html__('Credits', 'event_espresso'), |
|
82 | + 'icon' => 'dashicons-thumbs-up', |
|
83 | + 'order' => 30, |
|
84 | + ], |
|
85 | + 'require_nonce' => false, |
|
86 | + ], |
|
87 | + /*'decafvpro' => array( |
|
88 | 88 | 'nav' => array( |
89 | 89 | 'label' => esc_html__('Decaf vs Regular', 'event_espresso'), |
90 | 90 | 'order' => 40), |
91 | 91 | 'require_nonce' => FALSE |
92 | 92 | ),*/ |
93 | - 'reviews' => [ |
|
94 | - 'nav' => [ |
|
95 | - 'label' => esc_html__('Reviews', 'event_espresso'), |
|
96 | - 'icon' => 'dashicons-star-filled', |
|
97 | - 'order' => 50, |
|
98 | - ], |
|
99 | - 'require_nonce' => false, |
|
100 | - ], |
|
101 | - |
|
102 | - ]; |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - protected function _whats_new() |
|
107 | - { |
|
108 | - $steps = MaintenanceStatus::isNotDisabled() ? $this->_get_started_steps() : ''; |
|
109 | - $this->_admin_page_title = sprintf( |
|
110 | - esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
111 | - EVENT_ESPRESSO_VERSION |
|
112 | - ); |
|
113 | - $settings_message = $steps; |
|
114 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
115 | - 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
116 | - 'event_espresso' |
|
117 | - ) . $settings_message; |
|
118 | - $template = |
|
119 | - is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php') |
|
120 | - ? EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php' |
|
121 | - : EE_ABOUT_TEMPLATE_PATH |
|
122 | - . 'whats_new.template.php'; |
|
123 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
124 | - $template, |
|
125 | - $this->_template_args, |
|
126 | - true |
|
127 | - ); |
|
128 | - $this->display_about_admin_page(); |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - protected function _overview() |
|
133 | - { |
|
134 | - $this->_admin_page_title = esc_html__('About Event Espresso', 'event_espresso'); |
|
135 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
136 | - 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
137 | - 'event_espresso' |
|
138 | - ); |
|
139 | - $template = |
|
140 | - is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php') |
|
141 | - ? EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php' |
|
142 | - : EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php'; |
|
143 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
144 | - $template, |
|
145 | - $this->_template_args, |
|
146 | - true |
|
147 | - ); |
|
148 | - $this->display_about_admin_page(); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - protected function _credits() |
|
153 | - { |
|
154 | - // $this->_template_args['admin_page_title'] = sprintf( |
|
155 | - // esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
156 | - // EVENT_ESPRESSO_VERSION |
|
157 | - // ); |
|
158 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
159 | - 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
160 | - 'event_espresso' |
|
161 | - ); |
|
162 | - $template = EE_ABOUT_TEMPLATE_PATH . 'credits.template.php'; |
|
163 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
164 | - $template, |
|
165 | - $this->_template_args, |
|
166 | - true |
|
167 | - ); |
|
168 | - $this->display_about_admin_page(); |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - protected function _decafvpro() |
|
173 | - { |
|
174 | - $this->_template_args['admin_page_title'] = sprintf( |
|
175 | - esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
176 | - EVENT_ESPRESSO_VERSION |
|
177 | - ); |
|
178 | - $this->_template_args['admin_page_subtitle'] = sprintf( |
|
179 | - esc_html__( |
|
180 | - 'Event Espresso lets you focus on doing %swhat you love%s — %sorganizing your events%s', |
|
181 | - 'event_espresso' |
|
182 | - ), |
|
183 | - '<em>', |
|
184 | - '</em>', |
|
185 | - '<strong>', |
|
186 | - '</strong>' |
|
187 | - ); |
|
188 | - $template = EE_ABOUT_TEMPLATE_PATH . 'decafvpro.template.php'; |
|
189 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
190 | - $template, |
|
191 | - $this->_template_args, |
|
192 | - true |
|
193 | - ); |
|
194 | - $this->display_about_admin_page(); |
|
195 | - } |
|
196 | - |
|
197 | - |
|
198 | - protected function _reviews() |
|
199 | - { |
|
200 | - $this->_template_args['admin_page_title'] = |
|
201 | - esc_html__('Rave Reviews About Event Espresso 4', 'event_espresso'); |
|
202 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
203 | - 'At Event Espresso, customer satisfaction is our ultimate goal.', |
|
204 | - 'event_espresso' |
|
205 | - ); |
|
206 | - $template = EE_ABOUT_TEMPLATE_PATH . 'reviews.template.php'; |
|
207 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
208 | - $template, |
|
209 | - $this->_template_args, |
|
210 | - true |
|
211 | - ); |
|
212 | - $this->display_about_admin_page(); |
|
213 | - } |
|
93 | + 'reviews' => [ |
|
94 | + 'nav' => [ |
|
95 | + 'label' => esc_html__('Reviews', 'event_espresso'), |
|
96 | + 'icon' => 'dashicons-star-filled', |
|
97 | + 'order' => 50, |
|
98 | + ], |
|
99 | + 'require_nonce' => false, |
|
100 | + ], |
|
101 | + |
|
102 | + ]; |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + protected function _whats_new() |
|
107 | + { |
|
108 | + $steps = MaintenanceStatus::isNotDisabled() ? $this->_get_started_steps() : ''; |
|
109 | + $this->_admin_page_title = sprintf( |
|
110 | + esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
111 | + EVENT_ESPRESSO_VERSION |
|
112 | + ); |
|
113 | + $settings_message = $steps; |
|
114 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
115 | + 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
116 | + 'event_espresso' |
|
117 | + ) . $settings_message; |
|
118 | + $template = |
|
119 | + is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php') |
|
120 | + ? EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php' |
|
121 | + : EE_ABOUT_TEMPLATE_PATH |
|
122 | + . 'whats_new.template.php'; |
|
123 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
124 | + $template, |
|
125 | + $this->_template_args, |
|
126 | + true |
|
127 | + ); |
|
128 | + $this->display_about_admin_page(); |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + protected function _overview() |
|
133 | + { |
|
134 | + $this->_admin_page_title = esc_html__('About Event Espresso', 'event_espresso'); |
|
135 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
136 | + 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
137 | + 'event_espresso' |
|
138 | + ); |
|
139 | + $template = |
|
140 | + is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php') |
|
141 | + ? EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php' |
|
142 | + : EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php'; |
|
143 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
144 | + $template, |
|
145 | + $this->_template_args, |
|
146 | + true |
|
147 | + ); |
|
148 | + $this->display_about_admin_page(); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + protected function _credits() |
|
153 | + { |
|
154 | + // $this->_template_args['admin_page_title'] = sprintf( |
|
155 | + // esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
156 | + // EVENT_ESPRESSO_VERSION |
|
157 | + // ); |
|
158 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
159 | + 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
160 | + 'event_espresso' |
|
161 | + ); |
|
162 | + $template = EE_ABOUT_TEMPLATE_PATH . 'credits.template.php'; |
|
163 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
164 | + $template, |
|
165 | + $this->_template_args, |
|
166 | + true |
|
167 | + ); |
|
168 | + $this->display_about_admin_page(); |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + protected function _decafvpro() |
|
173 | + { |
|
174 | + $this->_template_args['admin_page_title'] = sprintf( |
|
175 | + esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
176 | + EVENT_ESPRESSO_VERSION |
|
177 | + ); |
|
178 | + $this->_template_args['admin_page_subtitle'] = sprintf( |
|
179 | + esc_html__( |
|
180 | + 'Event Espresso lets you focus on doing %swhat you love%s — %sorganizing your events%s', |
|
181 | + 'event_espresso' |
|
182 | + ), |
|
183 | + '<em>', |
|
184 | + '</em>', |
|
185 | + '<strong>', |
|
186 | + '</strong>' |
|
187 | + ); |
|
188 | + $template = EE_ABOUT_TEMPLATE_PATH . 'decafvpro.template.php'; |
|
189 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
190 | + $template, |
|
191 | + $this->_template_args, |
|
192 | + true |
|
193 | + ); |
|
194 | + $this->display_about_admin_page(); |
|
195 | + } |
|
196 | + |
|
197 | + |
|
198 | + protected function _reviews() |
|
199 | + { |
|
200 | + $this->_template_args['admin_page_title'] = |
|
201 | + esc_html__('Rave Reviews About Event Espresso 4', 'event_espresso'); |
|
202 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
203 | + 'At Event Espresso, customer satisfaction is our ultimate goal.', |
|
204 | + 'event_espresso' |
|
205 | + ); |
|
206 | + $template = EE_ABOUT_TEMPLATE_PATH . 'reviews.template.php'; |
|
207 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
208 | + $template, |
|
209 | + $this->_template_args, |
|
210 | + true |
|
211 | + ); |
|
212 | + $this->display_about_admin_page(); |
|
213 | + } |
|
214 | 214 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function __construct($routing = true) |
22 | 22 | { |
23 | 23 | parent::__construct($routing); |
24 | - define('EE_ABOUT_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'about/templates/'); |
|
24 | + define('EE_ABOUT_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'about/templates/'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | { |
59 | 59 | parent::_set_page_config(); |
60 | 60 | |
61 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'about'; |
|
61 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'about'; |
|
62 | 62 | $this->_page_config = [ |
63 | 63 | 'default' => [ |
64 | 64 | 'nav' => [ |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | protected function _whats_new() |
107 | 107 | { |
108 | 108 | $steps = MaintenanceStatus::isNotDisabled() ? $this->_get_started_steps() : ''; |
109 | - $this->_admin_page_title = sprintf( |
|
109 | + $this->_admin_page_title = sprintf( |
|
110 | 110 | esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
111 | 111 | EVENT_ESPRESSO_VERSION |
112 | 112 | ); |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | $this->_template_args['admin_page_subtitle'] = esc_html__( |
115 | 115 | 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
116 | 116 | 'event_espresso' |
117 | - ) . $settings_message; |
|
118 | - $template = |
|
119 | - is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php') |
|
117 | + ).$settings_message; |
|
118 | + $template = |
|
119 | + is_readable(EE_ABOUT_CAF_TEMPLATE_PATH.'whats_new.template.php') |
|
120 | 120 | ? EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php' |
121 | 121 | : EE_ABOUT_TEMPLATE_PATH |
122 | 122 | . 'whats_new.template.php'; |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
137 | 137 | 'event_espresso' |
138 | 138 | ); |
139 | - $template = |
|
140 | - is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php') |
|
139 | + $template = |
|
140 | + is_readable(EE_ABOUT_CAF_TEMPLATE_PATH.'ee4-overview.template.php') |
|
141 | 141 | ? EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php' |
142 | - : EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php'; |
|
142 | + : EE_ABOUT_TEMPLATE_PATH.'ee4-overview.template.php'; |
|
143 | 143 | $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
144 | 144 | $template, |
145 | 145 | $this->_template_args, |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | // esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
156 | 156 | // EVENT_ESPRESSO_VERSION |
157 | 157 | // ); |
158 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
158 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
159 | 159 | 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
160 | 160 | 'event_espresso' |
161 | 161 | ); |
162 | - $template = EE_ABOUT_TEMPLATE_PATH . 'credits.template.php'; |
|
162 | + $template = EE_ABOUT_TEMPLATE_PATH.'credits.template.php'; |
|
163 | 163 | $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
164 | 164 | $template, |
165 | 165 | $this->_template_args, |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | |
172 | 172 | protected function _decafvpro() |
173 | 173 | { |
174 | - $this->_template_args['admin_page_title'] = sprintf( |
|
174 | + $this->_template_args['admin_page_title'] = sprintf( |
|
175 | 175 | esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
176 | 176 | EVENT_ESPRESSO_VERSION |
177 | 177 | ); |
178 | - $this->_template_args['admin_page_subtitle'] = sprintf( |
|
178 | + $this->_template_args['admin_page_subtitle'] = sprintf( |
|
179 | 179 | esc_html__( |
180 | 180 | 'Event Espresso lets you focus on doing %swhat you love%s — %sorganizing your events%s', |
181 | 181 | 'event_espresso' |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | '<strong>', |
186 | 186 | '</strong>' |
187 | 187 | ); |
188 | - $template = EE_ABOUT_TEMPLATE_PATH . 'decafvpro.template.php'; |
|
188 | + $template = EE_ABOUT_TEMPLATE_PATH.'decafvpro.template.php'; |
|
189 | 189 | $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
190 | 190 | $template, |
191 | 191 | $this->_template_args, |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | 'At Event Espresso, customer satisfaction is our ultimate goal.', |
204 | 204 | 'event_espresso' |
205 | 205 | ); |
206 | - $template = EE_ABOUT_TEMPLATE_PATH . 'reviews.template.php'; |
|
206 | + $template = EE_ABOUT_TEMPLATE_PATH.'reviews.template.php'; |
|
207 | 207 | $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
208 | 208 | $template, |
209 | 209 | $this->_template_args, |
@@ -16,322 +16,322 @@ |
||
16 | 16 | */ |
17 | 17 | class espresso_events_Messages_Hooks_Extend extends espresso_events_Messages_Hooks |
18 | 18 | { |
19 | - /** |
|
20 | - * espresso_events_Messages_Hooks_Extend constructor. |
|
21 | - * |
|
22 | - * @param EE_Admin_Page $admin_page |
|
23 | - * @throws EE_Error |
|
24 | - * @throws ReflectionException |
|
25 | - */ |
|
26 | - public function __construct(EE_Admin_Page $admin_page) |
|
27 | - { |
|
28 | - /** |
|
29 | - * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages |
|
30 | - */ |
|
31 | - if ( |
|
32 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
33 | - 'ee_edit_messages', |
|
34 | - 'messages_events_editor_metabox' |
|
35 | - ) |
|
36 | - ) { |
|
37 | - return; |
|
38 | - } |
|
39 | - add_filter( |
|
40 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
41 | - [$this, 'caf_updates'] |
|
42 | - ); |
|
43 | - add_action( |
|
44 | - 'AHEE__Extend_Events_Admin_Page___duplicate_event__after', |
|
45 | - [$this, 'duplicate_custom_message_settings'], |
|
46 | - 10, |
|
47 | - 2 |
|
48 | - ); |
|
49 | - parent::__construct($admin_page); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * extending the properties set in espresso_events_Messages_Hooks |
|
55 | - * |
|
56 | - * @access protected |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - protected function _extend_properties() |
|
60 | - { |
|
61 | - define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/'); |
|
62 | - $this->_ajax_func = ['ee_msgs_create_new_custom' => 'create_new_custom']; |
|
63 | - $this->_metaboxes = [ |
|
64 | - 0 => [ |
|
65 | - 'page_route' => ['edit', 'create_new'], |
|
66 | - 'func' => 'messages_metabox', |
|
67 | - 'label' => esc_html__('Notifications', 'event_espresso'), |
|
68 | - 'priority' => 'high', |
|
69 | - ], |
|
70 | - ]; |
|
71 | - |
|
72 | - // see explanation for layout in EE_Admin_Hooks |
|
73 | - $this->_scripts_styles = [ |
|
74 | - 'registers' => [ |
|
75 | - 'events_msg_admin' => [ |
|
76 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js', |
|
77 | - 'depends' => ['ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'], |
|
78 | - ], |
|
79 | - 'events_msg_admin_css' => [ |
|
80 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css', |
|
81 | - 'type' => 'css', |
|
82 | - ], |
|
83 | - ], |
|
84 | - 'enqueues' => [ |
|
85 | - 'events_msg_admin' => ['edit', 'create_new'], |
|
86 | - 'events_msg_admin_css' => ['edit', 'create_new'], |
|
87 | - ], |
|
88 | - ]; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - public function caf_updates($update_callbacks) |
|
93 | - { |
|
94 | - $update_callbacks[] = [$this, 'attach_evt_message_templates']; |
|
95 | - return $update_callbacks; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Handles attaching Message Templates to the Event on save. |
|
101 | - * |
|
102 | - * @param EE_Event $event EE event object |
|
103 | - * @param array $data The request data from the form |
|
104 | - * @return bool success or fail |
|
105 | - * @throws EE_Error |
|
106 | - * @throws ReflectionException |
|
107 | - */ |
|
108 | - public function attach_evt_message_templates(EE_Event $event, array $data): bool |
|
109 | - { |
|
110 | - $success = true; |
|
111 | - if (isset($data['event_message_templates_relation'])) { |
|
112 | - // first get all existing relations on the Event for message types. |
|
113 | - $existing_templates = EEM_Event_Message_Template::instance()->messageTemplateGroupIDsForEvent($event); |
|
114 | - $current_templates = $data['event_message_templates_relation']; |
|
115 | - // new templates are those in the $current_templates array that don't exist in $existing_templates |
|
116 | - $templates_to_add = array_diff($current_templates, $existing_templates); |
|
117 | - foreach ($templates_to_add as $template_ID) { |
|
118 | - $template_to_add = EEM_Message_Template_Group::instance()->get_one_by_ID($template_ID); |
|
119 | - if (! $template_to_add instanceof EE_Base_Class) { |
|
120 | - continue; |
|
121 | - } |
|
122 | - $added_template = $event->_add_relation_to($template_to_add, 'Message_Template_Group'); |
|
123 | - // toggle success to false if we don't get back a template group object |
|
124 | - $success = $added_template instanceof EE_Message_Template_Group ? $success : false; |
|
125 | - } |
|
126 | - // templates to remove are those in the $existing_templates array that don't exist in $current_templates |
|
127 | - $templates_to_remove = array_diff($existing_templates, $current_templates); |
|
128 | - foreach ($templates_to_remove as $template_ID) { |
|
129 | - $template_to_remove = EEM_Message_Template_Group::instance()->get_one_by_ID($template_ID); |
|
130 | - if (! $template_to_remove instanceof EE_Base_Class) { |
|
131 | - continue; |
|
132 | - } |
|
133 | - $removed_template = $event->_remove_relation_to($template_to_remove, 'Message_Template_Group'); |
|
134 | - // toggle success to false if we don't get back a template group object |
|
135 | - $success = $removed_template instanceof EE_Message_Template_Group ? $success : false; |
|
136 | - } |
|
137 | - } |
|
138 | - return $success; |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @param $event |
|
144 | - * @param $callback_args |
|
145 | - * @return string |
|
146 | - * @throws EE_Error |
|
147 | - * @throws ReflectionException |
|
148 | - */ |
|
149 | - public function messages_metabox($event, $callback_args) |
|
150 | - { |
|
151 | - // convert 'evt_id' to 'EVT_ID' |
|
152 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
153 | - $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
|
154 | - $EVT_ID = $this->request->getRequestParam('evt_id', $EVT_ID, 'int'); |
|
155 | - $this->request->setRequestParam('EVT_ID', $EVT_ID); |
|
156 | - |
|
157 | - // get the active messengers (b/c messenger objects have the active message templates) |
|
158 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
159 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
160 | - $active_messengers = $message_resource_manager->active_messengers(); |
|
161 | - $tabs = []; |
|
162 | - |
|
163 | - // empty messengers? |
|
164 | - // Note message types will always have at least one available because every messenger has a default message type |
|
165 | - // associated with it (payment) if no other message types are selected. |
|
166 | - if (empty($active_messengers)) { |
|
167 | - $msg_activate_url = EE_Admin_Page::add_query_args_and_nonce( |
|
168 | - ['action' => 'settings'], |
|
169 | - EE_MSG_ADMIN_URL |
|
170 | - ); |
|
171 | - $error_msg = sprintf( |
|
172 | - esc_html__( |
|
173 | - 'There are no active messengers. So no notifications will go out for %1$sany%2$s events. You will want to %3$sActivate a Messenger%4$s.', |
|
174 | - 'event_espresso' |
|
175 | - ), |
|
176 | - '<strong>', |
|
177 | - '</strong>', |
|
178 | - '<a href="' . esc_url_raw($msg_activate_url) . '">', |
|
179 | - '</a>' |
|
180 | - ); |
|
181 | - $error_content = '<div class="error"><p>' . $error_msg . '</p></div>'; |
|
182 | - $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>'; |
|
183 | - |
|
184 | - echo wp_kses($error_content, AllowedTags::getAllowedTags()); |
|
185 | - echo wp_kses($internal_content, AllowedTags::getAllowedTags()); |
|
186 | - return ''; |
|
187 | - } |
|
188 | - |
|
189 | - // get content for active messengers |
|
190 | - foreach ($active_messengers as $name => $messenger) { |
|
191 | - // first check if there are any active message types for this messenger. |
|
192 | - $active_mts = $message_resource_manager->get_active_message_types_for_messenger($name); |
|
193 | - if (empty($active_mts)) { |
|
194 | - continue; |
|
195 | - } |
|
196 | - |
|
197 | - $tab_content = $messenger->get_messenger_admin_page_content( |
|
198 | - 'events', |
|
199 | - 'edit', |
|
200 | - ['event' => $EVT_ID] |
|
201 | - ); |
|
202 | - |
|
203 | - if (! empty($tab_content)) { |
|
204 | - $tabs[ $name ] = $tab_content; |
|
205 | - } |
|
206 | - } |
|
207 | - |
|
208 | - // we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper. |
|
209 | - $tabbed_content = EEH_Tabbed_Content::display($tabs); |
|
210 | - if ($tabbed_content instanceof WP_Error) { |
|
211 | - $tabbed_content = $tabbed_content->get_error_message(); |
|
212 | - } |
|
213 | - |
|
214 | - $notices = ' |
|
19 | + /** |
|
20 | + * espresso_events_Messages_Hooks_Extend constructor. |
|
21 | + * |
|
22 | + * @param EE_Admin_Page $admin_page |
|
23 | + * @throws EE_Error |
|
24 | + * @throws ReflectionException |
|
25 | + */ |
|
26 | + public function __construct(EE_Admin_Page $admin_page) |
|
27 | + { |
|
28 | + /** |
|
29 | + * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages |
|
30 | + */ |
|
31 | + if ( |
|
32 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
33 | + 'ee_edit_messages', |
|
34 | + 'messages_events_editor_metabox' |
|
35 | + ) |
|
36 | + ) { |
|
37 | + return; |
|
38 | + } |
|
39 | + add_filter( |
|
40 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
41 | + [$this, 'caf_updates'] |
|
42 | + ); |
|
43 | + add_action( |
|
44 | + 'AHEE__Extend_Events_Admin_Page___duplicate_event__after', |
|
45 | + [$this, 'duplicate_custom_message_settings'], |
|
46 | + 10, |
|
47 | + 2 |
|
48 | + ); |
|
49 | + parent::__construct($admin_page); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * extending the properties set in espresso_events_Messages_Hooks |
|
55 | + * |
|
56 | + * @access protected |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + protected function _extend_properties() |
|
60 | + { |
|
61 | + define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/'); |
|
62 | + $this->_ajax_func = ['ee_msgs_create_new_custom' => 'create_new_custom']; |
|
63 | + $this->_metaboxes = [ |
|
64 | + 0 => [ |
|
65 | + 'page_route' => ['edit', 'create_new'], |
|
66 | + 'func' => 'messages_metabox', |
|
67 | + 'label' => esc_html__('Notifications', 'event_espresso'), |
|
68 | + 'priority' => 'high', |
|
69 | + ], |
|
70 | + ]; |
|
71 | + |
|
72 | + // see explanation for layout in EE_Admin_Hooks |
|
73 | + $this->_scripts_styles = [ |
|
74 | + 'registers' => [ |
|
75 | + 'events_msg_admin' => [ |
|
76 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js', |
|
77 | + 'depends' => ['ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'], |
|
78 | + ], |
|
79 | + 'events_msg_admin_css' => [ |
|
80 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css', |
|
81 | + 'type' => 'css', |
|
82 | + ], |
|
83 | + ], |
|
84 | + 'enqueues' => [ |
|
85 | + 'events_msg_admin' => ['edit', 'create_new'], |
|
86 | + 'events_msg_admin_css' => ['edit', 'create_new'], |
|
87 | + ], |
|
88 | + ]; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + public function caf_updates($update_callbacks) |
|
93 | + { |
|
94 | + $update_callbacks[] = [$this, 'attach_evt_message_templates']; |
|
95 | + return $update_callbacks; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Handles attaching Message Templates to the Event on save. |
|
101 | + * |
|
102 | + * @param EE_Event $event EE event object |
|
103 | + * @param array $data The request data from the form |
|
104 | + * @return bool success or fail |
|
105 | + * @throws EE_Error |
|
106 | + * @throws ReflectionException |
|
107 | + */ |
|
108 | + public function attach_evt_message_templates(EE_Event $event, array $data): bool |
|
109 | + { |
|
110 | + $success = true; |
|
111 | + if (isset($data['event_message_templates_relation'])) { |
|
112 | + // first get all existing relations on the Event for message types. |
|
113 | + $existing_templates = EEM_Event_Message_Template::instance()->messageTemplateGroupIDsForEvent($event); |
|
114 | + $current_templates = $data['event_message_templates_relation']; |
|
115 | + // new templates are those in the $current_templates array that don't exist in $existing_templates |
|
116 | + $templates_to_add = array_diff($current_templates, $existing_templates); |
|
117 | + foreach ($templates_to_add as $template_ID) { |
|
118 | + $template_to_add = EEM_Message_Template_Group::instance()->get_one_by_ID($template_ID); |
|
119 | + if (! $template_to_add instanceof EE_Base_Class) { |
|
120 | + continue; |
|
121 | + } |
|
122 | + $added_template = $event->_add_relation_to($template_to_add, 'Message_Template_Group'); |
|
123 | + // toggle success to false if we don't get back a template group object |
|
124 | + $success = $added_template instanceof EE_Message_Template_Group ? $success : false; |
|
125 | + } |
|
126 | + // templates to remove are those in the $existing_templates array that don't exist in $current_templates |
|
127 | + $templates_to_remove = array_diff($existing_templates, $current_templates); |
|
128 | + foreach ($templates_to_remove as $template_ID) { |
|
129 | + $template_to_remove = EEM_Message_Template_Group::instance()->get_one_by_ID($template_ID); |
|
130 | + if (! $template_to_remove instanceof EE_Base_Class) { |
|
131 | + continue; |
|
132 | + } |
|
133 | + $removed_template = $event->_remove_relation_to($template_to_remove, 'Message_Template_Group'); |
|
134 | + // toggle success to false if we don't get back a template group object |
|
135 | + $success = $removed_template instanceof EE_Message_Template_Group ? $success : false; |
|
136 | + } |
|
137 | + } |
|
138 | + return $success; |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @param $event |
|
144 | + * @param $callback_args |
|
145 | + * @return string |
|
146 | + * @throws EE_Error |
|
147 | + * @throws ReflectionException |
|
148 | + */ |
|
149 | + public function messages_metabox($event, $callback_args) |
|
150 | + { |
|
151 | + // convert 'evt_id' to 'EVT_ID' |
|
152 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
153 | + $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
|
154 | + $EVT_ID = $this->request->getRequestParam('evt_id', $EVT_ID, 'int'); |
|
155 | + $this->request->setRequestParam('EVT_ID', $EVT_ID); |
|
156 | + |
|
157 | + // get the active messengers (b/c messenger objects have the active message templates) |
|
158 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
159 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
160 | + $active_messengers = $message_resource_manager->active_messengers(); |
|
161 | + $tabs = []; |
|
162 | + |
|
163 | + // empty messengers? |
|
164 | + // Note message types will always have at least one available because every messenger has a default message type |
|
165 | + // associated with it (payment) if no other message types are selected. |
|
166 | + if (empty($active_messengers)) { |
|
167 | + $msg_activate_url = EE_Admin_Page::add_query_args_and_nonce( |
|
168 | + ['action' => 'settings'], |
|
169 | + EE_MSG_ADMIN_URL |
|
170 | + ); |
|
171 | + $error_msg = sprintf( |
|
172 | + esc_html__( |
|
173 | + 'There are no active messengers. So no notifications will go out for %1$sany%2$s events. You will want to %3$sActivate a Messenger%4$s.', |
|
174 | + 'event_espresso' |
|
175 | + ), |
|
176 | + '<strong>', |
|
177 | + '</strong>', |
|
178 | + '<a href="' . esc_url_raw($msg_activate_url) . '">', |
|
179 | + '</a>' |
|
180 | + ); |
|
181 | + $error_content = '<div class="error"><p>' . $error_msg . '</p></div>'; |
|
182 | + $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>'; |
|
183 | + |
|
184 | + echo wp_kses($error_content, AllowedTags::getAllowedTags()); |
|
185 | + echo wp_kses($internal_content, AllowedTags::getAllowedTags()); |
|
186 | + return ''; |
|
187 | + } |
|
188 | + |
|
189 | + // get content for active messengers |
|
190 | + foreach ($active_messengers as $name => $messenger) { |
|
191 | + // first check if there are any active message types for this messenger. |
|
192 | + $active_mts = $message_resource_manager->get_active_message_types_for_messenger($name); |
|
193 | + if (empty($active_mts)) { |
|
194 | + continue; |
|
195 | + } |
|
196 | + |
|
197 | + $tab_content = $messenger->get_messenger_admin_page_content( |
|
198 | + 'events', |
|
199 | + 'edit', |
|
200 | + ['event' => $EVT_ID] |
|
201 | + ); |
|
202 | + |
|
203 | + if (! empty($tab_content)) { |
|
204 | + $tabs[ $name ] = $tab_content; |
|
205 | + } |
|
206 | + } |
|
207 | + |
|
208 | + // we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper. |
|
209 | + $tabbed_content = EEH_Tabbed_Content::display($tabs); |
|
210 | + if ($tabbed_content instanceof WP_Error) { |
|
211 | + $tabbed_content = $tabbed_content->get_error_message(); |
|
212 | + } |
|
213 | + |
|
214 | + $notices = ' |
|
215 | 215 | <div id="espresso-ajax-loading" class="ajax-loader-grey"> |
216 | 216 | <span class="ee-spinner ee-spin"></span> |
217 | 217 | <span class="hidden">' . esc_html__('loading...', 'event_espresso') . '</span> |
218 | 218 | </div> |
219 | 219 | <div class="ee-notices"></div>'; |
220 | 220 | |
221 | - if (defined('DOING_AJAX')) { |
|
222 | - return $tabbed_content; |
|
223 | - } |
|
224 | - |
|
225 | - do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content'); |
|
226 | - echo wp_kses( |
|
227 | - $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>', |
|
228 | - AllowedTags::getWithFormTags() |
|
229 | - ); |
|
230 | - do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content'); |
|
231 | - return ''; |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * Ajax callback for ee_msgs_create_new_custom ajax request. |
|
237 | - * Takes incoming GRP_ID and name and description values from ajax request |
|
238 | - * to create a new custom template based off of the incoming GRP_ID. |
|
239 | - * |
|
240 | - * @access public |
|
241 | - * @return void |
|
242 | - * @throws EE_Error |
|
243 | - * @throws ReflectionException |
|
244 | - */ |
|
245 | - public function create_new_custom() |
|
246 | - { |
|
247 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) { |
|
248 | - wp_die(esc_html__('You don\'t have privileges to do this action', 'event_espresso')); |
|
249 | - } |
|
250 | - |
|
251 | - /** @var RequestInterface $request */ |
|
252 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
253 | - $new_template = []; |
|
254 | - |
|
255 | - // let's clean up the request data a bit for downstream usage of name and description. |
|
256 | - $templateName = $this->request->getRequestParam('custom_template_args[MTP_name]', ''); |
|
257 | - if (! $templateName) { |
|
258 | - EE_Error::add_error( |
|
259 | - esc_html__( |
|
260 | - 'Please provide a template name when creating a new message template.', |
|
261 | - 'event_espresso' |
|
262 | - ), |
|
263 | - __FILE__, |
|
264 | - __FUNCTION__, |
|
265 | - __LINE__ |
|
266 | - ); |
|
267 | - } else { |
|
268 | - $request->setRequestParam('templateName', $templateName); |
|
269 | - $templateDescription = $this->request->getRequestParam('custom_template_args[MTP_description]', ''); |
|
270 | - $request->setRequestParam('templateDescription', $templateDescription); |
|
271 | - |
|
272 | - /** @var MessageTemplateManager $message_template_manager */ |
|
273 | - $message_template_manager = LoaderFactory::getShared(MessageTemplateManager::class); |
|
274 | - $new_template = $message_template_manager->generateNewTemplates(); |
|
275 | - } |
|
276 | - |
|
277 | - if ($templateName && $new_template) { |
|
278 | - EE_Error::overwrite_success(); |
|
279 | - EE_Error::add_success( |
|
280 | - esc_html__( |
|
281 | - 'The new template has been created and automatically selected for this event. You can edit the new template by clicking the edit button. Note before this template is assigned to this event, the event must be saved.', |
|
282 | - 'event_espresso' |
|
283 | - ) |
|
284 | - ); |
|
285 | - } |
|
286 | - $this->returnJson( |
|
287 | - '', |
|
288 | - [ |
|
289 | - 'grpID' => $new_template['GRP_ID'] ?? 0, |
|
290 | - 'templateName' => $templateName, |
|
291 | - 'success' => (bool) $new_template, |
|
292 | - 'close' => true, |
|
293 | - ], |
|
294 | - ); |
|
295 | - } |
|
296 | - |
|
297 | - |
|
298 | - public function create_new_admin_footer() |
|
299 | - { |
|
300 | - $this->edit_admin_footer(); |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - /** |
|
305 | - * This is the dynamic method for this class |
|
306 | - * that will end up hooking into the 'admin_footer' hook on the 'edit_event' route in the events page. |
|
307 | - * |
|
308 | - * @return void |
|
309 | - * @throws DomainException |
|
310 | - */ |
|
311 | - public function edit_admin_footer() |
|
312 | - { |
|
313 | - EEH_Template::display_template( |
|
314 | - EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php' |
|
315 | - ); |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - /** |
|
320 | - * Callback for AHEE__Extend_Events_Admin_Page___duplicate_event__after hook used to ensure new events duplicate |
|
321 | - * the assigned custom message templates. |
|
322 | - * |
|
323 | - * @param EE_Event $new_event |
|
324 | - * @param EE_Event $original_event |
|
325 | - * @throws EE_Error |
|
326 | - * @throws ReflectionException |
|
327 | - */ |
|
328 | - public function duplicate_custom_message_settings(EE_Event $new_event, EE_Event $original_event) |
|
329 | - { |
|
330 | - $message_template_groups = $original_event->get_many_related('Message_Template_Group'); |
|
331 | - foreach ($message_template_groups as $message_template_group) { |
|
332 | - $new_event->_add_relation_to($message_template_group, 'Message_Template_Group'); |
|
333 | - } |
|
334 | - // save new event |
|
335 | - $new_event->save(); |
|
336 | - } |
|
221 | + if (defined('DOING_AJAX')) { |
|
222 | + return $tabbed_content; |
|
223 | + } |
|
224 | + |
|
225 | + do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content'); |
|
226 | + echo wp_kses( |
|
227 | + $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>', |
|
228 | + AllowedTags::getWithFormTags() |
|
229 | + ); |
|
230 | + do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content'); |
|
231 | + return ''; |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * Ajax callback for ee_msgs_create_new_custom ajax request. |
|
237 | + * Takes incoming GRP_ID and name and description values from ajax request |
|
238 | + * to create a new custom template based off of the incoming GRP_ID. |
|
239 | + * |
|
240 | + * @access public |
|
241 | + * @return void |
|
242 | + * @throws EE_Error |
|
243 | + * @throws ReflectionException |
|
244 | + */ |
|
245 | + public function create_new_custom() |
|
246 | + { |
|
247 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) { |
|
248 | + wp_die(esc_html__('You don\'t have privileges to do this action', 'event_espresso')); |
|
249 | + } |
|
250 | + |
|
251 | + /** @var RequestInterface $request */ |
|
252 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
253 | + $new_template = []; |
|
254 | + |
|
255 | + // let's clean up the request data a bit for downstream usage of name and description. |
|
256 | + $templateName = $this->request->getRequestParam('custom_template_args[MTP_name]', ''); |
|
257 | + if (! $templateName) { |
|
258 | + EE_Error::add_error( |
|
259 | + esc_html__( |
|
260 | + 'Please provide a template name when creating a new message template.', |
|
261 | + 'event_espresso' |
|
262 | + ), |
|
263 | + __FILE__, |
|
264 | + __FUNCTION__, |
|
265 | + __LINE__ |
|
266 | + ); |
|
267 | + } else { |
|
268 | + $request->setRequestParam('templateName', $templateName); |
|
269 | + $templateDescription = $this->request->getRequestParam('custom_template_args[MTP_description]', ''); |
|
270 | + $request->setRequestParam('templateDescription', $templateDescription); |
|
271 | + |
|
272 | + /** @var MessageTemplateManager $message_template_manager */ |
|
273 | + $message_template_manager = LoaderFactory::getShared(MessageTemplateManager::class); |
|
274 | + $new_template = $message_template_manager->generateNewTemplates(); |
|
275 | + } |
|
276 | + |
|
277 | + if ($templateName && $new_template) { |
|
278 | + EE_Error::overwrite_success(); |
|
279 | + EE_Error::add_success( |
|
280 | + esc_html__( |
|
281 | + 'The new template has been created and automatically selected for this event. You can edit the new template by clicking the edit button. Note before this template is assigned to this event, the event must be saved.', |
|
282 | + 'event_espresso' |
|
283 | + ) |
|
284 | + ); |
|
285 | + } |
|
286 | + $this->returnJson( |
|
287 | + '', |
|
288 | + [ |
|
289 | + 'grpID' => $new_template['GRP_ID'] ?? 0, |
|
290 | + 'templateName' => $templateName, |
|
291 | + 'success' => (bool) $new_template, |
|
292 | + 'close' => true, |
|
293 | + ], |
|
294 | + ); |
|
295 | + } |
|
296 | + |
|
297 | + |
|
298 | + public function create_new_admin_footer() |
|
299 | + { |
|
300 | + $this->edit_admin_footer(); |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + /** |
|
305 | + * This is the dynamic method for this class |
|
306 | + * that will end up hooking into the 'admin_footer' hook on the 'edit_event' route in the events page. |
|
307 | + * |
|
308 | + * @return void |
|
309 | + * @throws DomainException |
|
310 | + */ |
|
311 | + public function edit_admin_footer() |
|
312 | + { |
|
313 | + EEH_Template::display_template( |
|
314 | + EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php' |
|
315 | + ); |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + /** |
|
320 | + * Callback for AHEE__Extend_Events_Admin_Page___duplicate_event__after hook used to ensure new events duplicate |
|
321 | + * the assigned custom message templates. |
|
322 | + * |
|
323 | + * @param EE_Event $new_event |
|
324 | + * @param EE_Event $original_event |
|
325 | + * @throws EE_Error |
|
326 | + * @throws ReflectionException |
|
327 | + */ |
|
328 | + public function duplicate_custom_message_settings(EE_Event $new_event, EE_Event $original_event) |
|
329 | + { |
|
330 | + $message_template_groups = $original_event->get_many_related('Message_Template_Group'); |
|
331 | + foreach ($message_template_groups as $message_template_group) { |
|
332 | + $new_event->_add_relation_to($message_template_group, 'Message_Template_Group'); |
|
333 | + } |
|
334 | + // save new event |
|
335 | + $new_event->save(); |
|
336 | + } |
|
337 | 337 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function _extend_properties() |
60 | 60 | { |
61 | - define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/'); |
|
61 | + define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'messages/assets/'); |
|
62 | 62 | $this->_ajax_func = ['ee_msgs_create_new_custom' => 'create_new_custom']; |
63 | 63 | $this->_metaboxes = [ |
64 | 64 | 0 => [ |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | $this->_scripts_styles = [ |
74 | 74 | 'registers' => [ |
75 | 75 | 'events_msg_admin' => [ |
76 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js', |
|
76 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL.'events_messages_admin.js', |
|
77 | 77 | 'depends' => ['ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'], |
78 | 78 | ], |
79 | 79 | 'events_msg_admin_css' => [ |
80 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css', |
|
80 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL.'ee_msg_events_admin.css', |
|
81 | 81 | 'type' => 'css', |
82 | 82 | ], |
83 | 83 | ], |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $templates_to_add = array_diff($current_templates, $existing_templates); |
117 | 117 | foreach ($templates_to_add as $template_ID) { |
118 | 118 | $template_to_add = EEM_Message_Template_Group::instance()->get_one_by_ID($template_ID); |
119 | - if (! $template_to_add instanceof EE_Base_Class) { |
|
119 | + if ( ! $template_to_add instanceof EE_Base_Class) { |
|
120 | 120 | continue; |
121 | 121 | } |
122 | 122 | $added_template = $event->_add_relation_to($template_to_add, 'Message_Template_Group'); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $templates_to_remove = array_diff($existing_templates, $current_templates); |
128 | 128 | foreach ($templates_to_remove as $template_ID) { |
129 | 129 | $template_to_remove = EEM_Message_Template_Group::instance()->get_one_by_ID($template_ID); |
130 | - if (! $template_to_remove instanceof EE_Base_Class) { |
|
130 | + if ( ! $template_to_remove instanceof EE_Base_Class) { |
|
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | $removed_template = $event->_remove_relation_to($template_to_remove, 'Message_Template_Group'); |
@@ -168,18 +168,18 @@ discard block |
||
168 | 168 | ['action' => 'settings'], |
169 | 169 | EE_MSG_ADMIN_URL |
170 | 170 | ); |
171 | - $error_msg = sprintf( |
|
171 | + $error_msg = sprintf( |
|
172 | 172 | esc_html__( |
173 | 173 | 'There are no active messengers. So no notifications will go out for %1$sany%2$s events. You will want to %3$sActivate a Messenger%4$s.', |
174 | 174 | 'event_espresso' |
175 | 175 | ), |
176 | 176 | '<strong>', |
177 | 177 | '</strong>', |
178 | - '<a href="' . esc_url_raw($msg_activate_url) . '">', |
|
178 | + '<a href="'.esc_url_raw($msg_activate_url).'">', |
|
179 | 179 | '</a>' |
180 | 180 | ); |
181 | - $error_content = '<div class="error"><p>' . $error_msg . '</p></div>'; |
|
182 | - $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>'; |
|
181 | + $error_content = '<div class="error"><p>'.$error_msg.'</p></div>'; |
|
182 | + $internal_content = '<div id="messages-error"><p>'.$error_msg.'</p></div>'; |
|
183 | 183 | |
184 | 184 | echo wp_kses($error_content, AllowedTags::getAllowedTags()); |
185 | 185 | echo wp_kses($internal_content, AllowedTags::getAllowedTags()); |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | ['event' => $EVT_ID] |
201 | 201 | ); |
202 | 202 | |
203 | - if (! empty($tab_content)) { |
|
204 | - $tabs[ $name ] = $tab_content; |
|
203 | + if ( ! empty($tab_content)) { |
|
204 | + $tabs[$name] = $tab_content; |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $notices = ' |
215 | 215 | <div id="espresso-ajax-loading" class="ajax-loader-grey"> |
216 | 216 | <span class="ee-spinner ee-spin"></span> |
217 | - <span class="hidden">' . esc_html__('loading...', 'event_espresso') . '</span> |
|
217 | + <span class="hidden">' . esc_html__('loading...', 'event_espresso').'</span> |
|
218 | 218 | </div> |
219 | 219 | <div class="ee-notices"></div>'; |
220 | 220 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content'); |
226 | 226 | echo wp_kses( |
227 | - $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>', |
|
227 | + $notices.'<div class="messages-tabs-content">'.$tabbed_content.'</div>', |
|
228 | 228 | AllowedTags::getWithFormTags() |
229 | 229 | ); |
230 | 230 | do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content'); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function create_new_custom() |
246 | 246 | { |
247 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) { |
|
247 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) { |
|
248 | 248 | wp_die(esc_html__('You don\'t have privileges to do this action', 'event_espresso')); |
249 | 249 | } |
250 | 250 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | |
255 | 255 | // let's clean up the request data a bit for downstream usage of name and description. |
256 | 256 | $templateName = $this->request->getRequestParam('custom_template_args[MTP_name]', ''); |
257 | - if (! $templateName) { |
|
257 | + if ( ! $templateName) { |
|
258 | 258 | EE_Error::add_error( |
259 | 259 | esc_html__( |
260 | 260 | 'Please provide a template name when creating a new message template.', |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | public function edit_admin_footer() |
312 | 312 | { |
313 | 313 | EEH_Template::display_template( |
314 | - EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php' |
|
314 | + EE_CORE_CAF_ADMIN_EXTEND.'messages/templates/create_custom_template_form.template.php' |
|
315 | 315 | ); |
316 | 316 | } |
317 | 317 |
@@ -16,201 +16,201 @@ |
||
16 | 16 | */ |
17 | 17 | class Extend_Messages_Admin_Page extends Messages_Admin_Page |
18 | 18 | { |
19 | - public function __construct($routing = true) |
|
20 | - { |
|
21 | - parent::__construct($routing); |
|
22 | - if (! defined('EE_MSG_CAF_ASSETS_PATH')) { |
|
23 | - define('EE_MSG_CAF_ASSETS_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/assets/'); |
|
24 | - define('EE_MSG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/'); |
|
25 | - define('EE_MSG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/'); |
|
26 | - define('EE_MSG_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/templates/'); |
|
27 | - } |
|
28 | - } |
|
29 | - |
|
30 | - |
|
31 | - protected function _set_page_config() |
|
32 | - { |
|
33 | - parent::_set_page_config(); |
|
34 | - |
|
35 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'messages'; |
|
36 | - $this->_page_routes['custom_mtps'] = [ |
|
37 | - 'func' => '_ee_custom_messages_overview_list_table', |
|
38 | - 'capability' => 'ee_read_messages', |
|
39 | - ]; |
|
40 | - $this->_page_config['custom_mtps'] = [ |
|
41 | - 'nav' => [ |
|
42 | - 'label' => esc_html__('Custom Message Templates', 'event_espresso'), |
|
43 | - 'icon' => 'dashicons-art', |
|
44 | - 'order' => 30, |
|
45 | - ], |
|
46 | - 'list_table' => 'Custom_Messages_Template_List_Table', |
|
47 | - 'help_tabs' => [ |
|
48 | - 'message_overview_message_types_help_tab' => [ |
|
49 | - 'title' => esc_html__('Message Types', 'event_espresso'), |
|
50 | - 'filename' => 'messages_overview_types', |
|
51 | - ], |
|
52 | - 'messages_overview_messengers_help_tab' => [ |
|
53 | - 'title' => esc_html__('Messengers', 'event_espresso'), |
|
54 | - 'filename' => 'messages_overview_messengers', |
|
55 | - ], |
|
56 | - 'messages_overview_other_help_tab' => [ |
|
57 | - 'title' => esc_html__('Messages Other', 'event_espresso'), |
|
58 | - 'filename' => 'messages_overview_other', |
|
59 | - ], |
|
60 | - ], |
|
61 | - 'require_nonce' => false, |
|
62 | - ]; |
|
63 | - |
|
64 | - add_action('current_screen', [$this, 'dynamic_screen_hooks'], 10); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * Callback for current_screen action |
|
70 | - * This is used for any filters and/or actions that require the dynamic screen hook_prefix to be correct. |
|
71 | - * |
|
72 | - * @return void |
|
73 | - * @since 4.5.0 |
|
74 | - * |
|
75 | - */ |
|
76 | - public function dynamic_screen_hooks() |
|
77 | - { |
|
78 | - global $admin_page_hooks; |
|
79 | - |
|
80 | - if (! empty($admin_page_hooks['espresso_events'])) { |
|
81 | - // we're on a EE specific page... good stuff! |
|
82 | - $hook_prefix = $admin_page_hooks['espresso_events']; |
|
83 | - $filter_ref = "{$hook_prefix}_page_$this->page_slug"; |
|
84 | - add_filter("FHEE_manage_{$filter_ref}_columns", [$this, 'add_custom_mtps_columns'], 10, 3); |
|
85 | - add_action( |
|
86 | - 'AHEE__EE_Admin_List_Table__column_actions__' . $filter_ref, |
|
87 | - [$this, 'custom_mtp_create_button_column'], |
|
88 | - 10, |
|
89 | - 2 |
|
90 | - ); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * This is the callback for the FHEE__manage_event-espresso_page_espresso_messages_columns to register the |
|
97 | - * caffeinated columns for the global message templates list table. |
|
98 | - * |
|
99 | - * @param array $columns Original defined list of columns |
|
100 | - * @param string $screen_id The unique screen id for the page. |
|
101 | - * @return array |
|
102 | - * @since 4.3.2 |
|
103 | - * |
|
104 | - */ |
|
105 | - public function add_custom_mtps_columns($columns, $screen_id, EE_Admin_List_Table $list_table) |
|
106 | - { |
|
107 | - if ($screen_id !== 'espresso_messages_global_mtps') { |
|
108 | - return $columns; |
|
109 | - } |
|
110 | - $columns['actions'] = $list_table->actionsColumnHeader(); |
|
111 | - return $columns; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Callback for FHEE__EE_Admin_List_Table__column_actions__event-espresso_page_espresso_messages action that allows |
|
117 | - * for adding the content for the registered "action" column. |
|
118 | - * |
|
119 | - * @param EE_Base_Class |
|
120 | - * @param string $screen_id Unique screen id for the page |
|
121 | - * |
|
122 | - * @return string html content for the page. |
|
123 | - * @throws EE_Error |
|
124 | - * @throws ReflectionException |
|
125 | - * @since 4.3.2 |
|
126 | - */ |
|
127 | - public function custom_mtp_create_button_column(EE_Base_Class $item, string $screen_id) |
|
128 | - { |
|
129 | - if ( |
|
130 | - $screen_id !== 'espresso_messages_global_mtps' |
|
131 | - || ! EE_Registry::instance()->CAP->current_user_can( |
|
132 | - 'ee_edit_messages', |
|
133 | - 'espresso_messages_add_new_message_template' |
|
134 | - ) |
|
135 | - ) { |
|
136 | - return ''; |
|
137 | - } |
|
138 | - |
|
139 | - // first we consider whether this template has override set. If it does then that means no custom templates can be created from this template as a base. So let's just skip the button creation. |
|
140 | - if ($item->get('MTP_is_override')) { |
|
141 | - return ''; |
|
142 | - } |
|
143 | - |
|
144 | - $create_link = EE_Admin_Page::add_query_args_and_nonce( |
|
145 | - [ |
|
146 | - 'GRP_ID' => $item->ID(), |
|
147 | - 'messenger' => $item->messenger(), |
|
148 | - 'message_type' => $item->message_type(), |
|
149 | - 'action' => 'add_new_message_template', |
|
150 | - ], |
|
151 | - EE_MSG_ADMIN_URL |
|
152 | - ); |
|
153 | - $aria_label = esc_html__('Create Custom Message Template', 'event_espresso'); |
|
154 | - echo " |
|
19 | + public function __construct($routing = true) |
|
20 | + { |
|
21 | + parent::__construct($routing); |
|
22 | + if (! defined('EE_MSG_CAF_ASSETS_PATH')) { |
|
23 | + define('EE_MSG_CAF_ASSETS_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/assets/'); |
|
24 | + define('EE_MSG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/'); |
|
25 | + define('EE_MSG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/'); |
|
26 | + define('EE_MSG_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/templates/'); |
|
27 | + } |
|
28 | + } |
|
29 | + |
|
30 | + |
|
31 | + protected function _set_page_config() |
|
32 | + { |
|
33 | + parent::_set_page_config(); |
|
34 | + |
|
35 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'messages'; |
|
36 | + $this->_page_routes['custom_mtps'] = [ |
|
37 | + 'func' => '_ee_custom_messages_overview_list_table', |
|
38 | + 'capability' => 'ee_read_messages', |
|
39 | + ]; |
|
40 | + $this->_page_config['custom_mtps'] = [ |
|
41 | + 'nav' => [ |
|
42 | + 'label' => esc_html__('Custom Message Templates', 'event_espresso'), |
|
43 | + 'icon' => 'dashicons-art', |
|
44 | + 'order' => 30, |
|
45 | + ], |
|
46 | + 'list_table' => 'Custom_Messages_Template_List_Table', |
|
47 | + 'help_tabs' => [ |
|
48 | + 'message_overview_message_types_help_tab' => [ |
|
49 | + 'title' => esc_html__('Message Types', 'event_espresso'), |
|
50 | + 'filename' => 'messages_overview_types', |
|
51 | + ], |
|
52 | + 'messages_overview_messengers_help_tab' => [ |
|
53 | + 'title' => esc_html__('Messengers', 'event_espresso'), |
|
54 | + 'filename' => 'messages_overview_messengers', |
|
55 | + ], |
|
56 | + 'messages_overview_other_help_tab' => [ |
|
57 | + 'title' => esc_html__('Messages Other', 'event_espresso'), |
|
58 | + 'filename' => 'messages_overview_other', |
|
59 | + ], |
|
60 | + ], |
|
61 | + 'require_nonce' => false, |
|
62 | + ]; |
|
63 | + |
|
64 | + add_action('current_screen', [$this, 'dynamic_screen_hooks'], 10); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * Callback for current_screen action |
|
70 | + * This is used for any filters and/or actions that require the dynamic screen hook_prefix to be correct. |
|
71 | + * |
|
72 | + * @return void |
|
73 | + * @since 4.5.0 |
|
74 | + * |
|
75 | + */ |
|
76 | + public function dynamic_screen_hooks() |
|
77 | + { |
|
78 | + global $admin_page_hooks; |
|
79 | + |
|
80 | + if (! empty($admin_page_hooks['espresso_events'])) { |
|
81 | + // we're on a EE specific page... good stuff! |
|
82 | + $hook_prefix = $admin_page_hooks['espresso_events']; |
|
83 | + $filter_ref = "{$hook_prefix}_page_$this->page_slug"; |
|
84 | + add_filter("FHEE_manage_{$filter_ref}_columns", [$this, 'add_custom_mtps_columns'], 10, 3); |
|
85 | + add_action( |
|
86 | + 'AHEE__EE_Admin_List_Table__column_actions__' . $filter_ref, |
|
87 | + [$this, 'custom_mtp_create_button_column'], |
|
88 | + 10, |
|
89 | + 2 |
|
90 | + ); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * This is the callback for the FHEE__manage_event-espresso_page_espresso_messages_columns to register the |
|
97 | + * caffeinated columns for the global message templates list table. |
|
98 | + * |
|
99 | + * @param array $columns Original defined list of columns |
|
100 | + * @param string $screen_id The unique screen id for the page. |
|
101 | + * @return array |
|
102 | + * @since 4.3.2 |
|
103 | + * |
|
104 | + */ |
|
105 | + public function add_custom_mtps_columns($columns, $screen_id, EE_Admin_List_Table $list_table) |
|
106 | + { |
|
107 | + if ($screen_id !== 'espresso_messages_global_mtps') { |
|
108 | + return $columns; |
|
109 | + } |
|
110 | + $columns['actions'] = $list_table->actionsColumnHeader(); |
|
111 | + return $columns; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Callback for FHEE__EE_Admin_List_Table__column_actions__event-espresso_page_espresso_messages action that allows |
|
117 | + * for adding the content for the registered "action" column. |
|
118 | + * |
|
119 | + * @param EE_Base_Class |
|
120 | + * @param string $screen_id Unique screen id for the page |
|
121 | + * |
|
122 | + * @return string html content for the page. |
|
123 | + * @throws EE_Error |
|
124 | + * @throws ReflectionException |
|
125 | + * @since 4.3.2 |
|
126 | + */ |
|
127 | + public function custom_mtp_create_button_column(EE_Base_Class $item, string $screen_id) |
|
128 | + { |
|
129 | + if ( |
|
130 | + $screen_id !== 'espresso_messages_global_mtps' |
|
131 | + || ! EE_Registry::instance()->CAP->current_user_can( |
|
132 | + 'ee_edit_messages', |
|
133 | + 'espresso_messages_add_new_message_template' |
|
134 | + ) |
|
135 | + ) { |
|
136 | + return ''; |
|
137 | + } |
|
138 | + |
|
139 | + // first we consider whether this template has override set. If it does then that means no custom templates can be created from this template as a base. So let's just skip the button creation. |
|
140 | + if ($item->get('MTP_is_override')) { |
|
141 | + return ''; |
|
142 | + } |
|
143 | + |
|
144 | + $create_link = EE_Admin_Page::add_query_args_and_nonce( |
|
145 | + [ |
|
146 | + 'GRP_ID' => $item->ID(), |
|
147 | + 'messenger' => $item->messenger(), |
|
148 | + 'message_type' => $item->message_type(), |
|
149 | + 'action' => 'add_new_message_template', |
|
150 | + ], |
|
151 | + EE_MSG_ADMIN_URL |
|
152 | + ); |
|
153 | + $aria_label = esc_html__('Create Custom Message Template', 'event_espresso'); |
|
154 | + echo " |
|
155 | 155 | <a href='$create_link' class='ee-aria-tooltip button button--icon-only' aria-label='$aria_label'> |
156 | 156 | <span class='dashicons dashicons-admin-customizer'></span> |
157 | 157 | </a>"; |
158 | - return ''; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - protected function _add_screen_options_custom_mtps() |
|
163 | - { |
|
164 | - $page_title = $this->_admin_page_title; |
|
165 | - $this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso'); |
|
166 | - $this->_per_page_screen_option(); |
|
167 | - $this->_admin_page_title = $page_title; |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * set views array for Custom Templates list table |
|
173 | - * |
|
174 | - * @access public |
|
175 | - * @return void |
|
176 | - */ |
|
177 | - public function _set_list_table_views_custom_mtps() |
|
178 | - { |
|
179 | - $this->_views = [ |
|
180 | - 'in_use' => [ |
|
181 | - 'slug' => 'in_use', |
|
182 | - 'label' => esc_html__('In Use', 'event_espresso'), |
|
183 | - 'count' => 0, |
|
184 | - 'bulk_action' => [ |
|
185 | - 'trash_message_template' => esc_html__('Move to Trash', 'event_espresso'), |
|
186 | - ], |
|
187 | - ], |
|
188 | - ]; |
|
189 | - if ( |
|
190 | - EE_Registry::instance()->CAP->current_user_can( |
|
191 | - 'ee_delete_messages', |
|
192 | - 'espresso_messages_trash_message_template' |
|
193 | - ) |
|
194 | - ) { |
|
195 | - $this->_views['trashed'] = [ |
|
196 | - 'slug' => 'trashed', |
|
197 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
198 | - 'count' => 0, |
|
199 | - 'bulk_action' => [ |
|
200 | - 'restore_message_template' => esc_html__('Restore From Trash', 'event_espresso'), |
|
201 | - 'delete_message_template' => esc_html__('Delete Permanently', 'event_espresso'), |
|
202 | - ], |
|
203 | - ]; |
|
204 | - } |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * @throws EE_Error |
|
210 | - */ |
|
211 | - protected function _ee_custom_messages_overview_list_table() |
|
212 | - { |
|
213 | - $this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso'); |
|
214 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
215 | - } |
|
158 | + return ''; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + protected function _add_screen_options_custom_mtps() |
|
163 | + { |
|
164 | + $page_title = $this->_admin_page_title; |
|
165 | + $this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso'); |
|
166 | + $this->_per_page_screen_option(); |
|
167 | + $this->_admin_page_title = $page_title; |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * set views array for Custom Templates list table |
|
173 | + * |
|
174 | + * @access public |
|
175 | + * @return void |
|
176 | + */ |
|
177 | + public function _set_list_table_views_custom_mtps() |
|
178 | + { |
|
179 | + $this->_views = [ |
|
180 | + 'in_use' => [ |
|
181 | + 'slug' => 'in_use', |
|
182 | + 'label' => esc_html__('In Use', 'event_espresso'), |
|
183 | + 'count' => 0, |
|
184 | + 'bulk_action' => [ |
|
185 | + 'trash_message_template' => esc_html__('Move to Trash', 'event_espresso'), |
|
186 | + ], |
|
187 | + ], |
|
188 | + ]; |
|
189 | + if ( |
|
190 | + EE_Registry::instance()->CAP->current_user_can( |
|
191 | + 'ee_delete_messages', |
|
192 | + 'espresso_messages_trash_message_template' |
|
193 | + ) |
|
194 | + ) { |
|
195 | + $this->_views['trashed'] = [ |
|
196 | + 'slug' => 'trashed', |
|
197 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
198 | + 'count' => 0, |
|
199 | + 'bulk_action' => [ |
|
200 | + 'restore_message_template' => esc_html__('Restore From Trash', 'event_espresso'), |
|
201 | + 'delete_message_template' => esc_html__('Delete Permanently', 'event_espresso'), |
|
202 | + ], |
|
203 | + ]; |
|
204 | + } |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * @throws EE_Error |
|
210 | + */ |
|
211 | + protected function _ee_custom_messages_overview_list_table() |
|
212 | + { |
|
213 | + $this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso'); |
|
214 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
215 | + } |
|
216 | 216 | } |
@@ -16,1495 +16,1495 @@ |
||
16 | 16 | */ |
17 | 17 | class Extend_Registration_Form_Admin_Page extends Registration_Form_Admin_Page |
18 | 18 | { |
19 | - /** |
|
20 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
21 | - * @throws EE_Error |
|
22 | - * @throws ReflectionException |
|
23 | - */ |
|
24 | - public function __construct($routing = true) |
|
25 | - { |
|
26 | - define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/'); |
|
27 | - define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/'); |
|
28 | - define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
29 | - define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/'); |
|
30 | - define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
31 | - parent::__construct($routing); |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - protected function _define_page_props() |
|
36 | - { |
|
37 | - parent::_define_page_props(); |
|
38 | - $this->_labels['publishbox'] = [ |
|
39 | - 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
40 | - 'edit_question' => esc_html__('Edit Question', 'event_espresso'), |
|
41 | - 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
42 | - 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
43 | - ]; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - protected function _set_page_config() |
|
48 | - { |
|
49 | - parent::_set_page_config(); |
|
50 | - |
|
51 | - $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
52 | - $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) |
|
53 | - ? $this->_req_data['QST_ID'] : 0; |
|
54 | - $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) |
|
55 | - ? $this->_req_data['QSG_ID'] : 0; |
|
56 | - |
|
57 | - $new_page_routes = [ |
|
58 | - 'question_groups' => [ |
|
59 | - 'func' => '_question_groups_overview_list_table', |
|
60 | - 'capability' => 'ee_read_question_groups', |
|
61 | - ], |
|
62 | - 'add_question' => [ |
|
63 | - 'func' => '_edit_question', |
|
64 | - 'capability' => 'ee_edit_questions', |
|
65 | - ], |
|
66 | - 'insert_question' => [ |
|
67 | - 'func' => '_insert_or_update_question', |
|
68 | - 'args' => ['new_question' => true], |
|
69 | - 'capability' => 'ee_edit_questions', |
|
70 | - 'noheader' => true, |
|
71 | - ], |
|
72 | - 'duplicate_question' => [ |
|
73 | - 'func' => '_duplicate_question', |
|
74 | - 'capability' => 'ee_edit_questions', |
|
75 | - 'noheader' => true, |
|
76 | - ], |
|
77 | - 'trash_question' => [ |
|
78 | - 'func' => '_trash_question', |
|
79 | - 'capability' => 'ee_delete_question', |
|
80 | - 'obj_id' => $qst_id, |
|
81 | - 'noheader' => true, |
|
82 | - ], |
|
83 | - |
|
84 | - 'restore_question' => [ |
|
85 | - 'func' => '_trash_or_restore_questions', |
|
86 | - 'capability' => 'ee_delete_question', |
|
87 | - 'obj_id' => $qst_id, |
|
88 | - 'args' => ['trash' => false], |
|
89 | - 'noheader' => true, |
|
90 | - ], |
|
91 | - |
|
92 | - 'delete_question' => [ |
|
93 | - 'func' => '_delete_question', |
|
94 | - 'capability' => 'ee_delete_question', |
|
95 | - 'obj_id' => $qst_id, |
|
96 | - 'noheader' => true, |
|
97 | - ], |
|
98 | - |
|
99 | - 'trash_questions' => [ |
|
100 | - 'func' => '_trash_or_restore_questions', |
|
101 | - 'capability' => 'ee_delete_questions', |
|
102 | - 'args' => ['trash' => true], |
|
103 | - 'noheader' => true, |
|
104 | - ], |
|
105 | - |
|
106 | - 'restore_questions' => [ |
|
107 | - 'func' => '_trash_or_restore_questions', |
|
108 | - 'capability' => 'ee_delete_questions', |
|
109 | - 'args' => ['trash' => false], |
|
110 | - 'noheader' => true, |
|
111 | - ], |
|
112 | - |
|
113 | - 'delete_questions' => [ |
|
114 | - 'func' => '_delete_questions', |
|
115 | - 'args' => [], |
|
116 | - 'capability' => 'ee_delete_questions', |
|
117 | - 'noheader' => true, |
|
118 | - ], |
|
119 | - |
|
120 | - 'add_question_group' => [ |
|
121 | - 'func' => '_edit_question_group', |
|
122 | - 'capability' => 'ee_edit_question_groups', |
|
123 | - ], |
|
124 | - |
|
125 | - 'edit_question_group' => [ |
|
126 | - 'func' => '_edit_question_group', |
|
127 | - 'capability' => 'ee_edit_question_group', |
|
128 | - 'obj_id' => $qsg_id, |
|
129 | - 'args' => ['edit'], |
|
130 | - ], |
|
131 | - |
|
132 | - 'delete_question_groups' => [ |
|
133 | - 'func' => '_delete_question_groups', |
|
134 | - 'capability' => 'ee_delete_question_groups', |
|
135 | - 'noheader' => true, |
|
136 | - ], |
|
137 | - |
|
138 | - 'delete_question_group' => [ |
|
139 | - 'func' => '_delete_question_groups', |
|
140 | - 'capability' => 'ee_delete_question_group', |
|
141 | - 'obj_id' => $qsg_id, |
|
142 | - 'noheader' => true, |
|
143 | - ], |
|
144 | - |
|
145 | - 'trash_question_group' => [ |
|
146 | - 'func' => '_trash_or_restore_question_groups', |
|
147 | - 'args' => ['trash' => true], |
|
148 | - 'capability' => 'ee_delete_question_group', |
|
149 | - 'obj_id' => $qsg_id, |
|
150 | - 'noheader' => true, |
|
151 | - ], |
|
152 | - |
|
153 | - 'restore_question_group' => [ |
|
154 | - 'func' => '_trash_or_restore_question_groups', |
|
155 | - 'args' => ['trash' => false], |
|
156 | - 'capability' => 'ee_delete_question_group', |
|
157 | - 'obj_id' => $qsg_id, |
|
158 | - 'noheader' => true, |
|
159 | - ], |
|
160 | - |
|
161 | - 'insert_question_group' => [ |
|
162 | - 'func' => '_insert_or_update_question_group', |
|
163 | - 'args' => ['new_question_group' => true], |
|
164 | - 'capability' => 'ee_edit_question_groups', |
|
165 | - 'noheader' => true, |
|
166 | - ], |
|
167 | - |
|
168 | - 'update_question_group' => [ |
|
169 | - 'func' => '_insert_or_update_question_group', |
|
170 | - 'args' => ['new_question_group' => false], |
|
171 | - 'capability' => 'ee_edit_question_group', |
|
172 | - 'obj_id' => $qsg_id, |
|
173 | - 'noheader' => true, |
|
174 | - ], |
|
175 | - |
|
176 | - 'trash_question_groups' => [ |
|
177 | - 'func' => '_trash_or_restore_question_groups', |
|
178 | - 'args' => ['trash' => true], |
|
179 | - 'capability' => 'ee_delete_question_groups', |
|
180 | - 'noheader' => ['trash' => false], |
|
181 | - ], |
|
182 | - |
|
183 | - 'restore_question_groups' => [ |
|
184 | - 'func' => '_trash_or_restore_question_groups', |
|
185 | - 'args' => ['trash' => false], |
|
186 | - 'capability' => 'ee_delete_question_groups', |
|
187 | - 'noheader' => true, |
|
188 | - ], |
|
189 | - |
|
190 | - |
|
191 | - 'espresso_update_question_group_order' => [ |
|
192 | - 'func' => 'update_question_group_order', |
|
193 | - 'capability' => 'ee_edit_question_groups', |
|
194 | - 'noheader' => true, |
|
195 | - ], |
|
196 | - |
|
197 | - 'view_reg_form_settings' => [ |
|
198 | - 'func' => '_reg_form_settings', |
|
199 | - 'capability' => 'manage_options', |
|
200 | - ], |
|
201 | - |
|
202 | - 'update_reg_form_settings' => [ |
|
203 | - 'func' => '_update_reg_form_settings', |
|
204 | - 'capability' => 'manage_options', |
|
205 | - 'noheader' => true, |
|
206 | - ], |
|
207 | - ]; |
|
208 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
209 | - |
|
210 | - $new_page_config = [ |
|
211 | - |
|
212 | - 'question_groups' => [ |
|
213 | - 'nav' => [ |
|
214 | - 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
215 | - 'icon' => 'dashicons-forms', |
|
216 | - 'order' => 20, |
|
217 | - ], |
|
218 | - 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
219 | - 'help_tabs' => [ |
|
220 | - 'registration_form_question_groups_help_tab' => [ |
|
221 | - 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
222 | - 'filename' => 'registration_form_question_groups', |
|
223 | - ], |
|
224 | - 'registration_form_question_groups_table_column_headings_help_tab' => [ |
|
225 | - 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
226 | - 'filename' => 'registration_form_question_groups_table_column_headings', |
|
227 | - ], |
|
228 | - 'registration_form_question_groups_views_bulk_actions_search_help_tab' => [ |
|
229 | - 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
230 | - 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
231 | - ], |
|
232 | - ], |
|
233 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
234 | - 'require_nonce' => false, |
|
235 | - ], |
|
236 | - |
|
237 | - 'add_question' => [ |
|
238 | - 'nav' => [ |
|
239 | - 'label' => esc_html__('Add Question', 'event_espresso'), |
|
240 | - 'icon' => 'dashicons-plus-alt', |
|
241 | - 'order' => 15, |
|
242 | - 'persistent' => false, |
|
243 | - ], |
|
244 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
245 | - 'help_tabs' => [ |
|
246 | - 'registration_form_add_question_help_tab' => [ |
|
247 | - 'title' => esc_html__('Add Question', 'event_espresso'), |
|
248 | - 'filename' => 'registration_form_add_question', |
|
249 | - ], |
|
250 | - ], |
|
251 | - 'require_nonce' => false, |
|
252 | - ], |
|
253 | - |
|
254 | - 'add_question_group' => [ |
|
255 | - 'nav' => [ |
|
256 | - 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
257 | - 'icon' => 'dashicons-plus-alt', |
|
258 | - 'order' => 25, |
|
259 | - 'persistent' => false, |
|
260 | - ], |
|
261 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
262 | - 'help_tabs' => [ |
|
263 | - 'registration_form_add_question_group_help_tab' => [ |
|
264 | - 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
265 | - 'filename' => 'registration_form_add_question_group', |
|
266 | - ], |
|
267 | - ], |
|
268 | - 'require_nonce' => false, |
|
269 | - ], |
|
270 | - |
|
271 | - 'edit_question_group' => [ |
|
272 | - 'nav' => [ |
|
273 | - 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
274 | - 'icon' => 'dashicons-edit-large', |
|
275 | - 'order' => 25, |
|
276 | - 'persistent' => false, |
|
277 | - 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg( |
|
278 | - ['question_group_id' => $this->_req_data['question_group_id']], |
|
279 | - $this->_current_page_view_url |
|
280 | - ) : $this->_admin_base_url, |
|
281 | - ], |
|
282 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
283 | - 'help_tabs' => [ |
|
284 | - 'registration_form_edit_question_group_help_tab' => [ |
|
285 | - 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
286 | - 'filename' => 'registration_form_edit_question_group', |
|
287 | - ], |
|
288 | - ], |
|
289 | - 'require_nonce' => false, |
|
290 | - ], |
|
291 | - |
|
292 | - 'view_reg_form_settings' => [ |
|
293 | - 'nav' => [ |
|
294 | - 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
295 | - 'icon' => 'dashicons-admin-generic', |
|
296 | - 'order' => 40, |
|
297 | - ], |
|
298 | - 'labels' => [ |
|
299 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
300 | - ], |
|
301 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
302 | - 'help_tabs' => [ |
|
303 | - 'registration_form_reg_form_settings_help_tab' => [ |
|
304 | - 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
305 | - 'filename' => 'registration_form_reg_form_settings', |
|
306 | - ], |
|
307 | - ], |
|
308 | - 'require_nonce' => false, |
|
309 | - ], |
|
310 | - |
|
311 | - ]; |
|
312 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
313 | - |
|
314 | - // change the list table we're going to use so it's the NEW list table! |
|
315 | - $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
316 | - |
|
317 | - |
|
318 | - // additional labels |
|
319 | - $new_labels = [ |
|
320 | - 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
321 | - 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
322 | - 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
323 | - 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
324 | - 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
325 | - ]; |
|
326 | - $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * @return void |
|
332 | - */ |
|
333 | - protected function _ajax_hooks() |
|
334 | - { |
|
335 | - if (! $this->capabilities->current_user_can('ee_edit_question_groups', 'edit-questions')) { |
|
336 | - return; |
|
337 | - } |
|
338 | - add_action('wp_ajax_espresso_update_question_group_order', [$this, 'update_question_group_order']); |
|
339 | - } |
|
340 | - |
|
341 | - |
|
342 | - /** |
|
343 | - * @return void |
|
344 | - */ |
|
345 | - public function load_scripts_styles_question_groups() |
|
346 | - { |
|
347 | - wp_enqueue_script('espresso_ajax_table_sorting'); |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - /** |
|
352 | - * @return void |
|
353 | - */ |
|
354 | - public function load_scripts_styles_add_question_group() |
|
355 | - { |
|
356 | - $this->load_scripts_styles_forms(); |
|
357 | - $this->load_sortable_question_script(); |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * @return void |
|
363 | - */ |
|
364 | - public function load_scripts_styles_edit_question_group() |
|
365 | - { |
|
366 | - $this->load_scripts_styles_forms(); |
|
367 | - $this->load_sortable_question_script(); |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * registers and enqueues script for questions |
|
373 | - * |
|
374 | - * @return void |
|
375 | - */ |
|
376 | - public function load_sortable_question_script() |
|
377 | - { |
|
378 | - wp_register_script( |
|
379 | - 'ee-question-sortable', |
|
380 | - REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
381 | - ['jquery-ui-sortable'], |
|
382 | - EVENT_ESPRESSO_VERSION, |
|
383 | - true |
|
384 | - ); |
|
385 | - wp_enqueue_script('ee-question-sortable'); |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * @return void |
|
391 | - */ |
|
392 | - protected function _set_list_table_views_default() |
|
393 | - { |
|
394 | - $this->_views = [ |
|
395 | - 'all' => [ |
|
396 | - 'slug' => 'all', |
|
397 | - 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
398 | - 'count' => 0, |
|
399 | - 'bulk_action' => [ |
|
400 | - 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
401 | - ], |
|
402 | - ], |
|
403 | - ]; |
|
404 | - |
|
405 | - if ( |
|
406 | - EE_Registry::instance()->CAP->current_user_can( |
|
407 | - 'ee_delete_questions', |
|
408 | - 'espresso_registration_form_trash_questions' |
|
409 | - ) |
|
410 | - ) { |
|
411 | - $this->_views['trash'] = [ |
|
412 | - 'slug' => 'trash', |
|
413 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
414 | - 'count' => 0, |
|
415 | - 'bulk_action' => [ |
|
416 | - 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
417 | - 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
418 | - ], |
|
419 | - ]; |
|
420 | - } |
|
421 | - } |
|
422 | - |
|
423 | - |
|
424 | - /** |
|
425 | - * @return void |
|
426 | - */ |
|
427 | - protected function _set_list_table_views_question_groups() |
|
428 | - { |
|
429 | - $this->_views = [ |
|
430 | - 'all' => [ |
|
431 | - 'slug' => 'all', |
|
432 | - 'label' => esc_html__('All', 'event_espresso'), |
|
433 | - 'count' => 0, |
|
434 | - 'bulk_action' => [ |
|
435 | - 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
436 | - ], |
|
437 | - ], |
|
438 | - ]; |
|
439 | - |
|
440 | - if ( |
|
441 | - EE_Registry::instance()->CAP->current_user_can( |
|
442 | - 'ee_delete_question_groups', |
|
443 | - 'espresso_registration_form_trash_question_groups' |
|
444 | - ) |
|
445 | - ) { |
|
446 | - $this->_views['trash'] = [ |
|
447 | - 'slug' => 'trash', |
|
448 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
449 | - 'count' => 0, |
|
450 | - 'bulk_action' => [ |
|
451 | - 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
452 | - 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
453 | - ], |
|
454 | - ]; |
|
455 | - } |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - /** |
|
460 | - * @return void |
|
461 | - * @throws EE_Error |
|
462 | - * @throws InvalidArgumentException |
|
463 | - * @throws InvalidDataTypeException |
|
464 | - * @throws InvalidInterfaceException |
|
465 | - */ |
|
466 | - protected function _questions_overview_list_table() |
|
467 | - { |
|
468 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
469 | - 'add_question', |
|
470 | - 'add_question', |
|
471 | - [], |
|
472 | - 'add-new-h2' |
|
473 | - ); |
|
474 | - parent::_questions_overview_list_table(); |
|
475 | - } |
|
476 | - |
|
477 | - |
|
478 | - /** |
|
479 | - * @return void |
|
480 | - * @throws DomainException |
|
481 | - * @throws EE_Error |
|
482 | - * @throws InvalidArgumentException |
|
483 | - * @throws InvalidDataTypeException |
|
484 | - * @throws InvalidInterfaceException |
|
485 | - */ |
|
486 | - protected function _question_groups_overview_list_table() |
|
487 | - { |
|
488 | - $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
489 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
490 | - 'add_question_group', |
|
491 | - 'add_question_group', |
|
492 | - [], |
|
493 | - 'add-new-h2' |
|
494 | - ); |
|
495 | - $this->display_admin_list_table_page_with_sidebar(); |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - /** |
|
500 | - * @return void |
|
501 | - * @throws EE_Error |
|
502 | - * @throws InvalidArgumentException |
|
503 | - * @throws InvalidDataTypeException |
|
504 | - * @throws InvalidInterfaceException |
|
505 | - * @throws ReflectionException |
|
506 | - */ |
|
507 | - protected function _delete_question() |
|
508 | - { |
|
509 | - $success = $this->_delete_items($this->_question_model); |
|
510 | - $this->_redirect_after_action( |
|
511 | - $success, |
|
512 | - $this->_question_model->item_name($success), |
|
513 | - 'deleted', |
|
514 | - ['action' => 'default', 'status' => 'all'] |
|
515 | - ); |
|
516 | - } |
|
517 | - |
|
518 | - |
|
519 | - /** |
|
520 | - * @return void |
|
521 | - * @throws EE_Error |
|
522 | - * @throws InvalidArgumentException |
|
523 | - * @throws InvalidDataTypeException |
|
524 | - * @throws InvalidInterfaceException |
|
525 | - * @throws ReflectionException |
|
526 | - */ |
|
527 | - protected function _delete_questions() |
|
528 | - { |
|
529 | - $success = $this->_delete_items($this->_question_model); |
|
530 | - $this->_redirect_after_action( |
|
531 | - $success, |
|
532 | - $this->_question_model->item_name($success), |
|
533 | - 'deleted permanently', |
|
534 | - ['action' => 'default', 'status' => 'trash'] |
|
535 | - ); |
|
536 | - } |
|
537 | - |
|
538 | - |
|
539 | - /** |
|
540 | - * Performs the deletion of a single or multiple questions or question groups. |
|
541 | - * |
|
542 | - * @param EEM_Soft_Delete_Base $model |
|
543 | - * @return int number of items deleted permanently |
|
544 | - * @throws EE_Error |
|
545 | - * @throws InvalidArgumentException |
|
546 | - * @throws InvalidDataTypeException |
|
547 | - * @throws InvalidInterfaceException |
|
548 | - * @throws ReflectionException |
|
549 | - */ |
|
550 | - private function _delete_items(EEM_Soft_Delete_Base $model) |
|
551 | - { |
|
552 | - $success = 0; |
|
553 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
554 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
555 | - // if array has more than one element than success message should be plural |
|
556 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
557 | - // cycle thru bulk action checkboxes |
|
558 | - $checkboxes = $this->_req_data['checkbox']; |
|
559 | - foreach (array_keys($checkboxes) as $ID) { |
|
560 | - if (! $this->_delete_item($ID, $model)) { |
|
561 | - $success = 0; |
|
562 | - } |
|
563 | - } |
|
564 | - } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
565 | - $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
566 | - } elseif (! empty($this->_req_data['QST_ID'])) { |
|
567 | - $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
568 | - } else { |
|
569 | - EE_Error::add_error( |
|
570 | - sprintf( |
|
571 | - esc_html__( |
|
572 | - "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.", |
|
573 | - "event_espresso" |
|
574 | - ) |
|
575 | - ), |
|
576 | - __FILE__, |
|
577 | - __FUNCTION__, |
|
578 | - __LINE__ |
|
579 | - ); |
|
580 | - } |
|
581 | - return $success; |
|
582 | - } |
|
583 | - |
|
584 | - |
|
585 | - /** |
|
586 | - * Deletes the specified question (and its associated question options) or question group |
|
587 | - * |
|
588 | - * @param int $id |
|
589 | - * @param EEM_Soft_Delete_Base $model |
|
590 | - * @return boolean |
|
591 | - * @throws EE_Error |
|
592 | - * @throws InvalidArgumentException |
|
593 | - * @throws InvalidDataTypeException |
|
594 | - * @throws InvalidInterfaceException |
|
595 | - * @throws ReflectionException |
|
596 | - */ |
|
597 | - protected function _delete_item($id, $model) |
|
598 | - { |
|
599 | - if ($model instanceof EEM_Question) { |
|
600 | - EEM_Question_Option::instance()->delete_permanently([['QST_ID' => absint($id)]]); |
|
601 | - } |
|
602 | - return $model->delete_permanently_by_ID(absint($id)); |
|
603 | - } |
|
604 | - |
|
605 | - |
|
606 | - /****************************** QUESTION GROUPS ******************************/ |
|
607 | - |
|
608 | - |
|
609 | - /** |
|
610 | - * @param string $type |
|
611 | - * @return void |
|
612 | - * @throws DomainException |
|
613 | - * @throws EE_Error |
|
614 | - * @throws InvalidArgumentException |
|
615 | - * @throws InvalidDataTypeException |
|
616 | - * @throws InvalidInterfaceException |
|
617 | - * @throws ReflectionException |
|
618 | - */ |
|
619 | - protected function _edit_question_group($type = 'add') |
|
620 | - { |
|
621 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
622 | - $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) |
|
623 | - ? absint($this->_req_data['QSG_ID']) |
|
624 | - : false; |
|
625 | - |
|
626 | - switch ($this->_req_action) { |
|
627 | - case 'add_question_group': |
|
628 | - $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
629 | - break; |
|
630 | - case 'edit_question_group': |
|
631 | - $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
632 | - break; |
|
633 | - default: |
|
634 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
635 | - } |
|
636 | - // add ID to title if editing |
|
637 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
638 | - if ($ID) { |
|
639 | - /** @var EE_Question_Group $questionGroup */ |
|
640 | - $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
641 | - $additional_hidden_fields = ['QSG_ID' => ['type' => 'hidden', 'value' => $ID]]; |
|
642 | - $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
643 | - } else { |
|
644 | - /** @var EE_Question_Group $questionGroup */ |
|
645 | - $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
646 | - $questionGroup->set_order_to_latest(); |
|
647 | - $this->_set_add_edit_form_tags('insert_question_group'); |
|
648 | - } |
|
649 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
650 | - $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
651 | - $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
652 | - $this->_template_args['question_group'] = $questionGroup; |
|
653 | - |
|
654 | - $redirect_URL = add_query_arg(['action' => 'question_groups'], $this->_admin_base_url); |
|
655 | - $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL, true); |
|
656 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
657 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
658 | - $this->_template_args, |
|
659 | - true |
|
660 | - ); |
|
661 | - |
|
662 | - // the details template wrapper |
|
663 | - $this->display_admin_page_with_sidebar(); |
|
664 | - } |
|
665 | - |
|
666 | - |
|
667 | - /** |
|
668 | - * @return void |
|
669 | - * @throws EE_Error |
|
670 | - * @throws InvalidArgumentException |
|
671 | - * @throws InvalidDataTypeException |
|
672 | - * @throws InvalidInterfaceException |
|
673 | - * @throws ReflectionException |
|
674 | - */ |
|
675 | - protected function _delete_question_groups() |
|
676 | - { |
|
677 | - $success = $this->_delete_items($this->_question_group_model); |
|
678 | - $this->_redirect_after_action( |
|
679 | - $success, |
|
680 | - $this->_question_group_model->item_name($success), |
|
681 | - 'deleted permanently', |
|
682 | - ['action' => 'question_groups', 'status' => 'trash'] |
|
683 | - ); |
|
684 | - } |
|
685 | - |
|
686 | - |
|
687 | - /** |
|
688 | - * @param bool $new_question_group |
|
689 | - * @throws EE_Error |
|
690 | - * @throws InvalidArgumentException |
|
691 | - * @throws InvalidDataTypeException |
|
692 | - * @throws InvalidInterfaceException |
|
693 | - * @throws ReflectionException |
|
694 | - */ |
|
695 | - protected function _insert_or_update_question_group($new_question_group = true) |
|
696 | - { |
|
697 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
698 | - $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
699 | - |
|
700 | - // make sure identifier is unique |
|
701 | - $identifier_value = $set_column_values['QSG_identifier'] ?? ''; |
|
702 | - $where_values = ['QSG_identifier' => $identifier_value]; |
|
703 | - if (! $new_question_group && isset($set_column_values['QSG_ID'])) { |
|
704 | - $where_values['QSG_ID'] = ['!=', $set_column_values['QSG_ID']]; |
|
705 | - } |
|
706 | - $identifier_exists = ! empty($identifier_value) && $this->_question_group_model->count([$where_values]) > 0; |
|
707 | - if ($identifier_exists) { |
|
708 | - $set_column_values['QSG_identifier'] .= uniqid('id', true); |
|
709 | - } |
|
710 | - |
|
711 | - if ($new_question_group) { |
|
712 | - $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
713 | - $success = $QSG_ID ? 1 : 0; |
|
714 | - if ($success === 0) { |
|
715 | - EE_Error::add_error( |
|
716 | - esc_html__('Something went wrong saving the question group.', 'event_espresso'), |
|
717 | - __FILE__, |
|
718 | - __FUNCTION__, |
|
719 | - __LINE__ |
|
720 | - ); |
|
721 | - $this->_redirect_after_action( |
|
722 | - false, |
|
723 | - '', |
|
724 | - '', |
|
725 | - ['action' => 'edit_question_group', 'QSG_ID' => $QSG_ID], |
|
726 | - true |
|
727 | - ); |
|
728 | - } |
|
729 | - } else { |
|
730 | - $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
731 | - unset($set_column_values['QSG_ID']); |
|
732 | - $success = $this->_question_group_model->update($set_column_values, [['QSG_ID' => $QSG_ID]]); |
|
733 | - } |
|
734 | - |
|
735 | - $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( |
|
736 | - EEM_Attendee::system_question_phone |
|
737 | - ); |
|
738 | - // update the existing related questions |
|
739 | - // BUT FIRST... delete the phone question from the Question_Group_Question |
|
740 | - // if it is being added to this question group (therefore removed from the existing group) |
|
741 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
742 | - // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
743 | - EEM_Question_Group_Question::instance()->delete( |
|
744 | - [ |
|
745 | - [ |
|
746 | - 'QST_ID' => $phone_question_id, |
|
747 | - 'QSG_ID' => ['!=', $QSG_ID], |
|
748 | - ], |
|
749 | - ] |
|
750 | - ); |
|
751 | - } |
|
752 | - /** @type EE_Question_Group $question_group */ |
|
753 | - $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
754 | - $questions = $question_group->questions(); |
|
755 | - // make sure system phone question is added to list of questions for this group |
|
756 | - if (! isset($questions[ $phone_question_id ])) { |
|
757 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
758 | - } |
|
759 | - |
|
760 | - foreach ($questions as $question_ID => $question) { |
|
761 | - // first we always check for order. |
|
762 | - if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
763 | - // update question order |
|
764 | - $question_group->update_question_order( |
|
765 | - $question_ID, |
|
766 | - $this->_req_data['question_orders'][ $question_ID ] |
|
767 | - ); |
|
768 | - } |
|
769 | - |
|
770 | - // then we always check if adding or removing. |
|
771 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
772 | - $question_group->add_question($question_ID); |
|
773 | - } else { |
|
774 | - // not found, remove it (but only if not a system question for the personal group |
|
775 | - // with the exception of lname system question - we allow removal of it) |
|
776 | - if ( |
|
777 | - in_array( |
|
778 | - $question->system_ID(), |
|
779 | - EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
780 | - $question_group->system_group() |
|
781 | - ) |
|
782 | - ) |
|
783 | - ) { |
|
784 | - continue; |
|
785 | - } else { |
|
786 | - $question_group->remove_question($question_ID); |
|
787 | - } |
|
788 | - } |
|
789 | - } |
|
790 | - // save new related questions |
|
791 | - if (isset($this->_req_data['questions'])) { |
|
792 | - foreach ($this->_req_data['questions'] as $QST_ID) { |
|
793 | - $question_group->add_question($QST_ID); |
|
794 | - if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
795 | - $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
796 | - } |
|
797 | - } |
|
798 | - } |
|
799 | - |
|
800 | - if ($success !== false) { |
|
801 | - $msg = $new_question_group |
|
802 | - ? sprintf( |
|
803 | - esc_html__('The %s has been created', 'event_espresso'), |
|
804 | - $this->_question_group_model->item_name() |
|
805 | - ) |
|
806 | - : sprintf( |
|
807 | - esc_html__( |
|
808 | - 'The %s has been updated', |
|
809 | - 'event_espresso' |
|
810 | - ), |
|
811 | - $this->_question_group_model->item_name() |
|
812 | - ); |
|
813 | - EE_Error::add_success($msg); |
|
814 | - } |
|
815 | - $this->_redirect_after_action( |
|
816 | - false, |
|
817 | - '', |
|
818 | - '', |
|
819 | - ['action' => 'edit_question_group', 'QSG_ID' => $QSG_ID], |
|
820 | - true |
|
821 | - ); |
|
822 | - } |
|
823 | - |
|
824 | - |
|
825 | - /** |
|
826 | - * duplicates a question and all its question options and redirects to the new question. |
|
827 | - * |
|
828 | - * @return void |
|
829 | - * @throws EE_Error |
|
830 | - * @throws InvalidArgumentException |
|
831 | - * @throws ReflectionException |
|
832 | - * @throws InvalidDataTypeException |
|
833 | - * @throws InvalidInterfaceException |
|
834 | - */ |
|
835 | - public function _duplicate_question() |
|
836 | - { |
|
837 | - $question_ID = (int) $this->_req_data['QST_ID']; |
|
838 | - $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
839 | - if ($question instanceof EE_Question) { |
|
840 | - $new_question = $question->duplicate(); |
|
841 | - if ($new_question instanceof EE_Question) { |
|
842 | - $this->_redirect_after_action( |
|
843 | - true, |
|
844 | - esc_html__('Question', 'event_espresso'), |
|
845 | - esc_html__('Duplicated', 'event_espresso'), |
|
846 | - ['action' => 'edit_question', 'QST_ID' => $new_question->ID()], |
|
847 | - true |
|
848 | - ); |
|
849 | - } else { |
|
850 | - global $wpdb; |
|
851 | - EE_Error::add_error( |
|
852 | - sprintf( |
|
853 | - esc_html__( |
|
854 | - 'Could not duplicate question with ID %1$d because: %2$s', |
|
855 | - 'event_espresso' |
|
856 | - ), |
|
857 | - $question_ID, |
|
858 | - $wpdb->last_error |
|
859 | - ), |
|
860 | - __FILE__, |
|
861 | - __FUNCTION__, |
|
862 | - __LINE__ |
|
863 | - ); |
|
864 | - $this->_redirect_after_action(false, '', '', ['action' => 'default'], false); |
|
865 | - } |
|
866 | - } else { |
|
867 | - EE_Error::add_error( |
|
868 | - sprintf( |
|
869 | - esc_html__( |
|
870 | - 'Could not duplicate question with ID %d because it didn\'t exist!', |
|
871 | - 'event_espresso' |
|
872 | - ), |
|
873 | - $question_ID |
|
874 | - ), |
|
875 | - __FILE__, |
|
876 | - __FUNCTION__, |
|
877 | - __LINE__ |
|
878 | - ); |
|
879 | - $this->_redirect_after_action(false, '', '', ['action' => 'default'], false); |
|
880 | - } |
|
881 | - } |
|
882 | - |
|
883 | - |
|
884 | - /** |
|
885 | - * @param bool $trash |
|
886 | - * @throws EE_Error |
|
887 | - */ |
|
888 | - protected function _trash_or_restore_question_groups($trash = true) |
|
889 | - { |
|
890 | - $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
891 | - } |
|
892 | - |
|
893 | - |
|
894 | - /** |
|
895 | - *_trash_question |
|
896 | - * |
|
897 | - * @return void |
|
898 | - * @throws EE_Error |
|
899 | - */ |
|
900 | - protected function _trash_question() |
|
901 | - { |
|
902 | - $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
903 | - $query_args = ['action' => 'default', 'status' => 'all']; |
|
904 | - $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
905 | - } |
|
906 | - |
|
907 | - |
|
908 | - /** |
|
909 | - * @param bool $trash |
|
910 | - * @throws EE_Error |
|
911 | - */ |
|
912 | - protected function _trash_or_restore_questions($trash = true) |
|
913 | - { |
|
914 | - $this->_trash_or_restore_items($this->_question_model, $trash); |
|
915 | - } |
|
916 | - |
|
917 | - |
|
918 | - /** |
|
919 | - * Internally used to delete or restore items, using the request data. Meant to be |
|
920 | - * flexible between question or question groups |
|
921 | - * |
|
922 | - * @param EEM_Soft_Delete_Base $model |
|
923 | - * @param boolean $trash whether to trash or restore |
|
924 | - * @throws EE_Error |
|
925 | - */ |
|
926 | - private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
927 | - { |
|
928 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
929 | - |
|
930 | - $success = 1; |
|
931 | - // Checkboxes |
|
932 | - // echo "trash $trash"; |
|
933 | - // var_dump($this->_req_data['checkbox']);die; |
|
934 | - if (isset($this->_req_data['checkbox'])) { |
|
935 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
936 | - // if array has more than one element than success message should be plural |
|
937 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
938 | - // cycle thru bulk action checkboxes |
|
939 | - $checkboxes = $this->_req_data['checkbox']; |
|
940 | - foreach (array_keys($checkboxes) as $ID) { |
|
941 | - if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
942 | - $success = 0; |
|
943 | - } |
|
944 | - } |
|
945 | - } else { |
|
946 | - // grab single id and delete |
|
947 | - $ID = absint($this->_req_data['checkbox']); |
|
948 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
949 | - $success = 0; |
|
950 | - } |
|
951 | - } |
|
952 | - } else { |
|
953 | - // delete via trash link |
|
954 | - // grab single id and delete |
|
955 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
956 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
957 | - $success = 0; |
|
958 | - } |
|
959 | - } |
|
960 | - |
|
961 | - |
|
962 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
963 | - // echo "action :$action"; |
|
964 | - // $action = 'questions' ? 'default' : $action; |
|
965 | - if ($trash) { |
|
966 | - $action_desc = 'trashed'; |
|
967 | - $status = 'trash'; |
|
968 | - } else { |
|
969 | - $action_desc = 'restored'; |
|
970 | - $status = 'all'; |
|
971 | - } |
|
972 | - $this->_redirect_after_action( |
|
973 | - $success, |
|
974 | - $model->item_name($success), |
|
975 | - $action_desc, |
|
976 | - ['action' => $action, 'status' => $status] |
|
977 | - ); |
|
978 | - } |
|
979 | - |
|
980 | - |
|
981 | - /** |
|
982 | - * @param $per_page |
|
983 | - * @param int $current_page |
|
984 | - * @param bool|false $count |
|
985 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
986 | - * @throws EE_Error |
|
987 | - * @throws InvalidArgumentException |
|
988 | - * @throws InvalidDataTypeException |
|
989 | - * @throws InvalidInterfaceException |
|
990 | - * @throws ReflectionException |
|
991 | - */ |
|
992 | - public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
993 | - { |
|
994 | - $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
995 | - |
|
996 | - if ($count) { |
|
997 | - // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
998 | - $where = isset($query_params[0]) ? [$query_params[0]] : []; |
|
999 | - $results = $this->_question_model->count_deleted($where); |
|
1000 | - } else { |
|
1001 | - // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
1002 | - $results = $this->_question_model->get_all_deleted($query_params); |
|
1003 | - } |
|
1004 | - return $results; |
|
1005 | - } |
|
1006 | - |
|
1007 | - |
|
1008 | - /** |
|
1009 | - * @param $per_page |
|
1010 | - * @param int $current_page |
|
1011 | - * @param bool|false $count |
|
1012 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
1013 | - * @throws EE_Error |
|
1014 | - * @throws InvalidArgumentException |
|
1015 | - * @throws InvalidDataTypeException |
|
1016 | - * @throws InvalidInterfaceException |
|
1017 | - * @throws ReflectionException |
|
1018 | - */ |
|
1019 | - public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
1020 | - { |
|
1021 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
1022 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1023 | - if ($count) { |
|
1024 | - $where = isset($query_params[0]) ? [$query_params[0]] : []; |
|
1025 | - $results = $questionGroupModel->count($where); |
|
1026 | - } else { |
|
1027 | - $results = $questionGroupModel->get_all($query_params); |
|
1028 | - } |
|
1029 | - return $results; |
|
1030 | - } |
|
1031 | - |
|
1032 | - |
|
1033 | - /** |
|
1034 | - * @param $per_page |
|
1035 | - * @param int $current_page |
|
1036 | - * @param bool $count |
|
1037 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
1038 | - * @throws EE_Error |
|
1039 | - * @throws InvalidArgumentException |
|
1040 | - * @throws InvalidDataTypeException |
|
1041 | - * @throws InvalidInterfaceException |
|
1042 | - * @throws ReflectionException |
|
1043 | - */ |
|
1044 | - public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
1045 | - { |
|
1046 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
1047 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1048 | - if ($count) { |
|
1049 | - $where = isset($query_params[0]) ? [$query_params[0]] : []; |
|
1050 | - $query_params['limit'] = null; |
|
1051 | - $results = $questionGroupModel->count_deleted($where); |
|
1052 | - } else { |
|
1053 | - $results = $questionGroupModel->get_all_deleted($query_params); |
|
1054 | - } |
|
1055 | - return $results; |
|
1056 | - } |
|
1057 | - |
|
1058 | - |
|
1059 | - /** |
|
1060 | - * method for performing updates to question order |
|
1061 | - * |
|
1062 | - * @return void results array |
|
1063 | - * @throws EE_Error |
|
1064 | - * @throws InvalidArgumentException |
|
1065 | - * @throws InvalidDataTypeException |
|
1066 | - * @throws InvalidInterfaceException |
|
1067 | - * @throws ReflectionException |
|
1068 | - */ |
|
1069 | - public function update_question_group_order() |
|
1070 | - { |
|
1071 | - if (! $this->capabilities->current_user_can('ee_edit_question_groups', __FUNCTION__)) { |
|
1072 | - wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
1073 | - } |
|
1074 | - $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
1075 | - |
|
1076 | - // grab our row IDs |
|
1077 | - $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
1078 | - ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
1079 | - : []; |
|
1080 | - |
|
1081 | - $perpage = ! empty($this->_req_data['perpage']) |
|
1082 | - ? (int) $this->_req_data['perpage'] |
|
1083 | - : null; |
|
1084 | - $curpage = ! empty($this->_req_data['curpage']) |
|
1085 | - ? (int) $this->_req_data['curpage'] |
|
1086 | - : null; |
|
1087 | - |
|
1088 | - if (! empty($row_ids)) { |
|
1089 | - // figure out where we start the row_id count at for the current page. |
|
1090 | - $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
1091 | - |
|
1092 | - $row_count = count($row_ids); |
|
1093 | - for ($i = 0; $i < $row_count; $i++) { |
|
1094 | - // Update the questions when re-ordering |
|
1095 | - $updated = EEM_Question_Group::instance()->update( |
|
1096 | - ['QSG_order' => $qsgcount], |
|
1097 | - [['QSG_ID' => $row_ids[ $i ]]] |
|
1098 | - ); |
|
1099 | - if ($updated === false) { |
|
1100 | - $success = false; |
|
1101 | - } |
|
1102 | - $qsgcount++; |
|
1103 | - } |
|
1104 | - } else { |
|
1105 | - $success = false; |
|
1106 | - } |
|
1107 | - |
|
1108 | - $errors = ! $success |
|
1109 | - ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
1110 | - : false; |
|
1111 | - |
|
1112 | - echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]); |
|
1113 | - die(); |
|
1114 | - } |
|
1115 | - |
|
1116 | - |
|
1117 | - |
|
1118 | - /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
1119 | - |
|
1120 | - |
|
1121 | - /** |
|
1122 | - * @throws DomainException |
|
1123 | - * @throws EE_Error |
|
1124 | - * @throws InvalidArgumentException |
|
1125 | - * @throws InvalidDataTypeException |
|
1126 | - * @throws InvalidInterfaceException |
|
1127 | - */ |
|
1128 | - protected function _reg_form_settings() |
|
1129 | - { |
|
1130 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
1131 | - add_action( |
|
1132 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1133 | - [$this, 'email_validation_settings_form'], |
|
1134 | - 2 |
|
1135 | - ); |
|
1136 | - add_action( |
|
1137 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1138 | - [$this, 'copy_attendee_info_settings_form'], |
|
1139 | - 4 |
|
1140 | - ); |
|
1141 | - add_action( |
|
1142 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1143 | - [$this, 'setSessionLifespan'], |
|
1144 | - 5 |
|
1145 | - ); |
|
1146 | - $this->_template_args = (array) apply_filters( |
|
1147 | - 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
1148 | - $this->_template_args |
|
1149 | - ); |
|
1150 | - $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
1151 | - $this->_set_publish_post_box_vars(); |
|
1152 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1153 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1154 | - $this->_template_args, |
|
1155 | - true |
|
1156 | - ); |
|
1157 | - $this->display_admin_page_with_sidebar(); |
|
1158 | - } |
|
1159 | - |
|
1160 | - |
|
1161 | - /** |
|
1162 | - * @return void |
|
1163 | - * @throws EE_Error |
|
1164 | - * @throws InvalidArgumentException |
|
1165 | - * @throws ReflectionException |
|
1166 | - * @throws InvalidDataTypeException |
|
1167 | - * @throws InvalidInterfaceException |
|
1168 | - */ |
|
1169 | - protected function _update_reg_form_settings() |
|
1170 | - { |
|
1171 | - EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
1172 | - EE_Registry::instance()->CFG->registration |
|
1173 | - ); |
|
1174 | - EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form( |
|
1175 | - EE_Registry::instance()->CFG->registration |
|
1176 | - ); |
|
1177 | - $this->updateSessionLifespan(); |
|
1178 | - EE_Registry::instance()->CFG->registration = apply_filters( |
|
1179 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
1180 | - EE_Registry::instance()->CFG->registration |
|
1181 | - ); |
|
1182 | - $success = $this->_update_espresso_configuration( |
|
1183 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1184 | - EE_Registry::instance()->CFG, |
|
1185 | - __FILE__, |
|
1186 | - __FUNCTION__, |
|
1187 | - __LINE__ |
|
1188 | - ); |
|
1189 | - $this->_redirect_after_action( |
|
1190 | - $success, |
|
1191 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1192 | - 'updated', |
|
1193 | - ['action' => 'view_reg_form_settings'] |
|
1194 | - ); |
|
1195 | - } |
|
1196 | - |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * @return void |
|
1200 | - * @throws EE_Error |
|
1201 | - * @throws InvalidArgumentException |
|
1202 | - * @throws InvalidDataTypeException |
|
1203 | - * @throws InvalidInterfaceException |
|
1204 | - */ |
|
1205 | - public function copy_attendee_info_settings_form() |
|
1206 | - { |
|
1207 | - echo wp_kses($this->_copy_attendee_info_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1208 | - } |
|
1209 | - |
|
1210 | - |
|
1211 | - /** |
|
1212 | - * _copy_attendee_info_settings_form |
|
1213 | - * |
|
1214 | - * @access protected |
|
1215 | - * @return EE_Form_Section_Proper |
|
1216 | - * @throws \EE_Error |
|
1217 | - */ |
|
1218 | - protected function _copy_attendee_info_settings_form() |
|
1219 | - { |
|
1220 | - return new EE_Form_Section_Proper( |
|
1221 | - [ |
|
1222 | - 'name' => 'copy_attendee_info_settings', |
|
1223 | - 'html_id' => 'copy_attendee_info_settings', |
|
1224 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1225 | - 'subsections' => apply_filters( |
|
1226 | - 'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections', |
|
1227 | - [ |
|
1228 | - 'copy_attendee_info_hdr' => new EE_Form_Section_HTML( |
|
1229 | - EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso')) |
|
1230 | - ), |
|
1231 | - 'copy_attendee_info' => new EE_Yes_No_Input( |
|
1232 | - [ |
|
1233 | - 'html_label_text' => esc_html__( |
|
1234 | - 'Allow copy #1 attendee info to extra attendees?', |
|
1235 | - 'event_espresso' |
|
1236 | - ), |
|
1237 | - 'html_help_text' => esc_html__( |
|
1238 | - 'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.', |
|
1239 | - 'event_espresso' |
|
1240 | - ), |
|
1241 | - 'default' => EE_Registry::instance( |
|
1242 | - )->CFG->registration->copyAttendeeInfo(), |
|
1243 | - 'required' => false, |
|
1244 | - 'display_html_label_text' => false, |
|
1245 | - ] |
|
1246 | - ), |
|
1247 | - ] |
|
1248 | - ), |
|
1249 | - ] |
|
1250 | - ); |
|
1251 | - } |
|
1252 | - |
|
1253 | - |
|
1254 | - /** |
|
1255 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1256 | - * @return EE_Registration_Config |
|
1257 | - * @throws EE_Error |
|
1258 | - * @throws InvalidArgumentException |
|
1259 | - * @throws ReflectionException |
|
1260 | - * @throws InvalidDataTypeException |
|
1261 | - * @throws InvalidInterfaceException |
|
1262 | - */ |
|
1263 | - public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1264 | - { |
|
1265 | - $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo(); |
|
1266 | - try { |
|
1267 | - $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form(); |
|
1268 | - // if not displaying a form, then check for form submission |
|
1269 | - if ($copy_attendee_info_settings_form->was_submitted()) { |
|
1270 | - // capture form data |
|
1271 | - $copy_attendee_info_settings_form->receive_form_submission(); |
|
1272 | - // validate form data |
|
1273 | - if ($copy_attendee_info_settings_form->is_valid()) { |
|
1274 | - // grab validated data from form |
|
1275 | - $valid_data = $copy_attendee_info_settings_form->valid_data(); |
|
1276 | - if (isset($valid_data['copy_attendee_info'])) { |
|
1277 | - $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']); |
|
1278 | - } else { |
|
1279 | - EE_Error::add_error( |
|
1280 | - esc_html__( |
|
1281 | - 'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.', |
|
1282 | - 'event_espresso' |
|
1283 | - ), |
|
1284 | - __FILE__, |
|
1285 | - __FUNCTION__, |
|
1286 | - __LINE__ |
|
1287 | - ); |
|
1288 | - } |
|
1289 | - } elseif ($copy_attendee_info_settings_form->submission_error_message() !== '') { |
|
1290 | - EE_Error::add_error( |
|
1291 | - $copy_attendee_info_settings_form->submission_error_message(), |
|
1292 | - __FILE__, |
|
1293 | - __FUNCTION__, |
|
1294 | - __LINE__ |
|
1295 | - ); |
|
1296 | - } |
|
1297 | - } |
|
1298 | - } catch (EE_Error $e) { |
|
1299 | - $e->get_error(); |
|
1300 | - } |
|
1301 | - return $EE_Registration_Config; |
|
1302 | - } |
|
1303 | - |
|
1304 | - |
|
1305 | - /** |
|
1306 | - * @return void |
|
1307 | - * @throws EE_Error |
|
1308 | - * @throws InvalidArgumentException |
|
1309 | - * @throws InvalidDataTypeException |
|
1310 | - * @throws InvalidInterfaceException |
|
1311 | - */ |
|
1312 | - public function email_validation_settings_form() |
|
1313 | - { |
|
1314 | - echo wp_kses($this->_email_validation_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1315 | - } |
|
1316 | - |
|
1317 | - |
|
1318 | - /** |
|
1319 | - * _email_validation_settings_form |
|
1320 | - * |
|
1321 | - * @access protected |
|
1322 | - * @return EE_Form_Section_Proper |
|
1323 | - * @throws \EE_Error |
|
1324 | - */ |
|
1325 | - protected function _email_validation_settings_form() |
|
1326 | - { |
|
1327 | - return new EE_Form_Section_Proper( |
|
1328 | - [ |
|
1329 | - 'name' => 'email_validation_settings', |
|
1330 | - 'html_id' => 'email_validation_settings', |
|
1331 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1332 | - 'subsections' => apply_filters( |
|
1333 | - 'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections', |
|
1334 | - [ |
|
1335 | - 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
1336 | - EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
1337 | - ), |
|
1338 | - 'email_validation_level' => new EE_Select_Input( |
|
1339 | - [ |
|
1340 | - 'basic' => esc_html__('Basic', 'event_espresso'), |
|
1341 | - 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
1342 | - 'i18n' => esc_html__('International', 'event_espresso'), |
|
1343 | - 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
1344 | - ], |
|
1345 | - [ |
|
1346 | - 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
1347 | - . EEH_Template::get_help_tab_link('email_validation_info'), |
|
1348 | - 'html_help_text' => esc_html__( |
|
1349 | - '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.', |
|
1350 | - 'event_espresso' |
|
1351 | - ), |
|
1352 | - 'default' => isset( |
|
1353 | - EE_Registry::instance()->CFG->registration->email_validation_level |
|
1354 | - ) |
|
1355 | - ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
1356 | - : 'wp_default', |
|
1357 | - 'required' => false, |
|
1358 | - ] |
|
1359 | - ), |
|
1360 | - ] |
|
1361 | - ), |
|
1362 | - ] |
|
1363 | - ); |
|
1364 | - } |
|
1365 | - |
|
1366 | - |
|
1367 | - /** |
|
1368 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1369 | - * @return EE_Registration_Config |
|
1370 | - * @throws EE_Error |
|
1371 | - * @throws InvalidArgumentException |
|
1372 | - * @throws ReflectionException |
|
1373 | - * @throws InvalidDataTypeException |
|
1374 | - * @throws InvalidInterfaceException |
|
1375 | - */ |
|
1376 | - public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1377 | - { |
|
1378 | - $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1379 | - try { |
|
1380 | - $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1381 | - // if not displaying a form, then check for form submission |
|
1382 | - if ($email_validation_settings_form->was_submitted()) { |
|
1383 | - // capture form data |
|
1384 | - $email_validation_settings_form->receive_form_submission(); |
|
1385 | - // validate form data |
|
1386 | - if ($email_validation_settings_form->is_valid()) { |
|
1387 | - // grab validated data from form |
|
1388 | - $valid_data = $email_validation_settings_form->valid_data(); |
|
1389 | - if (isset($valid_data['email_validation_level'])) { |
|
1390 | - $email_validation_level = $valid_data['email_validation_level']; |
|
1391 | - // now if they want to use international email addresses |
|
1392 | - if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1393 | - // in case we need to reset their email validation level, |
|
1394 | - // make sure that the previous value wasn't already set to one of the i18n options. |
|
1395 | - if ( |
|
1396 | - $prev_email_validation_level === 'i18n' |
|
1397 | - || $prev_email_validation_level |
|
1398 | - === 'i18n_dns' |
|
1399 | - ) { |
|
1400 | - // if so, then reset it back to "basic" since that is the only other option that, |
|
1401 | - // despite offering poor validation, supports i18n email addresses |
|
1402 | - $prev_email_validation_level = 'basic'; |
|
1403 | - } |
|
1404 | - // confirm our i18n email validation will work on the server |
|
1405 | - if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1406 | - // or reset email validation level to previous value |
|
1407 | - $email_validation_level = $prev_email_validation_level; |
|
1408 | - } |
|
1409 | - } |
|
1410 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1411 | - } else { |
|
1412 | - EE_Error::add_error( |
|
1413 | - esc_html__( |
|
1414 | - 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1415 | - 'event_espresso' |
|
1416 | - ), |
|
1417 | - __FILE__, |
|
1418 | - __FUNCTION__, |
|
1419 | - __LINE__ |
|
1420 | - ); |
|
1421 | - } |
|
1422 | - } elseif ($email_validation_settings_form->submission_error_message() !== '') { |
|
1423 | - EE_Error::add_error( |
|
1424 | - $email_validation_settings_form->submission_error_message(), |
|
1425 | - __FILE__, |
|
1426 | - __FUNCTION__, |
|
1427 | - __LINE__ |
|
1428 | - ); |
|
1429 | - } |
|
1430 | - } |
|
1431 | - } catch (EE_Error $e) { |
|
1432 | - $e->get_error(); |
|
1433 | - } |
|
1434 | - return $EE_Registration_Config; |
|
1435 | - } |
|
1436 | - |
|
1437 | - |
|
1438 | - /** |
|
1439 | - * confirms that the server's PHP version has the PCRE module enabled, |
|
1440 | - * and that the PCRE version works with our i18n email validation |
|
1441 | - * |
|
1442 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1443 | - * @param string $email_validation_level |
|
1444 | - * @return bool |
|
1445 | - */ |
|
1446 | - private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1447 | - { |
|
1448 | - // first check that PCRE is enabled |
|
1449 | - if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1450 | - EE_Error::add_error( |
|
1451 | - sprintf( |
|
1452 | - esc_html__( |
|
1453 | - '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.', |
|
1454 | - 'event_espresso' |
|
1455 | - ), |
|
1456 | - '<br />' |
|
1457 | - ), |
|
1458 | - __FILE__, |
|
1459 | - __FUNCTION__, |
|
1460 | - __LINE__ |
|
1461 | - ); |
|
1462 | - return false; |
|
1463 | - } else { |
|
1464 | - // PCRE support is enabled, but let's still |
|
1465 | - // perform a test to see if the server will support it. |
|
1466 | - // but first, save the updated validation level to the config, |
|
1467 | - // so that the validation strategy picks it up. |
|
1468 | - // this will get bumped back down if it doesn't work |
|
1469 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1470 | - try { |
|
1471 | - $email_validator = new EE_Email_Validation_Strategy(); |
|
1472 | - $i18n_email_address = apply_filters( |
|
1473 | - 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1474 | - 'jägerjü[email protected]' |
|
1475 | - ); |
|
1476 | - $email_validator->validate($i18n_email_address); |
|
1477 | - } catch (Exception $e) { |
|
1478 | - EE_Error::add_error( |
|
1479 | - sprintf( |
|
1480 | - esc_html__( |
|
1481 | - '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', |
|
1482 | - 'event_espresso' |
|
1483 | - ), |
|
1484 | - '<br />', |
|
1485 | - '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>' |
|
1486 | - ), |
|
1487 | - __FILE__, |
|
1488 | - __FUNCTION__, |
|
1489 | - __LINE__ |
|
1490 | - ); |
|
1491 | - return false; |
|
1492 | - } |
|
1493 | - } |
|
1494 | - return true; |
|
1495 | - } |
|
1496 | - |
|
1497 | - |
|
1498 | - public function setSessionLifespan() |
|
1499 | - { |
|
1500 | - $session_lifespan_form = $this->loader->getNew(SessionLifespanForm::class); |
|
1501 | - echo wp_kses($session_lifespan_form->get_html(), AllowedTags::getWithFormTags()); |
|
1502 | - } |
|
1503 | - |
|
1504 | - |
|
1505 | - public function updateSessionLifespan() |
|
1506 | - { |
|
1507 | - $handler = $this->loader->getNew(SessionLifespanFormHandler::class); |
|
1508 | - $handler->process($this->loader->getNew(SessionLifespanForm::class)); |
|
1509 | - } |
|
19 | + /** |
|
20 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
21 | + * @throws EE_Error |
|
22 | + * @throws ReflectionException |
|
23 | + */ |
|
24 | + public function __construct($routing = true) |
|
25 | + { |
|
26 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/'); |
|
27 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/'); |
|
28 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
29 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/'); |
|
30 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
31 | + parent::__construct($routing); |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + protected function _define_page_props() |
|
36 | + { |
|
37 | + parent::_define_page_props(); |
|
38 | + $this->_labels['publishbox'] = [ |
|
39 | + 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
40 | + 'edit_question' => esc_html__('Edit Question', 'event_espresso'), |
|
41 | + 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
42 | + 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
43 | + ]; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + protected function _set_page_config() |
|
48 | + { |
|
49 | + parent::_set_page_config(); |
|
50 | + |
|
51 | + $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
52 | + $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) |
|
53 | + ? $this->_req_data['QST_ID'] : 0; |
|
54 | + $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) |
|
55 | + ? $this->_req_data['QSG_ID'] : 0; |
|
56 | + |
|
57 | + $new_page_routes = [ |
|
58 | + 'question_groups' => [ |
|
59 | + 'func' => '_question_groups_overview_list_table', |
|
60 | + 'capability' => 'ee_read_question_groups', |
|
61 | + ], |
|
62 | + 'add_question' => [ |
|
63 | + 'func' => '_edit_question', |
|
64 | + 'capability' => 'ee_edit_questions', |
|
65 | + ], |
|
66 | + 'insert_question' => [ |
|
67 | + 'func' => '_insert_or_update_question', |
|
68 | + 'args' => ['new_question' => true], |
|
69 | + 'capability' => 'ee_edit_questions', |
|
70 | + 'noheader' => true, |
|
71 | + ], |
|
72 | + 'duplicate_question' => [ |
|
73 | + 'func' => '_duplicate_question', |
|
74 | + 'capability' => 'ee_edit_questions', |
|
75 | + 'noheader' => true, |
|
76 | + ], |
|
77 | + 'trash_question' => [ |
|
78 | + 'func' => '_trash_question', |
|
79 | + 'capability' => 'ee_delete_question', |
|
80 | + 'obj_id' => $qst_id, |
|
81 | + 'noheader' => true, |
|
82 | + ], |
|
83 | + |
|
84 | + 'restore_question' => [ |
|
85 | + 'func' => '_trash_or_restore_questions', |
|
86 | + 'capability' => 'ee_delete_question', |
|
87 | + 'obj_id' => $qst_id, |
|
88 | + 'args' => ['trash' => false], |
|
89 | + 'noheader' => true, |
|
90 | + ], |
|
91 | + |
|
92 | + 'delete_question' => [ |
|
93 | + 'func' => '_delete_question', |
|
94 | + 'capability' => 'ee_delete_question', |
|
95 | + 'obj_id' => $qst_id, |
|
96 | + 'noheader' => true, |
|
97 | + ], |
|
98 | + |
|
99 | + 'trash_questions' => [ |
|
100 | + 'func' => '_trash_or_restore_questions', |
|
101 | + 'capability' => 'ee_delete_questions', |
|
102 | + 'args' => ['trash' => true], |
|
103 | + 'noheader' => true, |
|
104 | + ], |
|
105 | + |
|
106 | + 'restore_questions' => [ |
|
107 | + 'func' => '_trash_or_restore_questions', |
|
108 | + 'capability' => 'ee_delete_questions', |
|
109 | + 'args' => ['trash' => false], |
|
110 | + 'noheader' => true, |
|
111 | + ], |
|
112 | + |
|
113 | + 'delete_questions' => [ |
|
114 | + 'func' => '_delete_questions', |
|
115 | + 'args' => [], |
|
116 | + 'capability' => 'ee_delete_questions', |
|
117 | + 'noheader' => true, |
|
118 | + ], |
|
119 | + |
|
120 | + 'add_question_group' => [ |
|
121 | + 'func' => '_edit_question_group', |
|
122 | + 'capability' => 'ee_edit_question_groups', |
|
123 | + ], |
|
124 | + |
|
125 | + 'edit_question_group' => [ |
|
126 | + 'func' => '_edit_question_group', |
|
127 | + 'capability' => 'ee_edit_question_group', |
|
128 | + 'obj_id' => $qsg_id, |
|
129 | + 'args' => ['edit'], |
|
130 | + ], |
|
131 | + |
|
132 | + 'delete_question_groups' => [ |
|
133 | + 'func' => '_delete_question_groups', |
|
134 | + 'capability' => 'ee_delete_question_groups', |
|
135 | + 'noheader' => true, |
|
136 | + ], |
|
137 | + |
|
138 | + 'delete_question_group' => [ |
|
139 | + 'func' => '_delete_question_groups', |
|
140 | + 'capability' => 'ee_delete_question_group', |
|
141 | + 'obj_id' => $qsg_id, |
|
142 | + 'noheader' => true, |
|
143 | + ], |
|
144 | + |
|
145 | + 'trash_question_group' => [ |
|
146 | + 'func' => '_trash_or_restore_question_groups', |
|
147 | + 'args' => ['trash' => true], |
|
148 | + 'capability' => 'ee_delete_question_group', |
|
149 | + 'obj_id' => $qsg_id, |
|
150 | + 'noheader' => true, |
|
151 | + ], |
|
152 | + |
|
153 | + 'restore_question_group' => [ |
|
154 | + 'func' => '_trash_or_restore_question_groups', |
|
155 | + 'args' => ['trash' => false], |
|
156 | + 'capability' => 'ee_delete_question_group', |
|
157 | + 'obj_id' => $qsg_id, |
|
158 | + 'noheader' => true, |
|
159 | + ], |
|
160 | + |
|
161 | + 'insert_question_group' => [ |
|
162 | + 'func' => '_insert_or_update_question_group', |
|
163 | + 'args' => ['new_question_group' => true], |
|
164 | + 'capability' => 'ee_edit_question_groups', |
|
165 | + 'noheader' => true, |
|
166 | + ], |
|
167 | + |
|
168 | + 'update_question_group' => [ |
|
169 | + 'func' => '_insert_or_update_question_group', |
|
170 | + 'args' => ['new_question_group' => false], |
|
171 | + 'capability' => 'ee_edit_question_group', |
|
172 | + 'obj_id' => $qsg_id, |
|
173 | + 'noheader' => true, |
|
174 | + ], |
|
175 | + |
|
176 | + 'trash_question_groups' => [ |
|
177 | + 'func' => '_trash_or_restore_question_groups', |
|
178 | + 'args' => ['trash' => true], |
|
179 | + 'capability' => 'ee_delete_question_groups', |
|
180 | + 'noheader' => ['trash' => false], |
|
181 | + ], |
|
182 | + |
|
183 | + 'restore_question_groups' => [ |
|
184 | + 'func' => '_trash_or_restore_question_groups', |
|
185 | + 'args' => ['trash' => false], |
|
186 | + 'capability' => 'ee_delete_question_groups', |
|
187 | + 'noheader' => true, |
|
188 | + ], |
|
189 | + |
|
190 | + |
|
191 | + 'espresso_update_question_group_order' => [ |
|
192 | + 'func' => 'update_question_group_order', |
|
193 | + 'capability' => 'ee_edit_question_groups', |
|
194 | + 'noheader' => true, |
|
195 | + ], |
|
196 | + |
|
197 | + 'view_reg_form_settings' => [ |
|
198 | + 'func' => '_reg_form_settings', |
|
199 | + 'capability' => 'manage_options', |
|
200 | + ], |
|
201 | + |
|
202 | + 'update_reg_form_settings' => [ |
|
203 | + 'func' => '_update_reg_form_settings', |
|
204 | + 'capability' => 'manage_options', |
|
205 | + 'noheader' => true, |
|
206 | + ], |
|
207 | + ]; |
|
208 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
209 | + |
|
210 | + $new_page_config = [ |
|
211 | + |
|
212 | + 'question_groups' => [ |
|
213 | + 'nav' => [ |
|
214 | + 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
215 | + 'icon' => 'dashicons-forms', |
|
216 | + 'order' => 20, |
|
217 | + ], |
|
218 | + 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
219 | + 'help_tabs' => [ |
|
220 | + 'registration_form_question_groups_help_tab' => [ |
|
221 | + 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
222 | + 'filename' => 'registration_form_question_groups', |
|
223 | + ], |
|
224 | + 'registration_form_question_groups_table_column_headings_help_tab' => [ |
|
225 | + 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
226 | + 'filename' => 'registration_form_question_groups_table_column_headings', |
|
227 | + ], |
|
228 | + 'registration_form_question_groups_views_bulk_actions_search_help_tab' => [ |
|
229 | + 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
230 | + 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
231 | + ], |
|
232 | + ], |
|
233 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
234 | + 'require_nonce' => false, |
|
235 | + ], |
|
236 | + |
|
237 | + 'add_question' => [ |
|
238 | + 'nav' => [ |
|
239 | + 'label' => esc_html__('Add Question', 'event_espresso'), |
|
240 | + 'icon' => 'dashicons-plus-alt', |
|
241 | + 'order' => 15, |
|
242 | + 'persistent' => false, |
|
243 | + ], |
|
244 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
245 | + 'help_tabs' => [ |
|
246 | + 'registration_form_add_question_help_tab' => [ |
|
247 | + 'title' => esc_html__('Add Question', 'event_espresso'), |
|
248 | + 'filename' => 'registration_form_add_question', |
|
249 | + ], |
|
250 | + ], |
|
251 | + 'require_nonce' => false, |
|
252 | + ], |
|
253 | + |
|
254 | + 'add_question_group' => [ |
|
255 | + 'nav' => [ |
|
256 | + 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
257 | + 'icon' => 'dashicons-plus-alt', |
|
258 | + 'order' => 25, |
|
259 | + 'persistent' => false, |
|
260 | + ], |
|
261 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
262 | + 'help_tabs' => [ |
|
263 | + 'registration_form_add_question_group_help_tab' => [ |
|
264 | + 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
265 | + 'filename' => 'registration_form_add_question_group', |
|
266 | + ], |
|
267 | + ], |
|
268 | + 'require_nonce' => false, |
|
269 | + ], |
|
270 | + |
|
271 | + 'edit_question_group' => [ |
|
272 | + 'nav' => [ |
|
273 | + 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
274 | + 'icon' => 'dashicons-edit-large', |
|
275 | + 'order' => 25, |
|
276 | + 'persistent' => false, |
|
277 | + 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg( |
|
278 | + ['question_group_id' => $this->_req_data['question_group_id']], |
|
279 | + $this->_current_page_view_url |
|
280 | + ) : $this->_admin_base_url, |
|
281 | + ], |
|
282 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
283 | + 'help_tabs' => [ |
|
284 | + 'registration_form_edit_question_group_help_tab' => [ |
|
285 | + 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
286 | + 'filename' => 'registration_form_edit_question_group', |
|
287 | + ], |
|
288 | + ], |
|
289 | + 'require_nonce' => false, |
|
290 | + ], |
|
291 | + |
|
292 | + 'view_reg_form_settings' => [ |
|
293 | + 'nav' => [ |
|
294 | + 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
295 | + 'icon' => 'dashicons-admin-generic', |
|
296 | + 'order' => 40, |
|
297 | + ], |
|
298 | + 'labels' => [ |
|
299 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
300 | + ], |
|
301 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
302 | + 'help_tabs' => [ |
|
303 | + 'registration_form_reg_form_settings_help_tab' => [ |
|
304 | + 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
305 | + 'filename' => 'registration_form_reg_form_settings', |
|
306 | + ], |
|
307 | + ], |
|
308 | + 'require_nonce' => false, |
|
309 | + ], |
|
310 | + |
|
311 | + ]; |
|
312 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
313 | + |
|
314 | + // change the list table we're going to use so it's the NEW list table! |
|
315 | + $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
316 | + |
|
317 | + |
|
318 | + // additional labels |
|
319 | + $new_labels = [ |
|
320 | + 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
321 | + 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
322 | + 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
323 | + 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
324 | + 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
325 | + ]; |
|
326 | + $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * @return void |
|
332 | + */ |
|
333 | + protected function _ajax_hooks() |
|
334 | + { |
|
335 | + if (! $this->capabilities->current_user_can('ee_edit_question_groups', 'edit-questions')) { |
|
336 | + return; |
|
337 | + } |
|
338 | + add_action('wp_ajax_espresso_update_question_group_order', [$this, 'update_question_group_order']); |
|
339 | + } |
|
340 | + |
|
341 | + |
|
342 | + /** |
|
343 | + * @return void |
|
344 | + */ |
|
345 | + public function load_scripts_styles_question_groups() |
|
346 | + { |
|
347 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + /** |
|
352 | + * @return void |
|
353 | + */ |
|
354 | + public function load_scripts_styles_add_question_group() |
|
355 | + { |
|
356 | + $this->load_scripts_styles_forms(); |
|
357 | + $this->load_sortable_question_script(); |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * @return void |
|
363 | + */ |
|
364 | + public function load_scripts_styles_edit_question_group() |
|
365 | + { |
|
366 | + $this->load_scripts_styles_forms(); |
|
367 | + $this->load_sortable_question_script(); |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * registers and enqueues script for questions |
|
373 | + * |
|
374 | + * @return void |
|
375 | + */ |
|
376 | + public function load_sortable_question_script() |
|
377 | + { |
|
378 | + wp_register_script( |
|
379 | + 'ee-question-sortable', |
|
380 | + REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
381 | + ['jquery-ui-sortable'], |
|
382 | + EVENT_ESPRESSO_VERSION, |
|
383 | + true |
|
384 | + ); |
|
385 | + wp_enqueue_script('ee-question-sortable'); |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * @return void |
|
391 | + */ |
|
392 | + protected function _set_list_table_views_default() |
|
393 | + { |
|
394 | + $this->_views = [ |
|
395 | + 'all' => [ |
|
396 | + 'slug' => 'all', |
|
397 | + 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
398 | + 'count' => 0, |
|
399 | + 'bulk_action' => [ |
|
400 | + 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
401 | + ], |
|
402 | + ], |
|
403 | + ]; |
|
404 | + |
|
405 | + if ( |
|
406 | + EE_Registry::instance()->CAP->current_user_can( |
|
407 | + 'ee_delete_questions', |
|
408 | + 'espresso_registration_form_trash_questions' |
|
409 | + ) |
|
410 | + ) { |
|
411 | + $this->_views['trash'] = [ |
|
412 | + 'slug' => 'trash', |
|
413 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
414 | + 'count' => 0, |
|
415 | + 'bulk_action' => [ |
|
416 | + 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
417 | + 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
418 | + ], |
|
419 | + ]; |
|
420 | + } |
|
421 | + } |
|
422 | + |
|
423 | + |
|
424 | + /** |
|
425 | + * @return void |
|
426 | + */ |
|
427 | + protected function _set_list_table_views_question_groups() |
|
428 | + { |
|
429 | + $this->_views = [ |
|
430 | + 'all' => [ |
|
431 | + 'slug' => 'all', |
|
432 | + 'label' => esc_html__('All', 'event_espresso'), |
|
433 | + 'count' => 0, |
|
434 | + 'bulk_action' => [ |
|
435 | + 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
436 | + ], |
|
437 | + ], |
|
438 | + ]; |
|
439 | + |
|
440 | + if ( |
|
441 | + EE_Registry::instance()->CAP->current_user_can( |
|
442 | + 'ee_delete_question_groups', |
|
443 | + 'espresso_registration_form_trash_question_groups' |
|
444 | + ) |
|
445 | + ) { |
|
446 | + $this->_views['trash'] = [ |
|
447 | + 'slug' => 'trash', |
|
448 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
449 | + 'count' => 0, |
|
450 | + 'bulk_action' => [ |
|
451 | + 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
452 | + 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
453 | + ], |
|
454 | + ]; |
|
455 | + } |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + /** |
|
460 | + * @return void |
|
461 | + * @throws EE_Error |
|
462 | + * @throws InvalidArgumentException |
|
463 | + * @throws InvalidDataTypeException |
|
464 | + * @throws InvalidInterfaceException |
|
465 | + */ |
|
466 | + protected function _questions_overview_list_table() |
|
467 | + { |
|
468 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
469 | + 'add_question', |
|
470 | + 'add_question', |
|
471 | + [], |
|
472 | + 'add-new-h2' |
|
473 | + ); |
|
474 | + parent::_questions_overview_list_table(); |
|
475 | + } |
|
476 | + |
|
477 | + |
|
478 | + /** |
|
479 | + * @return void |
|
480 | + * @throws DomainException |
|
481 | + * @throws EE_Error |
|
482 | + * @throws InvalidArgumentException |
|
483 | + * @throws InvalidDataTypeException |
|
484 | + * @throws InvalidInterfaceException |
|
485 | + */ |
|
486 | + protected function _question_groups_overview_list_table() |
|
487 | + { |
|
488 | + $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
489 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
490 | + 'add_question_group', |
|
491 | + 'add_question_group', |
|
492 | + [], |
|
493 | + 'add-new-h2' |
|
494 | + ); |
|
495 | + $this->display_admin_list_table_page_with_sidebar(); |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + /** |
|
500 | + * @return void |
|
501 | + * @throws EE_Error |
|
502 | + * @throws InvalidArgumentException |
|
503 | + * @throws InvalidDataTypeException |
|
504 | + * @throws InvalidInterfaceException |
|
505 | + * @throws ReflectionException |
|
506 | + */ |
|
507 | + protected function _delete_question() |
|
508 | + { |
|
509 | + $success = $this->_delete_items($this->_question_model); |
|
510 | + $this->_redirect_after_action( |
|
511 | + $success, |
|
512 | + $this->_question_model->item_name($success), |
|
513 | + 'deleted', |
|
514 | + ['action' => 'default', 'status' => 'all'] |
|
515 | + ); |
|
516 | + } |
|
517 | + |
|
518 | + |
|
519 | + /** |
|
520 | + * @return void |
|
521 | + * @throws EE_Error |
|
522 | + * @throws InvalidArgumentException |
|
523 | + * @throws InvalidDataTypeException |
|
524 | + * @throws InvalidInterfaceException |
|
525 | + * @throws ReflectionException |
|
526 | + */ |
|
527 | + protected function _delete_questions() |
|
528 | + { |
|
529 | + $success = $this->_delete_items($this->_question_model); |
|
530 | + $this->_redirect_after_action( |
|
531 | + $success, |
|
532 | + $this->_question_model->item_name($success), |
|
533 | + 'deleted permanently', |
|
534 | + ['action' => 'default', 'status' => 'trash'] |
|
535 | + ); |
|
536 | + } |
|
537 | + |
|
538 | + |
|
539 | + /** |
|
540 | + * Performs the deletion of a single or multiple questions or question groups. |
|
541 | + * |
|
542 | + * @param EEM_Soft_Delete_Base $model |
|
543 | + * @return int number of items deleted permanently |
|
544 | + * @throws EE_Error |
|
545 | + * @throws InvalidArgumentException |
|
546 | + * @throws InvalidDataTypeException |
|
547 | + * @throws InvalidInterfaceException |
|
548 | + * @throws ReflectionException |
|
549 | + */ |
|
550 | + private function _delete_items(EEM_Soft_Delete_Base $model) |
|
551 | + { |
|
552 | + $success = 0; |
|
553 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
554 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
555 | + // if array has more than one element than success message should be plural |
|
556 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
557 | + // cycle thru bulk action checkboxes |
|
558 | + $checkboxes = $this->_req_data['checkbox']; |
|
559 | + foreach (array_keys($checkboxes) as $ID) { |
|
560 | + if (! $this->_delete_item($ID, $model)) { |
|
561 | + $success = 0; |
|
562 | + } |
|
563 | + } |
|
564 | + } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
565 | + $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
566 | + } elseif (! empty($this->_req_data['QST_ID'])) { |
|
567 | + $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
568 | + } else { |
|
569 | + EE_Error::add_error( |
|
570 | + sprintf( |
|
571 | + esc_html__( |
|
572 | + "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.", |
|
573 | + "event_espresso" |
|
574 | + ) |
|
575 | + ), |
|
576 | + __FILE__, |
|
577 | + __FUNCTION__, |
|
578 | + __LINE__ |
|
579 | + ); |
|
580 | + } |
|
581 | + return $success; |
|
582 | + } |
|
583 | + |
|
584 | + |
|
585 | + /** |
|
586 | + * Deletes the specified question (and its associated question options) or question group |
|
587 | + * |
|
588 | + * @param int $id |
|
589 | + * @param EEM_Soft_Delete_Base $model |
|
590 | + * @return boolean |
|
591 | + * @throws EE_Error |
|
592 | + * @throws InvalidArgumentException |
|
593 | + * @throws InvalidDataTypeException |
|
594 | + * @throws InvalidInterfaceException |
|
595 | + * @throws ReflectionException |
|
596 | + */ |
|
597 | + protected function _delete_item($id, $model) |
|
598 | + { |
|
599 | + if ($model instanceof EEM_Question) { |
|
600 | + EEM_Question_Option::instance()->delete_permanently([['QST_ID' => absint($id)]]); |
|
601 | + } |
|
602 | + return $model->delete_permanently_by_ID(absint($id)); |
|
603 | + } |
|
604 | + |
|
605 | + |
|
606 | + /****************************** QUESTION GROUPS ******************************/ |
|
607 | + |
|
608 | + |
|
609 | + /** |
|
610 | + * @param string $type |
|
611 | + * @return void |
|
612 | + * @throws DomainException |
|
613 | + * @throws EE_Error |
|
614 | + * @throws InvalidArgumentException |
|
615 | + * @throws InvalidDataTypeException |
|
616 | + * @throws InvalidInterfaceException |
|
617 | + * @throws ReflectionException |
|
618 | + */ |
|
619 | + protected function _edit_question_group($type = 'add') |
|
620 | + { |
|
621 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
622 | + $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) |
|
623 | + ? absint($this->_req_data['QSG_ID']) |
|
624 | + : false; |
|
625 | + |
|
626 | + switch ($this->_req_action) { |
|
627 | + case 'add_question_group': |
|
628 | + $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
629 | + break; |
|
630 | + case 'edit_question_group': |
|
631 | + $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
632 | + break; |
|
633 | + default: |
|
634 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
635 | + } |
|
636 | + // add ID to title if editing |
|
637 | + $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
638 | + if ($ID) { |
|
639 | + /** @var EE_Question_Group $questionGroup */ |
|
640 | + $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
641 | + $additional_hidden_fields = ['QSG_ID' => ['type' => 'hidden', 'value' => $ID]]; |
|
642 | + $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
643 | + } else { |
|
644 | + /** @var EE_Question_Group $questionGroup */ |
|
645 | + $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
646 | + $questionGroup->set_order_to_latest(); |
|
647 | + $this->_set_add_edit_form_tags('insert_question_group'); |
|
648 | + } |
|
649 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
650 | + $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
651 | + $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
652 | + $this->_template_args['question_group'] = $questionGroup; |
|
653 | + |
|
654 | + $redirect_URL = add_query_arg(['action' => 'question_groups'], $this->_admin_base_url); |
|
655 | + $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL, true); |
|
656 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
657 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
658 | + $this->_template_args, |
|
659 | + true |
|
660 | + ); |
|
661 | + |
|
662 | + // the details template wrapper |
|
663 | + $this->display_admin_page_with_sidebar(); |
|
664 | + } |
|
665 | + |
|
666 | + |
|
667 | + /** |
|
668 | + * @return void |
|
669 | + * @throws EE_Error |
|
670 | + * @throws InvalidArgumentException |
|
671 | + * @throws InvalidDataTypeException |
|
672 | + * @throws InvalidInterfaceException |
|
673 | + * @throws ReflectionException |
|
674 | + */ |
|
675 | + protected function _delete_question_groups() |
|
676 | + { |
|
677 | + $success = $this->_delete_items($this->_question_group_model); |
|
678 | + $this->_redirect_after_action( |
|
679 | + $success, |
|
680 | + $this->_question_group_model->item_name($success), |
|
681 | + 'deleted permanently', |
|
682 | + ['action' => 'question_groups', 'status' => 'trash'] |
|
683 | + ); |
|
684 | + } |
|
685 | + |
|
686 | + |
|
687 | + /** |
|
688 | + * @param bool $new_question_group |
|
689 | + * @throws EE_Error |
|
690 | + * @throws InvalidArgumentException |
|
691 | + * @throws InvalidDataTypeException |
|
692 | + * @throws InvalidInterfaceException |
|
693 | + * @throws ReflectionException |
|
694 | + */ |
|
695 | + protected function _insert_or_update_question_group($new_question_group = true) |
|
696 | + { |
|
697 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
698 | + $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
699 | + |
|
700 | + // make sure identifier is unique |
|
701 | + $identifier_value = $set_column_values['QSG_identifier'] ?? ''; |
|
702 | + $where_values = ['QSG_identifier' => $identifier_value]; |
|
703 | + if (! $new_question_group && isset($set_column_values['QSG_ID'])) { |
|
704 | + $where_values['QSG_ID'] = ['!=', $set_column_values['QSG_ID']]; |
|
705 | + } |
|
706 | + $identifier_exists = ! empty($identifier_value) && $this->_question_group_model->count([$where_values]) > 0; |
|
707 | + if ($identifier_exists) { |
|
708 | + $set_column_values['QSG_identifier'] .= uniqid('id', true); |
|
709 | + } |
|
710 | + |
|
711 | + if ($new_question_group) { |
|
712 | + $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
713 | + $success = $QSG_ID ? 1 : 0; |
|
714 | + if ($success === 0) { |
|
715 | + EE_Error::add_error( |
|
716 | + esc_html__('Something went wrong saving the question group.', 'event_espresso'), |
|
717 | + __FILE__, |
|
718 | + __FUNCTION__, |
|
719 | + __LINE__ |
|
720 | + ); |
|
721 | + $this->_redirect_after_action( |
|
722 | + false, |
|
723 | + '', |
|
724 | + '', |
|
725 | + ['action' => 'edit_question_group', 'QSG_ID' => $QSG_ID], |
|
726 | + true |
|
727 | + ); |
|
728 | + } |
|
729 | + } else { |
|
730 | + $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
731 | + unset($set_column_values['QSG_ID']); |
|
732 | + $success = $this->_question_group_model->update($set_column_values, [['QSG_ID' => $QSG_ID]]); |
|
733 | + } |
|
734 | + |
|
735 | + $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( |
|
736 | + EEM_Attendee::system_question_phone |
|
737 | + ); |
|
738 | + // update the existing related questions |
|
739 | + // BUT FIRST... delete the phone question from the Question_Group_Question |
|
740 | + // if it is being added to this question group (therefore removed from the existing group) |
|
741 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
742 | + // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
743 | + EEM_Question_Group_Question::instance()->delete( |
|
744 | + [ |
|
745 | + [ |
|
746 | + 'QST_ID' => $phone_question_id, |
|
747 | + 'QSG_ID' => ['!=', $QSG_ID], |
|
748 | + ], |
|
749 | + ] |
|
750 | + ); |
|
751 | + } |
|
752 | + /** @type EE_Question_Group $question_group */ |
|
753 | + $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
754 | + $questions = $question_group->questions(); |
|
755 | + // make sure system phone question is added to list of questions for this group |
|
756 | + if (! isset($questions[ $phone_question_id ])) { |
|
757 | + $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
758 | + } |
|
759 | + |
|
760 | + foreach ($questions as $question_ID => $question) { |
|
761 | + // first we always check for order. |
|
762 | + if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
763 | + // update question order |
|
764 | + $question_group->update_question_order( |
|
765 | + $question_ID, |
|
766 | + $this->_req_data['question_orders'][ $question_ID ] |
|
767 | + ); |
|
768 | + } |
|
769 | + |
|
770 | + // then we always check if adding or removing. |
|
771 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
772 | + $question_group->add_question($question_ID); |
|
773 | + } else { |
|
774 | + // not found, remove it (but only if not a system question for the personal group |
|
775 | + // with the exception of lname system question - we allow removal of it) |
|
776 | + if ( |
|
777 | + in_array( |
|
778 | + $question->system_ID(), |
|
779 | + EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
780 | + $question_group->system_group() |
|
781 | + ) |
|
782 | + ) |
|
783 | + ) { |
|
784 | + continue; |
|
785 | + } else { |
|
786 | + $question_group->remove_question($question_ID); |
|
787 | + } |
|
788 | + } |
|
789 | + } |
|
790 | + // save new related questions |
|
791 | + if (isset($this->_req_data['questions'])) { |
|
792 | + foreach ($this->_req_data['questions'] as $QST_ID) { |
|
793 | + $question_group->add_question($QST_ID); |
|
794 | + if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
795 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
796 | + } |
|
797 | + } |
|
798 | + } |
|
799 | + |
|
800 | + if ($success !== false) { |
|
801 | + $msg = $new_question_group |
|
802 | + ? sprintf( |
|
803 | + esc_html__('The %s has been created', 'event_espresso'), |
|
804 | + $this->_question_group_model->item_name() |
|
805 | + ) |
|
806 | + : sprintf( |
|
807 | + esc_html__( |
|
808 | + 'The %s has been updated', |
|
809 | + 'event_espresso' |
|
810 | + ), |
|
811 | + $this->_question_group_model->item_name() |
|
812 | + ); |
|
813 | + EE_Error::add_success($msg); |
|
814 | + } |
|
815 | + $this->_redirect_after_action( |
|
816 | + false, |
|
817 | + '', |
|
818 | + '', |
|
819 | + ['action' => 'edit_question_group', 'QSG_ID' => $QSG_ID], |
|
820 | + true |
|
821 | + ); |
|
822 | + } |
|
823 | + |
|
824 | + |
|
825 | + /** |
|
826 | + * duplicates a question and all its question options and redirects to the new question. |
|
827 | + * |
|
828 | + * @return void |
|
829 | + * @throws EE_Error |
|
830 | + * @throws InvalidArgumentException |
|
831 | + * @throws ReflectionException |
|
832 | + * @throws InvalidDataTypeException |
|
833 | + * @throws InvalidInterfaceException |
|
834 | + */ |
|
835 | + public function _duplicate_question() |
|
836 | + { |
|
837 | + $question_ID = (int) $this->_req_data['QST_ID']; |
|
838 | + $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
839 | + if ($question instanceof EE_Question) { |
|
840 | + $new_question = $question->duplicate(); |
|
841 | + if ($new_question instanceof EE_Question) { |
|
842 | + $this->_redirect_after_action( |
|
843 | + true, |
|
844 | + esc_html__('Question', 'event_espresso'), |
|
845 | + esc_html__('Duplicated', 'event_espresso'), |
|
846 | + ['action' => 'edit_question', 'QST_ID' => $new_question->ID()], |
|
847 | + true |
|
848 | + ); |
|
849 | + } else { |
|
850 | + global $wpdb; |
|
851 | + EE_Error::add_error( |
|
852 | + sprintf( |
|
853 | + esc_html__( |
|
854 | + 'Could not duplicate question with ID %1$d because: %2$s', |
|
855 | + 'event_espresso' |
|
856 | + ), |
|
857 | + $question_ID, |
|
858 | + $wpdb->last_error |
|
859 | + ), |
|
860 | + __FILE__, |
|
861 | + __FUNCTION__, |
|
862 | + __LINE__ |
|
863 | + ); |
|
864 | + $this->_redirect_after_action(false, '', '', ['action' => 'default'], false); |
|
865 | + } |
|
866 | + } else { |
|
867 | + EE_Error::add_error( |
|
868 | + sprintf( |
|
869 | + esc_html__( |
|
870 | + 'Could not duplicate question with ID %d because it didn\'t exist!', |
|
871 | + 'event_espresso' |
|
872 | + ), |
|
873 | + $question_ID |
|
874 | + ), |
|
875 | + __FILE__, |
|
876 | + __FUNCTION__, |
|
877 | + __LINE__ |
|
878 | + ); |
|
879 | + $this->_redirect_after_action(false, '', '', ['action' => 'default'], false); |
|
880 | + } |
|
881 | + } |
|
882 | + |
|
883 | + |
|
884 | + /** |
|
885 | + * @param bool $trash |
|
886 | + * @throws EE_Error |
|
887 | + */ |
|
888 | + protected function _trash_or_restore_question_groups($trash = true) |
|
889 | + { |
|
890 | + $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
891 | + } |
|
892 | + |
|
893 | + |
|
894 | + /** |
|
895 | + *_trash_question |
|
896 | + * |
|
897 | + * @return void |
|
898 | + * @throws EE_Error |
|
899 | + */ |
|
900 | + protected function _trash_question() |
|
901 | + { |
|
902 | + $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
903 | + $query_args = ['action' => 'default', 'status' => 'all']; |
|
904 | + $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
905 | + } |
|
906 | + |
|
907 | + |
|
908 | + /** |
|
909 | + * @param bool $trash |
|
910 | + * @throws EE_Error |
|
911 | + */ |
|
912 | + protected function _trash_or_restore_questions($trash = true) |
|
913 | + { |
|
914 | + $this->_trash_or_restore_items($this->_question_model, $trash); |
|
915 | + } |
|
916 | + |
|
917 | + |
|
918 | + /** |
|
919 | + * Internally used to delete or restore items, using the request data. Meant to be |
|
920 | + * flexible between question or question groups |
|
921 | + * |
|
922 | + * @param EEM_Soft_Delete_Base $model |
|
923 | + * @param boolean $trash whether to trash or restore |
|
924 | + * @throws EE_Error |
|
925 | + */ |
|
926 | + private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
927 | + { |
|
928 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
929 | + |
|
930 | + $success = 1; |
|
931 | + // Checkboxes |
|
932 | + // echo "trash $trash"; |
|
933 | + // var_dump($this->_req_data['checkbox']);die; |
|
934 | + if (isset($this->_req_data['checkbox'])) { |
|
935 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
936 | + // if array has more than one element than success message should be plural |
|
937 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
938 | + // cycle thru bulk action checkboxes |
|
939 | + $checkboxes = $this->_req_data['checkbox']; |
|
940 | + foreach (array_keys($checkboxes) as $ID) { |
|
941 | + if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
942 | + $success = 0; |
|
943 | + } |
|
944 | + } |
|
945 | + } else { |
|
946 | + // grab single id and delete |
|
947 | + $ID = absint($this->_req_data['checkbox']); |
|
948 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
949 | + $success = 0; |
|
950 | + } |
|
951 | + } |
|
952 | + } else { |
|
953 | + // delete via trash link |
|
954 | + // grab single id and delete |
|
955 | + $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
956 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
957 | + $success = 0; |
|
958 | + } |
|
959 | + } |
|
960 | + |
|
961 | + |
|
962 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
963 | + // echo "action :$action"; |
|
964 | + // $action = 'questions' ? 'default' : $action; |
|
965 | + if ($trash) { |
|
966 | + $action_desc = 'trashed'; |
|
967 | + $status = 'trash'; |
|
968 | + } else { |
|
969 | + $action_desc = 'restored'; |
|
970 | + $status = 'all'; |
|
971 | + } |
|
972 | + $this->_redirect_after_action( |
|
973 | + $success, |
|
974 | + $model->item_name($success), |
|
975 | + $action_desc, |
|
976 | + ['action' => $action, 'status' => $status] |
|
977 | + ); |
|
978 | + } |
|
979 | + |
|
980 | + |
|
981 | + /** |
|
982 | + * @param $per_page |
|
983 | + * @param int $current_page |
|
984 | + * @param bool|false $count |
|
985 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
986 | + * @throws EE_Error |
|
987 | + * @throws InvalidArgumentException |
|
988 | + * @throws InvalidDataTypeException |
|
989 | + * @throws InvalidInterfaceException |
|
990 | + * @throws ReflectionException |
|
991 | + */ |
|
992 | + public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
993 | + { |
|
994 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
995 | + |
|
996 | + if ($count) { |
|
997 | + // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
998 | + $where = isset($query_params[0]) ? [$query_params[0]] : []; |
|
999 | + $results = $this->_question_model->count_deleted($where); |
|
1000 | + } else { |
|
1001 | + // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
1002 | + $results = $this->_question_model->get_all_deleted($query_params); |
|
1003 | + } |
|
1004 | + return $results; |
|
1005 | + } |
|
1006 | + |
|
1007 | + |
|
1008 | + /** |
|
1009 | + * @param $per_page |
|
1010 | + * @param int $current_page |
|
1011 | + * @param bool|false $count |
|
1012 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
1013 | + * @throws EE_Error |
|
1014 | + * @throws InvalidArgumentException |
|
1015 | + * @throws InvalidDataTypeException |
|
1016 | + * @throws InvalidInterfaceException |
|
1017 | + * @throws ReflectionException |
|
1018 | + */ |
|
1019 | + public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
1020 | + { |
|
1021 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
1022 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1023 | + if ($count) { |
|
1024 | + $where = isset($query_params[0]) ? [$query_params[0]] : []; |
|
1025 | + $results = $questionGroupModel->count($where); |
|
1026 | + } else { |
|
1027 | + $results = $questionGroupModel->get_all($query_params); |
|
1028 | + } |
|
1029 | + return $results; |
|
1030 | + } |
|
1031 | + |
|
1032 | + |
|
1033 | + /** |
|
1034 | + * @param $per_page |
|
1035 | + * @param int $current_page |
|
1036 | + * @param bool $count |
|
1037 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
1038 | + * @throws EE_Error |
|
1039 | + * @throws InvalidArgumentException |
|
1040 | + * @throws InvalidDataTypeException |
|
1041 | + * @throws InvalidInterfaceException |
|
1042 | + * @throws ReflectionException |
|
1043 | + */ |
|
1044 | + public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
1045 | + { |
|
1046 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
1047 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1048 | + if ($count) { |
|
1049 | + $where = isset($query_params[0]) ? [$query_params[0]] : []; |
|
1050 | + $query_params['limit'] = null; |
|
1051 | + $results = $questionGroupModel->count_deleted($where); |
|
1052 | + } else { |
|
1053 | + $results = $questionGroupModel->get_all_deleted($query_params); |
|
1054 | + } |
|
1055 | + return $results; |
|
1056 | + } |
|
1057 | + |
|
1058 | + |
|
1059 | + /** |
|
1060 | + * method for performing updates to question order |
|
1061 | + * |
|
1062 | + * @return void results array |
|
1063 | + * @throws EE_Error |
|
1064 | + * @throws InvalidArgumentException |
|
1065 | + * @throws InvalidDataTypeException |
|
1066 | + * @throws InvalidInterfaceException |
|
1067 | + * @throws ReflectionException |
|
1068 | + */ |
|
1069 | + public function update_question_group_order() |
|
1070 | + { |
|
1071 | + if (! $this->capabilities->current_user_can('ee_edit_question_groups', __FUNCTION__)) { |
|
1072 | + wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
1073 | + } |
|
1074 | + $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
1075 | + |
|
1076 | + // grab our row IDs |
|
1077 | + $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
1078 | + ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
1079 | + : []; |
|
1080 | + |
|
1081 | + $perpage = ! empty($this->_req_data['perpage']) |
|
1082 | + ? (int) $this->_req_data['perpage'] |
|
1083 | + : null; |
|
1084 | + $curpage = ! empty($this->_req_data['curpage']) |
|
1085 | + ? (int) $this->_req_data['curpage'] |
|
1086 | + : null; |
|
1087 | + |
|
1088 | + if (! empty($row_ids)) { |
|
1089 | + // figure out where we start the row_id count at for the current page. |
|
1090 | + $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
1091 | + |
|
1092 | + $row_count = count($row_ids); |
|
1093 | + for ($i = 0; $i < $row_count; $i++) { |
|
1094 | + // Update the questions when re-ordering |
|
1095 | + $updated = EEM_Question_Group::instance()->update( |
|
1096 | + ['QSG_order' => $qsgcount], |
|
1097 | + [['QSG_ID' => $row_ids[ $i ]]] |
|
1098 | + ); |
|
1099 | + if ($updated === false) { |
|
1100 | + $success = false; |
|
1101 | + } |
|
1102 | + $qsgcount++; |
|
1103 | + } |
|
1104 | + } else { |
|
1105 | + $success = false; |
|
1106 | + } |
|
1107 | + |
|
1108 | + $errors = ! $success |
|
1109 | + ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
1110 | + : false; |
|
1111 | + |
|
1112 | + echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]); |
|
1113 | + die(); |
|
1114 | + } |
|
1115 | + |
|
1116 | + |
|
1117 | + |
|
1118 | + /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
1119 | + |
|
1120 | + |
|
1121 | + /** |
|
1122 | + * @throws DomainException |
|
1123 | + * @throws EE_Error |
|
1124 | + * @throws InvalidArgumentException |
|
1125 | + * @throws InvalidDataTypeException |
|
1126 | + * @throws InvalidInterfaceException |
|
1127 | + */ |
|
1128 | + protected function _reg_form_settings() |
|
1129 | + { |
|
1130 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
1131 | + add_action( |
|
1132 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1133 | + [$this, 'email_validation_settings_form'], |
|
1134 | + 2 |
|
1135 | + ); |
|
1136 | + add_action( |
|
1137 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1138 | + [$this, 'copy_attendee_info_settings_form'], |
|
1139 | + 4 |
|
1140 | + ); |
|
1141 | + add_action( |
|
1142 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1143 | + [$this, 'setSessionLifespan'], |
|
1144 | + 5 |
|
1145 | + ); |
|
1146 | + $this->_template_args = (array) apply_filters( |
|
1147 | + 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
1148 | + $this->_template_args |
|
1149 | + ); |
|
1150 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
1151 | + $this->_set_publish_post_box_vars(); |
|
1152 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1153 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1154 | + $this->_template_args, |
|
1155 | + true |
|
1156 | + ); |
|
1157 | + $this->display_admin_page_with_sidebar(); |
|
1158 | + } |
|
1159 | + |
|
1160 | + |
|
1161 | + /** |
|
1162 | + * @return void |
|
1163 | + * @throws EE_Error |
|
1164 | + * @throws InvalidArgumentException |
|
1165 | + * @throws ReflectionException |
|
1166 | + * @throws InvalidDataTypeException |
|
1167 | + * @throws InvalidInterfaceException |
|
1168 | + */ |
|
1169 | + protected function _update_reg_form_settings() |
|
1170 | + { |
|
1171 | + EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
1172 | + EE_Registry::instance()->CFG->registration |
|
1173 | + ); |
|
1174 | + EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form( |
|
1175 | + EE_Registry::instance()->CFG->registration |
|
1176 | + ); |
|
1177 | + $this->updateSessionLifespan(); |
|
1178 | + EE_Registry::instance()->CFG->registration = apply_filters( |
|
1179 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
1180 | + EE_Registry::instance()->CFG->registration |
|
1181 | + ); |
|
1182 | + $success = $this->_update_espresso_configuration( |
|
1183 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1184 | + EE_Registry::instance()->CFG, |
|
1185 | + __FILE__, |
|
1186 | + __FUNCTION__, |
|
1187 | + __LINE__ |
|
1188 | + ); |
|
1189 | + $this->_redirect_after_action( |
|
1190 | + $success, |
|
1191 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1192 | + 'updated', |
|
1193 | + ['action' => 'view_reg_form_settings'] |
|
1194 | + ); |
|
1195 | + } |
|
1196 | + |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * @return void |
|
1200 | + * @throws EE_Error |
|
1201 | + * @throws InvalidArgumentException |
|
1202 | + * @throws InvalidDataTypeException |
|
1203 | + * @throws InvalidInterfaceException |
|
1204 | + */ |
|
1205 | + public function copy_attendee_info_settings_form() |
|
1206 | + { |
|
1207 | + echo wp_kses($this->_copy_attendee_info_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1208 | + } |
|
1209 | + |
|
1210 | + |
|
1211 | + /** |
|
1212 | + * _copy_attendee_info_settings_form |
|
1213 | + * |
|
1214 | + * @access protected |
|
1215 | + * @return EE_Form_Section_Proper |
|
1216 | + * @throws \EE_Error |
|
1217 | + */ |
|
1218 | + protected function _copy_attendee_info_settings_form() |
|
1219 | + { |
|
1220 | + return new EE_Form_Section_Proper( |
|
1221 | + [ |
|
1222 | + 'name' => 'copy_attendee_info_settings', |
|
1223 | + 'html_id' => 'copy_attendee_info_settings', |
|
1224 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1225 | + 'subsections' => apply_filters( |
|
1226 | + 'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections', |
|
1227 | + [ |
|
1228 | + 'copy_attendee_info_hdr' => new EE_Form_Section_HTML( |
|
1229 | + EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso')) |
|
1230 | + ), |
|
1231 | + 'copy_attendee_info' => new EE_Yes_No_Input( |
|
1232 | + [ |
|
1233 | + 'html_label_text' => esc_html__( |
|
1234 | + 'Allow copy #1 attendee info to extra attendees?', |
|
1235 | + 'event_espresso' |
|
1236 | + ), |
|
1237 | + 'html_help_text' => esc_html__( |
|
1238 | + 'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.', |
|
1239 | + 'event_espresso' |
|
1240 | + ), |
|
1241 | + 'default' => EE_Registry::instance( |
|
1242 | + )->CFG->registration->copyAttendeeInfo(), |
|
1243 | + 'required' => false, |
|
1244 | + 'display_html_label_text' => false, |
|
1245 | + ] |
|
1246 | + ), |
|
1247 | + ] |
|
1248 | + ), |
|
1249 | + ] |
|
1250 | + ); |
|
1251 | + } |
|
1252 | + |
|
1253 | + |
|
1254 | + /** |
|
1255 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1256 | + * @return EE_Registration_Config |
|
1257 | + * @throws EE_Error |
|
1258 | + * @throws InvalidArgumentException |
|
1259 | + * @throws ReflectionException |
|
1260 | + * @throws InvalidDataTypeException |
|
1261 | + * @throws InvalidInterfaceException |
|
1262 | + */ |
|
1263 | + public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1264 | + { |
|
1265 | + $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo(); |
|
1266 | + try { |
|
1267 | + $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form(); |
|
1268 | + // if not displaying a form, then check for form submission |
|
1269 | + if ($copy_attendee_info_settings_form->was_submitted()) { |
|
1270 | + // capture form data |
|
1271 | + $copy_attendee_info_settings_form->receive_form_submission(); |
|
1272 | + // validate form data |
|
1273 | + if ($copy_attendee_info_settings_form->is_valid()) { |
|
1274 | + // grab validated data from form |
|
1275 | + $valid_data = $copy_attendee_info_settings_form->valid_data(); |
|
1276 | + if (isset($valid_data['copy_attendee_info'])) { |
|
1277 | + $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']); |
|
1278 | + } else { |
|
1279 | + EE_Error::add_error( |
|
1280 | + esc_html__( |
|
1281 | + 'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.', |
|
1282 | + 'event_espresso' |
|
1283 | + ), |
|
1284 | + __FILE__, |
|
1285 | + __FUNCTION__, |
|
1286 | + __LINE__ |
|
1287 | + ); |
|
1288 | + } |
|
1289 | + } elseif ($copy_attendee_info_settings_form->submission_error_message() !== '') { |
|
1290 | + EE_Error::add_error( |
|
1291 | + $copy_attendee_info_settings_form->submission_error_message(), |
|
1292 | + __FILE__, |
|
1293 | + __FUNCTION__, |
|
1294 | + __LINE__ |
|
1295 | + ); |
|
1296 | + } |
|
1297 | + } |
|
1298 | + } catch (EE_Error $e) { |
|
1299 | + $e->get_error(); |
|
1300 | + } |
|
1301 | + return $EE_Registration_Config; |
|
1302 | + } |
|
1303 | + |
|
1304 | + |
|
1305 | + /** |
|
1306 | + * @return void |
|
1307 | + * @throws EE_Error |
|
1308 | + * @throws InvalidArgumentException |
|
1309 | + * @throws InvalidDataTypeException |
|
1310 | + * @throws InvalidInterfaceException |
|
1311 | + */ |
|
1312 | + public function email_validation_settings_form() |
|
1313 | + { |
|
1314 | + echo wp_kses($this->_email_validation_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1315 | + } |
|
1316 | + |
|
1317 | + |
|
1318 | + /** |
|
1319 | + * _email_validation_settings_form |
|
1320 | + * |
|
1321 | + * @access protected |
|
1322 | + * @return EE_Form_Section_Proper |
|
1323 | + * @throws \EE_Error |
|
1324 | + */ |
|
1325 | + protected function _email_validation_settings_form() |
|
1326 | + { |
|
1327 | + return new EE_Form_Section_Proper( |
|
1328 | + [ |
|
1329 | + 'name' => 'email_validation_settings', |
|
1330 | + 'html_id' => 'email_validation_settings', |
|
1331 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1332 | + 'subsections' => apply_filters( |
|
1333 | + 'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections', |
|
1334 | + [ |
|
1335 | + 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
1336 | + EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
1337 | + ), |
|
1338 | + 'email_validation_level' => new EE_Select_Input( |
|
1339 | + [ |
|
1340 | + 'basic' => esc_html__('Basic', 'event_espresso'), |
|
1341 | + 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
1342 | + 'i18n' => esc_html__('International', 'event_espresso'), |
|
1343 | + 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
1344 | + ], |
|
1345 | + [ |
|
1346 | + 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
1347 | + . EEH_Template::get_help_tab_link('email_validation_info'), |
|
1348 | + 'html_help_text' => esc_html__( |
|
1349 | + '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.', |
|
1350 | + 'event_espresso' |
|
1351 | + ), |
|
1352 | + 'default' => isset( |
|
1353 | + EE_Registry::instance()->CFG->registration->email_validation_level |
|
1354 | + ) |
|
1355 | + ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
1356 | + : 'wp_default', |
|
1357 | + 'required' => false, |
|
1358 | + ] |
|
1359 | + ), |
|
1360 | + ] |
|
1361 | + ), |
|
1362 | + ] |
|
1363 | + ); |
|
1364 | + } |
|
1365 | + |
|
1366 | + |
|
1367 | + /** |
|
1368 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1369 | + * @return EE_Registration_Config |
|
1370 | + * @throws EE_Error |
|
1371 | + * @throws InvalidArgumentException |
|
1372 | + * @throws ReflectionException |
|
1373 | + * @throws InvalidDataTypeException |
|
1374 | + * @throws InvalidInterfaceException |
|
1375 | + */ |
|
1376 | + public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1377 | + { |
|
1378 | + $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1379 | + try { |
|
1380 | + $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1381 | + // if not displaying a form, then check for form submission |
|
1382 | + if ($email_validation_settings_form->was_submitted()) { |
|
1383 | + // capture form data |
|
1384 | + $email_validation_settings_form->receive_form_submission(); |
|
1385 | + // validate form data |
|
1386 | + if ($email_validation_settings_form->is_valid()) { |
|
1387 | + // grab validated data from form |
|
1388 | + $valid_data = $email_validation_settings_form->valid_data(); |
|
1389 | + if (isset($valid_data['email_validation_level'])) { |
|
1390 | + $email_validation_level = $valid_data['email_validation_level']; |
|
1391 | + // now if they want to use international email addresses |
|
1392 | + if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1393 | + // in case we need to reset their email validation level, |
|
1394 | + // make sure that the previous value wasn't already set to one of the i18n options. |
|
1395 | + if ( |
|
1396 | + $prev_email_validation_level === 'i18n' |
|
1397 | + || $prev_email_validation_level |
|
1398 | + === 'i18n_dns' |
|
1399 | + ) { |
|
1400 | + // if so, then reset it back to "basic" since that is the only other option that, |
|
1401 | + // despite offering poor validation, supports i18n email addresses |
|
1402 | + $prev_email_validation_level = 'basic'; |
|
1403 | + } |
|
1404 | + // confirm our i18n email validation will work on the server |
|
1405 | + if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1406 | + // or reset email validation level to previous value |
|
1407 | + $email_validation_level = $prev_email_validation_level; |
|
1408 | + } |
|
1409 | + } |
|
1410 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1411 | + } else { |
|
1412 | + EE_Error::add_error( |
|
1413 | + esc_html__( |
|
1414 | + 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1415 | + 'event_espresso' |
|
1416 | + ), |
|
1417 | + __FILE__, |
|
1418 | + __FUNCTION__, |
|
1419 | + __LINE__ |
|
1420 | + ); |
|
1421 | + } |
|
1422 | + } elseif ($email_validation_settings_form->submission_error_message() !== '') { |
|
1423 | + EE_Error::add_error( |
|
1424 | + $email_validation_settings_form->submission_error_message(), |
|
1425 | + __FILE__, |
|
1426 | + __FUNCTION__, |
|
1427 | + __LINE__ |
|
1428 | + ); |
|
1429 | + } |
|
1430 | + } |
|
1431 | + } catch (EE_Error $e) { |
|
1432 | + $e->get_error(); |
|
1433 | + } |
|
1434 | + return $EE_Registration_Config; |
|
1435 | + } |
|
1436 | + |
|
1437 | + |
|
1438 | + /** |
|
1439 | + * confirms that the server's PHP version has the PCRE module enabled, |
|
1440 | + * and that the PCRE version works with our i18n email validation |
|
1441 | + * |
|
1442 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1443 | + * @param string $email_validation_level |
|
1444 | + * @return bool |
|
1445 | + */ |
|
1446 | + private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1447 | + { |
|
1448 | + // first check that PCRE is enabled |
|
1449 | + if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1450 | + EE_Error::add_error( |
|
1451 | + sprintf( |
|
1452 | + esc_html__( |
|
1453 | + '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.', |
|
1454 | + 'event_espresso' |
|
1455 | + ), |
|
1456 | + '<br />' |
|
1457 | + ), |
|
1458 | + __FILE__, |
|
1459 | + __FUNCTION__, |
|
1460 | + __LINE__ |
|
1461 | + ); |
|
1462 | + return false; |
|
1463 | + } else { |
|
1464 | + // PCRE support is enabled, but let's still |
|
1465 | + // perform a test to see if the server will support it. |
|
1466 | + // but first, save the updated validation level to the config, |
|
1467 | + // so that the validation strategy picks it up. |
|
1468 | + // this will get bumped back down if it doesn't work |
|
1469 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1470 | + try { |
|
1471 | + $email_validator = new EE_Email_Validation_Strategy(); |
|
1472 | + $i18n_email_address = apply_filters( |
|
1473 | + 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1474 | + 'jägerjü[email protected]' |
|
1475 | + ); |
|
1476 | + $email_validator->validate($i18n_email_address); |
|
1477 | + } catch (Exception $e) { |
|
1478 | + EE_Error::add_error( |
|
1479 | + sprintf( |
|
1480 | + esc_html__( |
|
1481 | + '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', |
|
1482 | + 'event_espresso' |
|
1483 | + ), |
|
1484 | + '<br />', |
|
1485 | + '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>' |
|
1486 | + ), |
|
1487 | + __FILE__, |
|
1488 | + __FUNCTION__, |
|
1489 | + __LINE__ |
|
1490 | + ); |
|
1491 | + return false; |
|
1492 | + } |
|
1493 | + } |
|
1494 | + return true; |
|
1495 | + } |
|
1496 | + |
|
1497 | + |
|
1498 | + public function setSessionLifespan() |
|
1499 | + { |
|
1500 | + $session_lifespan_form = $this->loader->getNew(SessionLifespanForm::class); |
|
1501 | + echo wp_kses($session_lifespan_form->get_html(), AllowedTags::getWithFormTags()); |
|
1502 | + } |
|
1503 | + |
|
1504 | + |
|
1505 | + public function updateSessionLifespan() |
|
1506 | + { |
|
1507 | + $handler = $this->loader->getNew(SessionLifespanFormHandler::class); |
|
1508 | + $handler->process($this->loader->getNew(SessionLifespanForm::class)); |
|
1509 | + } |
|
1510 | 1510 | } |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct($routing = true) |
25 | 25 | { |
26 | - define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/'); |
|
27 | - define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/'); |
|
28 | - define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
29 | - define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/'); |
|
30 | - define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
26 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form/'); |
|
27 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets/'); |
|
28 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/'); |
|
29 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates/'); |
|
30 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/'); |
|
31 | 31 | parent::__construct($routing); |
32 | 32 | } |
33 | 33 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) |
55 | 55 | ? $this->_req_data['QSG_ID'] : 0; |
56 | 56 | |
57 | - $new_page_routes = [ |
|
57 | + $new_page_routes = [ |
|
58 | 58 | 'question_groups' => [ |
59 | 59 | 'func' => '_question_groups_overview_list_table', |
60 | 60 | 'capability' => 'ee_read_question_groups', |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | |
317 | 317 | |
318 | 318 | // additional labels |
319 | - $new_labels = [ |
|
319 | + $new_labels = [ |
|
320 | 320 | 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
321 | 321 | 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
322 | 322 | 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | */ |
333 | 333 | protected function _ajax_hooks() |
334 | 334 | { |
335 | - if (! $this->capabilities->current_user_can('ee_edit_question_groups', 'edit-questions')) { |
|
335 | + if ( ! $this->capabilities->current_user_can('ee_edit_question_groups', 'edit-questions')) { |
|
336 | 336 | return; |
337 | 337 | } |
338 | 338 | add_action('wp_ajax_espresso_update_question_group_order', [$this, 'update_question_group_order']); |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | { |
378 | 378 | wp_register_script( |
379 | 379 | 'ee-question-sortable', |
380 | - REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
380 | + REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js', |
|
381 | 381 | ['jquery-ui-sortable'], |
382 | 382 | EVENT_ESPRESSO_VERSION, |
383 | 383 | true |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | */ |
466 | 466 | protected function _questions_overview_list_table() |
467 | 467 | { |
468 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
468 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
469 | 469 | 'add_question', |
470 | 470 | 'add_question', |
471 | 471 | [], |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | protected function _question_groups_overview_list_table() |
487 | 487 | { |
488 | 488 | $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
489 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
489 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
490 | 490 | 'add_question_group', |
491 | 491 | 'add_question_group', |
492 | 492 | [], |
@@ -551,19 +551,19 @@ discard block |
||
551 | 551 | { |
552 | 552 | $success = 0; |
553 | 553 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
554 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
554 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
555 | 555 | // if array has more than one element than success message should be plural |
556 | 556 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
557 | 557 | // cycle thru bulk action checkboxes |
558 | 558 | $checkboxes = $this->_req_data['checkbox']; |
559 | 559 | foreach (array_keys($checkboxes) as $ID) { |
560 | - if (! $this->_delete_item($ID, $model)) { |
|
560 | + if ( ! $this->_delete_item($ID, $model)) { |
|
561 | 561 | $success = 0; |
562 | 562 | } |
563 | 563 | } |
564 | - } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
564 | + } elseif ( ! empty($this->_req_data['QSG_ID'])) { |
|
565 | 565 | $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
566 | - } elseif (! empty($this->_req_data['QST_ID'])) { |
|
566 | + } elseif ( ! empty($this->_req_data['QST_ID'])) { |
|
567 | 567 | $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
568 | 568 | } else { |
569 | 569 | EE_Error::add_error( |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
635 | 635 | } |
636 | 636 | // add ID to title if editing |
637 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
637 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
638 | 638 | if ($ID) { |
639 | 639 | /** @var EE_Question_Group $questionGroup */ |
640 | 640 | $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | $redirect_URL = add_query_arg(['action' => 'question_groups'], $this->_admin_base_url); |
655 | 655 | $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL, true); |
656 | 656 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
657 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
657 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php', |
|
658 | 658 | $this->_template_args, |
659 | 659 | true |
660 | 660 | ); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | // make sure identifier is unique |
701 | 701 | $identifier_value = $set_column_values['QSG_identifier'] ?? ''; |
702 | 702 | $where_values = ['QSG_identifier' => $identifier_value]; |
703 | - if (! $new_question_group && isset($set_column_values['QSG_ID'])) { |
|
703 | + if ( ! $new_question_group && isset($set_column_values['QSG_ID'])) { |
|
704 | 704 | $where_values['QSG_ID'] = ['!=', $set_column_values['QSG_ID']]; |
705 | 705 | } |
706 | 706 | $identifier_exists = ! empty($identifier_value) && $this->_question_group_model->count([$where_values]) > 0; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | // update the existing related questions |
739 | 739 | // BUT FIRST... delete the phone question from the Question_Group_Question |
740 | 740 | // if it is being added to this question group (therefore removed from the existing group) |
741 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
741 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) { |
|
742 | 742 | // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
743 | 743 | EEM_Question_Group_Question::instance()->delete( |
744 | 744 | [ |
@@ -753,22 +753,22 @@ discard block |
||
753 | 753 | $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
754 | 754 | $questions = $question_group->questions(); |
755 | 755 | // make sure system phone question is added to list of questions for this group |
756 | - if (! isset($questions[ $phone_question_id ])) { |
|
757 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
756 | + if ( ! isset($questions[$phone_question_id])) { |
|
757 | + $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | foreach ($questions as $question_ID => $question) { |
761 | 761 | // first we always check for order. |
762 | - if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
762 | + if ( ! empty($this->_req_data['question_orders'][$question_ID])) { |
|
763 | 763 | // update question order |
764 | 764 | $question_group->update_question_order( |
765 | 765 | $question_ID, |
766 | - $this->_req_data['question_orders'][ $question_ID ] |
|
766 | + $this->_req_data['question_orders'][$question_ID] |
|
767 | 767 | ); |
768 | 768 | } |
769 | 769 | |
770 | 770 | // then we always check if adding or removing. |
771 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
771 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) { |
|
772 | 772 | $question_group->add_question($question_ID); |
773 | 773 | } else { |
774 | 774 | // not found, remove it (but only if not a system question for the personal group |
@@ -791,8 +791,8 @@ discard block |
||
791 | 791 | if (isset($this->_req_data['questions'])) { |
792 | 792 | foreach ($this->_req_data['questions'] as $QST_ID) { |
793 | 793 | $question_group->add_question($QST_ID); |
794 | - if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
795 | - $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
794 | + if (isset($this->_req_data['question_orders'][$QST_ID])) { |
|
795 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]); |
|
796 | 796 | } |
797 | 797 | } |
798 | 798 | } |
@@ -932,34 +932,34 @@ discard block |
||
932 | 932 | // echo "trash $trash"; |
933 | 933 | // var_dump($this->_req_data['checkbox']);die; |
934 | 934 | if (isset($this->_req_data['checkbox'])) { |
935 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
935 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
936 | 936 | // if array has more than one element than success message should be plural |
937 | 937 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
938 | 938 | // cycle thru bulk action checkboxes |
939 | 939 | $checkboxes = $this->_req_data['checkbox']; |
940 | 940 | foreach (array_keys($checkboxes) as $ID) { |
941 | - if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
941 | + if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
942 | 942 | $success = 0; |
943 | 943 | } |
944 | 944 | } |
945 | 945 | } else { |
946 | 946 | // grab single id and delete |
947 | 947 | $ID = absint($this->_req_data['checkbox']); |
948 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
948 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
949 | 949 | $success = 0; |
950 | 950 | } |
951 | 951 | } |
952 | 952 | } else { |
953 | 953 | // delete via trash link |
954 | 954 | // grab single id and delete |
955 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
956 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
955 | + $ID = absint($this->_req_data[$model->primary_key_name()]); |
|
956 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
957 | 957 | $success = 0; |
958 | 958 | } |
959 | 959 | } |
960 | 960 | |
961 | 961 | |
962 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
962 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; // strtolower( $model->item_name(2) ); |
|
963 | 963 | // echo "action :$action"; |
964 | 964 | // $action = 'questions' ? 'default' : $action; |
965 | 965 | if ($trash) { |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | */ |
1069 | 1069 | public function update_question_group_order() |
1070 | 1070 | { |
1071 | - if (! $this->capabilities->current_user_can('ee_edit_question_groups', __FUNCTION__)) { |
|
1071 | + if ( ! $this->capabilities->current_user_can('ee_edit_question_groups', __FUNCTION__)) { |
|
1072 | 1072 | wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
1073 | 1073 | } |
1074 | 1074 | $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | ? (int) $this->_req_data['curpage'] |
1086 | 1086 | : null; |
1087 | 1087 | |
1088 | - if (! empty($row_ids)) { |
|
1088 | + if ( ! empty($row_ids)) { |
|
1089 | 1089 | // figure out where we start the row_id count at for the current page. |
1090 | 1090 | $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
1091 | 1091 | |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | // Update the questions when re-ordering |
1095 | 1095 | $updated = EEM_Question_Group::instance()->update( |
1096 | 1096 | ['QSG_order' => $qsgcount], |
1097 | - [['QSG_ID' => $row_ids[ $i ]]] |
|
1097 | + [['QSG_ID' => $row_ids[$i]]] |
|
1098 | 1098 | ); |
1099 | 1099 | if ($updated === false) { |
1100 | 1100 | $success = false; |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | $this->_set_add_edit_form_tags('update_reg_form_settings'); |
1151 | 1151 | $this->_set_publish_post_box_vars(); |
1152 | 1152 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
1153 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1153 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php', |
|
1154 | 1154 | $this->_template_args, |
1155 | 1155 | true |
1156 | 1156 | ); |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
1180 | 1180 | EE_Registry::instance()->CFG->registration |
1181 | 1181 | ); |
1182 | - $success = $this->_update_espresso_configuration( |
|
1182 | + $success = $this->_update_espresso_configuration( |
|
1183 | 1183 | esc_html__('Registration Form Options', 'event_espresso'), |
1184 | 1184 | EE_Registry::instance()->CFG, |
1185 | 1185 | __FILE__, |
@@ -1402,7 +1402,7 @@ discard block |
||
1402 | 1402 | $prev_email_validation_level = 'basic'; |
1403 | 1403 | } |
1404 | 1404 | // confirm our i18n email validation will work on the server |
1405 | - if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1405 | + if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1406 | 1406 | // or reset email validation level to previous value |
1407 | 1407 | $email_validation_level = $prev_email_validation_level; |
1408 | 1408 | } |
@@ -1446,7 +1446,7 @@ discard block |
||
1446 | 1446 | private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
1447 | 1447 | { |
1448 | 1448 | // first check that PCRE is enabled |
1449 | - if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1449 | + if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
1450 | 1450 | EE_Error::add_error( |
1451 | 1451 | sprintf( |
1452 | 1452 | esc_html__( |
@@ -14,19 +14,19 @@ discard block |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | try { |
17 | - $question_order = 0; |
|
18 | - $QSG_system = $question_group->system_group(); |
|
19 | - $question_group_questions = $question_group->questions(); |
|
17 | + $question_order = 0; |
|
18 | + $QSG_system = $question_group->system_group(); |
|
19 | + $question_group_questions = $question_group->questions(); |
|
20 | 20 | |
21 | - $disabled = ! empty($QSG_system) ? 'disabled' : ''; |
|
22 | - $id = ! empty($QST_system) ? '_disabled' : ''; |
|
23 | - $required_question_group_questions = EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
24 | - $QSG_system |
|
25 | - ); |
|
26 | - $allowed_question_group_questions = EEM_Question::instance()->allowed_system_questions_in_system_question_group( |
|
27 | - $QSG_system |
|
28 | - ); |
|
29 | - ?> |
|
21 | + $disabled = ! empty($QSG_system) ? 'disabled' : ''; |
|
22 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
23 | + $required_question_group_questions = EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
24 | + $QSG_system |
|
25 | + ); |
|
26 | + $allowed_question_group_questions = EEM_Question::instance()->allowed_system_questions_in_system_question_group( |
|
27 | + $QSG_system |
|
28 | + ); |
|
29 | + ?> |
|
30 | 30 | |
31 | 31 | <div class="questions-group-wrap ee-layout-row"> |
32 | 32 | <div id="group-details" class="edit-group"> |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | <label for="QSG_name"> |
40 | 40 | <?php esc_html_e('Group Name', 'event_espresso'); ?> |
41 | 41 | <?php echo wp_kses( |
42 | - EEH_Template::get_help_tab_link('group_name_info'), |
|
43 | - AllowedTags::getAllowedTags() |
|
44 | - ); ?> |
|
42 | + EEH_Template::get_help_tab_link('group_name_info'), |
|
43 | + AllowedTags::getAllowedTags() |
|
44 | + ); ?> |
|
45 | 45 | </label> |
46 | 46 | </th> |
47 | 47 | <td> |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | <label for="QSG_identifier"> |
61 | 61 | <?php esc_html_e('Group Identifier', 'event_espresso'); ?> |
62 | 62 | <?php echo wp_kses( |
63 | - EEH_Template::get_help_tab_link('group_identifier_info'), |
|
64 | - AllowedTags::getAllowedTags() |
|
65 | - ); ?> |
|
63 | + EEH_Template::get_help_tab_link('group_identifier_info'), |
|
64 | + AllowedTags::getAllowedTags() |
|
65 | + ); ?> |
|
66 | 66 | </label> |
67 | 67 | </th> |
68 | 68 | <td> |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | <?php if (! empty($QSG_system)) { ?> |
77 | 77 | <p class="description ee-system-question"> |
78 | 78 | <?php esc_html_e( |
79 | - 'System question group! This field cannot be changed.', |
|
80 | - 'event_espresso' |
|
81 | - ) ?> |
|
79 | + 'System question group! This field cannot be changed.', |
|
80 | + 'event_espresso' |
|
81 | + ) ?> |
|
82 | 82 | </p> |
83 | 83 | <?php } ?> |
84 | 84 | </td> |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | <label for="QSG_desc"> |
89 | 89 | <?php esc_html_e('Description', 'event_espresso'); ?> |
90 | 90 | <?php echo wp_kses( |
91 | - EEH_Template::get_help_tab_link('group_description_info'), |
|
92 | - AllowedTags::getAllowedTags() |
|
93 | - ); ?> |
|
91 | + EEH_Template::get_help_tab_link('group_description_info'), |
|
92 | + AllowedTags::getAllowedTags() |
|
93 | + ); ?> |
|
94 | 94 | </label> |
95 | 95 | </th> |
96 | 96 | <td> |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | <label for="QSG_order"> |
109 | 109 | <?php esc_html_e('Question Group Order', 'event_espresso'); ?> |
110 | 110 | <?php echo wp_kses( |
111 | - EEH_Template::get_help_tab_link('group_order_info'), |
|
112 | - AllowedTags::getAllowedTags() |
|
113 | - ); ?> |
|
111 | + EEH_Template::get_help_tab_link('group_order_info'), |
|
112 | + AllowedTags::getAllowedTags() |
|
113 | + ); ?> |
|
114 | 114 | </label> |
115 | 115 | </th> |
116 | 116 | <td> |
@@ -132,15 +132,15 @@ discard block |
||
132 | 132 | </th> |
133 | 133 | <td> |
134 | 134 | <?php echo wp_kses( |
135 | - EEH_Form_Fields::select_input( |
|
136 | - 'QSG_show_group_name', |
|
137 | - $values, |
|
138 | - $question_group->show_group_name(), |
|
139 | - '', |
|
140 | - 'ee-input-width--tiny' |
|
141 | - ), |
|
142 | - AllowedTags::getWithFormTags() |
|
143 | - ); ?> |
|
135 | + EEH_Form_Fields::select_input( |
|
136 | + 'QSG_show_group_name', |
|
137 | + $values, |
|
138 | + $question_group->show_group_name(), |
|
139 | + '', |
|
140 | + 'ee-input-width--tiny' |
|
141 | + ), |
|
142 | + AllowedTags::getWithFormTags() |
|
143 | + ); ?> |
|
144 | 144 | <p class="description"> |
145 | 145 | <?php esc_html_e('Show Group Name on Registration Page?', 'event_espresso'); ?> |
146 | 146 | </p> |
@@ -152,25 +152,25 @@ discard block |
||
152 | 152 | <label for="QSG_show_group_order"> |
153 | 153 | <?php esc_html_e('Show Description', 'event_espresso'); ?> |
154 | 154 | <?php echo wp_kses( |
155 | - EEH_Template::get_help_tab_link('show_group_description_info'), |
|
156 | - AllowedTags::getAllowedTags() |
|
157 | - ); ?> |
|
155 | + EEH_Template::get_help_tab_link('show_group_description_info'), |
|
156 | + AllowedTags::getAllowedTags() |
|
157 | + ); ?> |
|
158 | 158 | </label> |
159 | 159 | </th> |
160 | 160 | <td> |
161 | 161 | <?php echo wp_kses( |
162 | - EEH_Form_Fields::select_input( |
|
163 | - 'QSG_show_group_desc', |
|
164 | - $values, |
|
165 | - $question_group->show_group_desc(), |
|
166 | - '', |
|
167 | - 'ee-input-width--tiny' |
|
168 | - ), |
|
169 | - AllowedTags::getWithFormTags() |
|
170 | - ); ?> |
|
162 | + EEH_Form_Fields::select_input( |
|
163 | + 'QSG_show_group_desc', |
|
164 | + $values, |
|
165 | + $question_group->show_group_desc(), |
|
166 | + '', |
|
167 | + 'ee-input-width--tiny' |
|
168 | + ), |
|
169 | + AllowedTags::getWithFormTags() |
|
170 | + ); ?> |
|
171 | 171 | <p class="description"><?php |
172 | - esc_html_e(' Show Group Description on Registration Page?', 'event_espresso'); |
|
173 | - ?></p> |
|
172 | + esc_html_e(' Show Group Description on Registration Page?', 'event_espresso'); |
|
173 | + ?></p> |
|
174 | 174 | <input type="hidden" name="QSG_system" value="<?php echo esc_attr($question_group->system_group()); ?>"> |
175 | 175 | </td> |
176 | 176 | </tr> |
@@ -184,40 +184,40 @@ discard block |
||
184 | 184 | <div class="question-group-questions"> |
185 | 185 | <p class='ee-status-outline ee-status-bg--info'> |
186 | 186 | <?php |
187 | - esc_html_e( |
|
188 | - 'Select which questions should be shown in this group by checking or unchecking boxes. You can drag and drop questions to reorder them. Your changes will be updated when you save.', |
|
189 | - 'event_espresso' |
|
190 | - ); ?> |
|
187 | + esc_html_e( |
|
188 | + 'Select which questions should be shown in this group by checking or unchecking boxes. You can drag and drop questions to reorder them. Your changes will be updated when you save.', |
|
189 | + 'event_espresso' |
|
190 | + ); ?> |
|
191 | 191 | </p> |
192 | 192 | <div> |
193 | 193 | <ul class="question-list-sortable"> |
194 | 194 | <?php |
195 | - foreach ($all_questions as $question_ID => $question) { |
|
196 | - if (! $question instanceof EE_Question) { |
|
197 | - continue; |
|
198 | - } |
|
199 | - $checked = isset($question_group_questions[ $question_ID ]) |
|
200 | - ? ' checked' |
|
201 | - : ''; |
|
202 | - // disable questions from the personal information question group |
|
203 | - // is it required in the current question group? if so don't allow admins to remove it |
|
204 | - $disabled = in_array($question->system_ID(), $required_question_group_questions) |
|
205 | - ? ' disabled' |
|
206 | - : ''; |
|
207 | - // limit where system questions can appear |
|
208 | - if ( |
|
209 | - $question->system_ID() |
|
210 | - && ! in_array($question->system_ID(), $allowed_question_group_questions) |
|
211 | - ) { |
|
212 | - // skip over system question not assigned to this group |
|
213 | - // except for the address system group because we want the address questions to display |
|
214 | - // even if they aren't selected (but still not show the personal system questions). |
|
215 | - // The third condition checks if we're displaying a non system question group |
|
216 | - // and the question is a system question, then we skip |
|
217 | - // because for non-system question groups we only want to show non-system questions. |
|
218 | - continue; |
|
219 | - } |
|
220 | - ?> |
|
195 | + foreach ($all_questions as $question_ID => $question) { |
|
196 | + if (! $question instanceof EE_Question) { |
|
197 | + continue; |
|
198 | + } |
|
199 | + $checked = isset($question_group_questions[ $question_ID ]) |
|
200 | + ? ' checked' |
|
201 | + : ''; |
|
202 | + // disable questions from the personal information question group |
|
203 | + // is it required in the current question group? if so don't allow admins to remove it |
|
204 | + $disabled = in_array($question->system_ID(), $required_question_group_questions) |
|
205 | + ? ' disabled' |
|
206 | + : ''; |
|
207 | + // limit where system questions can appear |
|
208 | + if ( |
|
209 | + $question->system_ID() |
|
210 | + && ! in_array($question->system_ID(), $allowed_question_group_questions) |
|
211 | + ) { |
|
212 | + // skip over system question not assigned to this group |
|
213 | + // except for the address system group because we want the address questions to display |
|
214 | + // even if they aren't selected (but still not show the personal system questions). |
|
215 | + // The third condition checks if we're displaying a non system question group |
|
216 | + // and the question is a system question, then we skip |
|
217 | + // because for non-system question groups we only want to show non-system questions. |
|
218 | + continue; |
|
219 | + } |
|
220 | + ?> |
|
221 | 221 | <li class="ee-question-sortable"> |
222 | 222 | <label for="question-<?php echo absint($question_ID); ?>"> |
223 | 223 | <input id="question-<?php echo absint($question_ID); ?>" |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | /> |
230 | 230 | <span class="question-text"> |
231 | 231 | <?php |
232 | - $trimmed_text = trim($question->display_text()); |
|
233 | - $trimmed_text .= strlen($trimmed_text) >= 95 ? "…" : ''; |
|
234 | - echo esc_html($trimmed_text); |
|
235 | - ?> |
|
232 | + $trimmed_text = trim($question->display_text()); |
|
233 | + $trimmed_text .= strlen($trimmed_text) >= 95 ? "…" : ''; |
|
234 | + echo esc_html($trimmed_text); |
|
235 | + ?> |
|
236 | 236 | </span> |
237 | 237 | <input class="question-group-QGQ_order" |
238 | 238 | name="question_orders[<?php echo absint($question_ID); ?>]" |
@@ -241,40 +241,40 @@ discard block |
||
241 | 241 | > |
242 | 242 | </label> |
243 | 243 | <?php |
244 | - if ( |
|
245 | - EE_Registry::instance()->CAP->current_user_can( |
|
246 | - 'ee_edit_question', |
|
247 | - 'espresso_registration_form_edit_question', |
|
248 | - $question->ID() |
|
249 | - ) |
|
250 | - ) { |
|
251 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
252 | - [ |
|
253 | - 'action' => 'edit_question', |
|
254 | - 'QST_ID' => $question->ID(), |
|
255 | - ], |
|
256 | - EE_FORMS_ADMIN_URL |
|
257 | - ); |
|
244 | + if ( |
|
245 | + EE_Registry::instance()->CAP->current_user_can( |
|
246 | + 'ee_edit_question', |
|
247 | + 'espresso_registration_form_edit_question', |
|
248 | + $question->ID() |
|
249 | + ) |
|
250 | + ) { |
|
251 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
252 | + [ |
|
253 | + 'action' => 'edit_question', |
|
254 | + 'QST_ID' => $question->ID(), |
|
255 | + ], |
|
256 | + EE_FORMS_ADMIN_URL |
|
257 | + ); |
|
258 | 258 | |
259 | - echo ' |
|
259 | + echo ' |
|
260 | 260 | <a href="' . esc_url_raw($edit_link) . '" |
261 | 261 | class="ee-aria-tooltip button button--small button--icon-only" |
262 | 262 | target="_blank" |
263 | 263 | aria-label="' . |
264 | - sprintf( |
|
265 | - esc_attr__('Edit %s', 'event_espresso'), |
|
266 | - $question->admin_label() |
|
267 | - ) . '" |
|
264 | + sprintf( |
|
265 | + esc_attr__('Edit %s', 'event_espresso'), |
|
266 | + $question->admin_label() |
|
267 | + ) . '" |
|
268 | 268 | > |
269 | 269 | <span class="dashicons dashicons-edit"></span> |
270 | 270 | </a>'; |
271 | - } |
|
272 | - ?> |
|
271 | + } |
|
272 | + ?> |
|
273 | 273 | </li> |
274 | 274 | <?php |
275 | - $question_order++; |
|
276 | - } |
|
277 | - ?> |
|
275 | + $question_order++; |
|
276 | + } |
|
277 | + ?> |
|
278 | 278 | </ul> |
279 | 279 | </div> |
280 | 280 | </div> |
@@ -283,5 +283,5 @@ discard block |
||
283 | 283 | |
284 | 284 | <?php |
285 | 285 | } catch (Exception $e) { |
286 | - EE_Error::add_error($e->getMessage(), __FILE__, __LINE__, __METHOD__); |
|
286 | + EE_Error::add_error($e->getMessage(), __FILE__, __LINE__, __METHOD__); |
|
287 | 287 | } |
@@ -14,70 +14,70 @@ |
||
14 | 14 | |
15 | 15 | class SessionLifespanForm extends EE_Form_Section_Proper |
16 | 16 | { |
17 | - /** |
|
18 | - * SessionLifespanForm constructor. |
|
19 | - * |
|
20 | - * @param SessionLifespanOption $session_lifespan_option |
|
21 | - * @param EE_Registration_Config $reg_config |
|
22 | - * @throws EE_Error |
|
23 | - */ |
|
24 | - public function __construct(SessionLifespanOption $session_lifespan_option, EE_Registration_Config $reg_config) |
|
25 | - { |
|
26 | - parent::__construct([ |
|
27 | - 'name' => 'session_lifespan', |
|
28 | - 'html_id' => 'session_lifespan', |
|
29 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
30 | - 'subsections' => apply_filters( |
|
31 | - 'FHEE__EventEspresso_caffeinated_admin_extend_registration_form_forms_SessionLifespanForm__construct__form_subsections', |
|
32 | - [ |
|
33 | - 'session_lifespan_hdr' => new EE_Form_Section_HTML( |
|
34 | - EEH_HTML::h2(esc_html__('Session Settings', 'event_espresso')) |
|
35 | - ), |
|
36 | - 'session_lifespan' => new EE_Select_Input( |
|
37 | - [ |
|
38 | - 300 => esc_html__('Five Minutes', 'event_espresso'), |
|
39 | - 900 => esc_html__('Fifteen Minutes', 'event_espresso'), |
|
40 | - 1800 => esc_html__('Thirty Minutes', 'event_espresso'), |
|
41 | - 3600 => esc_html__('One Hour', 'event_espresso'), |
|
42 | - 7200 => esc_html__('Two Hours', 'event_espresso'), |
|
43 | - ], |
|
44 | - [ |
|
45 | - 'html_label_text' => esc_html__('Session Lifespan', 'event_espresso'), |
|
46 | - 'html_help_text' => esc_html__( |
|
47 | - 'Controls how long a user has to complete the registration form. Defaults to 1 hour.', |
|
48 | - 'event_espresso' |
|
49 | - ), |
|
50 | - 'default' => $session_lifespan_option->getSessionLifespan(), |
|
51 | - 'required' => false, |
|
52 | - ] |
|
53 | - ), |
|
54 | - 'use_session_countdown' => new EE_Switch_Input( |
|
55 | - [ |
|
56 | - 'html_label_text' => esc_html__('Session Countdown Timer', 'event_espresso'), |
|
57 | - 'default' => $reg_config->useSessionCountdown() |
|
58 | - ? EE_Switch_Input::OPTION_ON |
|
59 | - : EE_Switch_Input::OPTION_OFF, |
|
60 | - 'html_name' => 'use_session_countdown', |
|
61 | - 'html_help_text' => esc_html__( |
|
62 | - 'Whether to display a countdown timer to the user showing how much time they have left to complete the registration form. Defaults to off.', |
|
63 | - 'event_espresso' |
|
64 | - ), |
|
65 | - 'layout_container_class' => 'ee-feature-highlight-2024', |
|
66 | - 'extra_container_html' => '<span class="ee-feature-highlight-2024-notice">✨ ' . esc_html__('NEW', 'event_espresso') . '</span>', |
|
67 | - ], |
|
68 | - [ |
|
69 | - EE_Switch_Input::OPTION_OFF => esc_html__( |
|
70 | - 'session countdown timer is NOT displayed', |
|
71 | - 'event_espresso' |
|
72 | - ), |
|
73 | - EE_Switch_Input::OPTION_ON => esc_html__( |
|
74 | - 'session countdown timer is displayed', |
|
75 | - 'event_espresso' |
|
76 | - ), |
|
77 | - ] |
|
78 | - ), |
|
79 | - ] |
|
80 | - ), |
|
81 | - ]); |
|
82 | - } |
|
17 | + /** |
|
18 | + * SessionLifespanForm constructor. |
|
19 | + * |
|
20 | + * @param SessionLifespanOption $session_lifespan_option |
|
21 | + * @param EE_Registration_Config $reg_config |
|
22 | + * @throws EE_Error |
|
23 | + */ |
|
24 | + public function __construct(SessionLifespanOption $session_lifespan_option, EE_Registration_Config $reg_config) |
|
25 | + { |
|
26 | + parent::__construct([ |
|
27 | + 'name' => 'session_lifespan', |
|
28 | + 'html_id' => 'session_lifespan', |
|
29 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
30 | + 'subsections' => apply_filters( |
|
31 | + 'FHEE__EventEspresso_caffeinated_admin_extend_registration_form_forms_SessionLifespanForm__construct__form_subsections', |
|
32 | + [ |
|
33 | + 'session_lifespan_hdr' => new EE_Form_Section_HTML( |
|
34 | + EEH_HTML::h2(esc_html__('Session Settings', 'event_espresso')) |
|
35 | + ), |
|
36 | + 'session_lifespan' => new EE_Select_Input( |
|
37 | + [ |
|
38 | + 300 => esc_html__('Five Minutes', 'event_espresso'), |
|
39 | + 900 => esc_html__('Fifteen Minutes', 'event_espresso'), |
|
40 | + 1800 => esc_html__('Thirty Minutes', 'event_espresso'), |
|
41 | + 3600 => esc_html__('One Hour', 'event_espresso'), |
|
42 | + 7200 => esc_html__('Two Hours', 'event_espresso'), |
|
43 | + ], |
|
44 | + [ |
|
45 | + 'html_label_text' => esc_html__('Session Lifespan', 'event_espresso'), |
|
46 | + 'html_help_text' => esc_html__( |
|
47 | + 'Controls how long a user has to complete the registration form. Defaults to 1 hour.', |
|
48 | + 'event_espresso' |
|
49 | + ), |
|
50 | + 'default' => $session_lifespan_option->getSessionLifespan(), |
|
51 | + 'required' => false, |
|
52 | + ] |
|
53 | + ), |
|
54 | + 'use_session_countdown' => new EE_Switch_Input( |
|
55 | + [ |
|
56 | + 'html_label_text' => esc_html__('Session Countdown Timer', 'event_espresso'), |
|
57 | + 'default' => $reg_config->useSessionCountdown() |
|
58 | + ? EE_Switch_Input::OPTION_ON |
|
59 | + : EE_Switch_Input::OPTION_OFF, |
|
60 | + 'html_name' => 'use_session_countdown', |
|
61 | + 'html_help_text' => esc_html__( |
|
62 | + 'Whether to display a countdown timer to the user showing how much time they have left to complete the registration form. Defaults to off.', |
|
63 | + 'event_espresso' |
|
64 | + ), |
|
65 | + 'layout_container_class' => 'ee-feature-highlight-2024', |
|
66 | + 'extra_container_html' => '<span class="ee-feature-highlight-2024-notice">✨ ' . esc_html__('NEW', 'event_espresso') . '</span>', |
|
67 | + ], |
|
68 | + [ |
|
69 | + EE_Switch_Input::OPTION_OFF => esc_html__( |
|
70 | + 'session countdown timer is NOT displayed', |
|
71 | + 'event_espresso' |
|
72 | + ), |
|
73 | + EE_Switch_Input::OPTION_ON => esc_html__( |
|
74 | + 'session countdown timer is displayed', |
|
75 | + 'event_espresso' |
|
76 | + ), |
|
77 | + ] |
|
78 | + ), |
|
79 | + ] |
|
80 | + ), |
|
81 | + ]); |
|
82 | + } |
|
83 | 83 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | 'event_espresso' |
64 | 64 | ), |
65 | 65 | 'layout_container_class' => 'ee-feature-highlight-2024', |
66 | - 'extra_container_html' => '<span class="ee-feature-highlight-2024-notice">✨ ' . esc_html__('NEW', 'event_espresso') . '</span>', |
|
66 | + 'extra_container_html' => '<span class="ee-feature-highlight-2024-notice">✨ '.esc_html__('NEW', 'event_espresso').'</span>', |
|
67 | 67 | ], |
68 | 68 | [ |
69 | 69 | EE_Switch_Input::OPTION_OFF => esc_html__( |
@@ -16,1277 +16,1277 @@ |
||
16 | 16 | */ |
17 | 17 | class Extend_Registrations_Admin_Page extends Registrations_Admin_Page |
18 | 18 | { |
19 | - /** |
|
20 | - * This is used to hold the reports template data which is setup early in the request. |
|
21 | - * |
|
22 | - * @type array |
|
23 | - */ |
|
24 | - protected array $_reports_template_data = []; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * Extend_Registrations_Admin_Page constructor. |
|
29 | - * |
|
30 | - * @param bool $routing |
|
31 | - * @throws ReflectionException |
|
32 | - */ |
|
33 | - public function __construct($routing = true) |
|
34 | - { |
|
35 | - parent::__construct($routing); |
|
36 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
37 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
38 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
39 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
40 | - } |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - protected function _set_page_config() |
|
45 | - { |
|
46 | - parent::_set_page_config(); |
|
47 | - |
|
48 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
49 | - $reg_id = |
|
50 | - ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
51 | - ? $this->_req_data['_REG_ID'] |
|
52 | - : 0; |
|
53 | - $new_page_routes = [ |
|
54 | - 'reports' => [ |
|
55 | - 'func' => [$this, '_registration_reports'], |
|
56 | - 'capability' => 'ee_read_registrations', |
|
57 | - ], |
|
58 | - 'registration_checkins' => [ |
|
59 | - 'func' => [$this, '_registration_checkin_list_table'], |
|
60 | - 'capability' => 'ee_read_checkins', |
|
61 | - ], |
|
62 | - 'newsletter_selected_send' => [ |
|
63 | - 'func' => [$this, '_newsletter_selected_send'], |
|
64 | - 'noheader' => true, |
|
65 | - 'capability' => 'ee_send_message', |
|
66 | - ], |
|
67 | - 'delete_checkin_rows' => [ |
|
68 | - 'func' => [$this, '_delete_checkin_rows'], |
|
69 | - 'noheader' => true, |
|
70 | - 'capability' => 'ee_delete_checkins', |
|
71 | - ], |
|
72 | - 'delete_checkin_row' => [ |
|
73 | - 'func' => [$this, '_delete_checkin_row'], |
|
74 | - 'noheader' => true, |
|
75 | - 'capability' => 'ee_delete_checkin', |
|
76 | - 'obj_id' => $reg_id, |
|
77 | - ], |
|
78 | - 'toggle_checkin_status' => [ |
|
79 | - 'func' => [$this, '_toggle_checkin_status'], |
|
80 | - 'noheader' => true, |
|
81 | - 'capability' => 'ee_edit_checkin', |
|
82 | - 'obj_id' => $reg_id, |
|
83 | - ], |
|
84 | - 'toggle_checkin_status_bulk' => [ |
|
85 | - 'func' => [$this, '_toggle_checkin_status'], |
|
86 | - 'noheader' => true, |
|
87 | - 'capability' => 'ee_edit_checkins', |
|
88 | - ], |
|
89 | - 'event_registrations' => [ |
|
90 | - 'func' => [$this, '_event_registrations_list_table'], |
|
91 | - 'capability' => 'ee_read_checkins', |
|
92 | - ], |
|
93 | - 'registrations_checkin_report' => [ |
|
94 | - 'func' => [$this, '_registrations_checkin_report'], |
|
95 | - 'noheader' => true, |
|
96 | - 'capability' => 'ee_read_registrations', |
|
97 | - ], |
|
98 | - ]; |
|
99 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
100 | - $new_page_config = [ |
|
101 | - 'reports' => [ |
|
102 | - 'nav' => [ |
|
103 | - 'label' => esc_html__('Reports', 'event_espresso'), |
|
104 | - 'icon' => 'dashicons-chart-bar', |
|
105 | - 'order' => 30, |
|
106 | - ], |
|
107 | - 'help_tabs' => [ |
|
108 | - 'registrations_reports_help_tab' => [ |
|
109 | - 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
110 | - 'filename' => 'registrations_reports', |
|
111 | - ], |
|
112 | - ], |
|
113 | - 'require_nonce' => false, |
|
114 | - ], |
|
115 | - 'event_registrations' => [ |
|
116 | - 'nav' => [ |
|
117 | - 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
118 | - 'icon' => 'dashicons-yes-alt', |
|
119 | - 'order' => 10, |
|
120 | - 'persistent' => true, |
|
121 | - ], |
|
122 | - 'help_tabs' => [ |
|
123 | - 'registrations_event_checkin_help_tab' => [ |
|
124 | - 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
125 | - 'filename' => 'registrations_event_checkin', |
|
126 | - ], |
|
127 | - 'registrations_event_checkin_table_column_headings_help_tab' => [ |
|
128 | - 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
129 | - 'filename' => 'registrations_event_checkin_table_column_headings', |
|
130 | - ], |
|
131 | - 'registrations_event_checkin_filters_help_tab' => [ |
|
132 | - 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
133 | - 'filename' => 'registrations_event_checkin_filters', |
|
134 | - ], |
|
135 | - 'registrations_event_checkin_views_help_tab' => [ |
|
136 | - 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
137 | - 'filename' => 'registrations_event_checkin_views', |
|
138 | - ], |
|
139 | - 'registrations_event_checkin_other_help_tab' => [ |
|
140 | - 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
141 | - 'filename' => 'registrations_event_checkin_other', |
|
142 | - ], |
|
143 | - ], |
|
144 | - 'list_table' => 'EE_Event_Registrations_List_Table', |
|
145 | - 'metaboxes' => [], |
|
146 | - 'require_nonce' => false, |
|
147 | - ], |
|
148 | - 'registration_checkins' => [ |
|
149 | - 'nav' => [ |
|
150 | - 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
151 | - 'icon' => 'dashicons-list-view', |
|
152 | - 'order' => 15, |
|
153 | - 'persistent' => false, |
|
154 | - 'url' => '', |
|
155 | - ], |
|
156 | - 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
157 | - 'metaboxes' => [], |
|
158 | - 'require_nonce' => false, |
|
159 | - ], |
|
160 | - ]; |
|
161 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
162 | - $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
163 | - $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * Ajax hooks for all routes in this page. |
|
169 | - */ |
|
170 | - protected function _ajax_hooks() |
|
171 | - { |
|
172 | - parent::_ajax_hooks(); |
|
173 | - add_action('wp_ajax_get_newsletter_form_content', [$this, 'get_newsletter_form_content']); |
|
174 | - add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']); |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * Global scripts for all routes in this page. |
|
180 | - * |
|
181 | - * @throws EE_Error |
|
182 | - * *@throws ReflectionException |
|
183 | - */ |
|
184 | - public function load_scripts_styles() |
|
185 | - { |
|
186 | - parent::load_scripts_styles(); |
|
187 | - // if newsletter message type is active then let's add filter and load js for it. |
|
188 | - if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
189 | - wp_enqueue_style( |
|
190 | - 'ee_message_shortcodes', |
|
191 | - EE_MSG_ASSETS_URL . 'ee_message_shortcodes.css', |
|
192 | - [EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN], |
|
193 | - EVENT_ESPRESSO_VERSION |
|
194 | - ); |
|
195 | - // enqueue newsletter js |
|
196 | - wp_enqueue_script( |
|
197 | - 'ee-newsletter-trigger', |
|
198 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
199 | - ['ee-dialog'], |
|
200 | - EVENT_ESPRESSO_VERSION, |
|
201 | - true |
|
202 | - ); |
|
203 | - // hook in buttons for newsletter message type trigger. |
|
204 | - add_action( |
|
205 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
206 | - [$this, 'add_newsletter_action_buttons'] |
|
207 | - ); |
|
208 | - } |
|
209 | - } |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * Scripts and styles for just the reports route. |
|
214 | - * |
|
215 | - * @throws EE_Error |
|
216 | - * @throws ReflectionException |
|
217 | - */ |
|
218 | - public function load_scripts_styles_reports() |
|
219 | - { |
|
220 | - wp_register_script( |
|
221 | - 'ee-reg-reports-js', |
|
222 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
223 | - ['google-charts'], |
|
224 | - EVENT_ESPRESSO_VERSION, |
|
225 | - true |
|
226 | - ); |
|
227 | - wp_enqueue_script('ee-reg-reports-js'); |
|
228 | - $this->_registration_reports_js_setup(); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * Register screen options for event_registrations route. |
|
234 | - */ |
|
235 | - protected function _add_screen_options_event_registrations() |
|
236 | - { |
|
237 | - $this->_per_page_screen_option(); |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * Register screen options for registration_checkins route |
|
243 | - */ |
|
244 | - protected function _add_screen_options_registration_checkins() |
|
245 | - { |
|
246 | - $page_title = $this->_admin_page_title; |
|
247 | - $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
248 | - $this->_per_page_screen_option(); |
|
249 | - $this->_admin_page_title = $page_title; |
|
250 | - } |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * Set views property for event_registrations route. |
|
255 | - */ |
|
256 | - protected function _set_list_table_views_event_registrations() |
|
257 | - { |
|
258 | - $this->_views = [ |
|
259 | - 'all' => [ |
|
260 | - 'slug' => 'all', |
|
261 | - 'label' => esc_html__('All', 'event_espresso'), |
|
262 | - 'count' => 0, |
|
263 | - 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
264 | - ? [] |
|
265 | - : [ |
|
266 | - 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
267 | - ], |
|
268 | - ], |
|
269 | - ]; |
|
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - /** |
|
274 | - * Set views property for registration_checkins route. |
|
275 | - */ |
|
276 | - protected function _set_list_table_views_registration_checkins() |
|
277 | - { |
|
278 | - $this->_views = [ |
|
279 | - 'all' => [ |
|
280 | - 'slug' => 'all', |
|
281 | - 'label' => esc_html__('All', 'event_espresso'), |
|
282 | - 'count' => 0, |
|
283 | - 'bulk_action' => ['delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')], |
|
284 | - ], |
|
285 | - ]; |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * callback for ajax action. |
|
291 | - * |
|
292 | - * @return void (JSON) |
|
293 | - * @throws EE_Error |
|
294 | - * @throws ReflectionException |
|
295 | - * @since 4.3.0 |
|
296 | - */ |
|
297 | - public function get_newsletter_form_content() |
|
298 | - { |
|
299 | - if (! $this->capabilities->current_user_can('ee_read_messages', __FUNCTION__)) { |
|
300 | - wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
301 | - } |
|
302 | - // do a nonce check because we're not coming in from a normal route here. |
|
303 | - $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
304 | - $this->_req_data['get_newsletter_form_content_nonce'] |
|
305 | - ) : ''; |
|
306 | - $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
307 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
308 | - // let's get the mtp for the incoming MTP_ ID |
|
309 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
310 | - EE_Error::add_error( |
|
311 | - esc_html__( |
|
312 | - 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
313 | - 'event_espresso' |
|
314 | - ), |
|
315 | - __FILE__, |
|
316 | - __FUNCTION__, |
|
317 | - __LINE__ |
|
318 | - ); |
|
319 | - $this->_template_args['success'] = false; |
|
320 | - $this->_template_args['error'] = true; |
|
321 | - $this->_return_json(); |
|
322 | - } |
|
323 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
324 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
325 | - EE_Error::add_error( |
|
326 | - sprintf( |
|
327 | - esc_html__( |
|
328 | - 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
329 | - 'event_espresso' |
|
330 | - ), |
|
331 | - $this->_req_data['GRP_ID'] |
|
332 | - ), |
|
333 | - __FILE__, |
|
334 | - __FUNCTION__, |
|
335 | - __LINE__ |
|
336 | - ); |
|
337 | - $this->_template_args['success'] = false; |
|
338 | - $this->_template_args['error'] = true; |
|
339 | - $this->_return_json(); |
|
340 | - } |
|
341 | - $MTPs = $MTPG->context_templates(); |
|
342 | - $MTPs = $MTPs['attendee']; |
|
343 | - $template_fields = []; |
|
344 | - /** @var EE_Message_Template $MTP */ |
|
345 | - foreach ($MTPs as $MTP) { |
|
346 | - $field = $MTP->get('MTP_template_field'); |
|
347 | - if ($field === 'content') { |
|
348 | - $content = $MTP->get('MTP_content'); |
|
349 | - if (! empty($content['newsletter_content'])) { |
|
350 | - $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
351 | - } |
|
352 | - continue; |
|
353 | - } |
|
354 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
355 | - } |
|
356 | - $this->_template_args['success'] = true; |
|
357 | - $this->_template_args['error'] = false; |
|
358 | - $this->_template_args['data'] = [ |
|
359 | - 'batch_message_from' => $template_fields['from'] ?? '', |
|
360 | - 'batch_message_subject' => $template_fields['subject'] ?? '', |
|
361 | - 'batch_message_content' => $template_fields['newsletter_content'] ?? '', |
|
362 | - ]; |
|
363 | - $this->_return_json(); |
|
364 | - } |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
369 | - * |
|
370 | - * @param EE_Admin_List_Table $list_table |
|
371 | - * @return void |
|
372 | - * @since 4.3.0 |
|
373 | - */ |
|
374 | - public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
375 | - { |
|
376 | - if ( |
|
377 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
378 | - 'ee_send_message', |
|
379 | - 'espresso_registrations_newsletter_selected_send' |
|
380 | - ) |
|
381 | - ) { |
|
382 | - return; |
|
383 | - } |
|
384 | - $routes_to_add_to = [ |
|
385 | - 'contact_list', |
|
386 | - 'event_registrations', |
|
387 | - 'default', |
|
388 | - ]; |
|
389 | - if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
390 | - if ( |
|
391 | - ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
392 | - || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
393 | - ) { |
|
394 | - echo ''; |
|
395 | - } else { |
|
396 | - $button_text = sprintf( |
|
397 | - esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
398 | - '<span class="send-selected-newsletter-count">0</span>' |
|
399 | - ); |
|
400 | - echo '<button id="selected-batch-send-trigger" class="button button--secondary">' |
|
401 | - . '<span class="dashicons dashicons-email "></span>' |
|
402 | - . $button_text |
|
403 | - . '</button>'; |
|
404 | - add_action('admin_footer', [$this, 'newsletter_send_form_skeleton']); |
|
405 | - } |
|
406 | - } |
|
407 | - } |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * @throws DomainException |
|
412 | - * @throws EE_Error |
|
413 | - * @throws ReflectionException |
|
414 | - */ |
|
415 | - public function newsletter_send_form_skeleton() |
|
416 | - { |
|
417 | - $list_table = $this->_list_table_object; |
|
418 | - $codes = []; |
|
419 | - // need to templates for the newsletter message type for the template selector. |
|
420 | - $values[] = ['text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0]; |
|
421 | - $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
422 | - [['MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email']] |
|
423 | - ); |
|
424 | - foreach ($mtps as $mtp) { |
|
425 | - $name = $mtp->name(); |
|
426 | - $values[] = [ |
|
427 | - 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
428 | - 'id' => $mtp->ID(), |
|
429 | - ]; |
|
430 | - } |
|
431 | - // need to get a list of shortcodes that are available for the newsletter message type. |
|
432 | - $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
433 | - 'newsletter', |
|
434 | - 'email', |
|
435 | - [], |
|
436 | - 'attendee' |
|
437 | - ); |
|
438 | - |
|
439 | - foreach ($shortcodes as $field => $shortcode_array) { |
|
440 | - $available_shortcodes = []; |
|
441 | - foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
442 | - $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
443 | - ? 'content' |
|
444 | - : strtolower($field); |
|
445 | - $field_id = "batch-message-$field_id"; |
|
446 | - $available_shortcodes[] = ' |
|
19 | + /** |
|
20 | + * This is used to hold the reports template data which is setup early in the request. |
|
21 | + * |
|
22 | + * @type array |
|
23 | + */ |
|
24 | + protected array $_reports_template_data = []; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * Extend_Registrations_Admin_Page constructor. |
|
29 | + * |
|
30 | + * @param bool $routing |
|
31 | + * @throws ReflectionException |
|
32 | + */ |
|
33 | + public function __construct($routing = true) |
|
34 | + { |
|
35 | + parent::__construct($routing); |
|
36 | + if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
37 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
38 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
39 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
40 | + } |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + protected function _set_page_config() |
|
45 | + { |
|
46 | + parent::_set_page_config(); |
|
47 | + |
|
48 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
49 | + $reg_id = |
|
50 | + ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
51 | + ? $this->_req_data['_REG_ID'] |
|
52 | + : 0; |
|
53 | + $new_page_routes = [ |
|
54 | + 'reports' => [ |
|
55 | + 'func' => [$this, '_registration_reports'], |
|
56 | + 'capability' => 'ee_read_registrations', |
|
57 | + ], |
|
58 | + 'registration_checkins' => [ |
|
59 | + 'func' => [$this, '_registration_checkin_list_table'], |
|
60 | + 'capability' => 'ee_read_checkins', |
|
61 | + ], |
|
62 | + 'newsletter_selected_send' => [ |
|
63 | + 'func' => [$this, '_newsletter_selected_send'], |
|
64 | + 'noheader' => true, |
|
65 | + 'capability' => 'ee_send_message', |
|
66 | + ], |
|
67 | + 'delete_checkin_rows' => [ |
|
68 | + 'func' => [$this, '_delete_checkin_rows'], |
|
69 | + 'noheader' => true, |
|
70 | + 'capability' => 'ee_delete_checkins', |
|
71 | + ], |
|
72 | + 'delete_checkin_row' => [ |
|
73 | + 'func' => [$this, '_delete_checkin_row'], |
|
74 | + 'noheader' => true, |
|
75 | + 'capability' => 'ee_delete_checkin', |
|
76 | + 'obj_id' => $reg_id, |
|
77 | + ], |
|
78 | + 'toggle_checkin_status' => [ |
|
79 | + 'func' => [$this, '_toggle_checkin_status'], |
|
80 | + 'noheader' => true, |
|
81 | + 'capability' => 'ee_edit_checkin', |
|
82 | + 'obj_id' => $reg_id, |
|
83 | + ], |
|
84 | + 'toggle_checkin_status_bulk' => [ |
|
85 | + 'func' => [$this, '_toggle_checkin_status'], |
|
86 | + 'noheader' => true, |
|
87 | + 'capability' => 'ee_edit_checkins', |
|
88 | + ], |
|
89 | + 'event_registrations' => [ |
|
90 | + 'func' => [$this, '_event_registrations_list_table'], |
|
91 | + 'capability' => 'ee_read_checkins', |
|
92 | + ], |
|
93 | + 'registrations_checkin_report' => [ |
|
94 | + 'func' => [$this, '_registrations_checkin_report'], |
|
95 | + 'noheader' => true, |
|
96 | + 'capability' => 'ee_read_registrations', |
|
97 | + ], |
|
98 | + ]; |
|
99 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
100 | + $new_page_config = [ |
|
101 | + 'reports' => [ |
|
102 | + 'nav' => [ |
|
103 | + 'label' => esc_html__('Reports', 'event_espresso'), |
|
104 | + 'icon' => 'dashicons-chart-bar', |
|
105 | + 'order' => 30, |
|
106 | + ], |
|
107 | + 'help_tabs' => [ |
|
108 | + 'registrations_reports_help_tab' => [ |
|
109 | + 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
110 | + 'filename' => 'registrations_reports', |
|
111 | + ], |
|
112 | + ], |
|
113 | + 'require_nonce' => false, |
|
114 | + ], |
|
115 | + 'event_registrations' => [ |
|
116 | + 'nav' => [ |
|
117 | + 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
118 | + 'icon' => 'dashicons-yes-alt', |
|
119 | + 'order' => 10, |
|
120 | + 'persistent' => true, |
|
121 | + ], |
|
122 | + 'help_tabs' => [ |
|
123 | + 'registrations_event_checkin_help_tab' => [ |
|
124 | + 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
125 | + 'filename' => 'registrations_event_checkin', |
|
126 | + ], |
|
127 | + 'registrations_event_checkin_table_column_headings_help_tab' => [ |
|
128 | + 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
129 | + 'filename' => 'registrations_event_checkin_table_column_headings', |
|
130 | + ], |
|
131 | + 'registrations_event_checkin_filters_help_tab' => [ |
|
132 | + 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
133 | + 'filename' => 'registrations_event_checkin_filters', |
|
134 | + ], |
|
135 | + 'registrations_event_checkin_views_help_tab' => [ |
|
136 | + 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
137 | + 'filename' => 'registrations_event_checkin_views', |
|
138 | + ], |
|
139 | + 'registrations_event_checkin_other_help_tab' => [ |
|
140 | + 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
141 | + 'filename' => 'registrations_event_checkin_other', |
|
142 | + ], |
|
143 | + ], |
|
144 | + 'list_table' => 'EE_Event_Registrations_List_Table', |
|
145 | + 'metaboxes' => [], |
|
146 | + 'require_nonce' => false, |
|
147 | + ], |
|
148 | + 'registration_checkins' => [ |
|
149 | + 'nav' => [ |
|
150 | + 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
151 | + 'icon' => 'dashicons-list-view', |
|
152 | + 'order' => 15, |
|
153 | + 'persistent' => false, |
|
154 | + 'url' => '', |
|
155 | + ], |
|
156 | + 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
157 | + 'metaboxes' => [], |
|
158 | + 'require_nonce' => false, |
|
159 | + ], |
|
160 | + ]; |
|
161 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
162 | + $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
163 | + $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * Ajax hooks for all routes in this page. |
|
169 | + */ |
|
170 | + protected function _ajax_hooks() |
|
171 | + { |
|
172 | + parent::_ajax_hooks(); |
|
173 | + add_action('wp_ajax_get_newsletter_form_content', [$this, 'get_newsletter_form_content']); |
|
174 | + add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']); |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * Global scripts for all routes in this page. |
|
180 | + * |
|
181 | + * @throws EE_Error |
|
182 | + * *@throws ReflectionException |
|
183 | + */ |
|
184 | + public function load_scripts_styles() |
|
185 | + { |
|
186 | + parent::load_scripts_styles(); |
|
187 | + // if newsletter message type is active then let's add filter and load js for it. |
|
188 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
189 | + wp_enqueue_style( |
|
190 | + 'ee_message_shortcodes', |
|
191 | + EE_MSG_ASSETS_URL . 'ee_message_shortcodes.css', |
|
192 | + [EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN], |
|
193 | + EVENT_ESPRESSO_VERSION |
|
194 | + ); |
|
195 | + // enqueue newsletter js |
|
196 | + wp_enqueue_script( |
|
197 | + 'ee-newsletter-trigger', |
|
198 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
199 | + ['ee-dialog'], |
|
200 | + EVENT_ESPRESSO_VERSION, |
|
201 | + true |
|
202 | + ); |
|
203 | + // hook in buttons for newsletter message type trigger. |
|
204 | + add_action( |
|
205 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
206 | + [$this, 'add_newsletter_action_buttons'] |
|
207 | + ); |
|
208 | + } |
|
209 | + } |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * Scripts and styles for just the reports route. |
|
214 | + * |
|
215 | + * @throws EE_Error |
|
216 | + * @throws ReflectionException |
|
217 | + */ |
|
218 | + public function load_scripts_styles_reports() |
|
219 | + { |
|
220 | + wp_register_script( |
|
221 | + 'ee-reg-reports-js', |
|
222 | + REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
223 | + ['google-charts'], |
|
224 | + EVENT_ESPRESSO_VERSION, |
|
225 | + true |
|
226 | + ); |
|
227 | + wp_enqueue_script('ee-reg-reports-js'); |
|
228 | + $this->_registration_reports_js_setup(); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * Register screen options for event_registrations route. |
|
234 | + */ |
|
235 | + protected function _add_screen_options_event_registrations() |
|
236 | + { |
|
237 | + $this->_per_page_screen_option(); |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * Register screen options for registration_checkins route |
|
243 | + */ |
|
244 | + protected function _add_screen_options_registration_checkins() |
|
245 | + { |
|
246 | + $page_title = $this->_admin_page_title; |
|
247 | + $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
248 | + $this->_per_page_screen_option(); |
|
249 | + $this->_admin_page_title = $page_title; |
|
250 | + } |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * Set views property for event_registrations route. |
|
255 | + */ |
|
256 | + protected function _set_list_table_views_event_registrations() |
|
257 | + { |
|
258 | + $this->_views = [ |
|
259 | + 'all' => [ |
|
260 | + 'slug' => 'all', |
|
261 | + 'label' => esc_html__('All', 'event_espresso'), |
|
262 | + 'count' => 0, |
|
263 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
264 | + ? [] |
|
265 | + : [ |
|
266 | + 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
267 | + ], |
|
268 | + ], |
|
269 | + ]; |
|
270 | + } |
|
271 | + |
|
272 | + |
|
273 | + /** |
|
274 | + * Set views property for registration_checkins route. |
|
275 | + */ |
|
276 | + protected function _set_list_table_views_registration_checkins() |
|
277 | + { |
|
278 | + $this->_views = [ |
|
279 | + 'all' => [ |
|
280 | + 'slug' => 'all', |
|
281 | + 'label' => esc_html__('All', 'event_espresso'), |
|
282 | + 'count' => 0, |
|
283 | + 'bulk_action' => ['delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')], |
|
284 | + ], |
|
285 | + ]; |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * callback for ajax action. |
|
291 | + * |
|
292 | + * @return void (JSON) |
|
293 | + * @throws EE_Error |
|
294 | + * @throws ReflectionException |
|
295 | + * @since 4.3.0 |
|
296 | + */ |
|
297 | + public function get_newsletter_form_content() |
|
298 | + { |
|
299 | + if (! $this->capabilities->current_user_can('ee_read_messages', __FUNCTION__)) { |
|
300 | + wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
301 | + } |
|
302 | + // do a nonce check because we're not coming in from a normal route here. |
|
303 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
304 | + $this->_req_data['get_newsletter_form_content_nonce'] |
|
305 | + ) : ''; |
|
306 | + $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
307 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
308 | + // let's get the mtp for the incoming MTP_ ID |
|
309 | + if (! isset($this->_req_data['GRP_ID'])) { |
|
310 | + EE_Error::add_error( |
|
311 | + esc_html__( |
|
312 | + 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
313 | + 'event_espresso' |
|
314 | + ), |
|
315 | + __FILE__, |
|
316 | + __FUNCTION__, |
|
317 | + __LINE__ |
|
318 | + ); |
|
319 | + $this->_template_args['success'] = false; |
|
320 | + $this->_template_args['error'] = true; |
|
321 | + $this->_return_json(); |
|
322 | + } |
|
323 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
324 | + if (! $MTPG instanceof EE_Message_Template_Group) { |
|
325 | + EE_Error::add_error( |
|
326 | + sprintf( |
|
327 | + esc_html__( |
|
328 | + 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
329 | + 'event_espresso' |
|
330 | + ), |
|
331 | + $this->_req_data['GRP_ID'] |
|
332 | + ), |
|
333 | + __FILE__, |
|
334 | + __FUNCTION__, |
|
335 | + __LINE__ |
|
336 | + ); |
|
337 | + $this->_template_args['success'] = false; |
|
338 | + $this->_template_args['error'] = true; |
|
339 | + $this->_return_json(); |
|
340 | + } |
|
341 | + $MTPs = $MTPG->context_templates(); |
|
342 | + $MTPs = $MTPs['attendee']; |
|
343 | + $template_fields = []; |
|
344 | + /** @var EE_Message_Template $MTP */ |
|
345 | + foreach ($MTPs as $MTP) { |
|
346 | + $field = $MTP->get('MTP_template_field'); |
|
347 | + if ($field === 'content') { |
|
348 | + $content = $MTP->get('MTP_content'); |
|
349 | + if (! empty($content['newsletter_content'])) { |
|
350 | + $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
351 | + } |
|
352 | + continue; |
|
353 | + } |
|
354 | + $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
355 | + } |
|
356 | + $this->_template_args['success'] = true; |
|
357 | + $this->_template_args['error'] = false; |
|
358 | + $this->_template_args['data'] = [ |
|
359 | + 'batch_message_from' => $template_fields['from'] ?? '', |
|
360 | + 'batch_message_subject' => $template_fields['subject'] ?? '', |
|
361 | + 'batch_message_content' => $template_fields['newsletter_content'] ?? '', |
|
362 | + ]; |
|
363 | + $this->_return_json(); |
|
364 | + } |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
369 | + * |
|
370 | + * @param EE_Admin_List_Table $list_table |
|
371 | + * @return void |
|
372 | + * @since 4.3.0 |
|
373 | + */ |
|
374 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
375 | + { |
|
376 | + if ( |
|
377 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
378 | + 'ee_send_message', |
|
379 | + 'espresso_registrations_newsletter_selected_send' |
|
380 | + ) |
|
381 | + ) { |
|
382 | + return; |
|
383 | + } |
|
384 | + $routes_to_add_to = [ |
|
385 | + 'contact_list', |
|
386 | + 'event_registrations', |
|
387 | + 'default', |
|
388 | + ]; |
|
389 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
390 | + if ( |
|
391 | + ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
392 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
393 | + ) { |
|
394 | + echo ''; |
|
395 | + } else { |
|
396 | + $button_text = sprintf( |
|
397 | + esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
398 | + '<span class="send-selected-newsletter-count">0</span>' |
|
399 | + ); |
|
400 | + echo '<button id="selected-batch-send-trigger" class="button button--secondary">' |
|
401 | + . '<span class="dashicons dashicons-email "></span>' |
|
402 | + . $button_text |
|
403 | + . '</button>'; |
|
404 | + add_action('admin_footer', [$this, 'newsletter_send_form_skeleton']); |
|
405 | + } |
|
406 | + } |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * @throws DomainException |
|
412 | + * @throws EE_Error |
|
413 | + * @throws ReflectionException |
|
414 | + */ |
|
415 | + public function newsletter_send_form_skeleton() |
|
416 | + { |
|
417 | + $list_table = $this->_list_table_object; |
|
418 | + $codes = []; |
|
419 | + // need to templates for the newsletter message type for the template selector. |
|
420 | + $values[] = ['text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0]; |
|
421 | + $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
422 | + [['MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email']] |
|
423 | + ); |
|
424 | + foreach ($mtps as $mtp) { |
|
425 | + $name = $mtp->name(); |
|
426 | + $values[] = [ |
|
427 | + 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
428 | + 'id' => $mtp->ID(), |
|
429 | + ]; |
|
430 | + } |
|
431 | + // need to get a list of shortcodes that are available for the newsletter message type. |
|
432 | + $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
433 | + 'newsletter', |
|
434 | + 'email', |
|
435 | + [], |
|
436 | + 'attendee' |
|
437 | + ); |
|
438 | + |
|
439 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
440 | + $available_shortcodes = []; |
|
441 | + foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
442 | + $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
443 | + ? 'content' |
|
444 | + : strtolower($field); |
|
445 | + $field_id = "batch-message-$field_id"; |
|
446 | + $available_shortcodes[] = ' |
|
447 | 447 | <span class="js-shortcode-selection" |
448 | 448 | data-value="' . $shortcode . '" |
449 | 449 | data-linked-input-id="' . $field_id . '" |
450 | 450 | >' . $shortcode . '</span>'; |
451 | - } |
|
452 | - $codes[ $field ] = '<ul><li>' . implode('</li><li>', $available_shortcodes) . '</li></ul>'; |
|
453 | - } |
|
454 | - |
|
455 | - EEH_Template::display_template( |
|
456 | - REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php', |
|
457 | - [ |
|
458 | - 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
459 | - 'form_route' => 'newsletter_selected_send', |
|
460 | - 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
461 | - 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
462 | - 'redirect_back_to' => $this->_req_action, |
|
463 | - 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
464 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
465 | - 'shortcodes' => $codes, |
|
466 | - 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' |
|
467 | - : 'registration', |
|
468 | - ] |
|
469 | - ); |
|
470 | - } |
|
471 | - |
|
472 | - |
|
473 | - /** |
|
474 | - * Handles sending selected registrations/contacts a newsletter. |
|
475 | - * |
|
476 | - * @return void |
|
477 | - * @throws EE_Error |
|
478 | - * @throws ReflectionException |
|
479 | - * @since 4.3.0 |
|
480 | - */ |
|
481 | - protected function _newsletter_selected_send() |
|
482 | - { |
|
483 | - $success = true; |
|
484 | - // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
485 | - if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
486 | - EE_Error::add_error( |
|
487 | - esc_html__( |
|
488 | - 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
489 | - 'event_espresso' |
|
490 | - ), |
|
491 | - __FILE__, |
|
492 | - __FUNCTION__, |
|
493 | - __LINE__ |
|
494 | - ); |
|
495 | - $success = false; |
|
496 | - } |
|
497 | - if ($success) { |
|
498 | - // update Message template in case there are any changes |
|
499 | - $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
500 | - $this->_req_data['newsletter_mtp_selected'] |
|
501 | - ); |
|
502 | - $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
503 | - ? $Message_Template_Group->context_templates() |
|
504 | - : []; |
|
505 | - if (empty($Message_Templates)) { |
|
506 | - EE_Error::add_error( |
|
507 | - esc_html__( |
|
508 | - 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
509 | - 'event_espresso' |
|
510 | - ), |
|
511 | - __FILE__, |
|
512 | - __FUNCTION__, |
|
513 | - __LINE__ |
|
514 | - ); |
|
515 | - } |
|
516 | - // let's just update the specific fields |
|
517 | - foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
518 | - if ($Message_Template instanceof EE_Message_Template) { |
|
519 | - $field = $Message_Template->get('MTP_template_field'); |
|
520 | - $content = $Message_Template->get('MTP_content'); |
|
521 | - switch ($field) { |
|
522 | - case 'from': |
|
523 | - $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
524 | - ? $this->_req_data['batch_message']['from'] |
|
525 | - : $content; |
|
526 | - break; |
|
527 | - case 'subject': |
|
528 | - $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
529 | - ? $this->_req_data['batch_message']['subject'] |
|
530 | - : $content; |
|
531 | - break; |
|
532 | - case 'content': |
|
533 | - $new_content = $content; |
|
534 | - $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
535 | - ? $this->_req_data['batch_message']['content'] |
|
536 | - : $content['newsletter_content']; |
|
537 | - break; |
|
538 | - default: |
|
539 | - // continue the foreach loop, we don't want to set $new_content nor save. |
|
540 | - continue 2; |
|
541 | - } |
|
542 | - $Message_Template->set('MTP_content', $new_content); |
|
543 | - $Message_Template->save(); |
|
544 | - } |
|
545 | - } |
|
546 | - // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
547 | - $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
548 | - ? $this->_req_data['batch_message']['id_type'] |
|
549 | - : 'registration'; |
|
550 | - // id_type will affect how we assemble the ids. |
|
551 | - $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
552 | - ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
553 | - : []; |
|
554 | - $registrations_used_for_contact_data = []; |
|
555 | - // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
556 | - switch ($id_type) { |
|
557 | - case 'registration': |
|
558 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
559 | - [ |
|
560 | - [ |
|
561 | - 'REG_ID' => ['IN', $ids], |
|
562 | - ], |
|
563 | - ] |
|
564 | - ); |
|
565 | - break; |
|
566 | - case 'contact': |
|
567 | - $registrations_used_for_contact_data = EEM_Registration::instance() |
|
568 | - ->get_latest_registration_for_each_of_given_contacts( |
|
569 | - $ids |
|
570 | - ); |
|
571 | - break; |
|
572 | - } |
|
573 | - do_action_ref_array( |
|
574 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
575 | - [ |
|
576 | - $registrations_used_for_contact_data, |
|
577 | - $Message_Template_Group->ID(), |
|
578 | - ] |
|
579 | - ); |
|
580 | - // kept for backward compat, internally we no longer use this action. |
|
581 | - // @deprecated 4.8.36.rc.002 |
|
582 | - $contacts = $id_type === 'registration' |
|
583 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
584 | - : EEM_Attendee::instance()->get_all([['ATT_ID' => ['in', $ids]]]); |
|
585 | - do_action_ref_array( |
|
586 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
587 | - [ |
|
588 | - $contacts, |
|
589 | - $Message_Template_Group->ID(), |
|
590 | - ] |
|
591 | - ); |
|
592 | - } |
|
593 | - $query_args = [ |
|
594 | - 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
595 | - ? $this->_req_data['redirect_back_to'] |
|
596 | - : 'default', |
|
597 | - ]; |
|
598 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
599 | - } |
|
600 | - |
|
601 | - |
|
602 | - /** |
|
603 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
604 | - * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
605 | - * |
|
606 | - * @throws EE_Error |
|
607 | - * @throws ReflectionException |
|
608 | - */ |
|
609 | - protected function _registration_reports_js_setup() |
|
610 | - { |
|
611 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
612 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
613 | - } |
|
614 | - |
|
615 | - |
|
616 | - /** |
|
617 | - * generates Business Reports regarding Registrations |
|
618 | - * |
|
619 | - * @return void |
|
620 | - * @throws DomainException |
|
621 | - * @throws EE_Error |
|
622 | - */ |
|
623 | - protected function _registration_reports() |
|
624 | - { |
|
625 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
626 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
627 | - $template_path, |
|
628 | - $this->_reports_template_data, |
|
629 | - true |
|
630 | - ); |
|
631 | - // the final template wrapper |
|
632 | - $this->display_admin_page_with_no_sidebar(); |
|
633 | - } |
|
634 | - |
|
635 | - |
|
636 | - /** |
|
637 | - * Generates Business Report showing total registrations per day. |
|
638 | - * |
|
639 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
640 | - * @return string |
|
641 | - * @throws EE_Error |
|
642 | - * @throws ReflectionException |
|
643 | - * @throws Exception |
|
644 | - * @throws Exception |
|
645 | - * @throws Exception |
|
646 | - */ |
|
647 | - private function _registrations_per_day_report(string $period = '-1 month'): string |
|
648 | - { |
|
649 | - $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
650 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
651 | - $regs = []; |
|
652 | - $subtitle = ''; |
|
653 | - if ($results) { |
|
654 | - $column_titles = []; |
|
655 | - $tracker = 0; |
|
656 | - foreach ($results as $result) { |
|
657 | - $report_column_values = []; |
|
658 | - foreach ($result as $property_name => $property_value) { |
|
659 | - $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
660 | - : (int) $property_value; |
|
661 | - $report_column_values[] = $property_value; |
|
662 | - if ($tracker === 0) { |
|
663 | - if ($property_name === 'Registration_REG_date') { |
|
664 | - $column_titles[] = esc_html__( |
|
665 | - 'Date (only days with registrations are shown)', |
|
666 | - 'event_espresso' |
|
667 | - ); |
|
668 | - } else { |
|
669 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
670 | - } |
|
671 | - } |
|
672 | - } |
|
673 | - $tracker++; |
|
674 | - $regs[] = $report_column_values; |
|
675 | - } |
|
676 | - // make sure the column_titles is pushed to the beginning of the array |
|
677 | - array_unshift($regs, $column_titles); |
|
678 | - // setup the date range. |
|
679 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
680 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
681 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
682 | - $subtitle = sprintf( |
|
683 | - wp_strip_all_tags( |
|
684 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
685 | - ), |
|
686 | - $beginning_date->format('Y-m-d'), |
|
687 | - $ending_date->format('Y-m-d') |
|
688 | - ); |
|
689 | - } |
|
690 | - $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
691 | - $report_params = [ |
|
692 | - 'title' => $report_title, |
|
693 | - 'subtitle' => $subtitle, |
|
694 | - 'id' => $report_ID, |
|
695 | - 'regs' => $regs, |
|
696 | - 'noResults' => empty($regs), |
|
697 | - 'noRegsMsg' => sprintf( |
|
698 | - wp_strip_all_tags( |
|
699 | - __( |
|
700 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
701 | - 'event_espresso' |
|
702 | - ) |
|
703 | - ), |
|
704 | - '<h2>' . $report_title . '</h2><p>', |
|
705 | - '</p>' |
|
706 | - ), |
|
707 | - ]; |
|
708 | - wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
709 | - return $report_ID; |
|
710 | - } |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * Generates Business Report showing total registrations per event. |
|
715 | - * |
|
716 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
717 | - * @return string |
|
718 | - * @throws EE_Error |
|
719 | - * @throws ReflectionException |
|
720 | - * @throws Exception |
|
721 | - * @throws Exception |
|
722 | - * @throws Exception |
|
723 | - */ |
|
724 | - private function _registrations_per_event_report(string $period = '-1 month'): string |
|
725 | - { |
|
726 | - $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
727 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
728 | - $regs = []; |
|
729 | - $subtitle = ''; |
|
730 | - if ($results) { |
|
731 | - $column_titles = []; |
|
732 | - $tracker = 0; |
|
733 | - foreach ($results as $result) { |
|
734 | - $report_column_values = []; |
|
735 | - foreach ($result as $property_name => $property_value) { |
|
736 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
737 | - $property_value, |
|
738 | - 4, |
|
739 | - '...' |
|
740 | - ) : (int) $property_value; |
|
741 | - $report_column_values[] = $property_value; |
|
742 | - if ($tracker === 0) { |
|
743 | - if ($property_name === 'Registration_Event') { |
|
744 | - $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
745 | - } else { |
|
746 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
747 | - } |
|
748 | - } |
|
749 | - } |
|
750 | - $tracker++; |
|
751 | - $regs[] = $report_column_values; |
|
752 | - } |
|
753 | - // make sure the column_titles is pushed to the beginning of the array |
|
754 | - array_unshift($regs, $column_titles); |
|
755 | - // setup the date range. |
|
756 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
757 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
758 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
759 | - $subtitle = sprintf( |
|
760 | - wp_strip_all_tags( |
|
761 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
762 | - ), |
|
763 | - $beginning_date->format('Y-m-d'), |
|
764 | - $ending_date->format('Y-m-d') |
|
765 | - ); |
|
766 | - } |
|
767 | - $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
768 | - $report_params = [ |
|
769 | - 'title' => $report_title, |
|
770 | - 'subtitle' => $subtitle, |
|
771 | - 'id' => $report_ID, |
|
772 | - 'regs' => $regs, |
|
773 | - 'noResults' => empty($regs), |
|
774 | - 'noRegsMsg' => sprintf( |
|
775 | - wp_strip_all_tags( |
|
776 | - __( |
|
777 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
778 | - 'event_espresso' |
|
779 | - ) |
|
780 | - ), |
|
781 | - '<h2>' . $report_title . '</h2><p>', |
|
782 | - '</p>' |
|
783 | - ), |
|
784 | - ]; |
|
785 | - wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
786 | - return $report_ID; |
|
787 | - } |
|
788 | - |
|
789 | - |
|
790 | - /** |
|
791 | - * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
792 | - * |
|
793 | - * @return void |
|
794 | - * @throws EE_Error |
|
795 | - * @throws EntityNotFoundException |
|
796 | - * @throws ReflectionException |
|
797 | - */ |
|
798 | - protected function _registration_checkin_list_table() |
|
799 | - { |
|
800 | - $REG_ID = $this->request->getRequestParam('_REG_ID', 0, DataType::INTEGER); |
|
801 | - /** @var EE_Registration $registration */ |
|
802 | - $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
803 | - if (! $registration instanceof EE_Registration) { |
|
804 | - throw new EE_Error( |
|
805 | - sprintf( |
|
806 | - esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
807 | - $REG_ID |
|
808 | - ) |
|
809 | - ); |
|
810 | - } |
|
811 | - $attendee = $registration->attendee(); |
|
812 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
813 | - 'new_registration', |
|
814 | - 'add-registrant', |
|
815 | - ['event_id' => $registration->event_ID()], |
|
816 | - 'add-new-h2' |
|
817 | - ); |
|
818 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
819 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
820 | - $legend_items = [ |
|
821 | - 'checkin' => [ |
|
822 | - 'class' => $checked_in->cssClasses(), |
|
823 | - 'desc' => $checked_in->legendLabel(), |
|
824 | - ], |
|
825 | - 'checkout' => [ |
|
826 | - 'class' => $checked_out->cssClasses(), |
|
827 | - 'desc' => $checked_out->legendLabel(), |
|
828 | - ], |
|
829 | - ]; |
|
830 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
831 | - |
|
832 | - $DTT_ID = $this->request->getRequestParam('DTT_ID', 0, DataType::INTEGER); |
|
833 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
834 | - $datetime_label = ''; |
|
835 | - if ($datetime instanceof EE_Datetime) { |
|
836 | - $datetime_label = $datetime->get_dtt_display_name(true); |
|
837 | - $datetime_label .= ! empty($datetime_label) |
|
838 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
839 | - : $datetime->get_dtt_display_name(); |
|
840 | - } |
|
841 | - $datetime_link = ! $DTT_ID |
|
842 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
843 | - [ |
|
844 | - 'action' => 'event_registrations', |
|
845 | - 'event_id' => $registration->event_ID(), |
|
846 | - 'DTT_ID' => $DTT_ID, |
|
847 | - ], |
|
848 | - $this->_admin_base_url |
|
849 | - ) |
|
850 | - : ''; |
|
851 | - $datetime_link = ! empty($datetime_link) |
|
852 | - ? '<a href="' . $datetime_link . '">' |
|
853 | - . '<span id="checkin-dtt">' |
|
854 | - . $datetime_label |
|
855 | - . '</span></a>' |
|
856 | - : $datetime_label; |
|
857 | - $attendee_name = $attendee instanceof EE_Attendee |
|
858 | - ? $attendee->full_name() |
|
859 | - : ''; |
|
860 | - $attendee_link = $attendee instanceof EE_Attendee |
|
861 | - ? $attendee->get_admin_details_link() |
|
862 | - : ''; |
|
863 | - $attendee_link = ! empty($attendee_link) |
|
864 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
865 | - . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
866 | - . '<span id="checkin-attendee-name">' |
|
867 | - . $attendee_name |
|
868 | - . '</span></a>' |
|
869 | - : ''; |
|
870 | - $event_link = $registration->event() instanceof EE_Event |
|
871 | - ? $registration->event()->get_admin_details_link() |
|
872 | - : ''; |
|
873 | - $event_link = ! empty($event_link) |
|
874 | - ? '<a href="' . $event_link . '"' |
|
875 | - . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
876 | - . '<span id="checkin-event-name">' |
|
877 | - . $registration->event_name() |
|
878 | - . '</span>' |
|
879 | - . '</a>' |
|
880 | - : ''; |
|
881 | - $this->_template_args['before_list_table'] = $REG_ID && $DTT_ID |
|
882 | - ? '<h2>' . sprintf( |
|
883 | - esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
884 | - $attendee_link, |
|
885 | - $datetime_link, |
|
886 | - $event_link |
|
887 | - ) . '</h2>' |
|
888 | - : ''; |
|
889 | - $this->_template_args['list_table_hidden_fields'] = $REG_ID |
|
890 | - ? '<input type="hidden" name="_REG_ID" value="' . $REG_ID . '">' |
|
891 | - : ''; |
|
892 | - $this->_template_args['list_table_hidden_fields'] .= $DTT_ID |
|
893 | - ? '<input type="hidden" name="DTT_ID" value="' . $DTT_ID . '">' |
|
894 | - : ''; |
|
895 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
896 | - } |
|
897 | - |
|
898 | - |
|
899 | - /** |
|
900 | - * toggle the Check-in status for the given registration (coming from ajax) |
|
901 | - * |
|
902 | - * @return void (JSON) |
|
903 | - * @throws EE_Error |
|
904 | - * @throws ReflectionException |
|
905 | - */ |
|
906 | - public function toggle_checkin_status() |
|
907 | - { |
|
908 | - if (! $this->capabilities->current_user_can('ee_edit_checkins', __FUNCTION__)) { |
|
909 | - wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
910 | - } |
|
911 | - // first make sure we have the necessary data |
|
912 | - if (! isset($this->_req_data['_regid'])) { |
|
913 | - EE_Error::add_error( |
|
914 | - esc_html__( |
|
915 | - 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
916 | - 'event_espresso' |
|
917 | - ), |
|
918 | - __FILE__, |
|
919 | - __FUNCTION__, |
|
920 | - __LINE__ |
|
921 | - ); |
|
922 | - $this->_template_args['success'] = false; |
|
923 | - $this->_template_args['error'] = true; |
|
924 | - $this->_return_json(); |
|
925 | - } |
|
926 | - // do a nonce check because we're not coming in from a normal route here. |
|
927 | - $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
928 | - : ''; |
|
929 | - $nonce_ref = 'checkin_nonce'; |
|
930 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
931 | - // beautiful! Made it this far so let's get the status. |
|
932 | - $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
933 | - // setup new class to return via ajax |
|
934 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
935 | - $this->_template_args['success'] = true; |
|
936 | - $this->_return_json(); |
|
937 | - } |
|
938 | - |
|
939 | - |
|
940 | - /** |
|
941 | - * handles toggling the checkin status for the registration, |
|
942 | - * |
|
943 | - * @return int|void |
|
944 | - * @throws EE_Error |
|
945 | - * @throws ReflectionException |
|
946 | - */ |
|
947 | - protected function _toggle_checkin_status() |
|
948 | - { |
|
949 | - // first let's get the query args out of the way for the redirect |
|
950 | - $query_args = [ |
|
951 | - 'action' => 'event_registrations', |
|
952 | - 'event_id' => $this->_req_data['event_id'] ?? null, |
|
953 | - 'DTT_ID' => $this->_req_data['DTT_ID'] ?? null, |
|
954 | - ]; |
|
955 | - $new_status = false; |
|
956 | - // bulk action check in toggle |
|
957 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
958 | - // cycle thru checkboxes |
|
959 | - $checkboxes = $this->_req_data['checkbox']; |
|
960 | - foreach (array_keys($checkboxes) as $REG_ID) { |
|
961 | - $DTT_ID = $this->_req_data['DTT_ID'] ?? null; |
|
962 | - $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
963 | - } |
|
964 | - } elseif (isset($this->_req_data['_regid'])) { |
|
965 | - // coming from ajax request |
|
966 | - $DTT_ID = $this->_req_data['dttid'] ?? null; |
|
967 | - $query_args['DTT_ID'] = $DTT_ID; |
|
968 | - $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
969 | - } else { |
|
970 | - EE_Error::add_error( |
|
971 | - esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
972 | - __FILE__, |
|
973 | - __FUNCTION__, |
|
974 | - __LINE__ |
|
975 | - ); |
|
976 | - } |
|
977 | - if (defined('DOING_AJAX')) { |
|
978 | - return $new_status; |
|
979 | - } |
|
980 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
981 | - } |
|
982 | - |
|
983 | - |
|
984 | - /** |
|
985 | - * This is toggles a single Check-in for the given registration and datetime. |
|
986 | - * |
|
987 | - * @param int $REG_ID The registration we're toggling |
|
988 | - * @param int $DTT_ID The datetime we're toggling |
|
989 | - * @return int The new status toggled to. |
|
990 | - * @throws EE_Error |
|
991 | - * @throws ReflectionException |
|
992 | - */ |
|
993 | - private function _toggle_checkin(int $REG_ID, int $DTT_ID) |
|
994 | - { |
|
995 | - /** @var EE_Registration $REG */ |
|
996 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
997 | - $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
998 | - if ($new_status !== false) { |
|
999 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
1000 | - } else { |
|
1001 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
1002 | - $new_status = false; |
|
1003 | - } |
|
1004 | - return $new_status; |
|
1005 | - } |
|
1006 | - |
|
1007 | - |
|
1008 | - /** |
|
1009 | - * Takes care of deleting multiple EE_Checkin table rows |
|
1010 | - * |
|
1011 | - * @return void |
|
1012 | - * @throws EE_Error |
|
1013 | - * @throws ReflectionException |
|
1014 | - */ |
|
1015 | - protected function _delete_checkin_rows() |
|
1016 | - { |
|
1017 | - $query_args = [ |
|
1018 | - 'action' => 'registration_checkins', |
|
1019 | - 'DTT_ID' => $this->_req_data['DTT_ID'] ?? 0, |
|
1020 | - '_REG_ID' => $this->_req_data['_REG_ID'] ?? 0, |
|
1021 | - ]; |
|
1022 | - $errors = 0; |
|
1023 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1024 | - $checkboxes = $this->_req_data['checkbox']; |
|
1025 | - foreach (array_keys($checkboxes) as $CHK_ID) { |
|
1026 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1027 | - $errors++; |
|
1028 | - } |
|
1029 | - } |
|
1030 | - } else { |
|
1031 | - EE_Error::add_error( |
|
1032 | - esc_html__( |
|
1033 | - 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
1034 | - 'event_espresso' |
|
1035 | - ), |
|
1036 | - __FILE__, |
|
1037 | - __FUNCTION__, |
|
1038 | - __LINE__ |
|
1039 | - ); |
|
1040 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1041 | - } |
|
1042 | - if ($errors > 0) { |
|
1043 | - EE_Error::add_error( |
|
1044 | - sprintf( |
|
1045 | - esc_html__('There were %d records that did not delete successfully', 'event_espresso'), |
|
1046 | - $errors |
|
1047 | - ), |
|
1048 | - __FILE__, |
|
1049 | - __FUNCTION__, |
|
1050 | - __LINE__ |
|
1051 | - ); |
|
1052 | - } else { |
|
1053 | - EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
1054 | - } |
|
1055 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1056 | - } |
|
1057 | - |
|
1058 | - |
|
1059 | - /** |
|
1060 | - * Deletes a single EE_Checkin row |
|
1061 | - * |
|
1062 | - * @return void |
|
1063 | - * @throws EE_Error |
|
1064 | - * @throws ReflectionException |
|
1065 | - */ |
|
1066 | - protected function _delete_checkin_row() |
|
1067 | - { |
|
1068 | - $query_args = [ |
|
1069 | - 'action' => 'registration_checkins', |
|
1070 | - 'DTT_ID' => $this->_req_data['DTT_ID'] ?? 0, |
|
1071 | - '_REG_ID' => $this->_req_data['_REG_ID'] ?? 0, |
|
1072 | - ]; |
|
1073 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
1074 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1075 | - EE_Error::add_error( |
|
1076 | - esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1077 | - __FILE__, |
|
1078 | - __FUNCTION__, |
|
1079 | - __LINE__ |
|
1080 | - ); |
|
1081 | - } else { |
|
1082 | - EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
1083 | - } |
|
1084 | - } else { |
|
1085 | - EE_Error::add_error( |
|
1086 | - esc_html__( |
|
1087 | - 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1088 | - 'event_espresso' |
|
1089 | - ), |
|
1090 | - __FILE__, |
|
1091 | - __FUNCTION__, |
|
1092 | - __LINE__ |
|
1093 | - ); |
|
1094 | - } |
|
1095 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1096 | - } |
|
1097 | - |
|
1098 | - |
|
1099 | - /** |
|
1100 | - * @return void |
|
1101 | - * @throws EE_Error |
|
1102 | - */ |
|
1103 | - protected function _event_registrations_list_table() |
|
1104 | - { |
|
1105 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, DataType::INTEGER); |
|
1106 | - $this->_admin_page_title .= $EVT_ID |
|
1107 | - ? $this->get_action_link_or_button( |
|
1108 | - 'new_registration', |
|
1109 | - 'add-registrant', |
|
1110 | - ['event_id' => $EVT_ID], |
|
1111 | - 'add-new-h2' |
|
1112 | - ) |
|
1113 | - : ''; |
|
1114 | - |
|
1115 | - $this->_template_args['before_list_table'] = $this->generateListTableHeaderText(); |
|
1116 | - $this->_template_args['after_list_table'] = $this->generateListTableLegend(); |
|
1117 | - |
|
1118 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1119 | - } |
|
1120 | - |
|
1121 | - |
|
1122 | - /** |
|
1123 | - * @return string |
|
1124 | - * @since 5.0.24.p |
|
1125 | - */ |
|
1126 | - private function generateListTableHeaderText(): string |
|
1127 | - { |
|
1128 | - $header_text = ''; |
|
1129 | - $admin_page_header_decorators = [ |
|
1130 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader', |
|
1131 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader', |
|
1132 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader', |
|
1133 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader', |
|
1134 | - ]; |
|
1135 | - foreach ($admin_page_header_decorators as $admin_page_header_decorator) { |
|
1136 | - $filter_header_decorator = $this->loader->getNew($admin_page_header_decorator); |
|
1137 | - $header_text = $filter_header_decorator->getHeaderText($header_text); |
|
1138 | - } |
|
1139 | - $header_text .= ' |
|
451 | + } |
|
452 | + $codes[ $field ] = '<ul><li>' . implode('</li><li>', $available_shortcodes) . '</li></ul>'; |
|
453 | + } |
|
454 | + |
|
455 | + EEH_Template::display_template( |
|
456 | + REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php', |
|
457 | + [ |
|
458 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
459 | + 'form_route' => 'newsletter_selected_send', |
|
460 | + 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
461 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
462 | + 'redirect_back_to' => $this->_req_action, |
|
463 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
464 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
465 | + 'shortcodes' => $codes, |
|
466 | + 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' |
|
467 | + : 'registration', |
|
468 | + ] |
|
469 | + ); |
|
470 | + } |
|
471 | + |
|
472 | + |
|
473 | + /** |
|
474 | + * Handles sending selected registrations/contacts a newsletter. |
|
475 | + * |
|
476 | + * @return void |
|
477 | + * @throws EE_Error |
|
478 | + * @throws ReflectionException |
|
479 | + * @since 4.3.0 |
|
480 | + */ |
|
481 | + protected function _newsletter_selected_send() |
|
482 | + { |
|
483 | + $success = true; |
|
484 | + // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
485 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
486 | + EE_Error::add_error( |
|
487 | + esc_html__( |
|
488 | + 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
489 | + 'event_espresso' |
|
490 | + ), |
|
491 | + __FILE__, |
|
492 | + __FUNCTION__, |
|
493 | + __LINE__ |
|
494 | + ); |
|
495 | + $success = false; |
|
496 | + } |
|
497 | + if ($success) { |
|
498 | + // update Message template in case there are any changes |
|
499 | + $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
500 | + $this->_req_data['newsletter_mtp_selected'] |
|
501 | + ); |
|
502 | + $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
503 | + ? $Message_Template_Group->context_templates() |
|
504 | + : []; |
|
505 | + if (empty($Message_Templates)) { |
|
506 | + EE_Error::add_error( |
|
507 | + esc_html__( |
|
508 | + 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
509 | + 'event_espresso' |
|
510 | + ), |
|
511 | + __FILE__, |
|
512 | + __FUNCTION__, |
|
513 | + __LINE__ |
|
514 | + ); |
|
515 | + } |
|
516 | + // let's just update the specific fields |
|
517 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
518 | + if ($Message_Template instanceof EE_Message_Template) { |
|
519 | + $field = $Message_Template->get('MTP_template_field'); |
|
520 | + $content = $Message_Template->get('MTP_content'); |
|
521 | + switch ($field) { |
|
522 | + case 'from': |
|
523 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
524 | + ? $this->_req_data['batch_message']['from'] |
|
525 | + : $content; |
|
526 | + break; |
|
527 | + case 'subject': |
|
528 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
529 | + ? $this->_req_data['batch_message']['subject'] |
|
530 | + : $content; |
|
531 | + break; |
|
532 | + case 'content': |
|
533 | + $new_content = $content; |
|
534 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
535 | + ? $this->_req_data['batch_message']['content'] |
|
536 | + : $content['newsletter_content']; |
|
537 | + break; |
|
538 | + default: |
|
539 | + // continue the foreach loop, we don't want to set $new_content nor save. |
|
540 | + continue 2; |
|
541 | + } |
|
542 | + $Message_Template->set('MTP_content', $new_content); |
|
543 | + $Message_Template->save(); |
|
544 | + } |
|
545 | + } |
|
546 | + // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
547 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
548 | + ? $this->_req_data['batch_message']['id_type'] |
|
549 | + : 'registration'; |
|
550 | + // id_type will affect how we assemble the ids. |
|
551 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
552 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
553 | + : []; |
|
554 | + $registrations_used_for_contact_data = []; |
|
555 | + // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
556 | + switch ($id_type) { |
|
557 | + case 'registration': |
|
558 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
559 | + [ |
|
560 | + [ |
|
561 | + 'REG_ID' => ['IN', $ids], |
|
562 | + ], |
|
563 | + ] |
|
564 | + ); |
|
565 | + break; |
|
566 | + case 'contact': |
|
567 | + $registrations_used_for_contact_data = EEM_Registration::instance() |
|
568 | + ->get_latest_registration_for_each_of_given_contacts( |
|
569 | + $ids |
|
570 | + ); |
|
571 | + break; |
|
572 | + } |
|
573 | + do_action_ref_array( |
|
574 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
575 | + [ |
|
576 | + $registrations_used_for_contact_data, |
|
577 | + $Message_Template_Group->ID(), |
|
578 | + ] |
|
579 | + ); |
|
580 | + // kept for backward compat, internally we no longer use this action. |
|
581 | + // @deprecated 4.8.36.rc.002 |
|
582 | + $contacts = $id_type === 'registration' |
|
583 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
584 | + : EEM_Attendee::instance()->get_all([['ATT_ID' => ['in', $ids]]]); |
|
585 | + do_action_ref_array( |
|
586 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
587 | + [ |
|
588 | + $contacts, |
|
589 | + $Message_Template_Group->ID(), |
|
590 | + ] |
|
591 | + ); |
|
592 | + } |
|
593 | + $query_args = [ |
|
594 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
595 | + ? $this->_req_data['redirect_back_to'] |
|
596 | + : 'default', |
|
597 | + ]; |
|
598 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
599 | + } |
|
600 | + |
|
601 | + |
|
602 | + /** |
|
603 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
604 | + * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
605 | + * |
|
606 | + * @throws EE_Error |
|
607 | + * @throws ReflectionException |
|
608 | + */ |
|
609 | + protected function _registration_reports_js_setup() |
|
610 | + { |
|
611 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
612 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
613 | + } |
|
614 | + |
|
615 | + |
|
616 | + /** |
|
617 | + * generates Business Reports regarding Registrations |
|
618 | + * |
|
619 | + * @return void |
|
620 | + * @throws DomainException |
|
621 | + * @throws EE_Error |
|
622 | + */ |
|
623 | + protected function _registration_reports() |
|
624 | + { |
|
625 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
626 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
627 | + $template_path, |
|
628 | + $this->_reports_template_data, |
|
629 | + true |
|
630 | + ); |
|
631 | + // the final template wrapper |
|
632 | + $this->display_admin_page_with_no_sidebar(); |
|
633 | + } |
|
634 | + |
|
635 | + |
|
636 | + /** |
|
637 | + * Generates Business Report showing total registrations per day. |
|
638 | + * |
|
639 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
640 | + * @return string |
|
641 | + * @throws EE_Error |
|
642 | + * @throws ReflectionException |
|
643 | + * @throws Exception |
|
644 | + * @throws Exception |
|
645 | + * @throws Exception |
|
646 | + */ |
|
647 | + private function _registrations_per_day_report(string $period = '-1 month'): string |
|
648 | + { |
|
649 | + $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
650 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
651 | + $regs = []; |
|
652 | + $subtitle = ''; |
|
653 | + if ($results) { |
|
654 | + $column_titles = []; |
|
655 | + $tracker = 0; |
|
656 | + foreach ($results as $result) { |
|
657 | + $report_column_values = []; |
|
658 | + foreach ($result as $property_name => $property_value) { |
|
659 | + $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
660 | + : (int) $property_value; |
|
661 | + $report_column_values[] = $property_value; |
|
662 | + if ($tracker === 0) { |
|
663 | + if ($property_name === 'Registration_REG_date') { |
|
664 | + $column_titles[] = esc_html__( |
|
665 | + 'Date (only days with registrations are shown)', |
|
666 | + 'event_espresso' |
|
667 | + ); |
|
668 | + } else { |
|
669 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
670 | + } |
|
671 | + } |
|
672 | + } |
|
673 | + $tracker++; |
|
674 | + $regs[] = $report_column_values; |
|
675 | + } |
|
676 | + // make sure the column_titles is pushed to the beginning of the array |
|
677 | + array_unshift($regs, $column_titles); |
|
678 | + // setup the date range. |
|
679 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
680 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
681 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
682 | + $subtitle = sprintf( |
|
683 | + wp_strip_all_tags( |
|
684 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
685 | + ), |
|
686 | + $beginning_date->format('Y-m-d'), |
|
687 | + $ending_date->format('Y-m-d') |
|
688 | + ); |
|
689 | + } |
|
690 | + $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
691 | + $report_params = [ |
|
692 | + 'title' => $report_title, |
|
693 | + 'subtitle' => $subtitle, |
|
694 | + 'id' => $report_ID, |
|
695 | + 'regs' => $regs, |
|
696 | + 'noResults' => empty($regs), |
|
697 | + 'noRegsMsg' => sprintf( |
|
698 | + wp_strip_all_tags( |
|
699 | + __( |
|
700 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
701 | + 'event_espresso' |
|
702 | + ) |
|
703 | + ), |
|
704 | + '<h2>' . $report_title . '</h2><p>', |
|
705 | + '</p>' |
|
706 | + ), |
|
707 | + ]; |
|
708 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
709 | + return $report_ID; |
|
710 | + } |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * Generates Business Report showing total registrations per event. |
|
715 | + * |
|
716 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
717 | + * @return string |
|
718 | + * @throws EE_Error |
|
719 | + * @throws ReflectionException |
|
720 | + * @throws Exception |
|
721 | + * @throws Exception |
|
722 | + * @throws Exception |
|
723 | + */ |
|
724 | + private function _registrations_per_event_report(string $period = '-1 month'): string |
|
725 | + { |
|
726 | + $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
727 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
728 | + $regs = []; |
|
729 | + $subtitle = ''; |
|
730 | + if ($results) { |
|
731 | + $column_titles = []; |
|
732 | + $tracker = 0; |
|
733 | + foreach ($results as $result) { |
|
734 | + $report_column_values = []; |
|
735 | + foreach ($result as $property_name => $property_value) { |
|
736 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
737 | + $property_value, |
|
738 | + 4, |
|
739 | + '...' |
|
740 | + ) : (int) $property_value; |
|
741 | + $report_column_values[] = $property_value; |
|
742 | + if ($tracker === 0) { |
|
743 | + if ($property_name === 'Registration_Event') { |
|
744 | + $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
745 | + } else { |
|
746 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
747 | + } |
|
748 | + } |
|
749 | + } |
|
750 | + $tracker++; |
|
751 | + $regs[] = $report_column_values; |
|
752 | + } |
|
753 | + // make sure the column_titles is pushed to the beginning of the array |
|
754 | + array_unshift($regs, $column_titles); |
|
755 | + // setup the date range. |
|
756 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
757 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
758 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
759 | + $subtitle = sprintf( |
|
760 | + wp_strip_all_tags( |
|
761 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
762 | + ), |
|
763 | + $beginning_date->format('Y-m-d'), |
|
764 | + $ending_date->format('Y-m-d') |
|
765 | + ); |
|
766 | + } |
|
767 | + $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
768 | + $report_params = [ |
|
769 | + 'title' => $report_title, |
|
770 | + 'subtitle' => $subtitle, |
|
771 | + 'id' => $report_ID, |
|
772 | + 'regs' => $regs, |
|
773 | + 'noResults' => empty($regs), |
|
774 | + 'noRegsMsg' => sprintf( |
|
775 | + wp_strip_all_tags( |
|
776 | + __( |
|
777 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
778 | + 'event_espresso' |
|
779 | + ) |
|
780 | + ), |
|
781 | + '<h2>' . $report_title . '</h2><p>', |
|
782 | + '</p>' |
|
783 | + ), |
|
784 | + ]; |
|
785 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
786 | + return $report_ID; |
|
787 | + } |
|
788 | + |
|
789 | + |
|
790 | + /** |
|
791 | + * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
792 | + * |
|
793 | + * @return void |
|
794 | + * @throws EE_Error |
|
795 | + * @throws EntityNotFoundException |
|
796 | + * @throws ReflectionException |
|
797 | + */ |
|
798 | + protected function _registration_checkin_list_table() |
|
799 | + { |
|
800 | + $REG_ID = $this->request->getRequestParam('_REG_ID', 0, DataType::INTEGER); |
|
801 | + /** @var EE_Registration $registration */ |
|
802 | + $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
803 | + if (! $registration instanceof EE_Registration) { |
|
804 | + throw new EE_Error( |
|
805 | + sprintf( |
|
806 | + esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
807 | + $REG_ID |
|
808 | + ) |
|
809 | + ); |
|
810 | + } |
|
811 | + $attendee = $registration->attendee(); |
|
812 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
813 | + 'new_registration', |
|
814 | + 'add-registrant', |
|
815 | + ['event_id' => $registration->event_ID()], |
|
816 | + 'add-new-h2' |
|
817 | + ); |
|
818 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
819 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
820 | + $legend_items = [ |
|
821 | + 'checkin' => [ |
|
822 | + 'class' => $checked_in->cssClasses(), |
|
823 | + 'desc' => $checked_in->legendLabel(), |
|
824 | + ], |
|
825 | + 'checkout' => [ |
|
826 | + 'class' => $checked_out->cssClasses(), |
|
827 | + 'desc' => $checked_out->legendLabel(), |
|
828 | + ], |
|
829 | + ]; |
|
830 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
831 | + |
|
832 | + $DTT_ID = $this->request->getRequestParam('DTT_ID', 0, DataType::INTEGER); |
|
833 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
834 | + $datetime_label = ''; |
|
835 | + if ($datetime instanceof EE_Datetime) { |
|
836 | + $datetime_label = $datetime->get_dtt_display_name(true); |
|
837 | + $datetime_label .= ! empty($datetime_label) |
|
838 | + ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
839 | + : $datetime->get_dtt_display_name(); |
|
840 | + } |
|
841 | + $datetime_link = ! $DTT_ID |
|
842 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
843 | + [ |
|
844 | + 'action' => 'event_registrations', |
|
845 | + 'event_id' => $registration->event_ID(), |
|
846 | + 'DTT_ID' => $DTT_ID, |
|
847 | + ], |
|
848 | + $this->_admin_base_url |
|
849 | + ) |
|
850 | + : ''; |
|
851 | + $datetime_link = ! empty($datetime_link) |
|
852 | + ? '<a href="' . $datetime_link . '">' |
|
853 | + . '<span id="checkin-dtt">' |
|
854 | + . $datetime_label |
|
855 | + . '</span></a>' |
|
856 | + : $datetime_label; |
|
857 | + $attendee_name = $attendee instanceof EE_Attendee |
|
858 | + ? $attendee->full_name() |
|
859 | + : ''; |
|
860 | + $attendee_link = $attendee instanceof EE_Attendee |
|
861 | + ? $attendee->get_admin_details_link() |
|
862 | + : ''; |
|
863 | + $attendee_link = ! empty($attendee_link) |
|
864 | + ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
865 | + . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
866 | + . '<span id="checkin-attendee-name">' |
|
867 | + . $attendee_name |
|
868 | + . '</span></a>' |
|
869 | + : ''; |
|
870 | + $event_link = $registration->event() instanceof EE_Event |
|
871 | + ? $registration->event()->get_admin_details_link() |
|
872 | + : ''; |
|
873 | + $event_link = ! empty($event_link) |
|
874 | + ? '<a href="' . $event_link . '"' |
|
875 | + . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
876 | + . '<span id="checkin-event-name">' |
|
877 | + . $registration->event_name() |
|
878 | + . '</span>' |
|
879 | + . '</a>' |
|
880 | + : ''; |
|
881 | + $this->_template_args['before_list_table'] = $REG_ID && $DTT_ID |
|
882 | + ? '<h2>' . sprintf( |
|
883 | + esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
884 | + $attendee_link, |
|
885 | + $datetime_link, |
|
886 | + $event_link |
|
887 | + ) . '</h2>' |
|
888 | + : ''; |
|
889 | + $this->_template_args['list_table_hidden_fields'] = $REG_ID |
|
890 | + ? '<input type="hidden" name="_REG_ID" value="' . $REG_ID . '">' |
|
891 | + : ''; |
|
892 | + $this->_template_args['list_table_hidden_fields'] .= $DTT_ID |
|
893 | + ? '<input type="hidden" name="DTT_ID" value="' . $DTT_ID . '">' |
|
894 | + : ''; |
|
895 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
896 | + } |
|
897 | + |
|
898 | + |
|
899 | + /** |
|
900 | + * toggle the Check-in status for the given registration (coming from ajax) |
|
901 | + * |
|
902 | + * @return void (JSON) |
|
903 | + * @throws EE_Error |
|
904 | + * @throws ReflectionException |
|
905 | + */ |
|
906 | + public function toggle_checkin_status() |
|
907 | + { |
|
908 | + if (! $this->capabilities->current_user_can('ee_edit_checkins', __FUNCTION__)) { |
|
909 | + wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
910 | + } |
|
911 | + // first make sure we have the necessary data |
|
912 | + if (! isset($this->_req_data['_regid'])) { |
|
913 | + EE_Error::add_error( |
|
914 | + esc_html__( |
|
915 | + 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
916 | + 'event_espresso' |
|
917 | + ), |
|
918 | + __FILE__, |
|
919 | + __FUNCTION__, |
|
920 | + __LINE__ |
|
921 | + ); |
|
922 | + $this->_template_args['success'] = false; |
|
923 | + $this->_template_args['error'] = true; |
|
924 | + $this->_return_json(); |
|
925 | + } |
|
926 | + // do a nonce check because we're not coming in from a normal route here. |
|
927 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
928 | + : ''; |
|
929 | + $nonce_ref = 'checkin_nonce'; |
|
930 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
931 | + // beautiful! Made it this far so let's get the status. |
|
932 | + $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
933 | + // setup new class to return via ajax |
|
934 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
935 | + $this->_template_args['success'] = true; |
|
936 | + $this->_return_json(); |
|
937 | + } |
|
938 | + |
|
939 | + |
|
940 | + /** |
|
941 | + * handles toggling the checkin status for the registration, |
|
942 | + * |
|
943 | + * @return int|void |
|
944 | + * @throws EE_Error |
|
945 | + * @throws ReflectionException |
|
946 | + */ |
|
947 | + protected function _toggle_checkin_status() |
|
948 | + { |
|
949 | + // first let's get the query args out of the way for the redirect |
|
950 | + $query_args = [ |
|
951 | + 'action' => 'event_registrations', |
|
952 | + 'event_id' => $this->_req_data['event_id'] ?? null, |
|
953 | + 'DTT_ID' => $this->_req_data['DTT_ID'] ?? null, |
|
954 | + ]; |
|
955 | + $new_status = false; |
|
956 | + // bulk action check in toggle |
|
957 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
958 | + // cycle thru checkboxes |
|
959 | + $checkboxes = $this->_req_data['checkbox']; |
|
960 | + foreach (array_keys($checkboxes) as $REG_ID) { |
|
961 | + $DTT_ID = $this->_req_data['DTT_ID'] ?? null; |
|
962 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
963 | + } |
|
964 | + } elseif (isset($this->_req_data['_regid'])) { |
|
965 | + // coming from ajax request |
|
966 | + $DTT_ID = $this->_req_data['dttid'] ?? null; |
|
967 | + $query_args['DTT_ID'] = $DTT_ID; |
|
968 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
969 | + } else { |
|
970 | + EE_Error::add_error( |
|
971 | + esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
972 | + __FILE__, |
|
973 | + __FUNCTION__, |
|
974 | + __LINE__ |
|
975 | + ); |
|
976 | + } |
|
977 | + if (defined('DOING_AJAX')) { |
|
978 | + return $new_status; |
|
979 | + } |
|
980 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
981 | + } |
|
982 | + |
|
983 | + |
|
984 | + /** |
|
985 | + * This is toggles a single Check-in for the given registration and datetime. |
|
986 | + * |
|
987 | + * @param int $REG_ID The registration we're toggling |
|
988 | + * @param int $DTT_ID The datetime we're toggling |
|
989 | + * @return int The new status toggled to. |
|
990 | + * @throws EE_Error |
|
991 | + * @throws ReflectionException |
|
992 | + */ |
|
993 | + private function _toggle_checkin(int $REG_ID, int $DTT_ID) |
|
994 | + { |
|
995 | + /** @var EE_Registration $REG */ |
|
996 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
997 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
998 | + if ($new_status !== false) { |
|
999 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
1000 | + } else { |
|
1001 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
1002 | + $new_status = false; |
|
1003 | + } |
|
1004 | + return $new_status; |
|
1005 | + } |
|
1006 | + |
|
1007 | + |
|
1008 | + /** |
|
1009 | + * Takes care of deleting multiple EE_Checkin table rows |
|
1010 | + * |
|
1011 | + * @return void |
|
1012 | + * @throws EE_Error |
|
1013 | + * @throws ReflectionException |
|
1014 | + */ |
|
1015 | + protected function _delete_checkin_rows() |
|
1016 | + { |
|
1017 | + $query_args = [ |
|
1018 | + 'action' => 'registration_checkins', |
|
1019 | + 'DTT_ID' => $this->_req_data['DTT_ID'] ?? 0, |
|
1020 | + '_REG_ID' => $this->_req_data['_REG_ID'] ?? 0, |
|
1021 | + ]; |
|
1022 | + $errors = 0; |
|
1023 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1024 | + $checkboxes = $this->_req_data['checkbox']; |
|
1025 | + foreach (array_keys($checkboxes) as $CHK_ID) { |
|
1026 | + if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1027 | + $errors++; |
|
1028 | + } |
|
1029 | + } |
|
1030 | + } else { |
|
1031 | + EE_Error::add_error( |
|
1032 | + esc_html__( |
|
1033 | + 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
1034 | + 'event_espresso' |
|
1035 | + ), |
|
1036 | + __FILE__, |
|
1037 | + __FUNCTION__, |
|
1038 | + __LINE__ |
|
1039 | + ); |
|
1040 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1041 | + } |
|
1042 | + if ($errors > 0) { |
|
1043 | + EE_Error::add_error( |
|
1044 | + sprintf( |
|
1045 | + esc_html__('There were %d records that did not delete successfully', 'event_espresso'), |
|
1046 | + $errors |
|
1047 | + ), |
|
1048 | + __FILE__, |
|
1049 | + __FUNCTION__, |
|
1050 | + __LINE__ |
|
1051 | + ); |
|
1052 | + } else { |
|
1053 | + EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
1054 | + } |
|
1055 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1056 | + } |
|
1057 | + |
|
1058 | + |
|
1059 | + /** |
|
1060 | + * Deletes a single EE_Checkin row |
|
1061 | + * |
|
1062 | + * @return void |
|
1063 | + * @throws EE_Error |
|
1064 | + * @throws ReflectionException |
|
1065 | + */ |
|
1066 | + protected function _delete_checkin_row() |
|
1067 | + { |
|
1068 | + $query_args = [ |
|
1069 | + 'action' => 'registration_checkins', |
|
1070 | + 'DTT_ID' => $this->_req_data['DTT_ID'] ?? 0, |
|
1071 | + '_REG_ID' => $this->_req_data['_REG_ID'] ?? 0, |
|
1072 | + ]; |
|
1073 | + if (! empty($this->_req_data['CHK_ID'])) { |
|
1074 | + if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1075 | + EE_Error::add_error( |
|
1076 | + esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1077 | + __FILE__, |
|
1078 | + __FUNCTION__, |
|
1079 | + __LINE__ |
|
1080 | + ); |
|
1081 | + } else { |
|
1082 | + EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
1083 | + } |
|
1084 | + } else { |
|
1085 | + EE_Error::add_error( |
|
1086 | + esc_html__( |
|
1087 | + 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1088 | + 'event_espresso' |
|
1089 | + ), |
|
1090 | + __FILE__, |
|
1091 | + __FUNCTION__, |
|
1092 | + __LINE__ |
|
1093 | + ); |
|
1094 | + } |
|
1095 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1096 | + } |
|
1097 | + |
|
1098 | + |
|
1099 | + /** |
|
1100 | + * @return void |
|
1101 | + * @throws EE_Error |
|
1102 | + */ |
|
1103 | + protected function _event_registrations_list_table() |
|
1104 | + { |
|
1105 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, DataType::INTEGER); |
|
1106 | + $this->_admin_page_title .= $EVT_ID |
|
1107 | + ? $this->get_action_link_or_button( |
|
1108 | + 'new_registration', |
|
1109 | + 'add-registrant', |
|
1110 | + ['event_id' => $EVT_ID], |
|
1111 | + 'add-new-h2' |
|
1112 | + ) |
|
1113 | + : ''; |
|
1114 | + |
|
1115 | + $this->_template_args['before_list_table'] = $this->generateListTableHeaderText(); |
|
1116 | + $this->_template_args['after_list_table'] = $this->generateListTableLegend(); |
|
1117 | + |
|
1118 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1119 | + } |
|
1120 | + |
|
1121 | + |
|
1122 | + /** |
|
1123 | + * @return string |
|
1124 | + * @since 5.0.24.p |
|
1125 | + */ |
|
1126 | + private function generateListTableHeaderText(): string |
|
1127 | + { |
|
1128 | + $header_text = ''; |
|
1129 | + $admin_page_header_decorators = [ |
|
1130 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader', |
|
1131 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader', |
|
1132 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader', |
|
1133 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader', |
|
1134 | + ]; |
|
1135 | + foreach ($admin_page_header_decorators as $admin_page_header_decorator) { |
|
1136 | + $filter_header_decorator = $this->loader->getNew($admin_page_header_decorator); |
|
1137 | + $header_text = $filter_header_decorator->getHeaderText($header_text); |
|
1138 | + } |
|
1139 | + $header_text .= ' |
|
1140 | 1140 | <div class="description ee-status-outline ee-status-bg--info ee-status-outline--fit-content"> |
1141 | 1141 | <strong>' . esc_html__( |
1142 | - 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1143 | - 'event_espresso' |
|
1144 | - ) . '</strong> |
|
1142 | + 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1143 | + 'event_espresso' |
|
1144 | + ) . '</strong> |
|
1145 | 1145 | </div>'; |
1146 | - return $header_text; |
|
1147 | - } |
|
1148 | - |
|
1149 | - |
|
1150 | - /** |
|
1151 | - * @return string |
|
1152 | - * @throws EE_Error |
|
1153 | - * @since 5.0.24.p |
|
1154 | - */ |
|
1155 | - private function generateListTableLegend(): string |
|
1156 | - { |
|
1157 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1158 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1159 | - $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1160 | - $checkin_invalid = new CheckinStatusDashicon(EE_Checkin::status_invalid); |
|
1161 | - |
|
1162 | - $legend_items = [ |
|
1163 | - 'star-icon' => [ |
|
1164 | - 'class' => 'dashicons dashicons-star-filled gold-icon', |
|
1165 | - 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1166 | - ], |
|
1167 | - 'checkin' => [ |
|
1168 | - 'class' => $checked_in->cssClasses(), |
|
1169 | - 'desc' => $checked_in->legendLabel(), |
|
1170 | - ], |
|
1171 | - 'checkout' => [ |
|
1172 | - 'class' => $checked_out->cssClasses(), |
|
1173 | - 'desc' => $checked_out->legendLabel(), |
|
1174 | - ], |
|
1175 | - 'nocheckinrecord' => [ |
|
1176 | - 'class' => $checked_never->cssClasses(), |
|
1177 | - 'desc' => $checked_never->legendLabel(), |
|
1178 | - ], |
|
1179 | - 'canNotCheckin' => [ |
|
1180 | - 'class' => $checkin_invalid->cssClasses(), |
|
1181 | - 'desc' => $checkin_invalid->legendLabel(), |
|
1182 | - ], |
|
1183 | - 'approved_status' => [ |
|
1184 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::APPROVED, |
|
1185 | - 'desc' => EEH_Template::pretty_status(RegStatus::APPROVED, false, 'sentence'), |
|
1186 | - ], |
|
1187 | - 'cancelled_status' => [ |
|
1188 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::CANCELLED, |
|
1189 | - 'desc' => EEH_Template::pretty_status(RegStatus::CANCELLED, false, 'sentence'), |
|
1190 | - ], |
|
1191 | - 'declined_status' => [ |
|
1192 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::DECLINED, |
|
1193 | - 'desc' => EEH_Template::pretty_status(RegStatus::DECLINED, false, 'sentence'), |
|
1194 | - ], |
|
1195 | - 'not_approved' => [ |
|
1196 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::AWAITING_REVIEW, |
|
1197 | - 'desc' => EEH_Template::pretty_status(RegStatus::AWAITING_REVIEW, false, 'sentence'), |
|
1198 | - ], |
|
1199 | - 'pending_status' => [ |
|
1200 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::PENDING_PAYMENT, |
|
1201 | - 'desc' => EEH_Template::pretty_status(RegStatus::PENDING_PAYMENT, false, 'sentence'), |
|
1202 | - ], |
|
1203 | - 'wait_list' => [ |
|
1204 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::WAIT_LIST, |
|
1205 | - 'desc' => EEH_Template::pretty_status(RegStatus::WAIT_LIST, false, 'sentence'), |
|
1206 | - ], |
|
1207 | - ]; |
|
1208 | - return $this->_display_legend($legend_items); |
|
1209 | - } |
|
1210 | - |
|
1211 | - |
|
1212 | - /** |
|
1213 | - * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1214 | - * conditions) |
|
1215 | - * |
|
1216 | - * @return void ends the request by a redirect or download |
|
1217 | - */ |
|
1218 | - public function _registrations_checkin_report() |
|
1219 | - { |
|
1220 | - $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1221 | - } |
|
1222 | - |
|
1223 | - |
|
1224 | - /** |
|
1225 | - * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1226 | - * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1227 | - * |
|
1228 | - * @param array $query_params |
|
1229 | - * @param int $per_page |
|
1230 | - * @param bool $count |
|
1231 | - * @return array |
|
1232 | - * @throws EE_Error |
|
1233 | - */ |
|
1234 | - protected function _get_checkin_query_params_from_request( |
|
1235 | - array $query_params, |
|
1236 | - int $per_page = 10, |
|
1237 | - bool $count = false |
|
1238 | - ): array { |
|
1239 | - $query_params = $this->_get_registration_query_parameters($query_params, $per_page, $count); |
|
1240 | - // unlike the regular registrations list table, |
|
1241 | - $status_ids_array = apply_filters( |
|
1242 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1243 | - [RegStatus::PENDING_PAYMENT, RegStatus::APPROVED] |
|
1244 | - ); |
|
1245 | - $query_params[0]['STS_ID'] = ['IN', $status_ids_array]; |
|
1246 | - return $query_params; |
|
1247 | - } |
|
1248 | - |
|
1249 | - |
|
1250 | - /** |
|
1251 | - * Gets registrations for an event |
|
1252 | - * |
|
1253 | - * @param int $per_page |
|
1254 | - * @param bool $count whether to return count or data. |
|
1255 | - * @param bool $trash |
|
1256 | - * @param string $orderby |
|
1257 | - * @return EE_Registration[]|int |
|
1258 | - * @throws EE_Error |
|
1259 | - * @throws ReflectionException |
|
1260 | - */ |
|
1261 | - public function get_event_attendees( |
|
1262 | - int $per_page = 10, |
|
1263 | - bool $count = false, |
|
1264 | - bool $trash = false, |
|
1265 | - string $orderby = 'ATT_fname' |
|
1266 | - ) { |
|
1267 | - // set some defaults, these will get overridden if included in the actual request parameters |
|
1268 | - $defaults = [ |
|
1269 | - 'orderby' => $orderby, |
|
1270 | - 'order' => 'ASC', |
|
1271 | - ]; |
|
1272 | - if ($trash) { |
|
1273 | - $defaults['status'] = 'trash'; |
|
1274 | - } |
|
1275 | - $query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count); |
|
1276 | - |
|
1277 | - /** |
|
1278 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1279 | - * |
|
1280 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1281 | - * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1282 | - * or if you have the development copy of EE you can view this at the path: |
|
1283 | - * /docs/G--Model-System/model-query-params.md |
|
1284 | - */ |
|
1285 | - $query_params['group_by'] = ''; |
|
1286 | - |
|
1287 | - return $count |
|
1288 | - ? EEM_Registration::instance()->count($query_params) |
|
1289 | - /** @type EE_Registration[] */ |
|
1290 | - : EEM_Registration::instance()->get_all($query_params); |
|
1291 | - } |
|
1146 | + return $header_text; |
|
1147 | + } |
|
1148 | + |
|
1149 | + |
|
1150 | + /** |
|
1151 | + * @return string |
|
1152 | + * @throws EE_Error |
|
1153 | + * @since 5.0.24.p |
|
1154 | + */ |
|
1155 | + private function generateListTableLegend(): string |
|
1156 | + { |
|
1157 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1158 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1159 | + $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1160 | + $checkin_invalid = new CheckinStatusDashicon(EE_Checkin::status_invalid); |
|
1161 | + |
|
1162 | + $legend_items = [ |
|
1163 | + 'star-icon' => [ |
|
1164 | + 'class' => 'dashicons dashicons-star-filled gold-icon', |
|
1165 | + 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1166 | + ], |
|
1167 | + 'checkin' => [ |
|
1168 | + 'class' => $checked_in->cssClasses(), |
|
1169 | + 'desc' => $checked_in->legendLabel(), |
|
1170 | + ], |
|
1171 | + 'checkout' => [ |
|
1172 | + 'class' => $checked_out->cssClasses(), |
|
1173 | + 'desc' => $checked_out->legendLabel(), |
|
1174 | + ], |
|
1175 | + 'nocheckinrecord' => [ |
|
1176 | + 'class' => $checked_never->cssClasses(), |
|
1177 | + 'desc' => $checked_never->legendLabel(), |
|
1178 | + ], |
|
1179 | + 'canNotCheckin' => [ |
|
1180 | + 'class' => $checkin_invalid->cssClasses(), |
|
1181 | + 'desc' => $checkin_invalid->legendLabel(), |
|
1182 | + ], |
|
1183 | + 'approved_status' => [ |
|
1184 | + 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::APPROVED, |
|
1185 | + 'desc' => EEH_Template::pretty_status(RegStatus::APPROVED, false, 'sentence'), |
|
1186 | + ], |
|
1187 | + 'cancelled_status' => [ |
|
1188 | + 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::CANCELLED, |
|
1189 | + 'desc' => EEH_Template::pretty_status(RegStatus::CANCELLED, false, 'sentence'), |
|
1190 | + ], |
|
1191 | + 'declined_status' => [ |
|
1192 | + 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::DECLINED, |
|
1193 | + 'desc' => EEH_Template::pretty_status(RegStatus::DECLINED, false, 'sentence'), |
|
1194 | + ], |
|
1195 | + 'not_approved' => [ |
|
1196 | + 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::AWAITING_REVIEW, |
|
1197 | + 'desc' => EEH_Template::pretty_status(RegStatus::AWAITING_REVIEW, false, 'sentence'), |
|
1198 | + ], |
|
1199 | + 'pending_status' => [ |
|
1200 | + 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::PENDING_PAYMENT, |
|
1201 | + 'desc' => EEH_Template::pretty_status(RegStatus::PENDING_PAYMENT, false, 'sentence'), |
|
1202 | + ], |
|
1203 | + 'wait_list' => [ |
|
1204 | + 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::WAIT_LIST, |
|
1205 | + 'desc' => EEH_Template::pretty_status(RegStatus::WAIT_LIST, false, 'sentence'), |
|
1206 | + ], |
|
1207 | + ]; |
|
1208 | + return $this->_display_legend($legend_items); |
|
1209 | + } |
|
1210 | + |
|
1211 | + |
|
1212 | + /** |
|
1213 | + * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1214 | + * conditions) |
|
1215 | + * |
|
1216 | + * @return void ends the request by a redirect or download |
|
1217 | + */ |
|
1218 | + public function _registrations_checkin_report() |
|
1219 | + { |
|
1220 | + $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1221 | + } |
|
1222 | + |
|
1223 | + |
|
1224 | + /** |
|
1225 | + * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1226 | + * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1227 | + * |
|
1228 | + * @param array $query_params |
|
1229 | + * @param int $per_page |
|
1230 | + * @param bool $count |
|
1231 | + * @return array |
|
1232 | + * @throws EE_Error |
|
1233 | + */ |
|
1234 | + protected function _get_checkin_query_params_from_request( |
|
1235 | + array $query_params, |
|
1236 | + int $per_page = 10, |
|
1237 | + bool $count = false |
|
1238 | + ): array { |
|
1239 | + $query_params = $this->_get_registration_query_parameters($query_params, $per_page, $count); |
|
1240 | + // unlike the regular registrations list table, |
|
1241 | + $status_ids_array = apply_filters( |
|
1242 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1243 | + [RegStatus::PENDING_PAYMENT, RegStatus::APPROVED] |
|
1244 | + ); |
|
1245 | + $query_params[0]['STS_ID'] = ['IN', $status_ids_array]; |
|
1246 | + return $query_params; |
|
1247 | + } |
|
1248 | + |
|
1249 | + |
|
1250 | + /** |
|
1251 | + * Gets registrations for an event |
|
1252 | + * |
|
1253 | + * @param int $per_page |
|
1254 | + * @param bool $count whether to return count or data. |
|
1255 | + * @param bool $trash |
|
1256 | + * @param string $orderby |
|
1257 | + * @return EE_Registration[]|int |
|
1258 | + * @throws EE_Error |
|
1259 | + * @throws ReflectionException |
|
1260 | + */ |
|
1261 | + public function get_event_attendees( |
|
1262 | + int $per_page = 10, |
|
1263 | + bool $count = false, |
|
1264 | + bool $trash = false, |
|
1265 | + string $orderby = 'ATT_fname' |
|
1266 | + ) { |
|
1267 | + // set some defaults, these will get overridden if included in the actual request parameters |
|
1268 | + $defaults = [ |
|
1269 | + 'orderby' => $orderby, |
|
1270 | + 'order' => 'ASC', |
|
1271 | + ]; |
|
1272 | + if ($trash) { |
|
1273 | + $defaults['status'] = 'trash'; |
|
1274 | + } |
|
1275 | + $query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count); |
|
1276 | + |
|
1277 | + /** |
|
1278 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1279 | + * |
|
1280 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1281 | + * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1282 | + * or if you have the development copy of EE you can view this at the path: |
|
1283 | + * /docs/G--Model-System/model-query-params.md |
|
1284 | + */ |
|
1285 | + $query_params['group_by'] = ''; |
|
1286 | + |
|
1287 | + return $count |
|
1288 | + ? EEM_Registration::instance()->count($query_params) |
|
1289 | + /** @type EE_Registration[] */ |
|
1290 | + : EEM_Registration::instance()->get_all($query_params); |
|
1291 | + } |
|
1292 | 1292 | } |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | public function __construct($routing = true) |
34 | 34 | { |
35 | 35 | parent::__construct($routing); |
36 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
37 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
38 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
39 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
36 | + if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
37 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/'); |
|
38 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/'); |
|
39 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/'); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | { |
46 | 46 | parent::_set_page_config(); |
47 | 47 | |
48 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
48 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations'; |
|
49 | 49 | $reg_id = |
50 | 50 | ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
51 | 51 | ? $this->_req_data['_REG_ID'] |
52 | 52 | : 0; |
53 | - $new_page_routes = [ |
|
53 | + $new_page_routes = [ |
|
54 | 54 | 'reports' => [ |
55 | 55 | 'func' => [$this, '_registration_reports'], |
56 | 56 | 'capability' => 'ee_read_registrations', |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | if (EEH_MSG_Template::is_mt_active('newsletter')) { |
189 | 189 | wp_enqueue_style( |
190 | 190 | 'ee_message_shortcodes', |
191 | - EE_MSG_ASSETS_URL . 'ee_message_shortcodes.css', |
|
191 | + EE_MSG_ASSETS_URL.'ee_message_shortcodes.css', |
|
192 | 192 | [EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN], |
193 | 193 | EVENT_ESPRESSO_VERSION |
194 | 194 | ); |
195 | 195 | // enqueue newsletter js |
196 | 196 | wp_enqueue_script( |
197 | 197 | 'ee-newsletter-trigger', |
198 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
198 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js', |
|
199 | 199 | ['ee-dialog'], |
200 | 200 | EVENT_ESPRESSO_VERSION, |
201 | 201 | true |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | { |
220 | 220 | wp_register_script( |
221 | 221 | 'ee-reg-reports-js', |
222 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
222 | + REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js', |
|
223 | 223 | ['google-charts'], |
224 | 224 | EVENT_ESPRESSO_VERSION, |
225 | 225 | true |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function get_newsletter_form_content() |
298 | 298 | { |
299 | - if (! $this->capabilities->current_user_can('ee_read_messages', __FUNCTION__)) { |
|
299 | + if ( ! $this->capabilities->current_user_can('ee_read_messages', __FUNCTION__)) { |
|
300 | 300 | wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
301 | 301 | } |
302 | 302 | // do a nonce check because we're not coming in from a normal route here. |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $nonce_ref = 'get_newsletter_form_content_nonce'; |
307 | 307 | $this->_verify_nonce($nonce, $nonce_ref); |
308 | 308 | // let's get the mtp for the incoming MTP_ ID |
309 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
309 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
310 | 310 | EE_Error::add_error( |
311 | 311 | esc_html__( |
312 | 312 | 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $this->_return_json(); |
322 | 322 | } |
323 | 323 | $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
324 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
324 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
325 | 325 | EE_Error::add_error( |
326 | 326 | sprintf( |
327 | 327 | esc_html__( |
@@ -346,12 +346,12 @@ discard block |
||
346 | 346 | $field = $MTP->get('MTP_template_field'); |
347 | 347 | if ($field === 'content') { |
348 | 348 | $content = $MTP->get('MTP_content'); |
349 | - if (! empty($content['newsletter_content'])) { |
|
349 | + if ( ! empty($content['newsletter_content'])) { |
|
350 | 350 | $template_fields['newsletter_content'] = $content['newsletter_content']; |
351 | 351 | } |
352 | 352 | continue; |
353 | 353 | } |
354 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
354 | + $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
355 | 355 | } |
356 | 356 | $this->_template_args['success'] = true; |
357 | 357 | $this->_template_args['error'] = false; |
@@ -445,15 +445,15 @@ discard block |
||
445 | 445 | $field_id = "batch-message-$field_id"; |
446 | 446 | $available_shortcodes[] = ' |
447 | 447 | <span class="js-shortcode-selection" |
448 | - data-value="' . $shortcode . '" |
|
449 | - data-linked-input-id="' . $field_id . '" |
|
450 | - >' . $shortcode . '</span>'; |
|
448 | + data-value="' . $shortcode.'" |
|
449 | + data-linked-input-id="' . $field_id.'" |
|
450 | + >' . $shortcode.'</span>'; |
|
451 | 451 | } |
452 | - $codes[ $field ] = '<ul><li>' . implode('</li><li>', $available_shortcodes) . '</li></ul>'; |
|
452 | + $codes[$field] = '<ul><li>'.implode('</li><li>', $available_shortcodes).'</li></ul>'; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | EEH_Template::display_template( |
456 | - REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php', |
|
456 | + REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php', |
|
457 | 457 | [ |
458 | 458 | 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
459 | 459 | 'form_route' => 'newsletter_selected_send', |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | */ |
623 | 623 | protected function _registration_reports() |
624 | 624 | { |
625 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
625 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
626 | 626 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
627 | 627 | $template_path, |
628 | 628 | $this->_reports_template_data, |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | array_unshift($regs, $column_titles); |
678 | 678 | // setup the date range. |
679 | 679 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
680 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
680 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
681 | 681 | $ending_date = new DateTime("now", $DateTimeZone); |
682 | 682 | $subtitle = sprintf( |
683 | 683 | wp_strip_all_tags( |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | 'event_espresso' |
702 | 702 | ) |
703 | 703 | ), |
704 | - '<h2>' . $report_title . '</h2><p>', |
|
704 | + '<h2>'.$report_title.'</h2><p>', |
|
705 | 705 | '</p>' |
706 | 706 | ), |
707 | 707 | ]; |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | foreach ($results as $result) { |
734 | 734 | $report_column_values = []; |
735 | 735 | foreach ($result as $property_name => $property_value) { |
736 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
736 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
737 | 737 | $property_value, |
738 | 738 | 4, |
739 | 739 | '...' |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | array_unshift($regs, $column_titles); |
755 | 755 | // setup the date range. |
756 | 756 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
757 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
757 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
758 | 758 | $ending_date = new DateTime("now", $DateTimeZone); |
759 | 759 | $subtitle = sprintf( |
760 | 760 | wp_strip_all_tags( |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | 'event_espresso' |
779 | 779 | ) |
780 | 780 | ), |
781 | - '<h2>' . $report_title . '</h2><p>', |
|
781 | + '<h2>'.$report_title.'</h2><p>', |
|
782 | 782 | '</p>' |
783 | 783 | ), |
784 | 784 | ]; |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | $REG_ID = $this->request->getRequestParam('_REG_ID', 0, DataType::INTEGER); |
801 | 801 | /** @var EE_Registration $registration */ |
802 | 802 | $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
803 | - if (! $registration instanceof EE_Registration) { |
|
803 | + if ( ! $registration instanceof EE_Registration) { |
|
804 | 804 | throw new EE_Error( |
805 | 805 | sprintf( |
806 | 806 | esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
@@ -808,8 +808,8 @@ discard block |
||
808 | 808 | ) |
809 | 809 | ); |
810 | 810 | } |
811 | - $attendee = $registration->attendee(); |
|
812 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
811 | + $attendee = $registration->attendee(); |
|
812 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
813 | 813 | 'new_registration', |
814 | 814 | 'add-registrant', |
815 | 815 | ['event_id' => $registration->event_ID()], |
@@ -835,10 +835,10 @@ discard block |
||
835 | 835 | if ($datetime instanceof EE_Datetime) { |
836 | 836 | $datetime_label = $datetime->get_dtt_display_name(true); |
837 | 837 | $datetime_label .= ! empty($datetime_label) |
838 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
838 | + ? ' ('.$datetime->get_dtt_display_name().')' |
|
839 | 839 | : $datetime->get_dtt_display_name(); |
840 | 840 | } |
841 | - $datetime_link = ! $DTT_ID |
|
841 | + $datetime_link = ! $DTT_ID |
|
842 | 842 | ? EE_Admin_Page::add_query_args_and_nonce( |
843 | 843 | [ |
844 | 844 | 'action' => 'event_registrations', |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | $this->_admin_base_url |
849 | 849 | ) |
850 | 850 | : ''; |
851 | - $datetime_link = ! empty($datetime_link) |
|
852 | - ? '<a href="' . $datetime_link . '">' |
|
851 | + $datetime_link = ! empty($datetime_link) |
|
852 | + ? '<a href="'.$datetime_link.'">' |
|
853 | 853 | . '<span id="checkin-dtt">' |
854 | 854 | . $datetime_label |
855 | 855 | . '</span></a>' |
@@ -861,8 +861,8 @@ discard block |
||
861 | 861 | ? $attendee->get_admin_details_link() |
862 | 862 | : ''; |
863 | 863 | $attendee_link = ! empty($attendee_link) |
864 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
865 | - . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
864 | + ? '<a href="'.$attendee->get_admin_details_link().'"' |
|
865 | + . ' aria-label="'.esc_html__('Click for attendee details', 'event_espresso').'">' |
|
866 | 866 | . '<span id="checkin-attendee-name">' |
867 | 867 | . $attendee_name |
868 | 868 | . '</span></a>' |
@@ -871,26 +871,26 @@ discard block |
||
871 | 871 | ? $registration->event()->get_admin_details_link() |
872 | 872 | : ''; |
873 | 873 | $event_link = ! empty($event_link) |
874 | - ? '<a href="' . $event_link . '"' |
|
875 | - . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
874 | + ? '<a href="'.$event_link.'"' |
|
875 | + . ' aria-label="'.esc_html__('Click here to edit event.', 'event_espresso').'">' |
|
876 | 876 | . '<span id="checkin-event-name">' |
877 | 877 | . $registration->event_name() |
878 | 878 | . '</span>' |
879 | 879 | . '</a>' |
880 | 880 | : ''; |
881 | - $this->_template_args['before_list_table'] = $REG_ID && $DTT_ID |
|
882 | - ? '<h2>' . sprintf( |
|
881 | + $this->_template_args['before_list_table'] = $REG_ID && $DTT_ID |
|
882 | + ? '<h2>'.sprintf( |
|
883 | 883 | esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
884 | 884 | $attendee_link, |
885 | 885 | $datetime_link, |
886 | 886 | $event_link |
887 | - ) . '</h2>' |
|
887 | + ).'</h2>' |
|
888 | 888 | : ''; |
889 | 889 | $this->_template_args['list_table_hidden_fields'] = $REG_ID |
890 | - ? '<input type="hidden" name="_REG_ID" value="' . $REG_ID . '">' |
|
890 | + ? '<input type="hidden" name="_REG_ID" value="'.$REG_ID.'">' |
|
891 | 891 | : ''; |
892 | 892 | $this->_template_args['list_table_hidden_fields'] .= $DTT_ID |
893 | - ? '<input type="hidden" name="DTT_ID" value="' . $DTT_ID . '">' |
|
893 | + ? '<input type="hidden" name="DTT_ID" value="'.$DTT_ID.'">' |
|
894 | 894 | : ''; |
895 | 895 | $this->display_admin_list_table_page_with_no_sidebar(); |
896 | 896 | } |
@@ -905,11 +905,11 @@ discard block |
||
905 | 905 | */ |
906 | 906 | public function toggle_checkin_status() |
907 | 907 | { |
908 | - if (! $this->capabilities->current_user_can('ee_edit_checkins', __FUNCTION__)) { |
|
908 | + if ( ! $this->capabilities->current_user_can('ee_edit_checkins', __FUNCTION__)) { |
|
909 | 909 | wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
910 | 910 | } |
911 | 911 | // first make sure we have the necessary data |
912 | - if (! isset($this->_req_data['_regid'])) { |
|
912 | + if ( ! isset($this->_req_data['_regid'])) { |
|
913 | 913 | EE_Error::add_error( |
914 | 914 | esc_html__( |
915 | 915 | 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | // beautiful! Made it this far so let's get the status. |
932 | 932 | $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
933 | 933 | // setup new class to return via ajax |
934 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
934 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin '.$new_status->cssClasses(); |
|
935 | 935 | $this->_template_args['success'] = true; |
936 | 936 | $this->_return_json(); |
937 | 937 | } |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | ]; |
955 | 955 | $new_status = false; |
956 | 956 | // bulk action check in toggle |
957 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
957 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
958 | 958 | // cycle thru checkboxes |
959 | 959 | $checkboxes = $this->_req_data['checkbox']; |
960 | 960 | foreach (array_keys($checkboxes) as $REG_ID) { |
@@ -1019,11 +1019,11 @@ discard block |
||
1019 | 1019 | 'DTT_ID' => $this->_req_data['DTT_ID'] ?? 0, |
1020 | 1020 | '_REG_ID' => $this->_req_data['_REG_ID'] ?? 0, |
1021 | 1021 | ]; |
1022 | - $errors = 0; |
|
1023 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1022 | + $errors = 0; |
|
1023 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1024 | 1024 | $checkboxes = $this->_req_data['checkbox']; |
1025 | 1025 | foreach (array_keys($checkboxes) as $CHK_ID) { |
1026 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1026 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1027 | 1027 | $errors++; |
1028 | 1028 | } |
1029 | 1029 | } |
@@ -1070,8 +1070,8 @@ discard block |
||
1070 | 1070 | 'DTT_ID' => $this->_req_data['DTT_ID'] ?? 0, |
1071 | 1071 | '_REG_ID' => $this->_req_data['_REG_ID'] ?? 0, |
1072 | 1072 | ]; |
1073 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
1074 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1073 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
1074 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1075 | 1075 | EE_Error::add_error( |
1076 | 1076 | esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
1077 | 1077 | __FILE__, |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | */ |
1103 | 1103 | protected function _event_registrations_list_table() |
1104 | 1104 | { |
1105 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, DataType::INTEGER); |
|
1105 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, DataType::INTEGER); |
|
1106 | 1106 | $this->_admin_page_title .= $EVT_ID |
1107 | 1107 | ? $this->get_action_link_or_button( |
1108 | 1108 | 'new_registration', |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | <strong>' . esc_html__( |
1142 | 1142 | 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
1143 | 1143 | 'event_espresso' |
1144 | - ) . '</strong> |
|
1144 | + ).'</strong> |
|
1145 | 1145 | </div>'; |
1146 | 1146 | return $header_text; |
1147 | 1147 | } |
@@ -1181,27 +1181,27 @@ discard block |
||
1181 | 1181 | 'desc' => $checkin_invalid->legendLabel(), |
1182 | 1182 | ], |
1183 | 1183 | 'approved_status' => [ |
1184 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::APPROVED, |
|
1184 | + 'class' => 'ee-status-legend ee-status-bg--'.RegStatus::APPROVED, |
|
1185 | 1185 | 'desc' => EEH_Template::pretty_status(RegStatus::APPROVED, false, 'sentence'), |
1186 | 1186 | ], |
1187 | 1187 | 'cancelled_status' => [ |
1188 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::CANCELLED, |
|
1188 | + 'class' => 'ee-status-legend ee-status-bg--'.RegStatus::CANCELLED, |
|
1189 | 1189 | 'desc' => EEH_Template::pretty_status(RegStatus::CANCELLED, false, 'sentence'), |
1190 | 1190 | ], |
1191 | 1191 | 'declined_status' => [ |
1192 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::DECLINED, |
|
1192 | + 'class' => 'ee-status-legend ee-status-bg--'.RegStatus::DECLINED, |
|
1193 | 1193 | 'desc' => EEH_Template::pretty_status(RegStatus::DECLINED, false, 'sentence'), |
1194 | 1194 | ], |
1195 | 1195 | 'not_approved' => [ |
1196 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::AWAITING_REVIEW, |
|
1196 | + 'class' => 'ee-status-legend ee-status-bg--'.RegStatus::AWAITING_REVIEW, |
|
1197 | 1197 | 'desc' => EEH_Template::pretty_status(RegStatus::AWAITING_REVIEW, false, 'sentence'), |
1198 | 1198 | ], |
1199 | 1199 | 'pending_status' => [ |
1200 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::PENDING_PAYMENT, |
|
1200 | + 'class' => 'ee-status-legend ee-status-bg--'.RegStatus::PENDING_PAYMENT, |
|
1201 | 1201 | 'desc' => EEH_Template::pretty_status(RegStatus::PENDING_PAYMENT, false, 'sentence'), |
1202 | 1202 | ], |
1203 | 1203 | 'wait_list' => [ |
1204 | - 'class' => 'ee-status-legend ee-status-bg--' . RegStatus::WAIT_LIST, |
|
1204 | + 'class' => 'ee-status-legend ee-status-bg--'.RegStatus::WAIT_LIST, |
|
1205 | 1205 | 'desc' => EEH_Template::pretty_status(RegStatus::WAIT_LIST, false, 'sentence'), |
1206 | 1206 | ], |
1207 | 1207 | ]; |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | ): array { |
1239 | 1239 | $query_params = $this->_get_registration_query_parameters($query_params, $per_page, $count); |
1240 | 1240 | // unlike the regular registrations list table, |
1241 | - $status_ids_array = apply_filters( |
|
1241 | + $status_ids_array = apply_filters( |
|
1242 | 1242 | 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
1243 | 1243 | [RegStatus::PENDING_PAYMENT, RegStatus::APPROVED] |
1244 | 1244 | ); |
@@ -13,175 +13,175 @@ |
||
13 | 13 | */ |
14 | 14 | class Extend_EE_Registrations_List_Table extends EE_Registrations_List_Table |
15 | 15 | { |
16 | - private RegistrationsListTableFilters $filters; |
|
16 | + private RegistrationsListTableFilters $filters; |
|
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @param Registrations_Admin_Page $admin_page |
|
21 | - * @throws EE_Error |
|
22 | - * @throws ReflectionException |
|
23 | - */ |
|
24 | - public function __construct(Registrations_Admin_Page $admin_page) |
|
25 | - { |
|
26 | - parent::__construct($admin_page); |
|
27 | - $this->filters = new RegistrationsListTableFilters($this->request); |
|
28 | - $this->filters->resolveRequestVars(); |
|
29 | - add_filter( |
|
30 | - 'FHEE__Extend_EE_Registrations_List_Table__filters', |
|
31 | - [$this->filters, 'addFiltersBefore'], |
|
32 | - ); |
|
33 | - } |
|
19 | + /** |
|
20 | + * @param Registrations_Admin_Page $admin_page |
|
21 | + * @throws EE_Error |
|
22 | + * @throws ReflectionException |
|
23 | + */ |
|
24 | + public function __construct(Registrations_Admin_Page $admin_page) |
|
25 | + { |
|
26 | + parent::__construct($admin_page); |
|
27 | + $this->filters = new RegistrationsListTableFilters($this->request); |
|
28 | + $this->filters->resolveRequestVars(); |
|
29 | + add_filter( |
|
30 | + 'FHEE__Extend_EE_Registrations_List_Table__filters', |
|
31 | + [$this->filters, 'addFiltersBefore'], |
|
32 | + ); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @param EE_Registration $registration |
|
38 | - * @return string |
|
39 | - * @throws EE_Error |
|
40 | - * @throws InvalidArgumentException |
|
41 | - * @throws InvalidDataTypeException |
|
42 | - * @throws InvalidInterfaceException |
|
43 | - * @throws ReflectionException |
|
44 | - */ |
|
45 | - public function column_event_name(EE_Registration $registration): string |
|
46 | - { |
|
47 | - $this->_set_related_details($registration); |
|
48 | - $edit_event = $this->editEventLink($registration); |
|
49 | - $actions['event_filter'] = $this->eventFilterLink($registration); |
|
50 | - $actions['event_checkins'] = $this->viewCheckinsLink($registration); |
|
51 | - return $this->columnContent( |
|
52 | - 'event_name', |
|
53 | - $edit_event . $this->row_actions($actions) |
|
54 | - ); |
|
55 | - } |
|
36 | + /** |
|
37 | + * @param EE_Registration $registration |
|
38 | + * @return string |
|
39 | + * @throws EE_Error |
|
40 | + * @throws InvalidArgumentException |
|
41 | + * @throws InvalidDataTypeException |
|
42 | + * @throws InvalidInterfaceException |
|
43 | + * @throws ReflectionException |
|
44 | + */ |
|
45 | + public function column_event_name(EE_Registration $registration): string |
|
46 | + { |
|
47 | + $this->_set_related_details($registration); |
|
48 | + $edit_event = $this->editEventLink($registration); |
|
49 | + $actions['event_filter'] = $this->eventFilterLink($registration); |
|
50 | + $actions['event_checkins'] = $this->viewCheckinsLink($registration); |
|
51 | + return $this->columnContent( |
|
52 | + 'event_name', |
|
53 | + $edit_event . $this->row_actions($actions) |
|
54 | + ); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * @param EE_Registration $registration |
|
60 | - * @return string |
|
61 | - * @throws EE_Error |
|
62 | - * @throws InvalidArgumentException |
|
63 | - * @throws InvalidDataTypeException |
|
64 | - * @throws InvalidInterfaceException |
|
65 | - * @throws ReflectionException |
|
66 | - */ |
|
67 | - public function column_DTT_EVT_start(EE_Registration $registration): string |
|
68 | - { |
|
69 | - $ticket = $registration->ticket(); |
|
70 | - $datetimes = $ticket instanceof EE_Ticket |
|
71 | - ? $ticket->datetimes(['default_where_conditions' => 'none']) |
|
72 | - : []; |
|
73 | - $datetimes_for_display = []; |
|
74 | - foreach ($datetimes as $datetime) { |
|
75 | - $datetime_string = '<div class="ee-reg-list-dates-list-date">'; |
|
76 | - $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
|
77 | - $datetime_string .= $this->row_actions( |
|
78 | - [ |
|
79 | - 'datetime_filter' => $this->datetimeFilterLink($registration, $datetime), |
|
80 | - 'datetime_checkins' => $this->viewCheckinsLink($registration, $datetime), |
|
81 | - ] |
|
82 | - ); |
|
83 | - $datetime_string .= '</div>'; |
|
84 | - $datetimes_for_display[] = $datetime_string; |
|
85 | - } |
|
86 | - return $this->columnContent( |
|
87 | - 'DTT_EVT_start', |
|
88 | - $this->generateDisplayForDateTimes($datetimes_for_display) |
|
89 | - ); |
|
90 | - } |
|
58 | + /** |
|
59 | + * @param EE_Registration $registration |
|
60 | + * @return string |
|
61 | + * @throws EE_Error |
|
62 | + * @throws InvalidArgumentException |
|
63 | + * @throws InvalidDataTypeException |
|
64 | + * @throws InvalidInterfaceException |
|
65 | + * @throws ReflectionException |
|
66 | + */ |
|
67 | + public function column_DTT_EVT_start(EE_Registration $registration): string |
|
68 | + { |
|
69 | + $ticket = $registration->ticket(); |
|
70 | + $datetimes = $ticket instanceof EE_Ticket |
|
71 | + ? $ticket->datetimes(['default_where_conditions' => 'none']) |
|
72 | + : []; |
|
73 | + $datetimes_for_display = []; |
|
74 | + foreach ($datetimes as $datetime) { |
|
75 | + $datetime_string = '<div class="ee-reg-list-dates-list-date">'; |
|
76 | + $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
|
77 | + $datetime_string .= $this->row_actions( |
|
78 | + [ |
|
79 | + 'datetime_filter' => $this->datetimeFilterLink($registration, $datetime), |
|
80 | + 'datetime_checkins' => $this->viewCheckinsLink($registration, $datetime), |
|
81 | + ] |
|
82 | + ); |
|
83 | + $datetime_string .= '</div>'; |
|
84 | + $datetimes_for_display[] = $datetime_string; |
|
85 | + } |
|
86 | + return $this->columnContent( |
|
87 | + 'DTT_EVT_start', |
|
88 | + $this->generateDisplayForDateTimes($datetimes_for_display) |
|
89 | + ); |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * @param EE_Registration $registration |
|
95 | - * @return string |
|
96 | - * @throws EE_Error |
|
97 | - * @throws ReflectionException |
|
98 | - */ |
|
99 | - public function column_REG_ticket(EE_Registration $registration): string |
|
100 | - { |
|
101 | - $ticket = $registration->ticket(); |
|
102 | - $ticket_name = $this->ticketName($ticket); |
|
103 | - $actions = [ |
|
104 | - 'ticket_filter' => $this->ticketFilterLink($ticket), |
|
105 | - 'ticket_checkins' => $this->viewCheckinsLink($registration, null, $ticket), |
|
106 | - ]; |
|
107 | - return $this->columnContent( |
|
108 | - 'REG_ticket', |
|
109 | - $ticket_name . $this->row_actions($actions) |
|
110 | - ); |
|
111 | - } |
|
93 | + /** |
|
94 | + * @param EE_Registration $registration |
|
95 | + * @return string |
|
96 | + * @throws EE_Error |
|
97 | + * @throws ReflectionException |
|
98 | + */ |
|
99 | + public function column_REG_ticket(EE_Registration $registration): string |
|
100 | + { |
|
101 | + $ticket = $registration->ticket(); |
|
102 | + $ticket_name = $this->ticketName($ticket); |
|
103 | + $actions = [ |
|
104 | + 'ticket_filter' => $this->ticketFilterLink($ticket), |
|
105 | + 'ticket_checkins' => $this->viewCheckinsLink($registration, null, $ticket), |
|
106 | + ]; |
|
107 | + return $this->columnContent( |
|
108 | + 'REG_ticket', |
|
109 | + $ticket_name . $this->row_actions($actions) |
|
110 | + ); |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * @param EE_Registration $registration |
|
116 | - * @param EE_Datetime $datetime |
|
117 | - * @return string |
|
118 | - * @throws EE_Error |
|
119 | - * @throws ReflectionException |
|
120 | - * @since 5.0.18.p |
|
121 | - */ |
|
122 | - protected function datetimeFilterLink(EE_Registration $registration, EE_Datetime $datetime): string |
|
123 | - { |
|
124 | - $datetime_filter_url = EE_Admin_Page::add_query_args_and_nonce( |
|
125 | - [ |
|
126 | - 'event_id' => $registration->event_ID(), |
|
127 | - 'datetime_id' => $datetime->ID(), |
|
128 | - ], |
|
129 | - REG_ADMIN_URL |
|
130 | - ); |
|
131 | - return ' |
|
114 | + /** |
|
115 | + * @param EE_Registration $registration |
|
116 | + * @param EE_Datetime $datetime |
|
117 | + * @return string |
|
118 | + * @throws EE_Error |
|
119 | + * @throws ReflectionException |
|
120 | + * @since 5.0.18.p |
|
121 | + */ |
|
122 | + protected function datetimeFilterLink(EE_Registration $registration, EE_Datetime $datetime): string |
|
123 | + { |
|
124 | + $datetime_filter_url = EE_Admin_Page::add_query_args_and_nonce( |
|
125 | + [ |
|
126 | + 'event_id' => $registration->event_ID(), |
|
127 | + 'datetime_id' => $datetime->ID(), |
|
128 | + ], |
|
129 | + REG_ADMIN_URL |
|
130 | + ); |
|
131 | + return ' |
|
132 | 132 | <a class="ee-aria-tooltip ee-datetime-filter-link" |
133 | 133 | href="' . $datetime_filter_url . '" |
134 | 134 | aria-label="' . sprintf( |
135 | - esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), |
|
136 | - $datetime->name() ?: esc_attr__('this datetime', 'event_espresso'), |
|
137 | - ) . '" |
|
135 | + esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), |
|
136 | + $datetime->name() ?: esc_attr__('this datetime', 'event_espresso'), |
|
137 | + ) . '" |
|
138 | 138 | > |
139 | 139 | <span class="dashicons dashicons-groups dashicons--small"></span> |
140 | 140 | </a>'; |
141 | - } |
|
141 | + } |
|
142 | 142 | |
143 | 143 | |
144 | - /** |
|
145 | - * @param EE_Registration $registration |
|
146 | - * @param EE_Datetime|null $datetime |
|
147 | - * @param EE_Ticket|null $ticket |
|
148 | - * @return string |
|
149 | - * @throws EE_Error |
|
150 | - * @throws ReflectionException |
|
151 | - * @since 5.0.18.p |
|
152 | - */ |
|
153 | - private function viewCheckinsLink( |
|
154 | - EE_Registration $registration, |
|
155 | - ?EE_Datetime $datetime = null, |
|
156 | - ?EE_Ticket $ticket = null |
|
157 | - ): string { |
|
158 | - if (! $this->caps_handler->userCanReadRegistrationCheckin($registration)) { |
|
159 | - return ''; |
|
160 | - } |
|
161 | - $text = esc_html__('View Check-ins', 'event_espresso'); |
|
162 | - $label = esc_attr__('View Check-ins for this Event', 'event_espresso'); |
|
163 | - $class = 'ee-aria-tooltip'; |
|
144 | + /** |
|
145 | + * @param EE_Registration $registration |
|
146 | + * @param EE_Datetime|null $datetime |
|
147 | + * @param EE_Ticket|null $ticket |
|
148 | + * @return string |
|
149 | + * @throws EE_Error |
|
150 | + * @throws ReflectionException |
|
151 | + * @since 5.0.18.p |
|
152 | + */ |
|
153 | + private function viewCheckinsLink( |
|
154 | + EE_Registration $registration, |
|
155 | + ?EE_Datetime $datetime = null, |
|
156 | + ?EE_Ticket $ticket = null |
|
157 | + ): string { |
|
158 | + if (! $this->caps_handler->userCanReadRegistrationCheckin($registration)) { |
|
159 | + return ''; |
|
160 | + } |
|
161 | + $text = esc_html__('View Check-ins', 'event_espresso'); |
|
162 | + $label = esc_attr__('View Check-ins for this Event', 'event_espresso'); |
|
163 | + $class = 'ee-aria-tooltip'; |
|
164 | 164 | |
165 | - $url_params = [ |
|
166 | - 'action' => 'event_registrations', |
|
167 | - 'event_id' => $registration->event_ID(), |
|
168 | - ]; |
|
169 | - if ($datetime instanceof EE_Datetime) { |
|
170 | - $url_params['DTT_ID'] = $datetime->ID(); |
|
171 | - $text = ''; |
|
172 | - $label = esc_attr__('View Check-ins for this Datetime', 'event_espresso'); |
|
173 | - $class .= ' ee-status-color--' . $datetime->get_active_status(); |
|
174 | - } |
|
175 | - if ($ticket instanceof EE_Ticket) { |
|
176 | - $url_params['TKT_ID'] = $ticket->ID(); |
|
177 | - $text = esc_html__('View Check-ins', 'event_espresso'); |
|
178 | - $label = esc_attr__('View Check-ins for this Ticket', 'event_espresso'); |
|
179 | - $class .= ' ee-status-color--' . $ticket->ticket_status(); |
|
180 | - } |
|
181 | - $url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
|
182 | - return " |
|
165 | + $url_params = [ |
|
166 | + 'action' => 'event_registrations', |
|
167 | + 'event_id' => $registration->event_ID(), |
|
168 | + ]; |
|
169 | + if ($datetime instanceof EE_Datetime) { |
|
170 | + $url_params['DTT_ID'] = $datetime->ID(); |
|
171 | + $text = ''; |
|
172 | + $label = esc_attr__('View Check-ins for this Datetime', 'event_espresso'); |
|
173 | + $class .= ' ee-status-color--' . $datetime->get_active_status(); |
|
174 | + } |
|
175 | + if ($ticket instanceof EE_Ticket) { |
|
176 | + $url_params['TKT_ID'] = $ticket->ID(); |
|
177 | + $text = esc_html__('View Check-ins', 'event_espresso'); |
|
178 | + $label = esc_attr__('View Check-ins for this Ticket', 'event_espresso'); |
|
179 | + $class .= ' ee-status-color--' . $ticket->ticket_status(); |
|
180 | + } |
|
181 | + $url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
|
182 | + return " |
|
183 | 183 | <a aria-label='$label' class='$class' href='$url'> |
184 | 184 | <span class='dashicons dashicons-yes-alt dashicons--small'></span>$text |
185 | 185 | </a>"; |
186 | - } |
|
186 | + } |
|
187 | 187 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $actions['event_checkins'] = $this->viewCheckinsLink($registration); |
51 | 51 | return $this->columnContent( |
52 | 52 | 'event_name', |
53 | - $edit_event . $this->row_actions($actions) |
|
53 | + $edit_event.$this->row_actions($actions) |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | : []; |
73 | 73 | $datetimes_for_display = []; |
74 | 74 | foreach ($datetimes as $datetime) { |
75 | - $datetime_string = '<div class="ee-reg-list-dates-list-date">'; |
|
75 | + $datetime_string = '<div class="ee-reg-list-dates-list-date">'; |
|
76 | 76 | $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
77 | 77 | $datetime_string .= $this->row_actions( |
78 | 78 | [ |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | 'datetime_checkins' => $this->viewCheckinsLink($registration, $datetime), |
81 | 81 | ] |
82 | 82 | ); |
83 | - $datetime_string .= '</div>'; |
|
83 | + $datetime_string .= '</div>'; |
|
84 | 84 | $datetimes_for_display[] = $datetime_string; |
85 | 85 | } |
86 | 86 | return $this->columnContent( |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | ]; |
107 | 107 | return $this->columnContent( |
108 | 108 | 'REG_ticket', |
109 | - $ticket_name . $this->row_actions($actions) |
|
109 | + $ticket_name.$this->row_actions($actions) |
|
110 | 110 | ); |
111 | 111 | } |
112 | 112 | |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | ); |
131 | 131 | return ' |
132 | 132 | <a class="ee-aria-tooltip ee-datetime-filter-link" |
133 | - href="' . $datetime_filter_url . '" |
|
133 | + href="' . $datetime_filter_url.'" |
|
134 | 134 | aria-label="' . sprintf( |
135 | 135 | esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), |
136 | 136 | $datetime->name() ?: esc_attr__('this datetime', 'event_espresso'), |
137 | - ) . '" |
|
137 | + ).'" |
|
138 | 138 | > |
139 | 139 | <span class="dashicons dashicons-groups dashicons--small"></span> |
140 | 140 | </a>'; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | ?EE_Datetime $datetime = null, |
156 | 156 | ?EE_Ticket $ticket = null |
157 | 157 | ): string { |
158 | - if (! $this->caps_handler->userCanReadRegistrationCheckin($registration)) { |
|
158 | + if ( ! $this->caps_handler->userCanReadRegistrationCheckin($registration)) { |
|
159 | 159 | return ''; |
160 | 160 | } |
161 | 161 | $text = esc_html__('View Check-ins', 'event_espresso'); |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | $url_params['DTT_ID'] = $datetime->ID(); |
171 | 171 | $text = ''; |
172 | 172 | $label = esc_attr__('View Check-ins for this Datetime', 'event_espresso'); |
173 | - $class .= ' ee-status-color--' . $datetime->get_active_status(); |
|
173 | + $class .= ' ee-status-color--'.$datetime->get_active_status(); |
|
174 | 174 | } |
175 | 175 | if ($ticket instanceof EE_Ticket) { |
176 | 176 | $url_params['TKT_ID'] = $ticket->ID(); |
177 | 177 | $text = esc_html__('View Check-ins', 'event_espresso'); |
178 | 178 | $label = esc_attr__('View Check-ins for this Ticket', 'event_espresso'); |
179 | - $class .= ' ee-status-color--' . $ticket->ticket_status(); |
|
179 | + $class .= ' ee-status-color--'.$ticket->ticket_status(); |
|
180 | 180 | } |
181 | 181 | $url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
182 | 182 | return " |
@@ -23,242 +23,242 @@ |
||
23 | 23 | */ |
24 | 24 | class RegistrationsListTableFilters |
25 | 25 | { |
26 | - protected RequestInterface $request; |
|
26 | + protected RequestInterface $request; |
|
27 | 27 | |
28 | - /** |
|
29 | - * This property will hold the related Datetimes on an event IF the event ID is included in the request. |
|
30 | - */ |
|
31 | - protected DatetimesForEventCheckIn $datetimes_for_event; |
|
28 | + /** |
|
29 | + * This property will hold the related Datetimes on an event IF the event ID is included in the request. |
|
30 | + */ |
|
31 | + protected DatetimesForEventCheckIn $datetimes_for_event; |
|
32 | 32 | |
33 | - protected ?EE_Datetime $datetime = null; |
|
33 | + protected ?EE_Datetime $datetime = null; |
|
34 | 34 | |
35 | - protected ?EE_Event $event = null; |
|
35 | + protected ?EE_Event $event = null; |
|
36 | 36 | |
37 | - /** |
|
38 | - * The DTT_ID if the current view has a specified datetime. |
|
39 | - */ |
|
40 | - protected int $DTT_ID = 0; |
|
37 | + /** |
|
38 | + * The DTT_ID if the current view has a specified datetime. |
|
39 | + */ |
|
40 | + protected int $DTT_ID = 0; |
|
41 | 41 | |
42 | - /** |
|
43 | - * The event ID if one is specified in the request |
|
44 | - */ |
|
45 | - protected int $EVT_ID = 0; |
|
42 | + /** |
|
43 | + * The event ID if one is specified in the request |
|
44 | + */ |
|
45 | + protected int $EVT_ID = 0; |
|
46 | 46 | |
47 | - protected bool $hide_expired = false; |
|
47 | + protected bool $hide_expired = false; |
|
48 | 48 | |
49 | - protected bool $hide_upcoming = false; |
|
50 | - |
|
51 | - protected string $label = ''; |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * @param RequestInterface $request |
|
56 | - */ |
|
57 | - public function __construct(RequestInterface $request) |
|
58 | - { |
|
59 | - $this->request = $request; |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * @throws EE_Error |
|
65 | - * @throws ReflectionException |
|
66 | - * @since 5.0.0.p |
|
67 | - */ |
|
68 | - public function resolveRequestVars() |
|
69 | - { |
|
70 | - $this->EVT_ID = $this->request->getRequestParam('EVT_ID', 0, DataType::INTEGER); |
|
71 | - $this->EVT_ID = $this->request->getRequestParam('event_id', $this->EVT_ID, DataType::INTEGER); |
|
72 | - $this->event = EEM_Event::instance()->get_one_by_ID($this->EVT_ID); |
|
73 | - $this->datetimes_for_event = new DatetimesForEventCheckIn(EE_Capabilities::instance(), $this->event); |
|
74 | - // if we're filtering for a specific event and it only has one datetime, then grab its ID |
|
75 | - $this->datetime = $this->datetimes_for_event->getOneDatetimeForEvent(); |
|
76 | - $this->DTT_ID = $this->datetime instanceof EE_Datetime ? $this->datetime->ID() : 0; |
|
77 | - // else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ) |
|
78 | - $this->DTT_ID = $this->request->getRequestParam('DTT_ID', $this->DTT_ID, DataType::INTEGER); |
|
79 | - $this->DTT_ID = $this->request->getRequestParam('datetime_id', $this->DTT_ID, DataType::INTEGER); |
|
80 | - $this->hide_expired = $this->request->getRequestParam('hide_expired', false, DataType::BOOL); |
|
81 | - $this->hide_upcoming = $this->request->getRequestParam('hide_upcoming', false, DataType::BOOL); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - public function datetime(): ?EE_Datetime |
|
86 | - { |
|
87 | - return $this->datetime; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - public function datetimeID(): int |
|
92 | - { |
|
93 | - return $this->DTT_ID; |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - public function event(): ?EE_Event |
|
98 | - { |
|
99 | - return $this->event; |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - public function eventID(): int |
|
104 | - { |
|
105 | - return $this->EVT_ID; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @throws EE_Error |
|
111 | - * @throws ReflectionException |
|
112 | - */ |
|
113 | - public function addFiltersAfter(array $filters): array |
|
114 | - { |
|
115 | - return array_merge($filters, $this->getFilters()); |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @throws EE_Error |
|
121 | - * @throws ReflectionException |
|
122 | - */ |
|
123 | - public function addFiltersBefore(array $filters): array |
|
124 | - { |
|
125 | - return array_merge($this->getFilters(), $filters); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - public function setLabel(string $label): void |
|
130 | - { |
|
131 | - $this->label = $label; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - private function getLabel(): string |
|
136 | - { |
|
137 | - return $this->label |
|
138 | - ? '<label class="ee-event-filter-main-label">' . esc_html($this->label) . '</label>' |
|
139 | - : ''; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @throws EE_Error |
|
145 | - * @throws ReflectionException |
|
146 | - */ |
|
147 | - public function getFilters(): array |
|
148 | - { |
|
149 | - $filters = []; |
|
150 | - $hide_expired_checked = $this->hide_expired ? 'checked' : ''; |
|
151 | - $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : ''; |
|
152 | - // get datetimes for ALL active events (note possible capability restrictions) |
|
153 | - $events = $this->datetimes_for_event->getAllEvents(); |
|
154 | - $event_options[] = [ |
|
155 | - 'id' => 0, |
|
156 | - 'text' => esc_html__('Select an Event', 'event_espresso'), |
|
157 | - ]; |
|
158 | - foreach ($events as $event) { |
|
159 | - // any registrations for this event? |
|
160 | - if (! $event instanceof EE_Event) { |
|
161 | - continue; |
|
162 | - } |
|
163 | - $expired_class = $event->is_expired() ? 'ee-expired-event' : ''; |
|
164 | - $upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : ''; |
|
165 | - |
|
166 | - $event_options[] = [ |
|
167 | - 'id' => $event->ID(), |
|
168 | - 'text' => apply_filters( |
|
169 | - 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
170 | - $event->name(), |
|
171 | - $event |
|
172 | - ), |
|
173 | - 'class' => $expired_class . $upcoming_class, |
|
174 | - ]; |
|
175 | - if ($event->ID() === $this->EVT_ID) { |
|
176 | - $this->hide_expired = $expired_class === '' ? $this->hide_expired : false; |
|
177 | - $hide_expired_checked = $expired_class === '' ? $hide_expired_checked : ''; |
|
178 | - $this->hide_upcoming = $upcoming_class === '' ? $this->hide_upcoming : false; |
|
179 | - $hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : ''; |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - $select_class = $this->hide_expired ? 'ee-hide-expired-events' : ''; |
|
184 | - $select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : ''; |
|
185 | - $select_input = EEH_Form_Fields::select_input( |
|
186 | - 'EVT_ID', |
|
187 | - $event_options, |
|
188 | - $this->EVT_ID, |
|
189 | - '', |
|
190 | - $select_class |
|
191 | - ); |
|
192 | - |
|
193 | - $filters[] = $this->getLabel() . ' |
|
49 | + protected bool $hide_upcoming = false; |
|
50 | + |
|
51 | + protected string $label = ''; |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * @param RequestInterface $request |
|
56 | + */ |
|
57 | + public function __construct(RequestInterface $request) |
|
58 | + { |
|
59 | + $this->request = $request; |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * @throws EE_Error |
|
65 | + * @throws ReflectionException |
|
66 | + * @since 5.0.0.p |
|
67 | + */ |
|
68 | + public function resolveRequestVars() |
|
69 | + { |
|
70 | + $this->EVT_ID = $this->request->getRequestParam('EVT_ID', 0, DataType::INTEGER); |
|
71 | + $this->EVT_ID = $this->request->getRequestParam('event_id', $this->EVT_ID, DataType::INTEGER); |
|
72 | + $this->event = EEM_Event::instance()->get_one_by_ID($this->EVT_ID); |
|
73 | + $this->datetimes_for_event = new DatetimesForEventCheckIn(EE_Capabilities::instance(), $this->event); |
|
74 | + // if we're filtering for a specific event and it only has one datetime, then grab its ID |
|
75 | + $this->datetime = $this->datetimes_for_event->getOneDatetimeForEvent(); |
|
76 | + $this->DTT_ID = $this->datetime instanceof EE_Datetime ? $this->datetime->ID() : 0; |
|
77 | + // else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ) |
|
78 | + $this->DTT_ID = $this->request->getRequestParam('DTT_ID', $this->DTT_ID, DataType::INTEGER); |
|
79 | + $this->DTT_ID = $this->request->getRequestParam('datetime_id', $this->DTT_ID, DataType::INTEGER); |
|
80 | + $this->hide_expired = $this->request->getRequestParam('hide_expired', false, DataType::BOOL); |
|
81 | + $this->hide_upcoming = $this->request->getRequestParam('hide_upcoming', false, DataType::BOOL); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + public function datetime(): ?EE_Datetime |
|
86 | + { |
|
87 | + return $this->datetime; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + public function datetimeID(): int |
|
92 | + { |
|
93 | + return $this->DTT_ID; |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + public function event(): ?EE_Event |
|
98 | + { |
|
99 | + return $this->event; |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + public function eventID(): int |
|
104 | + { |
|
105 | + return $this->EVT_ID; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @throws EE_Error |
|
111 | + * @throws ReflectionException |
|
112 | + */ |
|
113 | + public function addFiltersAfter(array $filters): array |
|
114 | + { |
|
115 | + return array_merge($filters, $this->getFilters()); |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @throws EE_Error |
|
121 | + * @throws ReflectionException |
|
122 | + */ |
|
123 | + public function addFiltersBefore(array $filters): array |
|
124 | + { |
|
125 | + return array_merge($this->getFilters(), $filters); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + public function setLabel(string $label): void |
|
130 | + { |
|
131 | + $this->label = $label; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + private function getLabel(): string |
|
136 | + { |
|
137 | + return $this->label |
|
138 | + ? '<label class="ee-event-filter-main-label">' . esc_html($this->label) . '</label>' |
|
139 | + : ''; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @throws EE_Error |
|
145 | + * @throws ReflectionException |
|
146 | + */ |
|
147 | + public function getFilters(): array |
|
148 | + { |
|
149 | + $filters = []; |
|
150 | + $hide_expired_checked = $this->hide_expired ? 'checked' : ''; |
|
151 | + $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : ''; |
|
152 | + // get datetimes for ALL active events (note possible capability restrictions) |
|
153 | + $events = $this->datetimes_for_event->getAllEvents(); |
|
154 | + $event_options[] = [ |
|
155 | + 'id' => 0, |
|
156 | + 'text' => esc_html__('Select an Event', 'event_espresso'), |
|
157 | + ]; |
|
158 | + foreach ($events as $event) { |
|
159 | + // any registrations for this event? |
|
160 | + if (! $event instanceof EE_Event) { |
|
161 | + continue; |
|
162 | + } |
|
163 | + $expired_class = $event->is_expired() ? 'ee-expired-event' : ''; |
|
164 | + $upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : ''; |
|
165 | + |
|
166 | + $event_options[] = [ |
|
167 | + 'id' => $event->ID(), |
|
168 | + 'text' => apply_filters( |
|
169 | + 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
170 | + $event->name(), |
|
171 | + $event |
|
172 | + ), |
|
173 | + 'class' => $expired_class . $upcoming_class, |
|
174 | + ]; |
|
175 | + if ($event->ID() === $this->EVT_ID) { |
|
176 | + $this->hide_expired = $expired_class === '' ? $this->hide_expired : false; |
|
177 | + $hide_expired_checked = $expired_class === '' ? $hide_expired_checked : ''; |
|
178 | + $this->hide_upcoming = $upcoming_class === '' ? $this->hide_upcoming : false; |
|
179 | + $hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : ''; |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + $select_class = $this->hide_expired ? 'ee-hide-expired-events' : ''; |
|
184 | + $select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : ''; |
|
185 | + $select_input = EEH_Form_Fields::select_input( |
|
186 | + 'EVT_ID', |
|
187 | + $event_options, |
|
188 | + $this->EVT_ID, |
|
189 | + '', |
|
190 | + $select_class |
|
191 | + ); |
|
192 | + |
|
193 | + $filters[] = $this->getLabel() . ' |
|
194 | 194 | <div class="ee-event-filter"> |
195 | 195 | <span class="ee-event-selector"> |
196 | 196 | <label for="event_selector">' . esc_html__('Event', 'event_espresso') . '</label> |
197 | 197 | ' . $select_input . ' |
198 | 198 | </span>'; |
199 | - // DTT datetimes filter |
|
200 | - $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent( |
|
201 | - $hide_upcoming_checked === 'checked' |
|
202 | - ); |
|
203 | - if (count($datetimes_for_event) > 1) { |
|
204 | - $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso'); |
|
205 | - foreach ($datetimes_for_event as $datetime) { |
|
206 | - if ($datetime instanceof EE_Datetime) { |
|
207 | - $datetime_string = $datetime->name(); |
|
208 | - $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : ''; |
|
209 | - $datetime_string .= $datetime->date_and_time_range(); |
|
210 | - $datetime_string .= $datetime->is_active() ? ' ∗' : ''; |
|
211 | - $datetime_string .= $datetime->is_expired() ? ' «' : ''; |
|
212 | - $datetime_string .= $datetime->is_upcoming() ? ' »' : ''; |
|
213 | - // now put it all together |
|
214 | - $datetimes[ $datetime->ID() ] = $datetime_string; |
|
215 | - } |
|
216 | - } |
|
217 | - $filters[] = ' |
|
199 | + // DTT datetimes filter |
|
200 | + $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent( |
|
201 | + $hide_upcoming_checked === 'checked' |
|
202 | + ); |
|
203 | + if (count($datetimes_for_event) > 1) { |
|
204 | + $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso'); |
|
205 | + foreach ($datetimes_for_event as $datetime) { |
|
206 | + if ($datetime instanceof EE_Datetime) { |
|
207 | + $datetime_string = $datetime->name(); |
|
208 | + $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : ''; |
|
209 | + $datetime_string .= $datetime->date_and_time_range(); |
|
210 | + $datetime_string .= $datetime->is_active() ? ' ∗' : ''; |
|
211 | + $datetime_string .= $datetime->is_expired() ? ' «' : ''; |
|
212 | + $datetime_string .= $datetime->is_upcoming() ? ' »' : ''; |
|
213 | + // now put it all together |
|
214 | + $datetimes[ $datetime->ID() ] = $datetime_string; |
|
215 | + } |
|
216 | + } |
|
217 | + $filters[] = ' |
|
218 | 218 | <span class="ee-datetime-selector"> |
219 | 219 | <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label> |
220 | 220 | ' . EEH_Form_Fields::select_input( |
221 | - 'DTT_ID', |
|
222 | - $datetimes, |
|
223 | - $this->DTT_ID |
|
224 | - ) . ' |
|
221 | + 'DTT_ID', |
|
222 | + $datetimes, |
|
223 | + $this->DTT_ID |
|
224 | + ) . ' |
|
225 | 225 | </span>'; |
226 | - } |
|
227 | - $filters[] = ' |
|
226 | + } |
|
227 | + $filters[] = ' |
|
228 | 228 | <span class="ee-hide-upcoming-check"> |
229 | 229 | <label for="js-ee-hide-upcoming-events"> |
230 | 230 | <input type="checkbox" id="js-ee-hide-upcoming-events" name="hide_upcoming" ' |
231 | - . $hide_upcoming_checked |
|
232 | - . '> |
|
231 | + . $hide_upcoming_checked |
|
232 | + . '> |
|
233 | 233 | ' |
234 | - . esc_html__('Hide Upcoming Events', 'event_espresso') |
|
235 | - . ' |
|
234 | + . esc_html__('Hide Upcoming Events', 'event_espresso') |
|
235 | + . ' |
|
236 | 236 | </label> |
237 | 237 | <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" |
238 | 238 | aria-label="' |
239 | - . esc_html__( |
|
240 | - 'Will not display events in the preceding event selector with start dates in the future (ie: have not yet begun)', |
|
241 | - 'event_espresso' |
|
242 | - ) . '" |
|
239 | + . esc_html__( |
|
240 | + 'Will not display events in the preceding event selector with start dates in the future (ie: have not yet begun)', |
|
241 | + 'event_espresso' |
|
242 | + ) . '" |
|
243 | 243 | ></span> |
244 | 244 | </span> |
245 | 245 | <span class="ee-hide-expired-check"> |
246 | 246 | <label for="js-ee-hide-expired-events"> |
247 | 247 | <input type="checkbox" id="js-ee-hide-expired-events" name="hide_expired" ' |
248 | - . $hide_expired_checked |
|
249 | - . '> |
|
248 | + . $hide_expired_checked |
|
249 | + . '> |
|
250 | 250 | ' . esc_html__('Hide Expired Events', 'event_espresso') . ' |
251 | 251 | </label> |
252 | 252 | <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" |
253 | 253 | aria-label="' |
254 | - . esc_html__( |
|
255 | - 'Will not display events in the preceding event selector with end dates in the past (ie: have already finished)', |
|
256 | - 'event_espresso' |
|
257 | - ) |
|
258 | - . '" |
|
254 | + . esc_html__( |
|
255 | + 'Will not display events in the preceding event selector with end dates in the past (ie: have already finished)', |
|
256 | + 'event_espresso' |
|
257 | + ) |
|
258 | + . '" |
|
259 | 259 | ></span> |
260 | 260 | </span> |
261 | 261 | </div>'; |
262 | - return $filters; |
|
263 | - } |
|
262 | + return $filters; |
|
263 | + } |
|
264 | 264 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | private function getLabel(): string |
136 | 136 | { |
137 | 137 | return $this->label |
138 | - ? '<label class="ee-event-filter-main-label">' . esc_html($this->label) . '</label>' |
|
138 | + ? '<label class="ee-event-filter-main-label">'.esc_html($this->label).'</label>' |
|
139 | 139 | : ''; |
140 | 140 | } |
141 | 141 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | ]; |
158 | 158 | foreach ($events as $event) { |
159 | 159 | // any registrations for this event? |
160 | - if (! $event instanceof EE_Event) { |
|
160 | + if ( ! $event instanceof EE_Event) { |
|
161 | 161 | continue; |
162 | 162 | } |
163 | 163 | $expired_class = $event->is_expired() ? 'ee-expired-event' : ''; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $event->name(), |
171 | 171 | $event |
172 | 172 | ), |
173 | - 'class' => $expired_class . $upcoming_class, |
|
173 | + 'class' => $expired_class.$upcoming_class, |
|
174 | 174 | ]; |
175 | 175 | if ($event->ID() === $this->EVT_ID) { |
176 | 176 | $this->hide_expired = $expired_class === '' ? $this->hide_expired : false; |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | $select_class |
191 | 191 | ); |
192 | 192 | |
193 | - $filters[] = $this->getLabel() . ' |
|
193 | + $filters[] = $this->getLabel().' |
|
194 | 194 | <div class="ee-event-filter"> |
195 | 195 | <span class="ee-event-selector"> |
196 | - <label for="event_selector">' . esc_html__('Event', 'event_espresso') . '</label> |
|
197 | - ' . $select_input . ' |
|
196 | + <label for="event_selector">' . esc_html__('Event', 'event_espresso').'</label> |
|
197 | + ' . $select_input.' |
|
198 | 198 | </span>'; |
199 | 199 | // DTT datetimes filter |
200 | 200 | $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent( |
@@ -205,23 +205,23 @@ discard block |
||
205 | 205 | foreach ($datetimes_for_event as $datetime) { |
206 | 206 | if ($datetime instanceof EE_Datetime) { |
207 | 207 | $datetime_string = $datetime->name(); |
208 | - $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : ''; |
|
208 | + $datetime_string = ! empty($datetime_string) ? $datetime_string.': ' : ''; |
|
209 | 209 | $datetime_string .= $datetime->date_and_time_range(); |
210 | 210 | $datetime_string .= $datetime->is_active() ? ' ∗' : ''; |
211 | 211 | $datetime_string .= $datetime->is_expired() ? ' «' : ''; |
212 | 212 | $datetime_string .= $datetime->is_upcoming() ? ' »' : ''; |
213 | 213 | // now put it all together |
214 | - $datetimes[ $datetime->ID() ] = $datetime_string; |
|
214 | + $datetimes[$datetime->ID()] = $datetime_string; |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | $filters[] = ' |
218 | 218 | <span class="ee-datetime-selector"> |
219 | - <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label> |
|
219 | + <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso').'</label> |
|
220 | 220 | ' . EEH_Form_Fields::select_input( |
221 | 221 | 'DTT_ID', |
222 | 222 | $datetimes, |
223 | 223 | $this->DTT_ID |
224 | - ) . ' |
|
224 | + ).' |
|
225 | 225 | </span>'; |
226 | 226 | } |
227 | 227 | $filters[] = ' |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | . esc_html__( |
240 | 240 | 'Will not display events in the preceding event selector with start dates in the future (ie: have not yet begun)', |
241 | 241 | 'event_espresso' |
242 | - ) . '" |
|
242 | + ).'" |
|
243 | 243 | ></span> |
244 | 244 | </span> |
245 | 245 | <span class="ee-hide-expired-check"> |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | <input type="checkbox" id="js-ee-hide-expired-events" name="hide_expired" ' |
248 | 248 | . $hide_expired_checked |
249 | 249 | . '> |
250 | - ' . esc_html__('Hide Expired Events', 'event_espresso') . ' |
|
250 | + ' . esc_html__('Hide Expired Events', 'event_espresso').' |
|
251 | 251 | </label> |
252 | 252 | <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" |
253 | 253 | aria-label="' |