@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -26,859 +26,859 @@ discard block |
||
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | - private $_status; |
|
30 | - |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * An array of transaction details for the related transaction to the registration being processed. |
|
35 | - * This is set via the _set_related_details method. |
|
36 | - * |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - protected $_transaction_details = array(); |
|
40 | - |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * An array of event details for the related event to the registration being processed. |
|
45 | - * This is set via the _set_related_details method. |
|
46 | - * |
|
47 | - * @var array |
|
48 | - */ |
|
49 | - protected $_event_details = array(); |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @param \Registrations_Admin_Page $admin_page |
|
55 | - */ |
|
56 | - public function __construct(Registrations_Admin_Page $admin_page) |
|
57 | - { |
|
58 | - if ( ! empty($_GET['event_id'])) { |
|
59 | - $extra_query_args = array(); |
|
60 | - foreach ($admin_page->get_views() as $key => $view_details) { |
|
61 | - $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
|
62 | - } |
|
63 | - $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
64 | - } |
|
65 | - parent::__construct($admin_page); |
|
66 | - $this->_status = $this->_admin_page->get_registration_status_array(); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * _setup_data |
|
73 | - * |
|
74 | - * @access protected |
|
75 | - * @return void |
|
76 | - */ |
|
77 | - protected function _setup_data() |
|
78 | - { |
|
79 | - $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
80 | - $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * _set_properties |
|
87 | - * |
|
88 | - * @access protected |
|
89 | - * @return void |
|
90 | - */ |
|
91 | - protected function _set_properties() |
|
92 | - { |
|
93 | - $this->_wp_list_args = array( |
|
94 | - 'singular' => __('registration', 'event_espresso'), |
|
95 | - 'plural' => __('registrations', 'event_espresso'), |
|
96 | - 'ajax' => true, |
|
97 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
98 | - ); |
|
99 | - $ID_column_name = __('ID', 'event_espresso'); |
|
100 | - $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
101 | - $ID_column_name .= __('Registrant Name', 'event_espresso'); |
|
102 | - $ID_column_name .= '</span> '; |
|
103 | - if (isset($_GET['event_id'])) { |
|
104 | - $this->_columns = array( |
|
105 | - 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
106 | - '_REG_ID' => $ID_column_name, |
|
107 | - 'ATT_fname' => __('Name', 'event_espresso'), |
|
108 | - 'ATT_email' => __('Email', 'event_espresso'), |
|
109 | - '_REG_date' => __('Reg Date', 'event_espresso'), |
|
110 | - 'PRC_amount' => __('TKT Price', 'event_espresso'), |
|
111 | - '_REG_final_price' => __('Final Price', 'event_espresso'), |
|
112 | - 'TXN_total' => __('Total Txn', 'event_espresso'), |
|
113 | - 'TXN_paid' => __('Paid', 'event_espresso'), |
|
114 | - 'actions' => __('Actions', 'event_espresso'), |
|
115 | - ); |
|
116 | - $this->_bottom_buttons = array( |
|
117 | - 'report' => array( |
|
118 | - 'route' => 'registrations_report', |
|
119 | - 'extra_request' => array( |
|
120 | - 'EVT_ID' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
121 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
122 | - ), |
|
123 | - ), |
|
124 | - ); |
|
125 | - } else { |
|
126 | - $this->_columns = array( |
|
127 | - 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
128 | - '_REG_ID' => $ID_column_name, |
|
129 | - 'ATT_fname' => __('Name', 'event_espresso'), |
|
130 | - '_REG_date' => __('TXN Date', 'event_espresso'), |
|
131 | - 'event_name' => __('Event', 'event_espresso'), |
|
132 | - 'DTT_EVT_start' => __('Event Date', 'event_espresso'), |
|
133 | - '_REG_final_price' => __('Price', 'event_espresso'), |
|
134 | - '_REG_paid' => __('Paid', 'event_espresso'), |
|
135 | - 'actions' => __('Actions', 'event_espresso'), |
|
136 | - ); |
|
137 | - $this->_bottom_buttons = array( |
|
138 | - 'report_all' => array( |
|
139 | - 'route' => 'registrations_report', |
|
140 | - 'extra_request' => array( |
|
141 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
142 | - ), |
|
143 | - ), |
|
144 | - ); |
|
145 | - } |
|
146 | - $this->_bottom_buttons['report_filtered'] = array( |
|
147 | - 'route' => 'registrations_report', |
|
148 | - 'extra_request' => array( |
|
149 | - 'use_filters' => true, |
|
150 | - 'filters' => array_diff_key($this->_req_data, array_flip(array( |
|
151 | - 'page', |
|
152 | - 'action', |
|
153 | - 'default_nonce', |
|
154 | - ))), |
|
155 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
156 | - ), |
|
157 | - ); |
|
158 | - $this->_primary_column = '_REG_ID'; |
|
159 | - $this->_sortable_columns = array( |
|
160 | - '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
161 | - 'ATT_fname' => array('ATT_fname' => false), |
|
162 | - 'event_name' => array('event_name' => false), |
|
163 | - 'DTT_EVT_start' => array('DTT_EVT_start' => false), |
|
164 | - '_REG_ID' => array('_REG_ID' => false), |
|
165 | - ); |
|
166 | - $this->_hidden_columns = array(); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * This simply sets up the row class for the table rows. |
|
173 | - * Allows for easier overriding of child methods for setting up sorting. |
|
174 | - * |
|
175 | - * @param EE_Registration $item the current item |
|
176 | - * @return string |
|
177 | - */ |
|
178 | - protected function _get_row_class($item) |
|
179 | - { |
|
180 | - $class = parent::_get_row_class($item); |
|
181 | - //add status class |
|
182 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
183 | - if ($this->_has_checkbox_column) { |
|
184 | - $class .= ' has-checkbox-column'; |
|
185 | - } |
|
186 | - return $class; |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * Set the $_transaction_details property if not set yet. |
|
193 | - * |
|
194 | - * @param EE_Registration $registration |
|
195 | - * @throws \EE_Error |
|
196 | - */ |
|
197 | - protected function _set_related_details(EE_Registration $registration) |
|
198 | - { |
|
199 | - $transaction = $registration->get_first_related('Transaction'); |
|
200 | - $status = $transaction instanceof EE_Transaction ? $transaction->status_ID() |
|
201 | - : EEM_Transaction::failed_status_code; |
|
202 | - $this->_transaction_details = array( |
|
203 | - 'transaction' => $transaction, |
|
204 | - 'status' => $status, |
|
205 | - 'id' => $transaction instanceof EE_Transaction ? $transaction->ID() : 0, |
|
206 | - 'title_attr' => sprintf(__('View Transaction Details (%s)', 'event_espresso'), |
|
207 | - EEH_Template::pretty_status($status, false, 'sentence')), |
|
208 | - ); |
|
209 | - try { |
|
210 | - $event = $registration->event(); |
|
211 | - } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
212 | - $event = null; |
|
213 | - } |
|
214 | - $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive; |
|
215 | - $this->_event_details = array( |
|
216 | - 'event' => $event, |
|
217 | - 'status' => $status, |
|
218 | - 'id' => $event instanceof EE_Event ? $event->ID() : 0, |
|
219 | - 'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'), |
|
220 | - EEH_Template::pretty_status($status, false, 'sentence')), |
|
221 | - ); |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * _get_table_filters |
|
228 | - * |
|
229 | - * @access protected |
|
230 | - * @return array |
|
231 | - */ |
|
232 | - protected function _get_table_filters() |
|
233 | - { |
|
234 | - $filters = array(); |
|
235 | - //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods. |
|
236 | - $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
237 | - $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
238 | - $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : ''; |
|
239 | - $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
240 | - $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
241 | - $status = array(); |
|
242 | - $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso')); |
|
243 | - foreach ($this->_status as $key => $value) { |
|
244 | - $status[] = array('id' => $key, 'text' => $value); |
|
245 | - } |
|
246 | - if ($this->_view !== 'incomplete') { |
|
247 | - $filters[] = EEH_Form_Fields::select_input('_reg_status', $status, |
|
248 | - isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
249 | - : ''); |
|
250 | - } |
|
251 | - if (isset($this->_req_data['event_id'])) { |
|
252 | - $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
253 | - } |
|
254 | - return $filters; |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - |
|
259 | - /** |
|
260 | - * _add_view_counts |
|
261 | - * |
|
262 | - * @access protected |
|
263 | - * @return void |
|
264 | - * @throws \EE_Error |
|
265 | - */ |
|
266 | - protected function _add_view_counts() |
|
267 | - { |
|
268 | - $this->_views['all']['count'] = $this->_total_registrations(); |
|
269 | - $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
270 | - $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
271 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
272 | - 'espresso_registrations_trash_registrations') |
|
273 | - ) { |
|
274 | - $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
275 | - $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
276 | - } |
|
277 | - } |
|
278 | - |
|
279 | - |
|
280 | - |
|
281 | - /** |
|
282 | - * _total_registrations |
|
283 | - * |
|
284 | - * @access protected |
|
285 | - * @param string $view |
|
286 | - * @return int |
|
287 | - * @throws \EE_Error |
|
288 | - */ |
|
289 | - protected function _total_registrations($view = '') |
|
290 | - { |
|
291 | - $_where = array(); |
|
292 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
293 | - if ($EVT_ID) { |
|
294 | - $_where['EVT_ID'] = $EVT_ID; |
|
295 | - } |
|
296 | - switch ($view) { |
|
297 | - case 'trash' : |
|
298 | - return EEM_Registration::instance()->count_deleted(array($_where)); |
|
299 | - break; |
|
300 | - case 'incomplete' : |
|
301 | - $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
302 | - break; |
|
303 | - default : |
|
304 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
305 | - } |
|
306 | - return EEM_Registration::instance()->count(array($_where)); |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * _total_registrations_this_month |
|
313 | - * |
|
314 | - * @access protected |
|
315 | - * @return int |
|
316 | - * @throws \EE_Error |
|
317 | - */ |
|
318 | - protected function _total_registrations_this_month() |
|
319 | - { |
|
320 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
321 | - $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
322 | - $this_year_r = date('Y', current_time('timestamp')); |
|
323 | - $time_start = ' 00:00:00'; |
|
324 | - $time_end = ' 23:59:59'; |
|
325 | - $this_month_r = date('m', current_time('timestamp')); |
|
326 | - $days_this_month = date('t', current_time('timestamp')); |
|
327 | - //setup date query. |
|
328 | - $beginning_string = EEM_Registration::instance() |
|
329 | - ->convert_datetime_for_query('REG_date', |
|
330 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
331 | - 'Y-m-d H:i:s'); |
|
332 | - $end_string = EEM_Registration::instance() |
|
333 | - ->convert_datetime_for_query('REG_date', |
|
334 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
335 | - 'Y-m-d H:i:s'); |
|
336 | - $_where['REG_date'] = array( |
|
337 | - 'BETWEEN', |
|
338 | - array( |
|
339 | - $beginning_string, |
|
340 | - $end_string, |
|
341 | - ), |
|
342 | - ); |
|
343 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
344 | - return EEM_Registration::instance()->count(array($_where)); |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * _total_registrations_today |
|
351 | - * |
|
352 | - * @access protected |
|
353 | - * @return int |
|
354 | - * @throws \EE_Error |
|
355 | - */ |
|
356 | - protected function _total_registrations_today() |
|
357 | - { |
|
358 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
359 | - $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
360 | - $current_date = date('Y-m-d', current_time('timestamp')); |
|
361 | - $time_start = ' 00:00:00'; |
|
362 | - $time_end = ' 23:59:59'; |
|
363 | - $_where['REG_date'] = array( |
|
364 | - 'BETWEEN', |
|
365 | - array( |
|
366 | - EEM_Registration::instance() |
|
367 | - ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'), |
|
368 | - EEM_Registration::instance() |
|
369 | - ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'), |
|
370 | - ), |
|
371 | - ); |
|
372 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
373 | - return EEM_Registration::instance()->count(array($_where)); |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * column_cb |
|
380 | - * |
|
381 | - * @access public |
|
382 | - * @param \EE_Registration $item |
|
383 | - * @return string |
|
384 | - * @throws \EE_Error |
|
385 | - */ |
|
386 | - public function column_cb($item) |
|
387 | - { |
|
388 | - /** checkbox/lock **/ |
|
389 | - $transaction = $item->get_first_related('Transaction'); |
|
390 | - $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0; |
|
391 | - return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()) |
|
392 | - . '<span class="ee-lock-icon"></span>' |
|
393 | - : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()); |
|
394 | - } |
|
395 | - |
|
396 | - |
|
397 | - |
|
398 | - /** |
|
399 | - * column__REG_ID |
|
400 | - * |
|
401 | - * @access public |
|
402 | - * @param \EE_Registration $item |
|
403 | - * @return string |
|
404 | - * @throws \EE_Error |
|
405 | - */ |
|
406 | - public function column__REG_ID(EE_Registration $item) |
|
407 | - { |
|
408 | - $attendee = $item->attendee(); |
|
409 | - $content = $item->ID(); |
|
410 | - $content .= '<div class="show-on-mobile-view-only">'; |
|
411 | - $content .= '<br>'; |
|
412 | - $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
413 | - $content .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
414 | - $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
415 | - $content .= '</div>'; |
|
416 | - return $content; |
|
417 | - } |
|
418 | - |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * column__REG_date |
|
423 | - * |
|
424 | - * @access public |
|
425 | - * @param \EE_Registration $item |
|
426 | - * @return string |
|
427 | - * @throws \EE_Error |
|
428 | - */ |
|
429 | - public function column__REG_date(EE_Registration $item) |
|
430 | - { |
|
431 | - $this->_set_related_details($item); |
|
432 | - //Build row actions |
|
433 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
434 | - 'action' => 'view_transaction', |
|
435 | - 'TXN_ID' => $this->_transaction_details['id'], |
|
436 | - ), TXN_ADMIN_URL); |
|
437 | - $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
438 | - 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' |
|
439 | - . $this->_transaction_details['status'] |
|
440 | - . '" href="' |
|
441 | - . $view_lnk_url |
|
442 | - . '" title="' |
|
443 | - . esc_attr($this->_transaction_details['title_attr']) |
|
444 | - . '">' |
|
445 | - . $item->get_i18n_datetime('REG_date') |
|
446 | - . '</a>' : $item->get_i18n_datetime('REG_date'); |
|
447 | - $view_link .= '<br><span class="ee-status-text-small">' |
|
448 | - . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence') |
|
449 | - . '</span>'; |
|
450 | - return $view_link; |
|
451 | - } |
|
452 | - |
|
453 | - |
|
454 | - |
|
455 | - /** |
|
456 | - * column_event_name |
|
457 | - * |
|
458 | - * @access public |
|
459 | - * @param \EE_Registration $item |
|
460 | - * @return string |
|
461 | - * @throws \EE_Error |
|
462 | - */ |
|
463 | - public function column_event_name(EE_Registration $item) |
|
464 | - { |
|
465 | - $this->_set_related_details($item); |
|
466 | - // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
467 | - $EVT_ID = $item->event_ID(); |
|
468 | - $event_name = $item->event_name(); |
|
469 | - $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso'); |
|
470 | - $event_name = wp_trim_words($event_name, 30, '...'); |
|
471 | - if ($EVT_ID) { |
|
472 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID), |
|
473 | - EVENTS_ADMIN_URL); |
|
474 | - $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID) |
|
475 | - ? '<a class="ee-status-color-' |
|
476 | - . $this->_event_details['status'] |
|
477 | - . '" href="' |
|
478 | - . $edit_event_url |
|
479 | - . '" title="' |
|
480 | - . esc_attr($this->_event_details['title_attr']) |
|
481 | - . '">' |
|
482 | - . $event_name |
|
483 | - . '</a>' : $event_name; |
|
484 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL); |
|
485 | - $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
486 | - $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s', |
|
487 | - 'event_espresso'), $event_name); |
|
488 | - $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>'; |
|
489 | - } else { |
|
490 | - $edit_event = $event_name; |
|
491 | - $actions['event_filter'] = ''; |
|
492 | - } |
|
493 | - return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - |
|
498 | - /** |
|
499 | - * column_DTT_EVT_start |
|
500 | - * |
|
501 | - * @access public |
|
502 | - * @param \EE_Registration $item |
|
503 | - * @return string |
|
504 | - * @throws \EE_Error |
|
505 | - */ |
|
506 | - public function column_DTT_EVT_start(EE_Registration $item) |
|
507 | - { |
|
508 | - $datetime_strings = array(); |
|
509 | - $ticket = $item->ticket(true); |
|
510 | - if ($ticket instanceof EE_Ticket) { |
|
511 | - $remove_defaults = array('default_where_conditions' => 'none'); |
|
512 | - $datetimes = $ticket->datetimes($remove_defaults); |
|
513 | - foreach ($datetimes as $datetime) { |
|
514 | - $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
515 | - } |
|
516 | - return implode("<br />", $datetime_strings); |
|
517 | - } else { |
|
518 | - return __('There is no ticket on this registration', 'event_espresso'); |
|
519 | - } |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - |
|
524 | - /** |
|
525 | - * column_ATT_fname |
|
526 | - * |
|
527 | - * @access public |
|
528 | - * @param \EE_Registration $item |
|
529 | - * @return string |
|
530 | - * @throws \EE_Error |
|
531 | - */ |
|
532 | - public function column_ATT_fname(EE_Registration $item) |
|
533 | - { |
|
534 | - $attendee = $item->attendee(); |
|
535 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
536 | - 'action' => 'view_registration', |
|
537 | - '_REG_ID' => $item->ID(), |
|
538 | - ), REG_ADMIN_URL); |
|
539 | - $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
540 | - $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
541 | - 'espresso_registrations_view_registration', $item->ID()) ? '<a href="' |
|
542 | - . $edit_lnk_url |
|
543 | - . '" title="' |
|
544 | - . esc_attr__('View Registration Details', |
|
545 | - 'event_espresso') |
|
546 | - . '">' |
|
547 | - . $attendee_name |
|
548 | - . '</a>' : $attendee_name; |
|
549 | - $link .= $item->count() === 1 |
|
550 | - ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : ''; |
|
551 | - $t = $item->get_first_related('Transaction'); |
|
552 | - $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
|
553 | - //append group count to name |
|
554 | - $link .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
555 | - //append reg_code |
|
556 | - $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
557 | - //reg status text for accessibility |
|
558 | - $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
559 | - 'sentence') . '</span>'; |
|
560 | - //trash/restore/delete actions |
|
561 | - $actions = array(); |
|
562 | - if ($this->_view !== 'trash' |
|
563 | - && $payment_count === 0 |
|
564 | - && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
565 | - 'espresso_registrations_trash_registrations', $item->ID()) |
|
566 | - ) { |
|
567 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
568 | - 'action' => 'trash_registrations', |
|
569 | - '_REG_ID' => $item->ID(), |
|
570 | - ), REG_ADMIN_URL); |
|
571 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration', |
|
572 | - 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
573 | - } elseif ($this->_view === 'trash') { |
|
574 | - // restore registration link |
|
575 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
576 | - 'espresso_registrations_restore_registrations', $item->ID()) |
|
577 | - ) { |
|
578 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
579 | - 'action' => 'restore_registrations', |
|
580 | - '_REG_ID' => $item->ID(), |
|
581 | - ), REG_ADMIN_URL); |
|
582 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration', |
|
583 | - 'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>'; |
|
584 | - } |
|
585 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
586 | - 'espresso_registrations_ee_delete_registrations', $item->ID()) |
|
587 | - ) { |
|
588 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
589 | - 'action' => 'delete_registrations', |
|
590 | - '_REG_ID' => $item->ID(), |
|
591 | - ), REG_ADMIN_URL); |
|
592 | - $actions['delete'] = '<a href="' |
|
593 | - . $delete_lnk_url |
|
594 | - . '" title="' |
|
595 | - . esc_attr__('Delete Registration Permanently', 'event_espresso') |
|
596 | - . '">' |
|
597 | - . __('Delete', 'event_espresso') |
|
598 | - . '</a>'; |
|
599 | - } |
|
600 | - } |
|
601 | - return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
602 | - } |
|
603 | - |
|
604 | - |
|
605 | - |
|
606 | - /** |
|
607 | - * column_ATT_email |
|
608 | - * |
|
609 | - * @access public |
|
610 | - * @param \EE_Registration $item |
|
611 | - * @return string |
|
612 | - * @throws \EE_Error |
|
613 | - */ |
|
614 | - public function column_ATT_email(EE_Registration $item) |
|
615 | - { |
|
616 | - $attendee = $item->get_first_related('Attendee'); |
|
617 | - return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso') |
|
618 | - : $attendee->email(); |
|
619 | - } |
|
620 | - |
|
621 | - |
|
622 | - |
|
623 | - /** |
|
624 | - * column__REG_count |
|
625 | - * |
|
626 | - * @access public |
|
627 | - * @param \EE_Registration $item |
|
628 | - * @return string |
|
629 | - */ |
|
630 | - public function column__REG_count(EE_Registration $item) |
|
631 | - { |
|
632 | - return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
633 | - } |
|
634 | - |
|
635 | - |
|
636 | - |
|
637 | - /** |
|
638 | - * column_PRC_amount |
|
639 | - * |
|
640 | - * @access public |
|
641 | - * @param \EE_Registration $item |
|
642 | - * @return string |
|
643 | - */ |
|
644 | - public function column_PRC_amount(EE_Registration $item) |
|
645 | - { |
|
646 | - $ticket = $item->ticket(); |
|
647 | - $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">' |
|
648 | - . $ticket->name() |
|
649 | - . '</span><br />' : ''; |
|
650 | - if ($item->final_price() > 0) { |
|
651 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
652 | - } else { |
|
653 | - // free event |
|
654 | - $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
|
655 | - . __('free', 'event_espresso') |
|
656 | - . '</span>'; |
|
657 | - } |
|
658 | - return $content; |
|
659 | - } |
|
660 | - |
|
661 | - |
|
662 | - |
|
663 | - /** |
|
664 | - * column__REG_final_price |
|
665 | - * |
|
666 | - * @access public |
|
667 | - * @param \EE_Registration $item |
|
668 | - * @return string |
|
669 | - */ |
|
670 | - public function column__REG_final_price(EE_Registration $item) |
|
671 | - { |
|
672 | - $ticket = $item->ticket(); |
|
673 | - $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket |
|
674 | - ? '' |
|
675 | - : '<span class="TKT_name">' |
|
676 | - . $ticket->name() |
|
677 | - . '</span><br />'; |
|
678 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
679 | - return $content; |
|
680 | - } |
|
681 | - |
|
682 | - |
|
683 | - |
|
684 | - /** |
|
685 | - * column__REG_paid |
|
686 | - * |
|
687 | - * @access public |
|
688 | - * @param \EE_Registration $item |
|
689 | - * @return string |
|
690 | - */ |
|
691 | - public function column__REG_paid(EE_Registration $item) |
|
692 | - { |
|
693 | - $payment_method = $item->payment_method(); |
|
694 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() |
|
695 | - : __('Unknown', 'event_espresso'); |
|
696 | - $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
697 | - if ($item->paid() > 0) { |
|
698 | - $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
699 | - $payment_method_name) . '</span>'; |
|
700 | - } |
|
701 | - return $content; |
|
702 | - } |
|
703 | - |
|
704 | - |
|
705 | - |
|
706 | - /** |
|
707 | - * column_TXN_total |
|
708 | - * |
|
709 | - * @access public |
|
710 | - * @param \EE_Registration $item |
|
711 | - * @return string |
|
712 | - * @throws \EE_Error |
|
713 | - */ |
|
714 | - public function column_TXN_total(EE_Registration $item) |
|
715 | - { |
|
716 | - if ($item->transaction()) { |
|
717 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
718 | - 'action' => 'view_transaction', |
|
719 | - 'TXN_ID' => $item->transaction_ID(), |
|
720 | - ), TXN_ADMIN_URL); |
|
721 | - return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
722 | - 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
723 | - ? '<span class="reg-pad-rght"><a class="status-' |
|
724 | - . $item->transaction()->status_ID() |
|
725 | - . '" href="' |
|
726 | - . $view_txn_lnk_url |
|
727 | - . '" title="' |
|
728 | - . esc_attr__('View Transaction', 'event_espresso') |
|
729 | - . '">' |
|
730 | - . $item->transaction()->pretty_total() |
|
731 | - . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
732 | - } else { |
|
733 | - return __("None", "event_espresso"); |
|
734 | - } |
|
735 | - } |
|
736 | - |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * column_TXN_paid |
|
741 | - * |
|
742 | - * @access public |
|
743 | - * @param \EE_Registration $item |
|
744 | - * @return string |
|
745 | - * @throws \EE_Error |
|
746 | - */ |
|
747 | - public function column_TXN_paid(EE_Registration $item) |
|
748 | - { |
|
749 | - if ($item->count() === 1) { |
|
750 | - $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance(); |
|
751 | - if ($transaction->paid() >= $transaction->total()) { |
|
752 | - return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
753 | - } else { |
|
754 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
755 | - 'action' => 'view_transaction', |
|
756 | - 'TXN_ID' => $item->transaction_ID(), |
|
757 | - ), TXN_ADMIN_URL); |
|
758 | - return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
759 | - 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
760 | - ? '<span class="reg-pad-rght"><a class="status-' |
|
761 | - . $transaction->status_ID() |
|
762 | - . '" href="' |
|
763 | - . $view_txn_lnk_url |
|
764 | - . '" title="' |
|
765 | - . esc_attr__('View Transaction', 'event_espresso') |
|
766 | - . '">' |
|
767 | - . $item->transaction()->pretty_paid() |
|
768 | - . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
769 | - } |
|
770 | - } |
|
771 | - return ' '; |
|
772 | - } |
|
773 | - |
|
774 | - |
|
775 | - |
|
776 | - /** |
|
777 | - * column_actions |
|
778 | - * |
|
779 | - * @access public |
|
780 | - * @param \EE_Registration $item |
|
781 | - * @return string |
|
782 | - * @throws \EE_Error |
|
783 | - */ |
|
784 | - public function column_actions(EE_Registration $item) |
|
785 | - { |
|
786 | - $actions = array(); |
|
787 | - $attendee = $item->attendee(); |
|
788 | - $this->_set_related_details($item); |
|
789 | - //Build row actions |
|
790 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
791 | - 'action' => 'view_registration', |
|
792 | - '_REG_ID' => $item->ID(), |
|
793 | - ), REG_ADMIN_URL); |
|
794 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
795 | - 'action' => 'edit_attendee', |
|
796 | - 'post' => $item->attendee_ID(), |
|
797 | - ), REG_ADMIN_URL); |
|
798 | - // page=attendees&event_admin_reports=resend_email®istration_id=43653465634&event_id=2&form_action=resend_email |
|
799 | - //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID ); |
|
800 | - $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
801 | - 'action' => 'resend_registration', |
|
802 | - '_REG_ID' => $item->ID(), |
|
803 | - ), REG_ADMIN_URL, true); |
|
804 | - //Build row actions |
|
805 | - $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
806 | - 'espresso_registrations_view_registration', $item->ID()) ? ' |
|
29 | + private $_status; |
|
30 | + |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * An array of transaction details for the related transaction to the registration being processed. |
|
35 | + * This is set via the _set_related_details method. |
|
36 | + * |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected $_transaction_details = array(); |
|
40 | + |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * An array of event details for the related event to the registration being processed. |
|
45 | + * This is set via the _set_related_details method. |
|
46 | + * |
|
47 | + * @var array |
|
48 | + */ |
|
49 | + protected $_event_details = array(); |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @param \Registrations_Admin_Page $admin_page |
|
55 | + */ |
|
56 | + public function __construct(Registrations_Admin_Page $admin_page) |
|
57 | + { |
|
58 | + if ( ! empty($_GET['event_id'])) { |
|
59 | + $extra_query_args = array(); |
|
60 | + foreach ($admin_page->get_views() as $key => $view_details) { |
|
61 | + $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
|
62 | + } |
|
63 | + $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
64 | + } |
|
65 | + parent::__construct($admin_page); |
|
66 | + $this->_status = $this->_admin_page->get_registration_status_array(); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * _setup_data |
|
73 | + * |
|
74 | + * @access protected |
|
75 | + * @return void |
|
76 | + */ |
|
77 | + protected function _setup_data() |
|
78 | + { |
|
79 | + $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
80 | + $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * _set_properties |
|
87 | + * |
|
88 | + * @access protected |
|
89 | + * @return void |
|
90 | + */ |
|
91 | + protected function _set_properties() |
|
92 | + { |
|
93 | + $this->_wp_list_args = array( |
|
94 | + 'singular' => __('registration', 'event_espresso'), |
|
95 | + 'plural' => __('registrations', 'event_espresso'), |
|
96 | + 'ajax' => true, |
|
97 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
98 | + ); |
|
99 | + $ID_column_name = __('ID', 'event_espresso'); |
|
100 | + $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
101 | + $ID_column_name .= __('Registrant Name', 'event_espresso'); |
|
102 | + $ID_column_name .= '</span> '; |
|
103 | + if (isset($_GET['event_id'])) { |
|
104 | + $this->_columns = array( |
|
105 | + 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
106 | + '_REG_ID' => $ID_column_name, |
|
107 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
108 | + 'ATT_email' => __('Email', 'event_espresso'), |
|
109 | + '_REG_date' => __('Reg Date', 'event_espresso'), |
|
110 | + 'PRC_amount' => __('TKT Price', 'event_espresso'), |
|
111 | + '_REG_final_price' => __('Final Price', 'event_espresso'), |
|
112 | + 'TXN_total' => __('Total Txn', 'event_espresso'), |
|
113 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
114 | + 'actions' => __('Actions', 'event_espresso'), |
|
115 | + ); |
|
116 | + $this->_bottom_buttons = array( |
|
117 | + 'report' => array( |
|
118 | + 'route' => 'registrations_report', |
|
119 | + 'extra_request' => array( |
|
120 | + 'EVT_ID' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
121 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
122 | + ), |
|
123 | + ), |
|
124 | + ); |
|
125 | + } else { |
|
126 | + $this->_columns = array( |
|
127 | + 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
128 | + '_REG_ID' => $ID_column_name, |
|
129 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
130 | + '_REG_date' => __('TXN Date', 'event_espresso'), |
|
131 | + 'event_name' => __('Event', 'event_espresso'), |
|
132 | + 'DTT_EVT_start' => __('Event Date', 'event_espresso'), |
|
133 | + '_REG_final_price' => __('Price', 'event_espresso'), |
|
134 | + '_REG_paid' => __('Paid', 'event_espresso'), |
|
135 | + 'actions' => __('Actions', 'event_espresso'), |
|
136 | + ); |
|
137 | + $this->_bottom_buttons = array( |
|
138 | + 'report_all' => array( |
|
139 | + 'route' => 'registrations_report', |
|
140 | + 'extra_request' => array( |
|
141 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
142 | + ), |
|
143 | + ), |
|
144 | + ); |
|
145 | + } |
|
146 | + $this->_bottom_buttons['report_filtered'] = array( |
|
147 | + 'route' => 'registrations_report', |
|
148 | + 'extra_request' => array( |
|
149 | + 'use_filters' => true, |
|
150 | + 'filters' => array_diff_key($this->_req_data, array_flip(array( |
|
151 | + 'page', |
|
152 | + 'action', |
|
153 | + 'default_nonce', |
|
154 | + ))), |
|
155 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
156 | + ), |
|
157 | + ); |
|
158 | + $this->_primary_column = '_REG_ID'; |
|
159 | + $this->_sortable_columns = array( |
|
160 | + '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
161 | + 'ATT_fname' => array('ATT_fname' => false), |
|
162 | + 'event_name' => array('event_name' => false), |
|
163 | + 'DTT_EVT_start' => array('DTT_EVT_start' => false), |
|
164 | + '_REG_ID' => array('_REG_ID' => false), |
|
165 | + ); |
|
166 | + $this->_hidden_columns = array(); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * This simply sets up the row class for the table rows. |
|
173 | + * Allows for easier overriding of child methods for setting up sorting. |
|
174 | + * |
|
175 | + * @param EE_Registration $item the current item |
|
176 | + * @return string |
|
177 | + */ |
|
178 | + protected function _get_row_class($item) |
|
179 | + { |
|
180 | + $class = parent::_get_row_class($item); |
|
181 | + //add status class |
|
182 | + $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
183 | + if ($this->_has_checkbox_column) { |
|
184 | + $class .= ' has-checkbox-column'; |
|
185 | + } |
|
186 | + return $class; |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * Set the $_transaction_details property if not set yet. |
|
193 | + * |
|
194 | + * @param EE_Registration $registration |
|
195 | + * @throws \EE_Error |
|
196 | + */ |
|
197 | + protected function _set_related_details(EE_Registration $registration) |
|
198 | + { |
|
199 | + $transaction = $registration->get_first_related('Transaction'); |
|
200 | + $status = $transaction instanceof EE_Transaction ? $transaction->status_ID() |
|
201 | + : EEM_Transaction::failed_status_code; |
|
202 | + $this->_transaction_details = array( |
|
203 | + 'transaction' => $transaction, |
|
204 | + 'status' => $status, |
|
205 | + 'id' => $transaction instanceof EE_Transaction ? $transaction->ID() : 0, |
|
206 | + 'title_attr' => sprintf(__('View Transaction Details (%s)', 'event_espresso'), |
|
207 | + EEH_Template::pretty_status($status, false, 'sentence')), |
|
208 | + ); |
|
209 | + try { |
|
210 | + $event = $registration->event(); |
|
211 | + } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
212 | + $event = null; |
|
213 | + } |
|
214 | + $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive; |
|
215 | + $this->_event_details = array( |
|
216 | + 'event' => $event, |
|
217 | + 'status' => $status, |
|
218 | + 'id' => $event instanceof EE_Event ? $event->ID() : 0, |
|
219 | + 'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'), |
|
220 | + EEH_Template::pretty_status($status, false, 'sentence')), |
|
221 | + ); |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * _get_table_filters |
|
228 | + * |
|
229 | + * @access protected |
|
230 | + * @return array |
|
231 | + */ |
|
232 | + protected function _get_table_filters() |
|
233 | + { |
|
234 | + $filters = array(); |
|
235 | + //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods. |
|
236 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
237 | + $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
238 | + $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : ''; |
|
239 | + $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
240 | + $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
241 | + $status = array(); |
|
242 | + $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso')); |
|
243 | + foreach ($this->_status as $key => $value) { |
|
244 | + $status[] = array('id' => $key, 'text' => $value); |
|
245 | + } |
|
246 | + if ($this->_view !== 'incomplete') { |
|
247 | + $filters[] = EEH_Form_Fields::select_input('_reg_status', $status, |
|
248 | + isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
249 | + : ''); |
|
250 | + } |
|
251 | + if (isset($this->_req_data['event_id'])) { |
|
252 | + $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
253 | + } |
|
254 | + return $filters; |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + |
|
259 | + /** |
|
260 | + * _add_view_counts |
|
261 | + * |
|
262 | + * @access protected |
|
263 | + * @return void |
|
264 | + * @throws \EE_Error |
|
265 | + */ |
|
266 | + protected function _add_view_counts() |
|
267 | + { |
|
268 | + $this->_views['all']['count'] = $this->_total_registrations(); |
|
269 | + $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
270 | + $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
271 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
272 | + 'espresso_registrations_trash_registrations') |
|
273 | + ) { |
|
274 | + $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
275 | + $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
276 | + } |
|
277 | + } |
|
278 | + |
|
279 | + |
|
280 | + |
|
281 | + /** |
|
282 | + * _total_registrations |
|
283 | + * |
|
284 | + * @access protected |
|
285 | + * @param string $view |
|
286 | + * @return int |
|
287 | + * @throws \EE_Error |
|
288 | + */ |
|
289 | + protected function _total_registrations($view = '') |
|
290 | + { |
|
291 | + $_where = array(); |
|
292 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
293 | + if ($EVT_ID) { |
|
294 | + $_where['EVT_ID'] = $EVT_ID; |
|
295 | + } |
|
296 | + switch ($view) { |
|
297 | + case 'trash' : |
|
298 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
299 | + break; |
|
300 | + case 'incomplete' : |
|
301 | + $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
302 | + break; |
|
303 | + default : |
|
304 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
305 | + } |
|
306 | + return EEM_Registration::instance()->count(array($_where)); |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * _total_registrations_this_month |
|
313 | + * |
|
314 | + * @access protected |
|
315 | + * @return int |
|
316 | + * @throws \EE_Error |
|
317 | + */ |
|
318 | + protected function _total_registrations_this_month() |
|
319 | + { |
|
320 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
321 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
322 | + $this_year_r = date('Y', current_time('timestamp')); |
|
323 | + $time_start = ' 00:00:00'; |
|
324 | + $time_end = ' 23:59:59'; |
|
325 | + $this_month_r = date('m', current_time('timestamp')); |
|
326 | + $days_this_month = date('t', current_time('timestamp')); |
|
327 | + //setup date query. |
|
328 | + $beginning_string = EEM_Registration::instance() |
|
329 | + ->convert_datetime_for_query('REG_date', |
|
330 | + $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
331 | + 'Y-m-d H:i:s'); |
|
332 | + $end_string = EEM_Registration::instance() |
|
333 | + ->convert_datetime_for_query('REG_date', |
|
334 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
335 | + 'Y-m-d H:i:s'); |
|
336 | + $_where['REG_date'] = array( |
|
337 | + 'BETWEEN', |
|
338 | + array( |
|
339 | + $beginning_string, |
|
340 | + $end_string, |
|
341 | + ), |
|
342 | + ); |
|
343 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
344 | + return EEM_Registration::instance()->count(array($_where)); |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * _total_registrations_today |
|
351 | + * |
|
352 | + * @access protected |
|
353 | + * @return int |
|
354 | + * @throws \EE_Error |
|
355 | + */ |
|
356 | + protected function _total_registrations_today() |
|
357 | + { |
|
358 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
359 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
360 | + $current_date = date('Y-m-d', current_time('timestamp')); |
|
361 | + $time_start = ' 00:00:00'; |
|
362 | + $time_end = ' 23:59:59'; |
|
363 | + $_where['REG_date'] = array( |
|
364 | + 'BETWEEN', |
|
365 | + array( |
|
366 | + EEM_Registration::instance() |
|
367 | + ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'), |
|
368 | + EEM_Registration::instance() |
|
369 | + ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'), |
|
370 | + ), |
|
371 | + ); |
|
372 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
373 | + return EEM_Registration::instance()->count(array($_where)); |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * column_cb |
|
380 | + * |
|
381 | + * @access public |
|
382 | + * @param \EE_Registration $item |
|
383 | + * @return string |
|
384 | + * @throws \EE_Error |
|
385 | + */ |
|
386 | + public function column_cb($item) |
|
387 | + { |
|
388 | + /** checkbox/lock **/ |
|
389 | + $transaction = $item->get_first_related('Transaction'); |
|
390 | + $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0; |
|
391 | + return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()) |
|
392 | + . '<span class="ee-lock-icon"></span>' |
|
393 | + : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()); |
|
394 | + } |
|
395 | + |
|
396 | + |
|
397 | + |
|
398 | + /** |
|
399 | + * column__REG_ID |
|
400 | + * |
|
401 | + * @access public |
|
402 | + * @param \EE_Registration $item |
|
403 | + * @return string |
|
404 | + * @throws \EE_Error |
|
405 | + */ |
|
406 | + public function column__REG_ID(EE_Registration $item) |
|
407 | + { |
|
408 | + $attendee = $item->attendee(); |
|
409 | + $content = $item->ID(); |
|
410 | + $content .= '<div class="show-on-mobile-view-only">'; |
|
411 | + $content .= '<br>'; |
|
412 | + $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
413 | + $content .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
414 | + $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
415 | + $content .= '</div>'; |
|
416 | + return $content; |
|
417 | + } |
|
418 | + |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * column__REG_date |
|
423 | + * |
|
424 | + * @access public |
|
425 | + * @param \EE_Registration $item |
|
426 | + * @return string |
|
427 | + * @throws \EE_Error |
|
428 | + */ |
|
429 | + public function column__REG_date(EE_Registration $item) |
|
430 | + { |
|
431 | + $this->_set_related_details($item); |
|
432 | + //Build row actions |
|
433 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
434 | + 'action' => 'view_transaction', |
|
435 | + 'TXN_ID' => $this->_transaction_details['id'], |
|
436 | + ), TXN_ADMIN_URL); |
|
437 | + $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
438 | + 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' |
|
439 | + . $this->_transaction_details['status'] |
|
440 | + . '" href="' |
|
441 | + . $view_lnk_url |
|
442 | + . '" title="' |
|
443 | + . esc_attr($this->_transaction_details['title_attr']) |
|
444 | + . '">' |
|
445 | + . $item->get_i18n_datetime('REG_date') |
|
446 | + . '</a>' : $item->get_i18n_datetime('REG_date'); |
|
447 | + $view_link .= '<br><span class="ee-status-text-small">' |
|
448 | + . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence') |
|
449 | + . '</span>'; |
|
450 | + return $view_link; |
|
451 | + } |
|
452 | + |
|
453 | + |
|
454 | + |
|
455 | + /** |
|
456 | + * column_event_name |
|
457 | + * |
|
458 | + * @access public |
|
459 | + * @param \EE_Registration $item |
|
460 | + * @return string |
|
461 | + * @throws \EE_Error |
|
462 | + */ |
|
463 | + public function column_event_name(EE_Registration $item) |
|
464 | + { |
|
465 | + $this->_set_related_details($item); |
|
466 | + // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
467 | + $EVT_ID = $item->event_ID(); |
|
468 | + $event_name = $item->event_name(); |
|
469 | + $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso'); |
|
470 | + $event_name = wp_trim_words($event_name, 30, '...'); |
|
471 | + if ($EVT_ID) { |
|
472 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID), |
|
473 | + EVENTS_ADMIN_URL); |
|
474 | + $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID) |
|
475 | + ? '<a class="ee-status-color-' |
|
476 | + . $this->_event_details['status'] |
|
477 | + . '" href="' |
|
478 | + . $edit_event_url |
|
479 | + . '" title="' |
|
480 | + . esc_attr($this->_event_details['title_attr']) |
|
481 | + . '">' |
|
482 | + . $event_name |
|
483 | + . '</a>' : $event_name; |
|
484 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL); |
|
485 | + $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
486 | + $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s', |
|
487 | + 'event_espresso'), $event_name); |
|
488 | + $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>'; |
|
489 | + } else { |
|
490 | + $edit_event = $event_name; |
|
491 | + $actions['event_filter'] = ''; |
|
492 | + } |
|
493 | + return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + |
|
498 | + /** |
|
499 | + * column_DTT_EVT_start |
|
500 | + * |
|
501 | + * @access public |
|
502 | + * @param \EE_Registration $item |
|
503 | + * @return string |
|
504 | + * @throws \EE_Error |
|
505 | + */ |
|
506 | + public function column_DTT_EVT_start(EE_Registration $item) |
|
507 | + { |
|
508 | + $datetime_strings = array(); |
|
509 | + $ticket = $item->ticket(true); |
|
510 | + if ($ticket instanceof EE_Ticket) { |
|
511 | + $remove_defaults = array('default_where_conditions' => 'none'); |
|
512 | + $datetimes = $ticket->datetimes($remove_defaults); |
|
513 | + foreach ($datetimes as $datetime) { |
|
514 | + $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
515 | + } |
|
516 | + return implode("<br />", $datetime_strings); |
|
517 | + } else { |
|
518 | + return __('There is no ticket on this registration', 'event_espresso'); |
|
519 | + } |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + |
|
524 | + /** |
|
525 | + * column_ATT_fname |
|
526 | + * |
|
527 | + * @access public |
|
528 | + * @param \EE_Registration $item |
|
529 | + * @return string |
|
530 | + * @throws \EE_Error |
|
531 | + */ |
|
532 | + public function column_ATT_fname(EE_Registration $item) |
|
533 | + { |
|
534 | + $attendee = $item->attendee(); |
|
535 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
536 | + 'action' => 'view_registration', |
|
537 | + '_REG_ID' => $item->ID(), |
|
538 | + ), REG_ADMIN_URL); |
|
539 | + $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
540 | + $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
541 | + 'espresso_registrations_view_registration', $item->ID()) ? '<a href="' |
|
542 | + . $edit_lnk_url |
|
543 | + . '" title="' |
|
544 | + . esc_attr__('View Registration Details', |
|
545 | + 'event_espresso') |
|
546 | + . '">' |
|
547 | + . $attendee_name |
|
548 | + . '</a>' : $attendee_name; |
|
549 | + $link .= $item->count() === 1 |
|
550 | + ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : ''; |
|
551 | + $t = $item->get_first_related('Transaction'); |
|
552 | + $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
|
553 | + //append group count to name |
|
554 | + $link .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
555 | + //append reg_code |
|
556 | + $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
557 | + //reg status text for accessibility |
|
558 | + $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
559 | + 'sentence') . '</span>'; |
|
560 | + //trash/restore/delete actions |
|
561 | + $actions = array(); |
|
562 | + if ($this->_view !== 'trash' |
|
563 | + && $payment_count === 0 |
|
564 | + && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
565 | + 'espresso_registrations_trash_registrations', $item->ID()) |
|
566 | + ) { |
|
567 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
568 | + 'action' => 'trash_registrations', |
|
569 | + '_REG_ID' => $item->ID(), |
|
570 | + ), REG_ADMIN_URL); |
|
571 | + $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration', |
|
572 | + 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
573 | + } elseif ($this->_view === 'trash') { |
|
574 | + // restore registration link |
|
575 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
576 | + 'espresso_registrations_restore_registrations', $item->ID()) |
|
577 | + ) { |
|
578 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
579 | + 'action' => 'restore_registrations', |
|
580 | + '_REG_ID' => $item->ID(), |
|
581 | + ), REG_ADMIN_URL); |
|
582 | + $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration', |
|
583 | + 'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>'; |
|
584 | + } |
|
585 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
586 | + 'espresso_registrations_ee_delete_registrations', $item->ID()) |
|
587 | + ) { |
|
588 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
589 | + 'action' => 'delete_registrations', |
|
590 | + '_REG_ID' => $item->ID(), |
|
591 | + ), REG_ADMIN_URL); |
|
592 | + $actions['delete'] = '<a href="' |
|
593 | + . $delete_lnk_url |
|
594 | + . '" title="' |
|
595 | + . esc_attr__('Delete Registration Permanently', 'event_espresso') |
|
596 | + . '">' |
|
597 | + . __('Delete', 'event_espresso') |
|
598 | + . '</a>'; |
|
599 | + } |
|
600 | + } |
|
601 | + return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
602 | + } |
|
603 | + |
|
604 | + |
|
605 | + |
|
606 | + /** |
|
607 | + * column_ATT_email |
|
608 | + * |
|
609 | + * @access public |
|
610 | + * @param \EE_Registration $item |
|
611 | + * @return string |
|
612 | + * @throws \EE_Error |
|
613 | + */ |
|
614 | + public function column_ATT_email(EE_Registration $item) |
|
615 | + { |
|
616 | + $attendee = $item->get_first_related('Attendee'); |
|
617 | + return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso') |
|
618 | + : $attendee->email(); |
|
619 | + } |
|
620 | + |
|
621 | + |
|
622 | + |
|
623 | + /** |
|
624 | + * column__REG_count |
|
625 | + * |
|
626 | + * @access public |
|
627 | + * @param \EE_Registration $item |
|
628 | + * @return string |
|
629 | + */ |
|
630 | + public function column__REG_count(EE_Registration $item) |
|
631 | + { |
|
632 | + return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
633 | + } |
|
634 | + |
|
635 | + |
|
636 | + |
|
637 | + /** |
|
638 | + * column_PRC_amount |
|
639 | + * |
|
640 | + * @access public |
|
641 | + * @param \EE_Registration $item |
|
642 | + * @return string |
|
643 | + */ |
|
644 | + public function column_PRC_amount(EE_Registration $item) |
|
645 | + { |
|
646 | + $ticket = $item->ticket(); |
|
647 | + $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">' |
|
648 | + . $ticket->name() |
|
649 | + . '</span><br />' : ''; |
|
650 | + if ($item->final_price() > 0) { |
|
651 | + $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
652 | + } else { |
|
653 | + // free event |
|
654 | + $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
|
655 | + . __('free', 'event_espresso') |
|
656 | + . '</span>'; |
|
657 | + } |
|
658 | + return $content; |
|
659 | + } |
|
660 | + |
|
661 | + |
|
662 | + |
|
663 | + /** |
|
664 | + * column__REG_final_price |
|
665 | + * |
|
666 | + * @access public |
|
667 | + * @param \EE_Registration $item |
|
668 | + * @return string |
|
669 | + */ |
|
670 | + public function column__REG_final_price(EE_Registration $item) |
|
671 | + { |
|
672 | + $ticket = $item->ticket(); |
|
673 | + $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket |
|
674 | + ? '' |
|
675 | + : '<span class="TKT_name">' |
|
676 | + . $ticket->name() |
|
677 | + . '</span><br />'; |
|
678 | + $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
679 | + return $content; |
|
680 | + } |
|
681 | + |
|
682 | + |
|
683 | + |
|
684 | + /** |
|
685 | + * column__REG_paid |
|
686 | + * |
|
687 | + * @access public |
|
688 | + * @param \EE_Registration $item |
|
689 | + * @return string |
|
690 | + */ |
|
691 | + public function column__REG_paid(EE_Registration $item) |
|
692 | + { |
|
693 | + $payment_method = $item->payment_method(); |
|
694 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() |
|
695 | + : __('Unknown', 'event_espresso'); |
|
696 | + $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
697 | + if ($item->paid() > 0) { |
|
698 | + $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
699 | + $payment_method_name) . '</span>'; |
|
700 | + } |
|
701 | + return $content; |
|
702 | + } |
|
703 | + |
|
704 | + |
|
705 | + |
|
706 | + /** |
|
707 | + * column_TXN_total |
|
708 | + * |
|
709 | + * @access public |
|
710 | + * @param \EE_Registration $item |
|
711 | + * @return string |
|
712 | + * @throws \EE_Error |
|
713 | + */ |
|
714 | + public function column_TXN_total(EE_Registration $item) |
|
715 | + { |
|
716 | + if ($item->transaction()) { |
|
717 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
718 | + 'action' => 'view_transaction', |
|
719 | + 'TXN_ID' => $item->transaction_ID(), |
|
720 | + ), TXN_ADMIN_URL); |
|
721 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
722 | + 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
723 | + ? '<span class="reg-pad-rght"><a class="status-' |
|
724 | + . $item->transaction()->status_ID() |
|
725 | + . '" href="' |
|
726 | + . $view_txn_lnk_url |
|
727 | + . '" title="' |
|
728 | + . esc_attr__('View Transaction', 'event_espresso') |
|
729 | + . '">' |
|
730 | + . $item->transaction()->pretty_total() |
|
731 | + . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
732 | + } else { |
|
733 | + return __("None", "event_espresso"); |
|
734 | + } |
|
735 | + } |
|
736 | + |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * column_TXN_paid |
|
741 | + * |
|
742 | + * @access public |
|
743 | + * @param \EE_Registration $item |
|
744 | + * @return string |
|
745 | + * @throws \EE_Error |
|
746 | + */ |
|
747 | + public function column_TXN_paid(EE_Registration $item) |
|
748 | + { |
|
749 | + if ($item->count() === 1) { |
|
750 | + $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance(); |
|
751 | + if ($transaction->paid() >= $transaction->total()) { |
|
752 | + return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
753 | + } else { |
|
754 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
755 | + 'action' => 'view_transaction', |
|
756 | + 'TXN_ID' => $item->transaction_ID(), |
|
757 | + ), TXN_ADMIN_URL); |
|
758 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
759 | + 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
760 | + ? '<span class="reg-pad-rght"><a class="status-' |
|
761 | + . $transaction->status_ID() |
|
762 | + . '" href="' |
|
763 | + . $view_txn_lnk_url |
|
764 | + . '" title="' |
|
765 | + . esc_attr__('View Transaction', 'event_espresso') |
|
766 | + . '">' |
|
767 | + . $item->transaction()->pretty_paid() |
|
768 | + . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
769 | + } |
|
770 | + } |
|
771 | + return ' '; |
|
772 | + } |
|
773 | + |
|
774 | + |
|
775 | + |
|
776 | + /** |
|
777 | + * column_actions |
|
778 | + * |
|
779 | + * @access public |
|
780 | + * @param \EE_Registration $item |
|
781 | + * @return string |
|
782 | + * @throws \EE_Error |
|
783 | + */ |
|
784 | + public function column_actions(EE_Registration $item) |
|
785 | + { |
|
786 | + $actions = array(); |
|
787 | + $attendee = $item->attendee(); |
|
788 | + $this->_set_related_details($item); |
|
789 | + //Build row actions |
|
790 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
791 | + 'action' => 'view_registration', |
|
792 | + '_REG_ID' => $item->ID(), |
|
793 | + ), REG_ADMIN_URL); |
|
794 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
795 | + 'action' => 'edit_attendee', |
|
796 | + 'post' => $item->attendee_ID(), |
|
797 | + ), REG_ADMIN_URL); |
|
798 | + // page=attendees&event_admin_reports=resend_email®istration_id=43653465634&event_id=2&form_action=resend_email |
|
799 | + //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID ); |
|
800 | + $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
801 | + 'action' => 'resend_registration', |
|
802 | + '_REG_ID' => $item->ID(), |
|
803 | + ), REG_ADMIN_URL, true); |
|
804 | + //Build row actions |
|
805 | + $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
806 | + 'espresso_registrations_view_registration', $item->ID()) ? ' |
|
807 | 807 | <li> |
808 | 808 | <a href="' . $view_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text"> |
809 | 809 | <div class="dashicons dashicons-clipboard"></div> |
810 | 810 | </a> |
811 | 811 | </li>' : ''; |
812 | - $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', |
|
813 | - 'espresso_registrations_edit_attendee') |
|
814 | - && $attendee instanceof EE_Attendee ? ' |
|
812 | + $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', |
|
813 | + 'espresso_registrations_edit_attendee') |
|
814 | + && $attendee instanceof EE_Attendee ? ' |
|
815 | 815 | <li> |
816 | 816 | <a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text"> |
817 | 817 | <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div> |
818 | 818 | </a> |
819 | 819 | </li>' : ''; |
820 | - $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee |
|
821 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
822 | - 'espresso_registrations_resend_registration', $item->ID()) ? ' |
|
820 | + $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee |
|
821 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
822 | + 'espresso_registrations_resend_registration', $item->ID()) ? ' |
|
823 | 823 | <li> |
824 | 824 | <a href="' |
825 | - . $resend_reg_lnk_url |
|
826 | - . '" title="' |
|
827 | - . esc_attr__('Resend Registration Details', |
|
828 | - 'event_espresso') |
|
829 | - . '" class="tiny-text"> |
|
825 | + . $resend_reg_lnk_url |
|
826 | + . '" title="' |
|
827 | + . esc_attr__('Resend Registration Details', |
|
828 | + 'event_espresso') |
|
829 | + . '" class="tiny-text"> |
|
830 | 830 | <div class="dashicons dashicons-email-alt"></div> |
831 | 831 | </a> |
832 | 832 | </li>' : ''; |
833 | - // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb |
|
834 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
835 | - 'action' => 'view_transaction', |
|
836 | - 'TXN_ID' => $this->_transaction_details['id'], |
|
837 | - ), TXN_ADMIN_URL); |
|
838 | - $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
839 | - 'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? ' |
|
833 | + // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb |
|
834 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
835 | + 'action' => 'view_transaction', |
|
836 | + 'TXN_ID' => $this->_transaction_details['id'], |
|
837 | + ), TXN_ADMIN_URL); |
|
838 | + $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
839 | + 'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? ' |
|
840 | 840 | <li> |
841 | 841 | <a class="ee-status-color-' |
842 | - . $this->_transaction_details['status'] |
|
843 | - . ' tiny-text" href="' |
|
844 | - . $view_txn_lnk_url |
|
845 | - . '" title="' |
|
846 | - . $this->_transaction_details['title_attr'] |
|
847 | - . '"> |
|
842 | + . $this->_transaction_details['status'] |
|
843 | + . ' tiny-text" href="' |
|
844 | + . $view_txn_lnk_url |
|
845 | + . '" title="' |
|
846 | + . $this->_transaction_details['title_attr'] |
|
847 | + . '"> |
|
848 | 848 | <div class="dashicons dashicons-cart"></div> |
849 | 849 | </a> |
850 | 850 | </li>' : ''; |
851 | - //invoice link |
|
852 | - $actions['dl_invoice_lnk'] = ''; |
|
853 | - $dl_invoice_lnk_url = $item->invoice_url(); |
|
854 | - //only show invoice link if message type is active. |
|
855 | - if ($attendee instanceof EE_Attendee |
|
856 | - && $item->is_primary_registrant() |
|
857 | - && EEH_MSG_Template::is_mt_active('invoice') |
|
858 | - ) { |
|
859 | - $actions['dl_invoice_lnk'] = ' |
|
851 | + //invoice link |
|
852 | + $actions['dl_invoice_lnk'] = ''; |
|
853 | + $dl_invoice_lnk_url = $item->invoice_url(); |
|
854 | + //only show invoice link if message type is active. |
|
855 | + if ($attendee instanceof EE_Attendee |
|
856 | + && $item->is_primary_registrant() |
|
857 | + && EEH_MSG_Template::is_mt_active('invoice') |
|
858 | + ) { |
|
859 | + $actions['dl_invoice_lnk'] = ' |
|
860 | 860 | <li> |
861 | 861 | <a title="' |
862 | - . esc_attr__('View Transaction Invoice', 'event_espresso') |
|
863 | - . '" target="_blank" href="' |
|
864 | - . $dl_invoice_lnk_url |
|
865 | - . '" class="tiny-text"> |
|
862 | + . esc_attr__('View Transaction Invoice', 'event_espresso') |
|
863 | + . '" target="_blank" href="' |
|
864 | + . $dl_invoice_lnk_url |
|
865 | + . '" class="tiny-text"> |
|
866 | 866 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
867 | 867 | </a> |
868 | 868 | </li>'; |
869 | - } |
|
870 | - $actions['filtered_messages_link'] = ''; |
|
871 | - //message list table link (filtered by REG_ID |
|
872 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
873 | - $actions['filtered_messages_link'] = '<li>' |
|
874 | - . EEH_MSG_Template::get_message_action_link('see_notifications_for', |
|
875 | - null, array( |
|
876 | - '_REG_ID' => $item->ID(), |
|
877 | - )) |
|
878 | - . '</li>'; |
|
879 | - } |
|
880 | - $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this); |
|
881 | - return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul'); |
|
882 | - } |
|
869 | + } |
|
870 | + $actions['filtered_messages_link'] = ''; |
|
871 | + //message list table link (filtered by REG_ID |
|
872 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
873 | + $actions['filtered_messages_link'] = '<li>' |
|
874 | + . EEH_MSG_Template::get_message_action_link('see_notifications_for', |
|
875 | + null, array( |
|
876 | + '_REG_ID' => $item->ID(), |
|
877 | + )) |
|
878 | + . '</li>'; |
|
879 | + } |
|
880 | + $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this); |
|
881 | + return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul'); |
|
882 | + } |
|
883 | 883 | |
884 | 884 | } |
@@ -111,14 +111,14 @@ |
||
111 | 111 | |
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * Alters the query params so that only trashed/soft-deleted items are considered |
|
116 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
117 | - * @return array like EEM_Base::get_all's $query_params |
|
118 | - */ |
|
114 | + /** |
|
115 | + * Alters the query params so that only trashed/soft-deleted items are considered |
|
116 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
117 | + * @return array like EEM_Base::get_all's $query_params |
|
118 | + */ |
|
119 | 119 | public function alter_query_params_so_only_trashed_items_included($query_params){ |
120 | - return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
121 | - } |
|
120 | + return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
121 | + } |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Alters the query params so each item's deleted status is ignored. |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once( EE_MODELS . 'EEM_Base.model.php'); |
|
2 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * EEM_Soft_Delete_Base |
5 | 5 | * |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | * @subpackage includes/models/ |
26 | 26 | * @author Michael Nelson |
27 | 27 | */ |
28 | -abstract class EEM_Soft_Delete_Base extends EEM_Base{ |
|
28 | +abstract class EEM_Soft_Delete_Base extends EEM_Base { |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param null $timezone |
32 | 32 | */ |
33 | 33 | protected function __construct($timezone = NULL) { |
34 | - if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ){ |
|
34 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
35 | 35 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
36 | 36 | } |
37 | 37 | parent::__construct($timezone); |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * @return string |
43 | 43 | * @throws EE_Error |
44 | 44 | */ |
45 | - public function deleted_field_name(){ |
|
45 | + public function deleted_field_name() { |
|
46 | 46 | $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
47 | - if($field){ |
|
47 | + if ($field) { |
|
48 | 48 | return $field->get_name(); |
49 | - }else{ |
|
50 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
49 | + } else { |
|
50 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $query_params like EEM_Base::get_all's $query_params |
58 | 58 | * @return EE_Soft_Delete_Base_Class |
59 | 59 | */ |
60 | - public function get_one_deleted($query_params = array()){ |
|
60 | + public function get_one_deleted($query_params = array()) { |
|
61 | 61 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
62 | 62 | return parent::get_one($query_params); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param array $query_params like EEM_base::get_all's $query_params |
68 | 68 | * @return EE_Soft_Delete_Base_Class |
69 | 69 | */ |
70 | - public function get_one_deleted_or_undeleted($query_params = array()){ |
|
70 | + public function get_one_deleted_or_undeleted($query_params = array()) { |
|
71 | 71 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
72 | 72 | return parent::get_one($query_params); |
73 | 73 | } |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param int|string $id |
78 | 78 | * @return EE_Soft_Delete_Base_Class |
79 | 79 | */ |
80 | - public function get_one_by_ID_but_ignore_deleted($id){ |
|
80 | + public function get_one_by_ID_but_ignore_deleted($id) { |
|
81 | 81 | return $this->get_one( |
82 | 82 | $this->alter_query_params_to_restrict_by_ID( |
83 | 83 | $id, |
84 | - array( 'default_where_conditions' => 'default' ) |
|
84 | + array('default_where_conditions' => 'default') |
|
85 | 85 | ) |
86 | 86 | ); |
87 | 87 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
94 | 94 | * @return int |
95 | 95 | */ |
96 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
96 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
97 | 97 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
98 | 98 | return parent::count($query_params, $field_to_count, $distinct); |
99 | 99 | } |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | * @param array $query_params like EEM_Base::get_all's $query_params |
104 | 104 | * @return array like EEM_Base::get_all's $query_params |
105 | 105 | */ |
106 | - protected function _alter_query_params_so_only_trashed_items_included($query_params){ |
|
107 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
108 | - $query_params[0][$deletedFlagFieldName]=true; |
|
106 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) { |
|
107 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
108 | + $query_params[0][$deletedFlagFieldName] = true; |
|
109 | 109 | return $query_params; |
110 | 110 | } |
111 | 111 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param array $query_params like EEM_Base::get_all's $query_params |
117 | 117 | * @return array like EEM_Base::get_all's $query_params |
118 | 118 | */ |
119 | - public function alter_query_params_so_only_trashed_items_included($query_params){ |
|
119 | + public function alter_query_params_so_only_trashed_items_included($query_params) { |
|
120 | 120 | return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
121 | 121 | } |
122 | 122 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param array $query_params |
126 | 126 | * @return array |
127 | 127 | */ |
128 | - public function alter_query_params_so_deleted_and_undeleted_items_included( $query_params = array() ){ |
|
128 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) { |
|
129 | 129 | return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
130 | 130 | } |
131 | 131 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @param array $query_params |
135 | 135 | * @return array |
136 | 136 | */ |
137 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
138 | - if( ! isset( $query_params[ 'default_where_conditions' ] ) ) { |
|
137 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
138 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
139 | 139 | $query_params['default_where_conditions'] = 'minimum'; |
140 | 140 | } |
141 | 141 | return $query_params; |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
149 | 149 | * @return int |
150 | 150 | */ |
151 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
151 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
152 | 152 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
153 | - return parent::count($query_params,$field_to_count, $distinct); |
|
153 | + return parent::count($query_params, $field_to_count, $distinct); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param string $field_to_sum |
160 | 160 | * @return int |
161 | 161 | */ |
162 | - public function sum_deleted($query_params = null, $field_to_sum = null){ |
|
162 | + public function sum_deleted($query_params = null, $field_to_sum = null) { |
|
163 | 163 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
164 | 164 | return parent::sum($query_params, $field_to_sum); |
165 | 165 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param string $field_to_sum |
171 | 171 | * @return int |
172 | 172 | */ |
173 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null){ |
|
173 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) { |
|
174 | 174 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
175 | 175 | parent::sum($query_params, $field_to_sum); |
176 | 176 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param array $query_params like EEM_Base::get_all |
181 | 181 | * @return EE_Soft_Delete_Base_Class[] |
182 | 182 | */ |
183 | - public function get_all_deleted_and_undeleted($query_params = array()){ |
|
183 | + public function get_all_deleted_and_undeleted($query_params = array()) { |
|
184 | 184 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
185 | 185 | return parent::get_all($query_params); |
186 | 186 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param array $query_params like EEM_Base::get_all |
191 | 191 | * @return EE_Soft_Delete_Base_Class[] |
192 | 192 | */ |
193 | - public function get_all_deleted($query_params = array()){ |
|
193 | + public function get_all_deleted($query_params = array()) { |
|
194 | 194 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
195 | 195 | return parent::get_all($query_params); |
196 | 196 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
209 | 209 | * @return boolean success |
210 | 210 | */ |
211 | - public function delete_permanently($query_params = array(), $allow_blocking = true){ |
|
211 | + public function delete_permanently($query_params = array(), $allow_blocking = true) { |
|
212 | 212 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
213 | 213 | return parent::delete_permanently($query_params, $allow_blocking); |
214 | 214 | } |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | * @param mixed $ID int if primary key is an int, string otherwise |
220 | 220 | * @return boolean success |
221 | 221 | */ |
222 | - public function restore_by_ID($ID=FALSE){ |
|
223 | - return $this->delete_or_restore_by_ID(false,$ID); |
|
222 | + public function restore_by_ID($ID = FALSE) { |
|
223 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
224 | 224 | } |
225 | 225 | /** |
226 | 226 | * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
@@ -229,14 +229,14 @@ discard block |
||
229 | 229 | * @param mixed $ID int if primary key is an int, string otherwise |
230 | 230 | * @return boolean |
231 | 231 | */ |
232 | - public function delete_or_restore_by_ID($delete=true,$ID=FALSE){ |
|
233 | - if ( ! $ID ) { |
|
232 | + public function delete_or_restore_by_ID($delete = true, $ID = FALSE) { |
|
233 | + if ( ! $ID) { |
|
234 | 234 | return FALSE; |
235 | 235 | } |
236 | 236 | if ( |
237 | 237 | $this->delete_or_restore( |
238 | 238 | $delete, |
239 | - $this->alter_query_params_to_restrict_by_ID( $ID ) |
|
239 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
240 | 240 | ) |
241 | 241 | ) { |
242 | 242 | return TRUE; |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @param bool $block_deletes |
257 | 257 | * @return boolean |
258 | 258 | */ |
259 | - public function delete($query_params = array(), $block_deletes = false){ |
|
259 | + public function delete($query_params = array(), $block_deletes = false) { |
|
260 | 260 | //no matter what, we WON'T block soft deletes. |
261 | 261 | return $this->delete_or_restore(true, $query_params); |
262 | 262 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @param array $query_params like EEM_Base::get_all |
268 | 268 | * @return boolean |
269 | 269 | */ |
270 | - public function restore($query_params = array()){ |
|
270 | + public function restore($query_params = array()) { |
|
271 | 271 | return $this->delete_or_restore(false, $query_params); |
272 | 272 | } |
273 | 273 | /** |
@@ -276,10 +276,10 @@ discard block |
||
276 | 276 | * @param array $query_params like EEM_Base::get_all |
277 | 277 | * @return boolean |
278 | 278 | */ |
279 | - function delete_or_restore($delete=true,$query_params = array()){ |
|
280 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
279 | + function delete_or_restore($delete = true, $query_params = array()) { |
|
280 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
281 | 281 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
282 | - if ( $this->update (array($deletedFlagFieldName=>$delete), $query_params )) { |
|
282 | + if ($this->update(array($deletedFlagFieldName=>$delete), $query_params)) { |
|
283 | 283 | return TRUE; |
284 | 284 | } else { |
285 | 285 | return FALSE; |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | * be aware that model objects being used could get out-of-sync with the database |
298 | 298 | * @return int number of items updated |
299 | 299 | */ |
300 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE ){ |
|
300 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
301 | 301 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
302 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync ); |
|
302 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
303 | 303 | } |
304 | 304 | } |
@@ -350,7 +350,7 @@ |
||
350 | 350 | static function ordinalize($number){ |
351 | 351 | if(in_array(($number % 100), range(11, 13))){ |
352 | 352 | return $number . 'th'; |
353 | - }else{ |
|
353 | + } else{ |
|
354 | 354 | switch(($number % 10)){ |
355 | 355 | case 1: |
356 | 356 | return $number . 'st'; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
18 | 18 | |
19 | 19 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
20 | - exit('No direct script access allowed'); |
|
20 | + exit('No direct script access allowed'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -25,424 +25,423 @@ discard block |
||
25 | 25 | class RegistrationsReport extends JobHandlerFile |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Performs any necessary setup for starting the job. This is also a good |
|
30 | - * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
31 | - * when continue_job will be called |
|
32 | - * |
|
33 | - * @param JobParameters $job_parameters |
|
34 | - * @throws BatchRequestException |
|
35 | - * @return JobStepResponse |
|
36 | - */ |
|
37 | - public function create_job(JobParameters $job_parameters) |
|
38 | - { |
|
39 | - $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
40 | - if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
41 | - throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso')); |
|
42 | - } |
|
43 | - $filepath = $this->create_file_from_job_with_name($job_parameters->job_id(), |
|
44 | - $this->get_filename($event_id)); |
|
45 | - $job_parameters->add_extra_data('filepath', $filepath); |
|
46 | - if ($job_parameters->request_datum('use_filters', false)) { |
|
47 | - $query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array()))); |
|
48 | - } else { |
|
49 | - $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
50 | - array( |
|
51 | - 'OR' => array( |
|
52 | - //don't include registrations from failed or abandoned transactions... |
|
53 | - 'Transaction.STS_ID' => array( |
|
54 | - 'NOT IN', |
|
55 | - array( |
|
56 | - \EEM_Transaction::failed_status_code, |
|
57 | - \EEM_Transaction::abandoned_status_code, |
|
58 | - ), |
|
59 | - ), |
|
60 | - //unless the registration is approved, in which case include it regardless of transaction status |
|
61 | - 'STS_ID' => \EEM_Registration::status_id_approved, |
|
62 | - ), |
|
63 | - 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
64 | - ), |
|
65 | - 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
66 | - 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
67 | - 'caps' => \EEM_Base::caps_read_admin, |
|
68 | - ), $event_id); |
|
69 | - if ($event_id) { |
|
70 | - $query_params[0]['EVT_ID'] = $event_id; |
|
71 | - } else { |
|
72 | - $query_params['force_join'][] = 'Event'; |
|
73 | - } |
|
74 | - } |
|
75 | - if ( ! isset($query_params['force_join'])) { |
|
76 | - $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee'); |
|
77 | - } |
|
78 | - $job_parameters->add_extra_data('query_params', $query_params); |
|
79 | - $question_labels = $this->_get_question_labels($query_params); |
|
80 | - $job_parameters->add_extra_data('question_labels', $question_labels); |
|
81 | - $job_parameters->set_job_size( |
|
82 | - \EEM_Registration::instance()->count( |
|
83 | - array_diff_key( |
|
84 | - $query_params, |
|
85 | - array_flip( |
|
86 | - array( 'limit' ) |
|
87 | - ) |
|
88 | - ) |
|
89 | - ) |
|
90 | - ); |
|
91 | - //we should also set the header columns |
|
92 | - $csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('question_labels'), |
|
93 | - $job_parameters->extra_datum('query_params')); |
|
94 | - \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
95 | - //if we actually processed a row there, record it |
|
96 | - if ($job_parameters->job_size()) { |
|
97 | - $job_parameters->mark_processed(1); |
|
98 | - } |
|
99 | - return new JobStepResponse($job_parameters, |
|
100 | - __('Registrations report started successfully...', 'event_espresso')); |
|
101 | - } |
|
28 | + /** |
|
29 | + * Performs any necessary setup for starting the job. This is also a good |
|
30 | + * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
31 | + * when continue_job will be called |
|
32 | + * |
|
33 | + * @param JobParameters $job_parameters |
|
34 | + * @throws BatchRequestException |
|
35 | + * @return JobStepResponse |
|
36 | + */ |
|
37 | + public function create_job(JobParameters $job_parameters) |
|
38 | + { |
|
39 | + $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
40 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
41 | + throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso')); |
|
42 | + } |
|
43 | + $filepath = $this->create_file_from_job_with_name($job_parameters->job_id(), |
|
44 | + $this->get_filename($event_id)); |
|
45 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
46 | + if ($job_parameters->request_datum('use_filters', false)) { |
|
47 | + $query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array()))); |
|
48 | + } else { |
|
49 | + $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
50 | + array( |
|
51 | + 'OR' => array( |
|
52 | + //don't include registrations from failed or abandoned transactions... |
|
53 | + 'Transaction.STS_ID' => array( |
|
54 | + 'NOT IN', |
|
55 | + array( |
|
56 | + \EEM_Transaction::failed_status_code, |
|
57 | + \EEM_Transaction::abandoned_status_code, |
|
58 | + ), |
|
59 | + ), |
|
60 | + //unless the registration is approved, in which case include it regardless of transaction status |
|
61 | + 'STS_ID' => \EEM_Registration::status_id_approved, |
|
62 | + ), |
|
63 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
64 | + ), |
|
65 | + 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
66 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
67 | + 'caps' => \EEM_Base::caps_read_admin, |
|
68 | + ), $event_id); |
|
69 | + if ($event_id) { |
|
70 | + $query_params[0]['EVT_ID'] = $event_id; |
|
71 | + } else { |
|
72 | + $query_params['force_join'][] = 'Event'; |
|
73 | + } |
|
74 | + } |
|
75 | + if ( ! isset($query_params['force_join'])) { |
|
76 | + $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee'); |
|
77 | + } |
|
78 | + $job_parameters->add_extra_data('query_params', $query_params); |
|
79 | + $question_labels = $this->_get_question_labels($query_params); |
|
80 | + $job_parameters->add_extra_data('question_labels', $question_labels); |
|
81 | + $job_parameters->set_job_size( |
|
82 | + \EEM_Registration::instance()->count( |
|
83 | + array_diff_key( |
|
84 | + $query_params, |
|
85 | + array_flip( |
|
86 | + array( 'limit' ) |
|
87 | + ) |
|
88 | + ) |
|
89 | + ) |
|
90 | + ); |
|
91 | + //we should also set the header columns |
|
92 | + $csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('question_labels'), |
|
93 | + $job_parameters->extra_datum('query_params')); |
|
94 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
95 | + //if we actually processed a row there, record it |
|
96 | + if ($job_parameters->job_size()) { |
|
97 | + $job_parameters->mark_processed(1); |
|
98 | + } |
|
99 | + return new JobStepResponse($job_parameters, |
|
100 | + __('Registrations report started successfully...', 'event_espresso')); |
|
101 | + } |
|
102 | 102 | |
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * Gets the filename |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - protected function get_filename() |
|
110 | - { |
|
111 | - return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql'))); |
|
112 | - } |
|
105 | + /** |
|
106 | + * Gets the filename |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + protected function get_filename() |
|
110 | + { |
|
111 | + return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql'))); |
|
112 | + } |
|
113 | 113 | |
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * Gets the questions which are to be used for this report, so they |
|
118 | - * can be remembered for later |
|
119 | - * |
|
120 | - * @param array $registration_query_params |
|
121 | - * @return array question admin labels to be used for this report |
|
122 | - */ |
|
123 | - protected function _get_question_labels($registration_query_params) |
|
124 | - { |
|
125 | - $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null; |
|
126 | - $question_query_params = array(); |
|
127 | - if ($where !== null) { |
|
128 | - $question_query_params = array( |
|
129 | - $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]), |
|
130 | - ); |
|
131 | - } |
|
132 | - $question_query_params[0]['Answer.ANS_ID'] = array( 'IS_NOT_NULL' ); |
|
133 | - $question_query_params['group_by'] = array( 'QST_ID' ); |
|
134 | - return array_unique( \EEM_Question::instance()->get_col( $question_query_params, 'QST_admin_label' ) ); |
|
135 | - } |
|
116 | + /** |
|
117 | + * Gets the questions which are to be used for this report, so they |
|
118 | + * can be remembered for later |
|
119 | + * |
|
120 | + * @param array $registration_query_params |
|
121 | + * @return array question admin labels to be used for this report |
|
122 | + */ |
|
123 | + protected function _get_question_labels($registration_query_params) |
|
124 | + { |
|
125 | + $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null; |
|
126 | + $question_query_params = array(); |
|
127 | + if ($where !== null) { |
|
128 | + $question_query_params = array( |
|
129 | + $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]), |
|
130 | + ); |
|
131 | + } |
|
132 | + $question_query_params[0]['Answer.ANS_ID'] = array( 'IS_NOT_NULL' ); |
|
133 | + $question_query_params['group_by'] = array( 'QST_ID' ); |
|
134 | + return array_unique( \EEM_Question::instance()->get_col( $question_query_params, 'QST_admin_label' ) ); |
|
135 | + } |
|
136 | 136 | |
137 | 137 | |
138 | 138 | |
139 | - /** |
|
140 | - * Takes where params meant for registrations and changes them to work for questions |
|
141 | - * |
|
142 | - * @param array $reg_where_params |
|
143 | - * @return array |
|
144 | - */ |
|
145 | - protected function _change_registration_where_params_to_question_where_params($reg_where_params) |
|
146 | - { |
|
147 | - $question_where_params = array(); |
|
148 | - foreach ($reg_where_params as $key => $val) { |
|
149 | - if (\EEM_Registration::instance()->is_logic_query_param_key($key)) { |
|
150 | - $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val); |
|
151 | - } else { |
|
152 | - //it's a normal where condition |
|
153 | - $question_where_params['Question_Group.Event.Registration.' . $key] = $val; |
|
154 | - } |
|
155 | - } |
|
156 | - return $question_where_params; |
|
157 | - } |
|
139 | + /** |
|
140 | + * Takes where params meant for registrations and changes them to work for questions |
|
141 | + * |
|
142 | + * @param array $reg_where_params |
|
143 | + * @return array |
|
144 | + */ |
|
145 | + protected function _change_registration_where_params_to_question_where_params($reg_where_params) |
|
146 | + { |
|
147 | + $question_where_params = array(); |
|
148 | + foreach ($reg_where_params as $key => $val) { |
|
149 | + if (\EEM_Registration::instance()->is_logic_query_param_key($key)) { |
|
150 | + $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val); |
|
151 | + } else { |
|
152 | + //it's a normal where condition |
|
153 | + $question_where_params['Question_Group.Event.Registration.' . $key] = $val; |
|
154 | + } |
|
155 | + } |
|
156 | + return $question_where_params; |
|
157 | + } |
|
158 | 158 | |
159 | 159 | |
160 | 160 | |
161 | - /** |
|
162 | - * Performs another step of the job |
|
163 | - * |
|
164 | - * @param JobParameters $job_parameters |
|
165 | - * @param int $batch_size |
|
166 | - * @return JobStepResponse |
|
167 | - * @throws \EE_Error |
|
168 | - */ |
|
169 | - public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
170 | - { |
|
171 | - if( $job_parameters->units_processed() < $job_parameters->job_size() ) { |
|
172 | - $csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'), |
|
173 | - $job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('question_labels'), |
|
174 | - $job_parameters->extra_datum('query_params')); |
|
175 | - \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
176 | - $units_processed = count($csv_data); |
|
177 | - }else{ |
|
178 | - $units_processed = 0; |
|
179 | - } |
|
180 | - $job_parameters->mark_processed($units_processed); |
|
181 | - $extra_response_data = array( |
|
182 | - 'file_url' => '', |
|
183 | - ); |
|
184 | - if ($units_processed < $batch_size) { |
|
185 | - $job_parameters->set_status(JobParameters::status_complete); |
|
186 | - $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
187 | - } |
|
161 | + /** |
|
162 | + * Performs another step of the job |
|
163 | + * |
|
164 | + * @param JobParameters $job_parameters |
|
165 | + * @param int $batch_size |
|
166 | + * @return JobStepResponse |
|
167 | + * @throws \EE_Error |
|
168 | + */ |
|
169 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
170 | + { |
|
171 | + if( $job_parameters->units_processed() < $job_parameters->job_size() ) { |
|
172 | + $csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'), |
|
173 | + $job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('question_labels'), |
|
174 | + $job_parameters->extra_datum('query_params')); |
|
175 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
176 | + $units_processed = count($csv_data); |
|
177 | + }else{ |
|
178 | + $units_processed = 0; |
|
179 | + } |
|
180 | + $job_parameters->mark_processed($units_processed); |
|
181 | + $extra_response_data = array( |
|
182 | + 'file_url' => '', |
|
183 | + ); |
|
184 | + if ($units_processed < $batch_size) { |
|
185 | + $job_parameters->set_status(JobParameters::status_complete); |
|
186 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
187 | + } |
|
188 | 188 | |
189 | - return new JobStepResponse($job_parameters, |
|
190 | - sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)), |
|
191 | - $extra_response_data); |
|
192 | - } |
|
189 | + return new JobStepResponse($job_parameters, |
|
190 | + sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)), |
|
191 | + $extra_response_data); |
|
192 | + } |
|
193 | 193 | |
194 | 194 | |
195 | 195 | |
196 | - /** |
|
197 | - * Gets the csv data for a batch of registrations |
|
198 | - |
|
199 | - * |
|
196 | + /** |
|
197 | + * Gets the csv data for a batch of registrations |
|
198 | + * |
|
200 | 199 | *@param int|null $event_id |
201 | - * @param int $offset |
|
202 | - * @param int $limit |
|
203 | - * @param array $question_labels the IDs for all the questions which were answered by someone in this selection |
|
204 | - * @param array $query_params for using where querying the model |
|
205 | - * @return array top-level keys are numeric, next-level keys are column headers |
|
206 | - */ |
|
207 | - function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params) |
|
208 | - { |
|
209 | - $reg_fields_to_include = array( |
|
210 | - 'TXN_ID', |
|
211 | - 'ATT_ID', |
|
212 | - 'REG_ID', |
|
213 | - 'REG_date', |
|
214 | - 'REG_code', |
|
215 | - 'REG_count', |
|
216 | - 'REG_final_price', |
|
217 | - ); |
|
218 | - $att_fields_to_include = array( |
|
219 | - 'ATT_fname', |
|
220 | - 'ATT_lname', |
|
221 | - 'ATT_email', |
|
222 | - 'ATT_address', |
|
223 | - 'ATT_address2', |
|
224 | - 'ATT_city', |
|
225 | - 'STA_ID', |
|
226 | - 'CNT_ISO', |
|
227 | - 'ATT_zip', |
|
228 | - 'ATT_phone', |
|
229 | - ); |
|
230 | - $registrations_csv_ready_array = array(); |
|
231 | - $reg_model = \EE_Registry::instance()->load_model('Registration'); |
|
232 | - $query_params['limit'] = array($offset, $limit); |
|
233 | - $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
234 | - $registration_ids = array(); |
|
235 | - foreach ($registration_rows as $reg_row) { |
|
236 | - $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
237 | - } |
|
238 | - foreach ($registration_rows as $reg_row) { |
|
239 | - if (is_array($reg_row)) { |
|
240 | - $reg_csv_array = array(); |
|
241 | - if ( ! $event_id) { |
|
242 | - //get the event's name and Id |
|
243 | - $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), |
|
244 | - \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', |
|
245 | - $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
246 | - } |
|
247 | - $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
248 | - /*@var $reg_row EE_Registration */ |
|
249 | - foreach ($reg_fields_to_include as $field_name) { |
|
250 | - $field = $reg_model->field_settings_for($field_name); |
|
251 | - if ($field_name == 'REG_final_price') { |
|
252 | - $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
253 | - $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
254 | - } elseif ($field_name == 'REG_count') { |
|
255 | - $value = sprintf(__('%s of %s', 'event_espresso'), |
|
256 | - \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', |
|
257 | - $reg_row['Registration.REG_count']), |
|
258 | - \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', |
|
259 | - $reg_row['Registration.REG_group_size'])); |
|
260 | - } elseif ($field_name == 'REG_date') { |
|
261 | - $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
262 | - $reg_row['Registration.REG_date'], 'no_html'); |
|
263 | - } else { |
|
264 | - $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
265 | - $reg_row[$field->get_qualified_column()]); |
|
266 | - } |
|
267 | - $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
|
268 | - if ($field_name == 'REG_final_price') { |
|
269 | - //add a column named Currency after the final price |
|
270 | - $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code; |
|
271 | - } |
|
272 | - } |
|
273 | - //get pretty status |
|
274 | - $stati = \EEM_Status::instance()->localized_status(array( |
|
275 | - $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
276 | - $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'), |
|
277 | - ), false, 'sentence'); |
|
278 | - $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
279 | - //get pretty transaction status |
|
280 | - $reg_csv_array[__("Transaction Status", |
|
281 | - 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']]; |
|
282 | - $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg |
|
283 | - ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', |
|
284 | - $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00'; |
|
285 | - $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg |
|
286 | - ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', |
|
287 | - $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00'; |
|
288 | - $payment_methods = array(); |
|
289 | - $gateway_txn_ids_etc = array(); |
|
290 | - $payment_times = array(); |
|
291 | - if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
292 | - $payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array( |
|
293 | - array( |
|
294 | - 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
295 | - 'STS_ID' => \EEM_Payment::status_id_approved, |
|
296 | - ), |
|
297 | - 'force_join' => array('Payment_Method'), |
|
298 | - ), ARRAY_A, |
|
299 | - 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'); |
|
300 | - foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
301 | - $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
302 | - ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
303 | - $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
304 | - ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
305 | - $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
306 | - ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
307 | - } |
|
308 | - } |
|
309 | - $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
310 | - $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
311 | - $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
312 | - //get whether or not the user has checked in |
|
313 | - $reg_csv_array[__("Check-Ins", |
|
314 | - "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
315 | - //get ticket of registration and its price |
|
316 | - $ticket_model = \EE_Registry::instance()->load_model('Ticket'); |
|
317 | - if ($reg_row['Ticket.TKT_ID']) { |
|
318 | - $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', |
|
319 | - $reg_row['Ticket.TKT_name']); |
|
320 | - $datetimes_strings = array(); |
|
321 | - foreach ( |
|
322 | - \EEM_Datetime::instance()->get_all_wpdb_results(array( |
|
323 | - array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), |
|
324 | - 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
325 | - 'default_where_conditions' => 'none', |
|
326 | - )) as $datetime |
|
327 | - ) { |
|
328 | - $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), |
|
329 | - 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
330 | - } |
|
331 | - } else { |
|
332 | - $ticket_name = __('Unknown', 'event_espresso'); |
|
333 | - $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
334 | - } |
|
335 | - $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
|
336 | - $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
|
337 | - //get datetime(s) of registration |
|
338 | - //add attendee columns |
|
339 | - foreach ($att_fields_to_include as $att_field_name) { |
|
340 | - $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name); |
|
341 | - if ($reg_row['Attendee_CPT.ID']) { |
|
342 | - if ($att_field_name == 'STA_ID') { |
|
343 | - $value = \EEM_State::instance() |
|
344 | - ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), |
|
345 | - 'STA_name'); |
|
346 | - } elseif ($att_field_name == 'CNT_ISO') { |
|
347 | - $value = \EEM_Country::instance() |
|
348 | - ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), |
|
349 | - 'CNT_name'); |
|
350 | - } else { |
|
351 | - $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), |
|
352 | - $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
353 | - } |
|
354 | - } else { |
|
355 | - $value = ''; |
|
356 | - } |
|
357 | - $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value; |
|
358 | - } |
|
359 | - //make sure each registration has the same questions in the same order |
|
360 | - foreach ($question_labels as $question_label) { |
|
361 | - if ( ! isset($reg_csv_array[$question_label])) { |
|
362 | - $reg_csv_array[$question_label] = null; |
|
363 | - } |
|
364 | - } |
|
365 | - $answers = \EEM_Answer::instance()->get_all_wpdb_results(array( |
|
366 | - array('REG_ID' => $reg_row['Registration.REG_ID']), |
|
367 | - 'force_join' => array('Question'), |
|
368 | - )); |
|
369 | - //now fill out the questions THEY answered |
|
370 | - foreach ($answers as $answer_row) { |
|
371 | - if ($answer_row['Question.QST_ID']) { |
|
372 | - $question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(), |
|
373 | - 'QST_admin_label', $answer_row['Question.QST_admin_label']); |
|
374 | - } else { |
|
375 | - $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
376 | - } |
|
377 | - if (isset($answer_row['Question.QST_type']) |
|
378 | - && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state |
|
379 | - ) { |
|
380 | - $reg_csv_array[$question_label] = \EEM_State::instance() |
|
381 | - ->get_state_name_by_ID($answer_row['Answer.ANS_value']); |
|
382 | - } else { |
|
383 | - //this isn't for html, so don't show html entities |
|
384 | - $reg_csv_array[$question_label] = html_entity_decode(\EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(), |
|
385 | - 'ANS_value', $answer_row['Answer.ANS_value'])); |
|
386 | - } |
|
387 | - } |
|
388 | - $registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', |
|
389 | - $reg_csv_array, $reg_row); |
|
390 | - } |
|
391 | - } |
|
392 | - //if we couldn't export anything, we want to at least show the column headers |
|
393 | - if (empty($registrations_csv_ready_array)) { |
|
394 | - $reg_csv_array = array(); |
|
395 | - $model_and_fields_to_include = array( |
|
396 | - 'Registration' => $reg_fields_to_include, |
|
397 | - 'Attendee' => $att_fields_to_include, |
|
398 | - ); |
|
399 | - foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
400 | - $model = \EE_Registry::instance()->load_model($model_name); |
|
401 | - foreach ($field_list as $field_name) { |
|
402 | - $field = $model->field_settings_for($field_name); |
|
403 | - $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null; |
|
404 | - } |
|
405 | - } |
|
406 | - $registrations_csv_ready_array[] = $reg_csv_array; |
|
407 | - } |
|
408 | - return $registrations_csv_ready_array; |
|
409 | - } |
|
200 | + * @param int $offset |
|
201 | + * @param int $limit |
|
202 | + * @param array $question_labels the IDs for all the questions which were answered by someone in this selection |
|
203 | + * @param array $query_params for using where querying the model |
|
204 | + * @return array top-level keys are numeric, next-level keys are column headers |
|
205 | + */ |
|
206 | + function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params) |
|
207 | + { |
|
208 | + $reg_fields_to_include = array( |
|
209 | + 'TXN_ID', |
|
210 | + 'ATT_ID', |
|
211 | + 'REG_ID', |
|
212 | + 'REG_date', |
|
213 | + 'REG_code', |
|
214 | + 'REG_count', |
|
215 | + 'REG_final_price', |
|
216 | + ); |
|
217 | + $att_fields_to_include = array( |
|
218 | + 'ATT_fname', |
|
219 | + 'ATT_lname', |
|
220 | + 'ATT_email', |
|
221 | + 'ATT_address', |
|
222 | + 'ATT_address2', |
|
223 | + 'ATT_city', |
|
224 | + 'STA_ID', |
|
225 | + 'CNT_ISO', |
|
226 | + 'ATT_zip', |
|
227 | + 'ATT_phone', |
|
228 | + ); |
|
229 | + $registrations_csv_ready_array = array(); |
|
230 | + $reg_model = \EE_Registry::instance()->load_model('Registration'); |
|
231 | + $query_params['limit'] = array($offset, $limit); |
|
232 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
233 | + $registration_ids = array(); |
|
234 | + foreach ($registration_rows as $reg_row) { |
|
235 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
236 | + } |
|
237 | + foreach ($registration_rows as $reg_row) { |
|
238 | + if (is_array($reg_row)) { |
|
239 | + $reg_csv_array = array(); |
|
240 | + if ( ! $event_id) { |
|
241 | + //get the event's name and Id |
|
242 | + $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), |
|
243 | + \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', |
|
244 | + $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
245 | + } |
|
246 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
247 | + /*@var $reg_row EE_Registration */ |
|
248 | + foreach ($reg_fields_to_include as $field_name) { |
|
249 | + $field = $reg_model->field_settings_for($field_name); |
|
250 | + if ($field_name == 'REG_final_price') { |
|
251 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
252 | + $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
253 | + } elseif ($field_name == 'REG_count') { |
|
254 | + $value = sprintf(__('%s of %s', 'event_espresso'), |
|
255 | + \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', |
|
256 | + $reg_row['Registration.REG_count']), |
|
257 | + \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', |
|
258 | + $reg_row['Registration.REG_group_size'])); |
|
259 | + } elseif ($field_name == 'REG_date') { |
|
260 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
261 | + $reg_row['Registration.REG_date'], 'no_html'); |
|
262 | + } else { |
|
263 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
264 | + $reg_row[$field->get_qualified_column()]); |
|
265 | + } |
|
266 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
|
267 | + if ($field_name == 'REG_final_price') { |
|
268 | + //add a column named Currency after the final price |
|
269 | + $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code; |
|
270 | + } |
|
271 | + } |
|
272 | + //get pretty status |
|
273 | + $stati = \EEM_Status::instance()->localized_status(array( |
|
274 | + $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
275 | + $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'), |
|
276 | + ), false, 'sentence'); |
|
277 | + $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
278 | + //get pretty transaction status |
|
279 | + $reg_csv_array[__("Transaction Status", |
|
280 | + 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']]; |
|
281 | + $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg |
|
282 | + ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', |
|
283 | + $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00'; |
|
284 | + $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg |
|
285 | + ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', |
|
286 | + $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00'; |
|
287 | + $payment_methods = array(); |
|
288 | + $gateway_txn_ids_etc = array(); |
|
289 | + $payment_times = array(); |
|
290 | + if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
291 | + $payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array( |
|
292 | + array( |
|
293 | + 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
294 | + 'STS_ID' => \EEM_Payment::status_id_approved, |
|
295 | + ), |
|
296 | + 'force_join' => array('Payment_Method'), |
|
297 | + ), ARRAY_A, |
|
298 | + 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'); |
|
299 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
300 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
301 | + ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
302 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
303 | + ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
304 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
305 | + ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
306 | + } |
|
307 | + } |
|
308 | + $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
309 | + $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
310 | + $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
311 | + //get whether or not the user has checked in |
|
312 | + $reg_csv_array[__("Check-Ins", |
|
313 | + "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
314 | + //get ticket of registration and its price |
|
315 | + $ticket_model = \EE_Registry::instance()->load_model('Ticket'); |
|
316 | + if ($reg_row['Ticket.TKT_ID']) { |
|
317 | + $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', |
|
318 | + $reg_row['Ticket.TKT_name']); |
|
319 | + $datetimes_strings = array(); |
|
320 | + foreach ( |
|
321 | + \EEM_Datetime::instance()->get_all_wpdb_results(array( |
|
322 | + array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), |
|
323 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
324 | + 'default_where_conditions' => 'none', |
|
325 | + )) as $datetime |
|
326 | + ) { |
|
327 | + $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), |
|
328 | + 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
329 | + } |
|
330 | + } else { |
|
331 | + $ticket_name = __('Unknown', 'event_espresso'); |
|
332 | + $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
333 | + } |
|
334 | + $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
|
335 | + $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
|
336 | + //get datetime(s) of registration |
|
337 | + //add attendee columns |
|
338 | + foreach ($att_fields_to_include as $att_field_name) { |
|
339 | + $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name); |
|
340 | + if ($reg_row['Attendee_CPT.ID']) { |
|
341 | + if ($att_field_name == 'STA_ID') { |
|
342 | + $value = \EEM_State::instance() |
|
343 | + ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), |
|
344 | + 'STA_name'); |
|
345 | + } elseif ($att_field_name == 'CNT_ISO') { |
|
346 | + $value = \EEM_Country::instance() |
|
347 | + ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), |
|
348 | + 'CNT_name'); |
|
349 | + } else { |
|
350 | + $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), |
|
351 | + $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
352 | + } |
|
353 | + } else { |
|
354 | + $value = ''; |
|
355 | + } |
|
356 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value; |
|
357 | + } |
|
358 | + //make sure each registration has the same questions in the same order |
|
359 | + foreach ($question_labels as $question_label) { |
|
360 | + if ( ! isset($reg_csv_array[$question_label])) { |
|
361 | + $reg_csv_array[$question_label] = null; |
|
362 | + } |
|
363 | + } |
|
364 | + $answers = \EEM_Answer::instance()->get_all_wpdb_results(array( |
|
365 | + array('REG_ID' => $reg_row['Registration.REG_ID']), |
|
366 | + 'force_join' => array('Question'), |
|
367 | + )); |
|
368 | + //now fill out the questions THEY answered |
|
369 | + foreach ($answers as $answer_row) { |
|
370 | + if ($answer_row['Question.QST_ID']) { |
|
371 | + $question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(), |
|
372 | + 'QST_admin_label', $answer_row['Question.QST_admin_label']); |
|
373 | + } else { |
|
374 | + $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
375 | + } |
|
376 | + if (isset($answer_row['Question.QST_type']) |
|
377 | + && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state |
|
378 | + ) { |
|
379 | + $reg_csv_array[$question_label] = \EEM_State::instance() |
|
380 | + ->get_state_name_by_ID($answer_row['Answer.ANS_value']); |
|
381 | + } else { |
|
382 | + //this isn't for html, so don't show html entities |
|
383 | + $reg_csv_array[$question_label] = html_entity_decode(\EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(), |
|
384 | + 'ANS_value', $answer_row['Answer.ANS_value'])); |
|
385 | + } |
|
386 | + } |
|
387 | + $registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', |
|
388 | + $reg_csv_array, $reg_row); |
|
389 | + } |
|
390 | + } |
|
391 | + //if we couldn't export anything, we want to at least show the column headers |
|
392 | + if (empty($registrations_csv_ready_array)) { |
|
393 | + $reg_csv_array = array(); |
|
394 | + $model_and_fields_to_include = array( |
|
395 | + 'Registration' => $reg_fields_to_include, |
|
396 | + 'Attendee' => $att_fields_to_include, |
|
397 | + ); |
|
398 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
399 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
400 | + foreach ($field_list as $field_name) { |
|
401 | + $field = $model->field_settings_for($field_name); |
|
402 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null; |
|
403 | + } |
|
404 | + } |
|
405 | + $registrations_csv_ready_array[] = $reg_csv_array; |
|
406 | + } |
|
407 | + return $registrations_csv_ready_array; |
|
408 | + } |
|
410 | 409 | |
411 | 410 | |
412 | 411 | |
413 | - /** |
|
414 | - * Counts total unit to process |
|
415 | - * |
|
416 | - * @deprecated since 4.9.19 |
|
417 | - * @param int|array $event_id |
|
418 | - * @return int |
|
419 | - */ |
|
420 | - public function count_units_to_process($event_id) |
|
421 | - { |
|
422 | - //use the legacy filter |
|
423 | - if ($event_id) { |
|
424 | - $query_params[0]['EVT_ID'] = $event_id; |
|
425 | - } else { |
|
426 | - $query_params['force_join'][] = 'Event'; |
|
427 | - } |
|
428 | - return \EEM_Registration::instance()->count($query_params); |
|
429 | - } |
|
412 | + /** |
|
413 | + * Counts total unit to process |
|
414 | + * |
|
415 | + * @deprecated since 4.9.19 |
|
416 | + * @param int|array $event_id |
|
417 | + * @return int |
|
418 | + */ |
|
419 | + public function count_units_to_process($event_id) |
|
420 | + { |
|
421 | + //use the legacy filter |
|
422 | + if ($event_id) { |
|
423 | + $query_params[0]['EVT_ID'] = $event_id; |
|
424 | + } else { |
|
425 | + $query_params['force_join'][] = 'Event'; |
|
426 | + } |
|
427 | + return \EEM_Registration::instance()->count($query_params); |
|
428 | + } |
|
430 | 429 | |
431 | 430 | |
432 | 431 | |
433 | - /** |
|
434 | - * Performs any clean-up logic when we know the job is completed. |
|
435 | - * In this case, we delete the temporary file |
|
436 | - * |
|
437 | - * @param JobParameters $job_parameters |
|
438 | - * @return boolean |
|
439 | - */ |
|
440 | - public function cleanup_job(JobParameters $job_parameters) |
|
441 | - { |
|
442 | - $this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
443 | - true, 'd'); |
|
444 | - return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
445 | - } |
|
432 | + /** |
|
433 | + * Performs any clean-up logic when we know the job is completed. |
|
434 | + * In this case, we delete the temporary file |
|
435 | + * |
|
436 | + * @param JobParameters $job_parameters |
|
437 | + * @return boolean |
|
438 | + */ |
|
439 | + public function cleanup_job(JobParameters $job_parameters) |
|
440 | + { |
|
441 | + $this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
442 | + true, 'd'); |
|
443 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
444 | + } |
|
446 | 445 | } |
447 | 446 | |
448 | 447 |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | array_diff_key( |
84 | 84 | $query_params, |
85 | 85 | array_flip( |
86 | - array( 'limit' ) |
|
86 | + array('limit') |
|
87 | 87 | ) |
88 | 88 | ) |
89 | 89 | ) |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]), |
130 | 130 | ); |
131 | 131 | } |
132 | - $question_query_params[0]['Answer.ANS_ID'] = array( 'IS_NOT_NULL' ); |
|
133 | - $question_query_params['group_by'] = array( 'QST_ID' ); |
|
134 | - return array_unique( \EEM_Question::instance()->get_col( $question_query_params, 'QST_admin_label' ) ); |
|
132 | + $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL'); |
|
133 | + $question_query_params['group_by'] = array('QST_ID'); |
|
134 | + return array_unique(\EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label')); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val); |
151 | 151 | } else { |
152 | 152 | //it's a normal where condition |
153 | - $question_where_params['Question_Group.Event.Registration.' . $key] = $val; |
|
153 | + $question_where_params['Question_Group.Event.Registration.'.$key] = $val; |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | return $question_where_params; |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
170 | 170 | { |
171 | - if( $job_parameters->units_processed() < $job_parameters->job_size() ) { |
|
171 | + if ($job_parameters->units_processed() < $job_parameters->job_size()) { |
|
172 | 172 | $csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'), |
173 | 173 | $job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('question_labels'), |
174 | 174 | $job_parameters->extra_datum('query_params')); |
175 | 175 | \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
176 | 176 | $units_processed = count($csv_data); |
177 | - }else{ |
|
177 | + } else { |
|
178 | 178 | $units_processed = 0; |
179 | 179 | } |
180 | 180 | $job_parameters->mark_processed($units_processed); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $this->_columns = array_merge( $columns, $this->_columns ); |
88 | 88 | $this->_primary_column = '_REG_att_checked_in'; |
89 | 89 | if ( ! empty( $evt_id ) |
90 | - && EE_Registry::instance()->CAP->current_user_can( |
|
90 | + && EE_Registry::instance()->CAP->current_user_can( |
|
91 | 91 | 'ee_read_registrations', |
92 | 92 | 'espresso_registrations_registrations_reports', |
93 | 93 | $evt_id |
@@ -104,28 +104,28 @@ discard block |
||
104 | 104 | ), |
105 | 105 | ); |
106 | 106 | } |
107 | - $this->_bottom_buttons['report_filtered'] = array( |
|
108 | - 'route' => 'registrations_checkin_report', |
|
109 | - 'extra_request' => array( |
|
110 | - 'use_filters' => true, |
|
111 | - 'filters' => array_merge( |
|
112 | - array( |
|
113 | - 'EVT_ID' => $evt_id, |
|
114 | - ), |
|
115 | - array_diff_key( |
|
116 | - $this->_req_data, |
|
117 | - array_flip( |
|
118 | - array( |
|
119 | - 'page', |
|
120 | - 'action', |
|
121 | - 'default_nonce', |
|
122 | - ) |
|
123 | - ) |
|
124 | - ) |
|
125 | - ), |
|
126 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
127 | - ), |
|
128 | - ); |
|
107 | + $this->_bottom_buttons['report_filtered'] = array( |
|
108 | + 'route' => 'registrations_checkin_report', |
|
109 | + 'extra_request' => array( |
|
110 | + 'use_filters' => true, |
|
111 | + 'filters' => array_merge( |
|
112 | + array( |
|
113 | + 'EVT_ID' => $evt_id, |
|
114 | + ), |
|
115 | + array_diff_key( |
|
116 | + $this->_req_data, |
|
117 | + array_flip( |
|
118 | + array( |
|
119 | + 'page', |
|
120 | + 'action', |
|
121 | + 'default_nonce', |
|
122 | + ) |
|
123 | + ) |
|
124 | + ) |
|
125 | + ), |
|
126 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
127 | + ), |
|
128 | + ); |
|
129 | 129 | $this->_sortable_columns = array( |
130 | 130 | //true means its already sorted |
131 | 131 | 'ATT_name' => array( 'ATT_name' => true ), |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | if ( count( $this->_dtts_for_event ) > 1 ) { |
212 | 212 | $dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' ); |
213 | 213 | foreach ( $this->_dtts_for_event as $dtt ) { |
214 | - $datetime_string = $dtt->name(); |
|
215 | - $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
214 | + $datetime_string = $dtt->name(); |
|
215 | + $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
216 | 216 | $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
217 | 217 | $dtts[ $dtt->ID() ] = $datetime_string; |
218 | 218 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $checkinstatus = $item->check_in_status_for_datetime( $this->_cur_dtt_id ); |
307 | 307 | $nonce = wp_create_nonce( 'checkin_nonce' ); |
308 | 308 | $toggle_active = ! empty ( $this->_cur_dtt_id ) |
309 | - && EE_Registry::instance()->CAP->current_user_can( |
|
309 | + && EE_Registry::instance()->CAP->current_user_can( |
|
310 | 310 | 'ee_edit_checkin', |
311 | 311 | 'espresso_registrations_toggle_checkin_status', |
312 | 312 | $item->ID() |
@@ -315,11 +315,11 @@ discard block |
||
315 | 315 | : ''; |
316 | 316 | $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
317 | 317 | return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '"' |
318 | - . ' data-_regid="' . $item->ID() . '"' |
|
319 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
320 | - . ' data-nonce="' . $nonce . '">' |
|
321 | - . '</span>' |
|
322 | - . $mobile_view_content; |
|
318 | + . ' data-_regid="' . $item->ID() . '"' |
|
319 | + . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
320 | + . ' data-nonce="' . $nonce . '">' |
|
321 | + . '</span>' |
|
322 | + . $mobile_view_content; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | 'espresso_registrations_edit_attendee' |
345 | 345 | ) |
346 | 346 | ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'Edit Contact', 'event_espresso' ) . '">' |
347 | - . $item->attendee()->full_name() |
|
348 | - . '</a>' |
|
347 | + . $item->attendee()->full_name() |
|
348 | + . '</a>' |
|
349 | 349 | : $item->attendee()->full_name(); |
350 | 350 | $name_link .= $item->count() === 1 |
351 | 351 | ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | ? $latest_related_datetime->ID() |
381 | 381 | : $DTT_ID; |
382 | 382 | if ( ! empty( $DTT_ID ) |
383 | - && EE_Registry::instance()->CAP->current_user_can( |
|
383 | + && EE_Registry::instance()->CAP->current_user_can( |
|
384 | 384 | 'ee_read_checkins', |
385 | 385 | 'espresso_registrations_registration_checkins' |
386 | 386 | ) |
@@ -480,15 +480,15 @@ discard block |
||
480 | 480 | ) ? ' |
481 | 481 | <span class="reg-pad-rght"> |
482 | 482 | <a class="status-' |
483 | - . $item->transaction()->status_ID() |
|
484 | - . '" href="' |
|
485 | - . $view_txn_lnk_url |
|
486 | - . '" title="' |
|
487 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
488 | - . '"> |
|
483 | + . $item->transaction()->status_ID() |
|
484 | + . '" href="' |
|
485 | + . $view_txn_lnk_url |
|
486 | + . '" title="' |
|
487 | + . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
488 | + . '"> |
|
489 | 489 | ' |
490 | - . $item->transaction()->pretty_paid() |
|
491 | - . ' |
|
490 | + . $item->transaction()->pretty_paid() |
|
491 | + . ' |
|
492 | 492 | </a> |
493 | 493 | <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
494 | 494 | } |
@@ -521,12 +521,12 @@ discard block |
||
521 | 521 | 'ee_read_transaction', |
522 | 522 | 'espresso_transactions_view_transaction' |
523 | 523 | ) ? '<a href="' |
524 | - . $view_txn_url |
|
525 | - . '" title="' |
|
526 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
527 | - . '"><span class="reg-pad-rght">' |
|
528 | - . $txn_total |
|
529 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
524 | + . $view_txn_url |
|
525 | + . '" title="' |
|
526 | + . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
527 | + . '"><span class="reg-pad-rght">' |
|
528 | + . $txn_total |
|
529 | + . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
530 | 530 | } else { |
531 | 531 | return '<span class="reg-pad-rght"></span>'; |
532 | 532 | } |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | * |
614 | 614 | * @since 4.6.0 |
615 | 615 | * @global WPDB $wpdb |
616 | - * @return mixed null|int WP_user ID or NULL |
|
616 | + * @return integer|null null|int WP_user ID or NULL |
|
617 | 617 | */ |
618 | 618 | public static function get_default_creator_id() |
619 | 619 | { |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * @static |
775 | 775 | * @deprecated instead use TableManager::dropTable() |
776 | 776 | * @param string $table_name |
777 | - * @return bool | int |
|
777 | + * @return integer | int |
|
778 | 778 | */ |
779 | 779 | public static function delete_unused_db_table($table_name) |
780 | 780 | { |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | * @deprecated instead use TableManager::dropIndex() |
792 | 792 | * @param string $table_name |
793 | 793 | * @param string $index_name |
794 | - * @return bool | int |
|
794 | + * @return integer | int |
|
795 | 795 | */ |
796 | 796 | public static function drop_index($table_name, $index_name) |
797 | 797 | { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -14,231 +14,231 @@ discard block |
||
14 | 14 | class EEH_Activation |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * constant used to indicate a cron task is no longer in use |
|
19 | - */ |
|
20 | - const cron_task_no_longer_in_use = 'no_longer_in_use'; |
|
21 | - |
|
22 | - /** |
|
23 | - * option name that will indicate whether or not we still |
|
24 | - * need to create EE's folders in the uploads directory |
|
25 | - * (because if EE was installed without file system access, |
|
26 | - * we need to request credentials before we can create them) |
|
27 | - */ |
|
28 | - const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete'; |
|
29 | - |
|
30 | - /** |
|
31 | - * WP_User->ID |
|
32 | - * |
|
33 | - * @var int |
|
34 | - */ |
|
35 | - private static $_default_creator_id; |
|
36 | - |
|
37 | - /** |
|
38 | - * indicates whether or not we've already verified core's default data during this request, |
|
39 | - * because after migrations are done, any addons activated while in maintenance mode |
|
40 | - * will want to setup their own default data, and they might hook into core's default data |
|
41 | - * and trigger core to setup its default data. In which case they might all ask for core to init its default data. |
|
42 | - * This prevents doing that for EVERY single addon. |
|
43 | - * |
|
44 | - * @var boolean |
|
45 | - */ |
|
46 | - protected static $_initialized_db_content_already_in_this_request = false; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
50 | - */ |
|
51 | - private static $table_analysis; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var \EventEspresso\core\services\database\TableManager $table_manager |
|
55 | - */ |
|
56 | - private static $table_manager; |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @return \EventEspresso\core\services\database\TableAnalysis |
|
61 | - */ |
|
62 | - public static function getTableAnalysis() |
|
63 | - { |
|
64 | - if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
65 | - self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
66 | - } |
|
67 | - return self::$table_analysis; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return \EventEspresso\core\services\database\TableManager |
|
73 | - */ |
|
74 | - public static function getTableManager() |
|
75 | - { |
|
76 | - if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
77 | - self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
78 | - } |
|
79 | - return self::$table_manager; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * _ensure_table_name_has_prefix |
|
85 | - * |
|
86 | - * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix() |
|
87 | - * @access public |
|
88 | - * @static |
|
89 | - * @param $table_name |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public static function ensure_table_name_has_prefix($table_name) |
|
93 | - { |
|
94 | - return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * system_initialization |
|
100 | - * ensures the EE configuration settings are loaded with at least default options set |
|
101 | - * and that all critical EE pages have been generated with the appropriate shortcodes in place |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @static |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - public static function system_initialization() |
|
108 | - { |
|
109 | - EEH_Activation::reset_and_update_config(); |
|
110 | - //which is fired BEFORE activation of plugin anyways |
|
111 | - EEH_Activation::verify_default_pages_exist(); |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Sets the database schema and creates folders. This should |
|
117 | - * be called on plugin activation and reactivation |
|
118 | - * |
|
119 | - * @return boolean success, whether the database and folders are setup properly |
|
120 | - * @throws \EE_Error |
|
121 | - */ |
|
122 | - public static function initialize_db_and_folders() |
|
123 | - { |
|
124 | - $good_filesystem = EEH_Activation::create_upload_directories(); |
|
125 | - $good_db = EEH_Activation::create_database_tables(); |
|
126 | - return $good_filesystem && $good_db; |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * assuming we have an up-to-date database schema, this will populate it |
|
132 | - * with default and initial data. This should be called |
|
133 | - * upon activation of a new plugin, reactivation, and at the end |
|
134 | - * of running migration scripts |
|
135 | - * |
|
136 | - * @throws \EE_Error |
|
137 | - */ |
|
138 | - public static function initialize_db_content() |
|
139 | - { |
|
140 | - //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
|
141 | - if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
142 | - return; |
|
143 | - } |
|
144 | - EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
|
145 | - |
|
146 | - EEH_Activation::initialize_system_questions(); |
|
147 | - EEH_Activation::insert_default_status_codes(); |
|
148 | - EEH_Activation::generate_default_message_templates(); |
|
149 | - EEH_Activation::create_no_ticket_prices_array(); |
|
150 | - EE_Registry::instance()->CAP->init_caps(); |
|
151 | - |
|
152 | - EEH_Activation::validate_messages_system(); |
|
153 | - EEH_Activation::insert_default_payment_methods(); |
|
154 | - //in case we've |
|
155 | - EEH_Activation::remove_cron_tasks(); |
|
156 | - EEH_Activation::create_cron_tasks(); |
|
157 | - // remove all TXN locks since that is being done via extra meta now |
|
158 | - delete_option('ee_locked_transactions'); |
|
159 | - //also, check for CAF default db content |
|
160 | - do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
161 | - //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
|
162 | - //which users really won't care about on initial activation |
|
163 | - EE_Error::overwrite_success(); |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"), |
|
169 | - * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event |
|
170 | - * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use |
|
171 | - * (null) |
|
172 | - * |
|
173 | - * @param string $which_to_include can be 'current' (ones that are currently in use), |
|
174 | - * 'old' (only returns ones that should no longer be used),or 'all', |
|
175 | - * @return array |
|
176 | - * @throws \EE_Error |
|
177 | - */ |
|
178 | - public static function get_cron_tasks($which_to_include) |
|
179 | - { |
|
180 | - $cron_tasks = apply_filters( |
|
181 | - 'FHEE__EEH_Activation__get_cron_tasks', |
|
182 | - array( |
|
183 | - 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions' => 'hourly', |
|
17 | + /** |
|
18 | + * constant used to indicate a cron task is no longer in use |
|
19 | + */ |
|
20 | + const cron_task_no_longer_in_use = 'no_longer_in_use'; |
|
21 | + |
|
22 | + /** |
|
23 | + * option name that will indicate whether or not we still |
|
24 | + * need to create EE's folders in the uploads directory |
|
25 | + * (because if EE was installed without file system access, |
|
26 | + * we need to request credentials before we can create them) |
|
27 | + */ |
|
28 | + const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete'; |
|
29 | + |
|
30 | + /** |
|
31 | + * WP_User->ID |
|
32 | + * |
|
33 | + * @var int |
|
34 | + */ |
|
35 | + private static $_default_creator_id; |
|
36 | + |
|
37 | + /** |
|
38 | + * indicates whether or not we've already verified core's default data during this request, |
|
39 | + * because after migrations are done, any addons activated while in maintenance mode |
|
40 | + * will want to setup their own default data, and they might hook into core's default data |
|
41 | + * and trigger core to setup its default data. In which case they might all ask for core to init its default data. |
|
42 | + * This prevents doing that for EVERY single addon. |
|
43 | + * |
|
44 | + * @var boolean |
|
45 | + */ |
|
46 | + protected static $_initialized_db_content_already_in_this_request = false; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
50 | + */ |
|
51 | + private static $table_analysis; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var \EventEspresso\core\services\database\TableManager $table_manager |
|
55 | + */ |
|
56 | + private static $table_manager; |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @return \EventEspresso\core\services\database\TableAnalysis |
|
61 | + */ |
|
62 | + public static function getTableAnalysis() |
|
63 | + { |
|
64 | + if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
65 | + self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
66 | + } |
|
67 | + return self::$table_analysis; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return \EventEspresso\core\services\database\TableManager |
|
73 | + */ |
|
74 | + public static function getTableManager() |
|
75 | + { |
|
76 | + if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
77 | + self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
78 | + } |
|
79 | + return self::$table_manager; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * _ensure_table_name_has_prefix |
|
85 | + * |
|
86 | + * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix() |
|
87 | + * @access public |
|
88 | + * @static |
|
89 | + * @param $table_name |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public static function ensure_table_name_has_prefix($table_name) |
|
93 | + { |
|
94 | + return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * system_initialization |
|
100 | + * ensures the EE configuration settings are loaded with at least default options set |
|
101 | + * and that all critical EE pages have been generated with the appropriate shortcodes in place |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @static |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + public static function system_initialization() |
|
108 | + { |
|
109 | + EEH_Activation::reset_and_update_config(); |
|
110 | + //which is fired BEFORE activation of plugin anyways |
|
111 | + EEH_Activation::verify_default_pages_exist(); |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Sets the database schema and creates folders. This should |
|
117 | + * be called on plugin activation and reactivation |
|
118 | + * |
|
119 | + * @return boolean success, whether the database and folders are setup properly |
|
120 | + * @throws \EE_Error |
|
121 | + */ |
|
122 | + public static function initialize_db_and_folders() |
|
123 | + { |
|
124 | + $good_filesystem = EEH_Activation::create_upload_directories(); |
|
125 | + $good_db = EEH_Activation::create_database_tables(); |
|
126 | + return $good_filesystem && $good_db; |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * assuming we have an up-to-date database schema, this will populate it |
|
132 | + * with default and initial data. This should be called |
|
133 | + * upon activation of a new plugin, reactivation, and at the end |
|
134 | + * of running migration scripts |
|
135 | + * |
|
136 | + * @throws \EE_Error |
|
137 | + */ |
|
138 | + public static function initialize_db_content() |
|
139 | + { |
|
140 | + //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
|
141 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
142 | + return; |
|
143 | + } |
|
144 | + EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
|
145 | + |
|
146 | + EEH_Activation::initialize_system_questions(); |
|
147 | + EEH_Activation::insert_default_status_codes(); |
|
148 | + EEH_Activation::generate_default_message_templates(); |
|
149 | + EEH_Activation::create_no_ticket_prices_array(); |
|
150 | + EE_Registry::instance()->CAP->init_caps(); |
|
151 | + |
|
152 | + EEH_Activation::validate_messages_system(); |
|
153 | + EEH_Activation::insert_default_payment_methods(); |
|
154 | + //in case we've |
|
155 | + EEH_Activation::remove_cron_tasks(); |
|
156 | + EEH_Activation::create_cron_tasks(); |
|
157 | + // remove all TXN locks since that is being done via extra meta now |
|
158 | + delete_option('ee_locked_transactions'); |
|
159 | + //also, check for CAF default db content |
|
160 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
161 | + //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
|
162 | + //which users really won't care about on initial activation |
|
163 | + EE_Error::overwrite_success(); |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"), |
|
169 | + * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event |
|
170 | + * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use |
|
171 | + * (null) |
|
172 | + * |
|
173 | + * @param string $which_to_include can be 'current' (ones that are currently in use), |
|
174 | + * 'old' (only returns ones that should no longer be used),or 'all', |
|
175 | + * @return array |
|
176 | + * @throws \EE_Error |
|
177 | + */ |
|
178 | + public static function get_cron_tasks($which_to_include) |
|
179 | + { |
|
180 | + $cron_tasks = apply_filters( |
|
181 | + 'FHEE__EEH_Activation__get_cron_tasks', |
|
182 | + array( |
|
183 | + 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions' => 'hourly', |
|
184 | 184 | // 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions' => EEH_Activation::cron_task_no_longer_in_use, actually this is still in use |
185 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, |
|
186 | - //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
|
187 | - ) |
|
188 | - ); |
|
189 | - if ($which_to_include === 'old') { |
|
190 | - $cron_tasks = array_filter( |
|
191 | - $cron_tasks, |
|
192 | - function ($value) { |
|
193 | - return $value === EEH_Activation::cron_task_no_longer_in_use; |
|
194 | - } |
|
195 | - ); |
|
196 | - } elseif ($which_to_include === 'current') { |
|
197 | - $cron_tasks = array_filter($cron_tasks); |
|
198 | - } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
199 | - throw new EE_Error( |
|
200 | - sprintf( |
|
201 | - __( |
|
202 | - 'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', |
|
203 | - 'event_espresso' |
|
204 | - ), |
|
205 | - $which_to_include |
|
206 | - ) |
|
207 | - ); |
|
208 | - } |
|
209 | - return $cron_tasks; |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * Ensure cron tasks are setup (the removal of crons should be done by remove_crons()) |
|
215 | - * |
|
216 | - * @throws \EE_Error |
|
217 | - */ |
|
218 | - public static function create_cron_tasks() |
|
219 | - { |
|
220 | - |
|
221 | - foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
222 | - if (! wp_next_scheduled($hook_name)) { |
|
223 | - wp_schedule_event(time(), $frequency, $hook_name); |
|
224 | - } |
|
225 | - } |
|
226 | - |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * Remove the currently-existing and now-removed cron tasks. |
|
232 | - * |
|
233 | - * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
|
234 | - * @throws \EE_Error |
|
235 | - */ |
|
236 | - public static function remove_cron_tasks($remove_all = true) |
|
237 | - { |
|
238 | - $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
|
239 | - $crons = _get_cron_array(); |
|
240 | - $crons = is_array($crons) ? $crons : array(); |
|
241 | - /* reminder of what $crons look like: |
|
185 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, |
|
186 | + //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
|
187 | + ) |
|
188 | + ); |
|
189 | + if ($which_to_include === 'old') { |
|
190 | + $cron_tasks = array_filter( |
|
191 | + $cron_tasks, |
|
192 | + function ($value) { |
|
193 | + return $value === EEH_Activation::cron_task_no_longer_in_use; |
|
194 | + } |
|
195 | + ); |
|
196 | + } elseif ($which_to_include === 'current') { |
|
197 | + $cron_tasks = array_filter($cron_tasks); |
|
198 | + } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
199 | + throw new EE_Error( |
|
200 | + sprintf( |
|
201 | + __( |
|
202 | + 'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', |
|
203 | + 'event_espresso' |
|
204 | + ), |
|
205 | + $which_to_include |
|
206 | + ) |
|
207 | + ); |
|
208 | + } |
|
209 | + return $cron_tasks; |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * Ensure cron tasks are setup (the removal of crons should be done by remove_crons()) |
|
215 | + * |
|
216 | + * @throws \EE_Error |
|
217 | + */ |
|
218 | + public static function create_cron_tasks() |
|
219 | + { |
|
220 | + |
|
221 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
222 | + if (! wp_next_scheduled($hook_name)) { |
|
223 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
224 | + } |
|
225 | + } |
|
226 | + |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * Remove the currently-existing and now-removed cron tasks. |
|
232 | + * |
|
233 | + * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
|
234 | + * @throws \EE_Error |
|
235 | + */ |
|
236 | + public static function remove_cron_tasks($remove_all = true) |
|
237 | + { |
|
238 | + $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
|
239 | + $crons = _get_cron_array(); |
|
240 | + $crons = is_array($crons) ? $crons : array(); |
|
241 | + /* reminder of what $crons look like: |
|
242 | 242 | * Top-level keys are timestamps, and their values are arrays. |
243 | 243 | * The 2nd level arrays have keys with each of the cron task hook names to run at that time |
244 | 244 | * and their values are arrays. |
@@ -255,966 +255,966 @@ discard block |
||
255 | 255 | * ... |
256 | 256 | * ... |
257 | 257 | */ |
258 | - $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
259 | - foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
260 | - if (is_array($hooks_to_fire_at_time)) { |
|
261 | - foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
262 | - if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
263 | - && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
264 | - ) { |
|
265 | - unset($crons[$timestamp][$hook_name]); |
|
266 | - } |
|
267 | - } |
|
268 | - //also take care of any empty cron timestamps. |
|
269 | - if (empty($hooks_to_fire_at_time)) { |
|
270 | - unset($crons[$timestamp]); |
|
271 | - } |
|
272 | - } |
|
273 | - } |
|
274 | - _set_cron_array($crons); |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * CPT_initialization |
|
280 | - * registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist |
|
281 | - * |
|
282 | - * @access public |
|
283 | - * @static |
|
284 | - * @return void |
|
285 | - */ |
|
286 | - public static function CPT_initialization() |
|
287 | - { |
|
288 | - // register Custom Post Types |
|
289 | - EE_Registry::instance()->load_core('Register_CPTs'); |
|
290 | - flush_rewrite_rules(); |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * reset_and_update_config |
|
297 | - * The following code was moved over from EE_Config so that it will no longer run on every request. |
|
298 | - * If there is old calendar config data saved, then it will get converted on activation. |
|
299 | - * This was basically a DMS before we had DMS's, and will get removed after a few more versions. |
|
300 | - * |
|
301 | - * @access public |
|
302 | - * @static |
|
303 | - * @return void |
|
304 | - */ |
|
305 | - public static function reset_and_update_config() |
|
306 | - { |
|
307 | - do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
308 | - add_filter( |
|
309 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
310 | - array('EEH_Activation', 'migrate_old_config_data'), |
|
311 | - 10, |
|
312 | - 3 |
|
313 | - ); |
|
314 | - //EE_Config::reset(); |
|
315 | - if (! EE_Config::logging_enabled()) { |
|
316 | - delete_option(EE_Config::LOG_NAME); |
|
317 | - } |
|
318 | - } |
|
319 | - |
|
320 | - |
|
321 | - /** |
|
322 | - * load_calendar_config |
|
323 | - * |
|
324 | - * @access public |
|
325 | - * @return void |
|
326 | - */ |
|
327 | - public static function load_calendar_config() |
|
328 | - { |
|
329 | - // grab array of all plugin folders and loop thru it |
|
330 | - $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR); |
|
331 | - if (empty($plugins)) { |
|
332 | - return; |
|
333 | - } |
|
334 | - foreach ($plugins as $plugin_path) { |
|
335 | - // grab plugin folder name from path |
|
336 | - $plugin = basename($plugin_path); |
|
337 | - // drill down to Espresso plugins |
|
338 | - // then to calendar related plugins |
|
339 | - if ( |
|
340 | - strpos($plugin, 'espresso') !== false |
|
341 | - || strpos($plugin, 'Espresso') !== false |
|
342 | - || strpos($plugin, 'ee4') !== false |
|
343 | - || strpos($plugin, 'EE4') !== false |
|
344 | - || strpos($plugin, 'calendar') !== false |
|
345 | - ) { |
|
346 | - // this is what we are looking for |
|
347 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
348 | - // does it exist in this folder ? |
|
349 | - if (is_readable($calendar_config)) { |
|
350 | - // YEAH! let's load it |
|
351 | - require_once($calendar_config); |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
355 | - } |
|
356 | - |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * _migrate_old_config_data |
|
361 | - * |
|
362 | - * @access public |
|
363 | - * @param array|stdClass $settings |
|
364 | - * @param string $config |
|
365 | - * @param \EE_Config $EE_Config |
|
366 | - * @return \stdClass |
|
367 | - */ |
|
368 | - public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) |
|
369 | - { |
|
370 | - $convert_from_array = array('addons'); |
|
371 | - // in case old settings were saved as an array |
|
372 | - if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
373 | - // convert existing settings to an object |
|
374 | - $config_array = $settings; |
|
375 | - $settings = new stdClass(); |
|
376 | - foreach ($config_array as $key => $value) { |
|
377 | - if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
378 | - $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
379 | - } else { |
|
380 | - $settings->{$key} = $value; |
|
381 | - } |
|
382 | - } |
|
383 | - add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
384 | - } |
|
385 | - return $settings; |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * deactivate_event_espresso |
|
391 | - * |
|
392 | - * @access public |
|
393 | - * @static |
|
394 | - * @return void |
|
395 | - */ |
|
396 | - public static function deactivate_event_espresso() |
|
397 | - { |
|
398 | - // check permissions |
|
399 | - if (current_user_can('activate_plugins')) { |
|
400 | - deactivate_plugins(EE_PLUGIN_BASENAME, true); |
|
401 | - } |
|
402 | - } |
|
403 | - |
|
404 | - |
|
405 | - |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * verify_default_pages_exist |
|
410 | - * |
|
411 | - * @access public |
|
412 | - * @static |
|
413 | - * @return void |
|
414 | - */ |
|
415 | - public static function verify_default_pages_exist() |
|
416 | - { |
|
417 | - $critical_page_problem = false; |
|
418 | - $critical_pages = array( |
|
419 | - array( |
|
420 | - 'id' => 'reg_page_id', |
|
421 | - 'name' => __('Registration Checkout', 'event_espresso'), |
|
422 | - 'post' => null, |
|
423 | - 'code' => 'ESPRESSO_CHECKOUT', |
|
424 | - ), |
|
425 | - array( |
|
426 | - 'id' => 'txn_page_id', |
|
427 | - 'name' => __('Transactions', 'event_espresso'), |
|
428 | - 'post' => null, |
|
429 | - 'code' => 'ESPRESSO_TXN_PAGE', |
|
430 | - ), |
|
431 | - array( |
|
432 | - 'id' => 'thank_you_page_id', |
|
433 | - 'name' => __('Thank You', 'event_espresso'), |
|
434 | - 'post' => null, |
|
435 | - 'code' => 'ESPRESSO_THANK_YOU', |
|
436 | - ), |
|
437 | - array( |
|
438 | - 'id' => 'cancel_page_id', |
|
439 | - 'name' => __('Registration Cancelled', 'event_espresso'), |
|
440 | - 'post' => null, |
|
441 | - 'code' => 'ESPRESSO_CANCELLED', |
|
442 | - ), |
|
443 | - ); |
|
444 | - $EE_Core_Config = EE_Registry::instance()->CFG->core; |
|
445 | - foreach ($critical_pages as $critical_page) { |
|
446 | - // is critical page ID set in config ? |
|
447 | - if ($EE_Core_Config->{$critical_page['id']} !== false) { |
|
448 | - // attempt to find post by ID |
|
449 | - $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']}); |
|
450 | - } |
|
451 | - // no dice? |
|
452 | - if ($critical_page['post'] === null) { |
|
453 | - // attempt to find post by title |
|
454 | - $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
455 | - // still nothing? |
|
456 | - if ($critical_page['post'] === null) { |
|
457 | - $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
458 | - // REALLY? Still nothing ??!?!? |
|
459 | - if ($critical_page['post'] === null) { |
|
460 | - $msg = __( |
|
461 | - 'The Event Espresso critical page configuration settings could not be updated.', |
|
462 | - 'event_espresso' |
|
463 | - ); |
|
464 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
465 | - break; |
|
466 | - } |
|
467 | - } |
|
468 | - } |
|
469 | - // track post_shortcodes |
|
470 | - if ($critical_page['post']) { |
|
471 | - EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
472 | - } |
|
473 | - // check that Post ID matches critical page ID in config |
|
474 | - if ( |
|
475 | - isset($critical_page['post']->ID) |
|
476 | - && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
477 | - ) { |
|
478 | - //update Config with post ID |
|
479 | - $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
480 | - if (! EE_Config::instance()->update_espresso_config(false, false)) { |
|
481 | - $msg = __( |
|
482 | - 'The Event Espresso critical page configuration settings could not be updated.', |
|
483 | - 'event_espresso' |
|
484 | - ); |
|
485 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
486 | - } |
|
487 | - } |
|
488 | - $critical_page_problem = |
|
489 | - ! isset($critical_page['post']->post_status) |
|
490 | - || $critical_page['post']->post_status !== 'publish' |
|
491 | - || strpos($critical_page['post']->post_content, $critical_page['code']) === false |
|
492 | - ? true |
|
493 | - : $critical_page_problem; |
|
494 | - } |
|
495 | - if ($critical_page_problem) { |
|
496 | - $msg = sprintf( |
|
497 | - __( |
|
498 | - 'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', |
|
499 | - 'event_espresso' |
|
500 | - ), |
|
501 | - '<a href="' |
|
502 | - . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') |
|
503 | - . '">' |
|
504 | - . __('Event Espresso Critical Pages Settings', 'event_espresso') |
|
505 | - . '</a>' |
|
506 | - ); |
|
507 | - EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
508 | - } |
|
509 | - if (EE_Error::has_notices()) { |
|
510 | - EE_Error::get_notices(false, true, true); |
|
511 | - } |
|
512 | - } |
|
513 | - |
|
514 | - |
|
515 | - |
|
516 | - /** |
|
517 | - * Returns the first post which uses the specified shortcode |
|
518 | - * |
|
519 | - * @param string $ee_shortcode usually one of the critical pages shortcodes, eg |
|
520 | - * ESPRESSO_THANK_YOU. So we will search fora post with the content |
|
521 | - * "[ESPRESSO_THANK_YOU" |
|
522 | - * (we don't search for the closing shortcode bracket because they might have added |
|
523 | - * parameter to the shortcode |
|
524 | - * @return WP_Post or NULl |
|
525 | - */ |
|
526 | - public static function get_page_by_ee_shortcode($ee_shortcode) |
|
527 | - { |
|
528 | - global $wpdb; |
|
529 | - $shortcode_and_opening_bracket = '[' . $ee_shortcode; |
|
530 | - $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
|
531 | - if ($post_id) { |
|
532 | - return get_post($post_id); |
|
533 | - } else { |
|
534 | - return null; |
|
535 | - } |
|
536 | - } |
|
537 | - |
|
538 | - |
|
539 | - /** |
|
540 | - * This function generates a post for critical espresso pages |
|
541 | - * |
|
542 | - * @access public |
|
543 | - * @static |
|
544 | - * @param array $critical_page |
|
545 | - * @return array |
|
546 | - */ |
|
547 | - public static function create_critical_page($critical_page) |
|
548 | - { |
|
549 | - |
|
550 | - $post_args = array( |
|
551 | - 'post_title' => $critical_page['name'], |
|
552 | - 'post_status' => 'publish', |
|
553 | - 'post_type' => 'page', |
|
554 | - 'comment_status' => 'closed', |
|
555 | - 'post_content' => '[' . $critical_page['code'] . ']', |
|
556 | - ); |
|
557 | - |
|
558 | - $post_id = wp_insert_post($post_args); |
|
559 | - if (! $post_id) { |
|
560 | - $msg = sprintf( |
|
561 | - __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
562 | - $critical_page['name'] |
|
563 | - ); |
|
564 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
565 | - return $critical_page; |
|
566 | - } |
|
567 | - // get newly created post's details |
|
568 | - if (! $critical_page['post'] = get_post($post_id)) { |
|
569 | - $msg = sprintf( |
|
570 | - __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
571 | - $critical_page['name'] |
|
572 | - ); |
|
573 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
574 | - } |
|
575 | - |
|
576 | - return $critical_page; |
|
577 | - |
|
578 | - } |
|
579 | - |
|
580 | - |
|
581 | - |
|
582 | - |
|
583 | - |
|
584 | - /** |
|
585 | - * This function adds a critical page's shortcode to the post_shortcodes array |
|
586 | - * |
|
587 | - * @access private |
|
588 | - * @static |
|
589 | - * @param array $critical_page |
|
590 | - * @return void |
|
591 | - */ |
|
592 | - private static function _track_critical_page_post_shortcodes($critical_page = array()) |
|
593 | - { |
|
594 | - // check the goods |
|
595 | - if ( ! $critical_page['post'] instanceof WP_Post) { |
|
596 | - $msg = sprintf( |
|
597 | - __( |
|
598 | - 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', |
|
599 | - 'event_espresso' |
|
600 | - ), |
|
601 | - $critical_page['name'] |
|
602 | - ); |
|
603 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
604 | - return; |
|
605 | - } |
|
606 | - $EE_Core_Config = EE_Registry::instance()->CFG->core; |
|
607 | - // map shortcode to post |
|
608 | - $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
609 | - // and make sure it's NOT added to the WP "Posts Page" |
|
610 | - // name of the WP Posts Page |
|
611 | - $posts_page = EE_Config::get_page_for_posts(); |
|
612 | - if (isset($EE_Core_Config->post_shortcodes[$posts_page])) { |
|
613 | - unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]); |
|
614 | - } |
|
615 | - if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) { |
|
616 | - unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]); |
|
617 | - } |
|
618 | - // update post_shortcode CFG |
|
619 | - if ( ! EE_Config::instance()->update_espresso_config(false, false)) { |
|
620 | - $msg = sprintf( |
|
621 | - __( |
|
622 | - 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', |
|
623 | - 'event_espresso' |
|
624 | - ), |
|
625 | - $critical_page['name'] |
|
626 | - ); |
|
627 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
628 | - } |
|
629 | - } |
|
630 | - |
|
631 | - |
|
632 | - |
|
633 | - /** |
|
634 | - * Tries to find the oldest admin for this site. If there are no admins for this site then return NULL. |
|
635 | - * The role being used to check is filterable. |
|
636 | - * |
|
637 | - * @since 4.6.0 |
|
638 | - * @global WPDB $wpdb |
|
639 | - * @return mixed null|int WP_user ID or NULL |
|
640 | - */ |
|
641 | - public static function get_default_creator_id() |
|
642 | - { |
|
643 | - global $wpdb; |
|
644 | - if ( ! empty(self::$_default_creator_id)) { |
|
645 | - return self::$_default_creator_id; |
|
646 | - }/**/ |
|
647 | - $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
648 | - //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
|
649 | - $pre_filtered_id = apply_filters( |
|
650 | - 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', |
|
651 | - false, |
|
652 | - $role_to_check |
|
653 | - ); |
|
654 | - if ($pre_filtered_id !== false) { |
|
655 | - return (int)$pre_filtered_id; |
|
656 | - } |
|
657 | - $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities'); |
|
658 | - $query = $wpdb->prepare( |
|
659 | - "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", |
|
660 | - '%' . $role_to_check . '%' |
|
661 | - ); |
|
662 | - $user_id = $wpdb->get_var($query); |
|
663 | - $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
664 | - if ($user_id && (int)$user_id) { |
|
665 | - self::$_default_creator_id = (int)$user_id; |
|
666 | - return self::$_default_creator_id; |
|
667 | - } else { |
|
668 | - return null; |
|
669 | - } |
|
670 | - } |
|
671 | - |
|
672 | - |
|
673 | - |
|
674 | - /** |
|
675 | - * used by EE and EE addons during plugin activation to create tables. |
|
676 | - * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable, |
|
677 | - * but includes extra logic regarding activations. |
|
678 | - * |
|
679 | - * @access public |
|
680 | - * @static |
|
681 | - * @param string $table_name without the $wpdb->prefix |
|
682 | - * @param string $sql SQL for creating the table (contents between brackets in an SQL create |
|
683 | - * table query) |
|
684 | - * @param string $engine like 'ENGINE=MyISAM' or 'ENGINE=InnoDB' |
|
685 | - * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty |
|
686 | - * and new once this function is done (ie, you really do want to CREATE a |
|
687 | - * table, and expect it to be empty once you're done) leave as FALSE when |
|
688 | - * you just want to verify the table exists and matches this definition |
|
689 | - * (and if it HAS data in it you want to leave it be) |
|
690 | - * @return void |
|
691 | - * @throws EE_Error if there are database errors |
|
692 | - */ |
|
693 | - public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) |
|
694 | - { |
|
695 | - if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) { |
|
696 | - return; |
|
697 | - } |
|
698 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
699 | - if ( ! function_exists('dbDelta')) { |
|
700 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
701 | - } |
|
702 | - $tableAnalysis = \EEH_Activation::getTableAnalysis(); |
|
703 | - $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name); |
|
704 | - // do we need to first delete an existing version of this table ? |
|
705 | - if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) { |
|
706 | - // ok, delete the table... but ONLY if it's empty |
|
707 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
708 | - // table is NOT empty, are you SURE you want to delete this table ??? |
|
709 | - if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
710 | - \EEH_Activation::getTableManager()->dropTable($wp_table_name); |
|
711 | - } else if ( ! $deleted_safely) { |
|
712 | - // so we should be more cautious rather than just dropping tables so easily |
|
713 | - error_log( |
|
714 | - sprintf( |
|
715 | - __( |
|
716 | - 'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.', |
|
717 | - 'event_espresso' |
|
718 | - ), |
|
719 | - $wp_table_name, |
|
720 | - '<br/>', |
|
721 | - 'espresso_db_update' |
|
722 | - ) |
|
723 | - ); |
|
724 | - } |
|
725 | - } |
|
726 | - $engine = str_replace('ENGINE=', '', $engine); |
|
727 | - \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine); |
|
728 | - } |
|
729 | - |
|
730 | - |
|
731 | - |
|
732 | - /** |
|
733 | - * add_column_if_it_doesn't_exist |
|
734 | - * Checks if this column already exists on the specified table. Handy for addons which want to add a column |
|
735 | - * |
|
736 | - * @access public |
|
737 | - * @static |
|
738 | - * @deprecated instead use TableManager::addColumn() |
|
739 | - * @param string $table_name (without "wp_", eg "esp_attendee" |
|
740 | - * @param string $column_name |
|
741 | - * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be |
|
742 | - * 'VARCHAR(10)' |
|
743 | - * @return bool|int |
|
744 | - */ |
|
745 | - public static function add_column_if_it_doesnt_exist( |
|
746 | - $table_name, |
|
747 | - $column_name, |
|
748 | - $column_info = 'INT UNSIGNED NOT NULL' |
|
749 | - ) { |
|
750 | - return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info); |
|
751 | - } |
|
752 | - |
|
753 | - |
|
754 | - /** |
|
755 | - * get_fields_on_table |
|
756 | - * Gets all the fields on the database table. |
|
757 | - * |
|
758 | - * @access public |
|
759 | - * @deprecated instead use TableManager::getTableColumns() |
|
760 | - * @static |
|
761 | - * @param string $table_name , without prefixed $wpdb->prefix |
|
762 | - * @return array of database column names |
|
763 | - */ |
|
764 | - public static function get_fields_on_table($table_name = null) |
|
765 | - { |
|
766 | - return \EEH_Activation::getTableManager()->getTableColumns($table_name); |
|
767 | - } |
|
768 | - |
|
769 | - |
|
770 | - /** |
|
771 | - * db_table_is_empty |
|
772 | - * |
|
773 | - * @access public\ |
|
774 | - * @deprecated instead use TableAnalysis::tableIsEmpty() |
|
775 | - * @static |
|
776 | - * @param string $table_name |
|
777 | - * @return bool |
|
778 | - */ |
|
779 | - public static function db_table_is_empty($table_name) |
|
780 | - { |
|
781 | - return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name); |
|
782 | - } |
|
783 | - |
|
784 | - |
|
785 | - /** |
|
786 | - * delete_db_table_if_empty |
|
787 | - * |
|
788 | - * @access public |
|
789 | - * @static |
|
790 | - * @param string $table_name |
|
791 | - * @return bool | int |
|
792 | - */ |
|
793 | - public static function delete_db_table_if_empty($table_name) |
|
794 | - { |
|
795 | - if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) { |
|
796 | - return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
797 | - } |
|
798 | - return false; |
|
799 | - } |
|
800 | - |
|
801 | - |
|
802 | - /** |
|
803 | - * delete_unused_db_table |
|
804 | - * |
|
805 | - * @access public |
|
806 | - * @static |
|
807 | - * @deprecated instead use TableManager::dropTable() |
|
808 | - * @param string $table_name |
|
809 | - * @return bool | int |
|
810 | - */ |
|
811 | - public static function delete_unused_db_table($table_name) |
|
812 | - { |
|
813 | - return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
814 | - } |
|
815 | - |
|
816 | - |
|
817 | - /** |
|
818 | - * drop_index |
|
819 | - * |
|
820 | - * @access public |
|
821 | - * @static |
|
822 | - * @deprecated instead use TableManager::dropIndex() |
|
823 | - * @param string $table_name |
|
824 | - * @param string $index_name |
|
825 | - * @return bool | int |
|
826 | - */ |
|
827 | - public static function drop_index($table_name, $index_name) |
|
828 | - { |
|
829 | - return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name); |
|
830 | - } |
|
831 | - |
|
832 | - |
|
833 | - |
|
834 | - /** |
|
835 | - * create_database_tables |
|
836 | - * |
|
837 | - * @access public |
|
838 | - * @static |
|
839 | - * @throws EE_Error |
|
840 | - * @return boolean success (whether database is setup properly or not) |
|
841 | - */ |
|
842 | - public static function create_database_tables() |
|
843 | - { |
|
844 | - EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
845 | - //find the migration script that sets the database to be compatible with the code |
|
846 | - $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
|
847 | - if ($dms_name) { |
|
848 | - $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
849 | - $current_data_migration_script->set_migrating(false); |
|
850 | - $current_data_migration_script->schema_changes_before_migration(); |
|
851 | - $current_data_migration_script->schema_changes_after_migration(); |
|
852 | - if ($current_data_migration_script->get_errors()) { |
|
853 | - if (WP_DEBUG) { |
|
854 | - foreach ($current_data_migration_script->get_errors() as $error) { |
|
855 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
856 | - } |
|
857 | - } else { |
|
858 | - EE_Error::add_error( |
|
859 | - __( |
|
860 | - 'There were errors creating the Event Espresso database tables and Event Espresso has been |
|
258 | + $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
259 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
260 | + if (is_array($hooks_to_fire_at_time)) { |
|
261 | + foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
262 | + if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
263 | + && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
264 | + ) { |
|
265 | + unset($crons[$timestamp][$hook_name]); |
|
266 | + } |
|
267 | + } |
|
268 | + //also take care of any empty cron timestamps. |
|
269 | + if (empty($hooks_to_fire_at_time)) { |
|
270 | + unset($crons[$timestamp]); |
|
271 | + } |
|
272 | + } |
|
273 | + } |
|
274 | + _set_cron_array($crons); |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * CPT_initialization |
|
280 | + * registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist |
|
281 | + * |
|
282 | + * @access public |
|
283 | + * @static |
|
284 | + * @return void |
|
285 | + */ |
|
286 | + public static function CPT_initialization() |
|
287 | + { |
|
288 | + // register Custom Post Types |
|
289 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
290 | + flush_rewrite_rules(); |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * reset_and_update_config |
|
297 | + * The following code was moved over from EE_Config so that it will no longer run on every request. |
|
298 | + * If there is old calendar config data saved, then it will get converted on activation. |
|
299 | + * This was basically a DMS before we had DMS's, and will get removed after a few more versions. |
|
300 | + * |
|
301 | + * @access public |
|
302 | + * @static |
|
303 | + * @return void |
|
304 | + */ |
|
305 | + public static function reset_and_update_config() |
|
306 | + { |
|
307 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
308 | + add_filter( |
|
309 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
310 | + array('EEH_Activation', 'migrate_old_config_data'), |
|
311 | + 10, |
|
312 | + 3 |
|
313 | + ); |
|
314 | + //EE_Config::reset(); |
|
315 | + if (! EE_Config::logging_enabled()) { |
|
316 | + delete_option(EE_Config::LOG_NAME); |
|
317 | + } |
|
318 | + } |
|
319 | + |
|
320 | + |
|
321 | + /** |
|
322 | + * load_calendar_config |
|
323 | + * |
|
324 | + * @access public |
|
325 | + * @return void |
|
326 | + */ |
|
327 | + public static function load_calendar_config() |
|
328 | + { |
|
329 | + // grab array of all plugin folders and loop thru it |
|
330 | + $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR); |
|
331 | + if (empty($plugins)) { |
|
332 | + return; |
|
333 | + } |
|
334 | + foreach ($plugins as $plugin_path) { |
|
335 | + // grab plugin folder name from path |
|
336 | + $plugin = basename($plugin_path); |
|
337 | + // drill down to Espresso plugins |
|
338 | + // then to calendar related plugins |
|
339 | + if ( |
|
340 | + strpos($plugin, 'espresso') !== false |
|
341 | + || strpos($plugin, 'Espresso') !== false |
|
342 | + || strpos($plugin, 'ee4') !== false |
|
343 | + || strpos($plugin, 'EE4') !== false |
|
344 | + || strpos($plugin, 'calendar') !== false |
|
345 | + ) { |
|
346 | + // this is what we are looking for |
|
347 | + $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
348 | + // does it exist in this folder ? |
|
349 | + if (is_readable($calendar_config)) { |
|
350 | + // YEAH! let's load it |
|
351 | + require_once($calendar_config); |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | + } |
|
356 | + |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * _migrate_old_config_data |
|
361 | + * |
|
362 | + * @access public |
|
363 | + * @param array|stdClass $settings |
|
364 | + * @param string $config |
|
365 | + * @param \EE_Config $EE_Config |
|
366 | + * @return \stdClass |
|
367 | + */ |
|
368 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) |
|
369 | + { |
|
370 | + $convert_from_array = array('addons'); |
|
371 | + // in case old settings were saved as an array |
|
372 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
373 | + // convert existing settings to an object |
|
374 | + $config_array = $settings; |
|
375 | + $settings = new stdClass(); |
|
376 | + foreach ($config_array as $key => $value) { |
|
377 | + if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
378 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
379 | + } else { |
|
380 | + $settings->{$key} = $value; |
|
381 | + } |
|
382 | + } |
|
383 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
384 | + } |
|
385 | + return $settings; |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * deactivate_event_espresso |
|
391 | + * |
|
392 | + * @access public |
|
393 | + * @static |
|
394 | + * @return void |
|
395 | + */ |
|
396 | + public static function deactivate_event_espresso() |
|
397 | + { |
|
398 | + // check permissions |
|
399 | + if (current_user_can('activate_plugins')) { |
|
400 | + deactivate_plugins(EE_PLUGIN_BASENAME, true); |
|
401 | + } |
|
402 | + } |
|
403 | + |
|
404 | + |
|
405 | + |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * verify_default_pages_exist |
|
410 | + * |
|
411 | + * @access public |
|
412 | + * @static |
|
413 | + * @return void |
|
414 | + */ |
|
415 | + public static function verify_default_pages_exist() |
|
416 | + { |
|
417 | + $critical_page_problem = false; |
|
418 | + $critical_pages = array( |
|
419 | + array( |
|
420 | + 'id' => 'reg_page_id', |
|
421 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
422 | + 'post' => null, |
|
423 | + 'code' => 'ESPRESSO_CHECKOUT', |
|
424 | + ), |
|
425 | + array( |
|
426 | + 'id' => 'txn_page_id', |
|
427 | + 'name' => __('Transactions', 'event_espresso'), |
|
428 | + 'post' => null, |
|
429 | + 'code' => 'ESPRESSO_TXN_PAGE', |
|
430 | + ), |
|
431 | + array( |
|
432 | + 'id' => 'thank_you_page_id', |
|
433 | + 'name' => __('Thank You', 'event_espresso'), |
|
434 | + 'post' => null, |
|
435 | + 'code' => 'ESPRESSO_THANK_YOU', |
|
436 | + ), |
|
437 | + array( |
|
438 | + 'id' => 'cancel_page_id', |
|
439 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
440 | + 'post' => null, |
|
441 | + 'code' => 'ESPRESSO_CANCELLED', |
|
442 | + ), |
|
443 | + ); |
|
444 | + $EE_Core_Config = EE_Registry::instance()->CFG->core; |
|
445 | + foreach ($critical_pages as $critical_page) { |
|
446 | + // is critical page ID set in config ? |
|
447 | + if ($EE_Core_Config->{$critical_page['id']} !== false) { |
|
448 | + // attempt to find post by ID |
|
449 | + $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']}); |
|
450 | + } |
|
451 | + // no dice? |
|
452 | + if ($critical_page['post'] === null) { |
|
453 | + // attempt to find post by title |
|
454 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
455 | + // still nothing? |
|
456 | + if ($critical_page['post'] === null) { |
|
457 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
458 | + // REALLY? Still nothing ??!?!? |
|
459 | + if ($critical_page['post'] === null) { |
|
460 | + $msg = __( |
|
461 | + 'The Event Espresso critical page configuration settings could not be updated.', |
|
462 | + 'event_espresso' |
|
463 | + ); |
|
464 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
465 | + break; |
|
466 | + } |
|
467 | + } |
|
468 | + } |
|
469 | + // track post_shortcodes |
|
470 | + if ($critical_page['post']) { |
|
471 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
472 | + } |
|
473 | + // check that Post ID matches critical page ID in config |
|
474 | + if ( |
|
475 | + isset($critical_page['post']->ID) |
|
476 | + && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
477 | + ) { |
|
478 | + //update Config with post ID |
|
479 | + $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
480 | + if (! EE_Config::instance()->update_espresso_config(false, false)) { |
|
481 | + $msg = __( |
|
482 | + 'The Event Espresso critical page configuration settings could not be updated.', |
|
483 | + 'event_espresso' |
|
484 | + ); |
|
485 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
486 | + } |
|
487 | + } |
|
488 | + $critical_page_problem = |
|
489 | + ! isset($critical_page['post']->post_status) |
|
490 | + || $critical_page['post']->post_status !== 'publish' |
|
491 | + || strpos($critical_page['post']->post_content, $critical_page['code']) === false |
|
492 | + ? true |
|
493 | + : $critical_page_problem; |
|
494 | + } |
|
495 | + if ($critical_page_problem) { |
|
496 | + $msg = sprintf( |
|
497 | + __( |
|
498 | + 'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', |
|
499 | + 'event_espresso' |
|
500 | + ), |
|
501 | + '<a href="' |
|
502 | + . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') |
|
503 | + . '">' |
|
504 | + . __('Event Espresso Critical Pages Settings', 'event_espresso') |
|
505 | + . '</a>' |
|
506 | + ); |
|
507 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
508 | + } |
|
509 | + if (EE_Error::has_notices()) { |
|
510 | + EE_Error::get_notices(false, true, true); |
|
511 | + } |
|
512 | + } |
|
513 | + |
|
514 | + |
|
515 | + |
|
516 | + /** |
|
517 | + * Returns the first post which uses the specified shortcode |
|
518 | + * |
|
519 | + * @param string $ee_shortcode usually one of the critical pages shortcodes, eg |
|
520 | + * ESPRESSO_THANK_YOU. So we will search fora post with the content |
|
521 | + * "[ESPRESSO_THANK_YOU" |
|
522 | + * (we don't search for the closing shortcode bracket because they might have added |
|
523 | + * parameter to the shortcode |
|
524 | + * @return WP_Post or NULl |
|
525 | + */ |
|
526 | + public static function get_page_by_ee_shortcode($ee_shortcode) |
|
527 | + { |
|
528 | + global $wpdb; |
|
529 | + $shortcode_and_opening_bracket = '[' . $ee_shortcode; |
|
530 | + $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
|
531 | + if ($post_id) { |
|
532 | + return get_post($post_id); |
|
533 | + } else { |
|
534 | + return null; |
|
535 | + } |
|
536 | + } |
|
537 | + |
|
538 | + |
|
539 | + /** |
|
540 | + * This function generates a post for critical espresso pages |
|
541 | + * |
|
542 | + * @access public |
|
543 | + * @static |
|
544 | + * @param array $critical_page |
|
545 | + * @return array |
|
546 | + */ |
|
547 | + public static function create_critical_page($critical_page) |
|
548 | + { |
|
549 | + |
|
550 | + $post_args = array( |
|
551 | + 'post_title' => $critical_page['name'], |
|
552 | + 'post_status' => 'publish', |
|
553 | + 'post_type' => 'page', |
|
554 | + 'comment_status' => 'closed', |
|
555 | + 'post_content' => '[' . $critical_page['code'] . ']', |
|
556 | + ); |
|
557 | + |
|
558 | + $post_id = wp_insert_post($post_args); |
|
559 | + if (! $post_id) { |
|
560 | + $msg = sprintf( |
|
561 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
562 | + $critical_page['name'] |
|
563 | + ); |
|
564 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
565 | + return $critical_page; |
|
566 | + } |
|
567 | + // get newly created post's details |
|
568 | + if (! $critical_page['post'] = get_post($post_id)) { |
|
569 | + $msg = sprintf( |
|
570 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
571 | + $critical_page['name'] |
|
572 | + ); |
|
573 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
574 | + } |
|
575 | + |
|
576 | + return $critical_page; |
|
577 | + |
|
578 | + } |
|
579 | + |
|
580 | + |
|
581 | + |
|
582 | + |
|
583 | + |
|
584 | + /** |
|
585 | + * This function adds a critical page's shortcode to the post_shortcodes array |
|
586 | + * |
|
587 | + * @access private |
|
588 | + * @static |
|
589 | + * @param array $critical_page |
|
590 | + * @return void |
|
591 | + */ |
|
592 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) |
|
593 | + { |
|
594 | + // check the goods |
|
595 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
596 | + $msg = sprintf( |
|
597 | + __( |
|
598 | + 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', |
|
599 | + 'event_espresso' |
|
600 | + ), |
|
601 | + $critical_page['name'] |
|
602 | + ); |
|
603 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
604 | + return; |
|
605 | + } |
|
606 | + $EE_Core_Config = EE_Registry::instance()->CFG->core; |
|
607 | + // map shortcode to post |
|
608 | + $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
609 | + // and make sure it's NOT added to the WP "Posts Page" |
|
610 | + // name of the WP Posts Page |
|
611 | + $posts_page = EE_Config::get_page_for_posts(); |
|
612 | + if (isset($EE_Core_Config->post_shortcodes[$posts_page])) { |
|
613 | + unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]); |
|
614 | + } |
|
615 | + if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) { |
|
616 | + unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]); |
|
617 | + } |
|
618 | + // update post_shortcode CFG |
|
619 | + if ( ! EE_Config::instance()->update_espresso_config(false, false)) { |
|
620 | + $msg = sprintf( |
|
621 | + __( |
|
622 | + 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', |
|
623 | + 'event_espresso' |
|
624 | + ), |
|
625 | + $critical_page['name'] |
|
626 | + ); |
|
627 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
628 | + } |
|
629 | + } |
|
630 | + |
|
631 | + |
|
632 | + |
|
633 | + /** |
|
634 | + * Tries to find the oldest admin for this site. If there are no admins for this site then return NULL. |
|
635 | + * The role being used to check is filterable. |
|
636 | + * |
|
637 | + * @since 4.6.0 |
|
638 | + * @global WPDB $wpdb |
|
639 | + * @return mixed null|int WP_user ID or NULL |
|
640 | + */ |
|
641 | + public static function get_default_creator_id() |
|
642 | + { |
|
643 | + global $wpdb; |
|
644 | + if ( ! empty(self::$_default_creator_id)) { |
|
645 | + return self::$_default_creator_id; |
|
646 | + }/**/ |
|
647 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
648 | + //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
|
649 | + $pre_filtered_id = apply_filters( |
|
650 | + 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', |
|
651 | + false, |
|
652 | + $role_to_check |
|
653 | + ); |
|
654 | + if ($pre_filtered_id !== false) { |
|
655 | + return (int)$pre_filtered_id; |
|
656 | + } |
|
657 | + $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities'); |
|
658 | + $query = $wpdb->prepare( |
|
659 | + "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", |
|
660 | + '%' . $role_to_check . '%' |
|
661 | + ); |
|
662 | + $user_id = $wpdb->get_var($query); |
|
663 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
664 | + if ($user_id && (int)$user_id) { |
|
665 | + self::$_default_creator_id = (int)$user_id; |
|
666 | + return self::$_default_creator_id; |
|
667 | + } else { |
|
668 | + return null; |
|
669 | + } |
|
670 | + } |
|
671 | + |
|
672 | + |
|
673 | + |
|
674 | + /** |
|
675 | + * used by EE and EE addons during plugin activation to create tables. |
|
676 | + * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable, |
|
677 | + * but includes extra logic regarding activations. |
|
678 | + * |
|
679 | + * @access public |
|
680 | + * @static |
|
681 | + * @param string $table_name without the $wpdb->prefix |
|
682 | + * @param string $sql SQL for creating the table (contents between brackets in an SQL create |
|
683 | + * table query) |
|
684 | + * @param string $engine like 'ENGINE=MyISAM' or 'ENGINE=InnoDB' |
|
685 | + * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty |
|
686 | + * and new once this function is done (ie, you really do want to CREATE a |
|
687 | + * table, and expect it to be empty once you're done) leave as FALSE when |
|
688 | + * you just want to verify the table exists and matches this definition |
|
689 | + * (and if it HAS data in it you want to leave it be) |
|
690 | + * @return void |
|
691 | + * @throws EE_Error if there are database errors |
|
692 | + */ |
|
693 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) |
|
694 | + { |
|
695 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) { |
|
696 | + return; |
|
697 | + } |
|
698 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
699 | + if ( ! function_exists('dbDelta')) { |
|
700 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
701 | + } |
|
702 | + $tableAnalysis = \EEH_Activation::getTableAnalysis(); |
|
703 | + $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name); |
|
704 | + // do we need to first delete an existing version of this table ? |
|
705 | + if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) { |
|
706 | + // ok, delete the table... but ONLY if it's empty |
|
707 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
708 | + // table is NOT empty, are you SURE you want to delete this table ??? |
|
709 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
710 | + \EEH_Activation::getTableManager()->dropTable($wp_table_name); |
|
711 | + } else if ( ! $deleted_safely) { |
|
712 | + // so we should be more cautious rather than just dropping tables so easily |
|
713 | + error_log( |
|
714 | + sprintf( |
|
715 | + __( |
|
716 | + 'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.', |
|
717 | + 'event_espresso' |
|
718 | + ), |
|
719 | + $wp_table_name, |
|
720 | + '<br/>', |
|
721 | + 'espresso_db_update' |
|
722 | + ) |
|
723 | + ); |
|
724 | + } |
|
725 | + } |
|
726 | + $engine = str_replace('ENGINE=', '', $engine); |
|
727 | + \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine); |
|
728 | + } |
|
729 | + |
|
730 | + |
|
731 | + |
|
732 | + /** |
|
733 | + * add_column_if_it_doesn't_exist |
|
734 | + * Checks if this column already exists on the specified table. Handy for addons which want to add a column |
|
735 | + * |
|
736 | + * @access public |
|
737 | + * @static |
|
738 | + * @deprecated instead use TableManager::addColumn() |
|
739 | + * @param string $table_name (without "wp_", eg "esp_attendee" |
|
740 | + * @param string $column_name |
|
741 | + * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be |
|
742 | + * 'VARCHAR(10)' |
|
743 | + * @return bool|int |
|
744 | + */ |
|
745 | + public static function add_column_if_it_doesnt_exist( |
|
746 | + $table_name, |
|
747 | + $column_name, |
|
748 | + $column_info = 'INT UNSIGNED NOT NULL' |
|
749 | + ) { |
|
750 | + return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info); |
|
751 | + } |
|
752 | + |
|
753 | + |
|
754 | + /** |
|
755 | + * get_fields_on_table |
|
756 | + * Gets all the fields on the database table. |
|
757 | + * |
|
758 | + * @access public |
|
759 | + * @deprecated instead use TableManager::getTableColumns() |
|
760 | + * @static |
|
761 | + * @param string $table_name , without prefixed $wpdb->prefix |
|
762 | + * @return array of database column names |
|
763 | + */ |
|
764 | + public static function get_fields_on_table($table_name = null) |
|
765 | + { |
|
766 | + return \EEH_Activation::getTableManager()->getTableColumns($table_name); |
|
767 | + } |
|
768 | + |
|
769 | + |
|
770 | + /** |
|
771 | + * db_table_is_empty |
|
772 | + * |
|
773 | + * @access public\ |
|
774 | + * @deprecated instead use TableAnalysis::tableIsEmpty() |
|
775 | + * @static |
|
776 | + * @param string $table_name |
|
777 | + * @return bool |
|
778 | + */ |
|
779 | + public static function db_table_is_empty($table_name) |
|
780 | + { |
|
781 | + return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name); |
|
782 | + } |
|
783 | + |
|
784 | + |
|
785 | + /** |
|
786 | + * delete_db_table_if_empty |
|
787 | + * |
|
788 | + * @access public |
|
789 | + * @static |
|
790 | + * @param string $table_name |
|
791 | + * @return bool | int |
|
792 | + */ |
|
793 | + public static function delete_db_table_if_empty($table_name) |
|
794 | + { |
|
795 | + if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) { |
|
796 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
797 | + } |
|
798 | + return false; |
|
799 | + } |
|
800 | + |
|
801 | + |
|
802 | + /** |
|
803 | + * delete_unused_db_table |
|
804 | + * |
|
805 | + * @access public |
|
806 | + * @static |
|
807 | + * @deprecated instead use TableManager::dropTable() |
|
808 | + * @param string $table_name |
|
809 | + * @return bool | int |
|
810 | + */ |
|
811 | + public static function delete_unused_db_table($table_name) |
|
812 | + { |
|
813 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
814 | + } |
|
815 | + |
|
816 | + |
|
817 | + /** |
|
818 | + * drop_index |
|
819 | + * |
|
820 | + * @access public |
|
821 | + * @static |
|
822 | + * @deprecated instead use TableManager::dropIndex() |
|
823 | + * @param string $table_name |
|
824 | + * @param string $index_name |
|
825 | + * @return bool | int |
|
826 | + */ |
|
827 | + public static function drop_index($table_name, $index_name) |
|
828 | + { |
|
829 | + return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name); |
|
830 | + } |
|
831 | + |
|
832 | + |
|
833 | + |
|
834 | + /** |
|
835 | + * create_database_tables |
|
836 | + * |
|
837 | + * @access public |
|
838 | + * @static |
|
839 | + * @throws EE_Error |
|
840 | + * @return boolean success (whether database is setup properly or not) |
|
841 | + */ |
|
842 | + public static function create_database_tables() |
|
843 | + { |
|
844 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
845 | + //find the migration script that sets the database to be compatible with the code |
|
846 | + $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
|
847 | + if ($dms_name) { |
|
848 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
849 | + $current_data_migration_script->set_migrating(false); |
|
850 | + $current_data_migration_script->schema_changes_before_migration(); |
|
851 | + $current_data_migration_script->schema_changes_after_migration(); |
|
852 | + if ($current_data_migration_script->get_errors()) { |
|
853 | + if (WP_DEBUG) { |
|
854 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
855 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
856 | + } |
|
857 | + } else { |
|
858 | + EE_Error::add_error( |
|
859 | + __( |
|
860 | + 'There were errors creating the Event Espresso database tables and Event Espresso has been |
|
861 | 861 | deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', |
862 | - 'event_espresso' |
|
863 | - ) |
|
864 | - ); |
|
865 | - } |
|
866 | - return false; |
|
867 | - } |
|
868 | - EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
|
869 | - } else { |
|
870 | - EE_Error::add_error( |
|
871 | - __( |
|
872 | - 'Could not determine most up-to-date data migration script from which to pull database schema |
|
862 | + 'event_espresso' |
|
863 | + ) |
|
864 | + ); |
|
865 | + } |
|
866 | + return false; |
|
867 | + } |
|
868 | + EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
|
869 | + } else { |
|
870 | + EE_Error::add_error( |
|
871 | + __( |
|
872 | + 'Could not determine most up-to-date data migration script from which to pull database schema |
|
873 | 873 | structure. So database is probably not setup properly', |
874 | - 'event_espresso' |
|
875 | - ), |
|
876 | - __FILE__, |
|
877 | - __FUNCTION__, |
|
878 | - __LINE__ |
|
879 | - ); |
|
880 | - return false; |
|
881 | - } |
|
882 | - return true; |
|
883 | - } |
|
884 | - |
|
885 | - |
|
886 | - |
|
887 | - /** |
|
888 | - * initialize_system_questions |
|
889 | - * |
|
890 | - * @access public |
|
891 | - * @static |
|
892 | - * @return void |
|
893 | - */ |
|
894 | - public static function initialize_system_questions() |
|
895 | - { |
|
896 | - // QUESTION GROUPS |
|
897 | - global $wpdb; |
|
898 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group'); |
|
899 | - $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
|
900 | - // what we have |
|
901 | - $question_groups = $wpdb->get_col($SQL); |
|
902 | - // check the response |
|
903 | - $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
904 | - // what we should have |
|
905 | - $QSG_systems = array(1, 2); |
|
906 | - // loop thru what we should have and compare to what we have |
|
907 | - foreach ($QSG_systems as $QSG_system) { |
|
908 | - // reset values array |
|
909 | - $QSG_values = array(); |
|
910 | - // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
|
911 | - if (! in_array("$QSG_system", $question_groups)) { |
|
912 | - // add it |
|
913 | - switch ($QSG_system) { |
|
914 | - case 1: |
|
915 | - $QSG_values = array( |
|
916 | - 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
917 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
918 | - 'QSG_desc' => '', |
|
919 | - 'QSG_order' => 1, |
|
920 | - 'QSG_show_group_name' => 1, |
|
921 | - 'QSG_show_group_desc' => 1, |
|
922 | - 'QSG_system' => EEM_Question_Group::system_personal, |
|
923 | - 'QSG_deleted' => 0, |
|
924 | - ); |
|
925 | - break; |
|
926 | - case 2: |
|
927 | - $QSG_values = array( |
|
928 | - 'QSG_name' => __('Address Information', 'event_espresso'), |
|
929 | - 'QSG_identifier' => 'address-information-' . time(), |
|
930 | - 'QSG_desc' => '', |
|
931 | - 'QSG_order' => 2, |
|
932 | - 'QSG_show_group_name' => 1, |
|
933 | - 'QSG_show_group_desc' => 1, |
|
934 | - 'QSG_system' => EEM_Question_Group::system_address, |
|
935 | - 'QSG_deleted' => 0, |
|
936 | - ); |
|
937 | - break; |
|
938 | - } |
|
939 | - // make sure we have some values before inserting them |
|
940 | - if (! empty($QSG_values)) { |
|
941 | - // insert system question |
|
942 | - $wpdb->insert( |
|
943 | - $table_name, |
|
944 | - $QSG_values, |
|
945 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
946 | - ); |
|
947 | - $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
948 | - } |
|
949 | - } |
|
950 | - } |
|
951 | - // QUESTIONS |
|
952 | - global $wpdb; |
|
953 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question'); |
|
954 | - $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
|
955 | - // what we have |
|
956 | - $questions = $wpdb->get_col($SQL); |
|
957 | - // what we should have |
|
958 | - $QST_systems = array( |
|
959 | - 'fname', |
|
960 | - 'lname', |
|
961 | - 'email', |
|
962 | - 'address', |
|
963 | - 'address2', |
|
964 | - 'city', |
|
965 | - 'country', |
|
966 | - 'state', |
|
967 | - 'zip', |
|
968 | - 'phone', |
|
969 | - ); |
|
970 | - $order_for_group_1 = 1; |
|
971 | - $order_for_group_2 = 1; |
|
972 | - // loop thru what we should have and compare to what we have |
|
973 | - foreach ($QST_systems as $QST_system) { |
|
974 | - // reset values array |
|
975 | - $QST_values = array(); |
|
976 | - // if we don't have what we should have |
|
977 | - if (! in_array($QST_system, $questions)) { |
|
978 | - // add it |
|
979 | - switch ($QST_system) { |
|
980 | - case 'fname': |
|
981 | - $QST_values = array( |
|
982 | - 'QST_display_text' => __('First Name', 'event_espresso'), |
|
983 | - 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
984 | - 'QST_system' => 'fname', |
|
985 | - 'QST_type' => 'TEXT', |
|
986 | - 'QST_required' => 1, |
|
987 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
988 | - 'QST_order' => 1, |
|
989 | - 'QST_admin_only' => 0, |
|
990 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
991 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
992 | - 'QST_deleted' => 0, |
|
993 | - ); |
|
994 | - break; |
|
995 | - case 'lname': |
|
996 | - $QST_values = array( |
|
997 | - 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
998 | - 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
999 | - 'QST_system' => 'lname', |
|
1000 | - 'QST_type' => 'TEXT', |
|
1001 | - 'QST_required' => 1, |
|
1002 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1003 | - 'QST_order' => 2, |
|
1004 | - 'QST_admin_only' => 0, |
|
1005 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1006 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1007 | - 'QST_deleted' => 0, |
|
1008 | - ); |
|
1009 | - break; |
|
1010 | - case 'email': |
|
1011 | - $QST_values = array( |
|
1012 | - 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
1013 | - 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
1014 | - 'QST_system' => 'email', |
|
1015 | - 'QST_type' => 'EMAIL', |
|
1016 | - 'QST_required' => 1, |
|
1017 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1018 | - 'QST_order' => 3, |
|
1019 | - 'QST_admin_only' => 0, |
|
1020 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1021 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1022 | - 'QST_deleted' => 0, |
|
1023 | - ); |
|
1024 | - break; |
|
1025 | - case 'address': |
|
1026 | - $QST_values = array( |
|
1027 | - 'QST_display_text' => __('Address', 'event_espresso'), |
|
1028 | - 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
1029 | - 'QST_system' => 'address', |
|
1030 | - 'QST_type' => 'TEXT', |
|
1031 | - 'QST_required' => 0, |
|
1032 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1033 | - 'QST_order' => 4, |
|
1034 | - 'QST_admin_only' => 0, |
|
1035 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1036 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1037 | - 'QST_deleted' => 0, |
|
1038 | - ); |
|
1039 | - break; |
|
1040 | - case 'address2': |
|
1041 | - $QST_values = array( |
|
1042 | - 'QST_display_text' => __('Address2', 'event_espresso'), |
|
1043 | - 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
1044 | - 'QST_system' => 'address2', |
|
1045 | - 'QST_type' => 'TEXT', |
|
1046 | - 'QST_required' => 0, |
|
1047 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1048 | - 'QST_order' => 5, |
|
1049 | - 'QST_admin_only' => 0, |
|
1050 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1051 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1052 | - 'QST_deleted' => 0, |
|
1053 | - ); |
|
1054 | - break; |
|
1055 | - case 'city': |
|
1056 | - $QST_values = array( |
|
1057 | - 'QST_display_text' => __('City', 'event_espresso'), |
|
1058 | - 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1059 | - 'QST_system' => 'city', |
|
1060 | - 'QST_type' => 'TEXT', |
|
1061 | - 'QST_required' => 0, |
|
1062 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1063 | - 'QST_order' => 6, |
|
1064 | - 'QST_admin_only' => 0, |
|
1065 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1066 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1067 | - 'QST_deleted' => 0, |
|
1068 | - ); |
|
1069 | - break; |
|
1070 | - case 'country': |
|
1071 | - $QST_values = array( |
|
1072 | - 'QST_display_text' => __('Country', 'event_espresso'), |
|
1073 | - 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1074 | - 'QST_system' => 'country', |
|
1075 | - 'QST_type' => 'COUNTRY', |
|
1076 | - 'QST_required' => 0, |
|
1077 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1078 | - 'QST_order' => 7, |
|
1079 | - 'QST_admin_only' => 0, |
|
1080 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1081 | - 'QST_deleted' => 0, |
|
1082 | - ); |
|
1083 | - break; |
|
1084 | - case 'state': |
|
1085 | - $QST_values = array( |
|
1086 | - 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1087 | - 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1088 | - 'QST_system' => 'state', |
|
1089 | - 'QST_type' => 'STATE', |
|
1090 | - 'QST_required' => 0, |
|
1091 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1092 | - 'QST_order' => 8, |
|
1093 | - 'QST_admin_only' => 0, |
|
1094 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1095 | - 'QST_deleted' => 0, |
|
1096 | - ); |
|
1097 | - break; |
|
1098 | - case 'zip': |
|
1099 | - $QST_values = array( |
|
1100 | - 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1101 | - 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1102 | - 'QST_system' => 'zip', |
|
1103 | - 'QST_type' => 'TEXT', |
|
1104 | - 'QST_required' => 0, |
|
1105 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1106 | - 'QST_order' => 9, |
|
1107 | - 'QST_admin_only' => 0, |
|
1108 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1109 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1110 | - 'QST_deleted' => 0, |
|
1111 | - ); |
|
1112 | - break; |
|
1113 | - case 'phone': |
|
1114 | - $QST_values = array( |
|
1115 | - 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1116 | - 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1117 | - 'QST_system' => 'phone', |
|
1118 | - 'QST_type' => 'TEXT', |
|
1119 | - 'QST_required' => 0, |
|
1120 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1121 | - 'QST_order' => 10, |
|
1122 | - 'QST_admin_only' => 0, |
|
1123 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1124 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1125 | - 'QST_deleted' => 0, |
|
1126 | - ); |
|
1127 | - break; |
|
1128 | - } |
|
1129 | - if (! empty($QST_values)) { |
|
1130 | - // insert system question |
|
1131 | - $wpdb->insert( |
|
1132 | - $table_name, |
|
1133 | - $QST_values, |
|
1134 | - array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1135 | - ); |
|
1136 | - $QST_ID = $wpdb->insert_id; |
|
1137 | - // QUESTION GROUP QUESTIONS |
|
1138 | - if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1139 | - $system_question_we_want = EEM_Question_Group::system_personal; |
|
1140 | - } else { |
|
1141 | - $system_question_we_want = EEM_Question_Group::system_address; |
|
1142 | - } |
|
1143 | - if (isset($QSG_IDs[$system_question_we_want])) { |
|
1144 | - $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1145 | - } else { |
|
1146 | - $id_col = EEM_Question_Group::instance() |
|
1147 | - ->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1148 | - if (is_array($id_col)) { |
|
1149 | - $QSG_ID = reset($id_col); |
|
1150 | - } else { |
|
1151 | - //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
|
1152 | - EE_Log::instance()->log( |
|
1153 | - __FILE__, |
|
1154 | - __FUNCTION__, |
|
1155 | - sprintf( |
|
1156 | - __( |
|
1157 | - 'Could not associate question %1$s to a question group because no system question |
|
874 | + 'event_espresso' |
|
875 | + ), |
|
876 | + __FILE__, |
|
877 | + __FUNCTION__, |
|
878 | + __LINE__ |
|
879 | + ); |
|
880 | + return false; |
|
881 | + } |
|
882 | + return true; |
|
883 | + } |
|
884 | + |
|
885 | + |
|
886 | + |
|
887 | + /** |
|
888 | + * initialize_system_questions |
|
889 | + * |
|
890 | + * @access public |
|
891 | + * @static |
|
892 | + * @return void |
|
893 | + */ |
|
894 | + public static function initialize_system_questions() |
|
895 | + { |
|
896 | + // QUESTION GROUPS |
|
897 | + global $wpdb; |
|
898 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group'); |
|
899 | + $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
|
900 | + // what we have |
|
901 | + $question_groups = $wpdb->get_col($SQL); |
|
902 | + // check the response |
|
903 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
904 | + // what we should have |
|
905 | + $QSG_systems = array(1, 2); |
|
906 | + // loop thru what we should have and compare to what we have |
|
907 | + foreach ($QSG_systems as $QSG_system) { |
|
908 | + // reset values array |
|
909 | + $QSG_values = array(); |
|
910 | + // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
|
911 | + if (! in_array("$QSG_system", $question_groups)) { |
|
912 | + // add it |
|
913 | + switch ($QSG_system) { |
|
914 | + case 1: |
|
915 | + $QSG_values = array( |
|
916 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
917 | + 'QSG_identifier' => 'personal-information-' . time(), |
|
918 | + 'QSG_desc' => '', |
|
919 | + 'QSG_order' => 1, |
|
920 | + 'QSG_show_group_name' => 1, |
|
921 | + 'QSG_show_group_desc' => 1, |
|
922 | + 'QSG_system' => EEM_Question_Group::system_personal, |
|
923 | + 'QSG_deleted' => 0, |
|
924 | + ); |
|
925 | + break; |
|
926 | + case 2: |
|
927 | + $QSG_values = array( |
|
928 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
929 | + 'QSG_identifier' => 'address-information-' . time(), |
|
930 | + 'QSG_desc' => '', |
|
931 | + 'QSG_order' => 2, |
|
932 | + 'QSG_show_group_name' => 1, |
|
933 | + 'QSG_show_group_desc' => 1, |
|
934 | + 'QSG_system' => EEM_Question_Group::system_address, |
|
935 | + 'QSG_deleted' => 0, |
|
936 | + ); |
|
937 | + break; |
|
938 | + } |
|
939 | + // make sure we have some values before inserting them |
|
940 | + if (! empty($QSG_values)) { |
|
941 | + // insert system question |
|
942 | + $wpdb->insert( |
|
943 | + $table_name, |
|
944 | + $QSG_values, |
|
945 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
946 | + ); |
|
947 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
948 | + } |
|
949 | + } |
|
950 | + } |
|
951 | + // QUESTIONS |
|
952 | + global $wpdb; |
|
953 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question'); |
|
954 | + $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
|
955 | + // what we have |
|
956 | + $questions = $wpdb->get_col($SQL); |
|
957 | + // what we should have |
|
958 | + $QST_systems = array( |
|
959 | + 'fname', |
|
960 | + 'lname', |
|
961 | + 'email', |
|
962 | + 'address', |
|
963 | + 'address2', |
|
964 | + 'city', |
|
965 | + 'country', |
|
966 | + 'state', |
|
967 | + 'zip', |
|
968 | + 'phone', |
|
969 | + ); |
|
970 | + $order_for_group_1 = 1; |
|
971 | + $order_for_group_2 = 1; |
|
972 | + // loop thru what we should have and compare to what we have |
|
973 | + foreach ($QST_systems as $QST_system) { |
|
974 | + // reset values array |
|
975 | + $QST_values = array(); |
|
976 | + // if we don't have what we should have |
|
977 | + if (! in_array($QST_system, $questions)) { |
|
978 | + // add it |
|
979 | + switch ($QST_system) { |
|
980 | + case 'fname': |
|
981 | + $QST_values = array( |
|
982 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
983 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
984 | + 'QST_system' => 'fname', |
|
985 | + 'QST_type' => 'TEXT', |
|
986 | + 'QST_required' => 1, |
|
987 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
988 | + 'QST_order' => 1, |
|
989 | + 'QST_admin_only' => 0, |
|
990 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
991 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
992 | + 'QST_deleted' => 0, |
|
993 | + ); |
|
994 | + break; |
|
995 | + case 'lname': |
|
996 | + $QST_values = array( |
|
997 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
998 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
999 | + 'QST_system' => 'lname', |
|
1000 | + 'QST_type' => 'TEXT', |
|
1001 | + 'QST_required' => 1, |
|
1002 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1003 | + 'QST_order' => 2, |
|
1004 | + 'QST_admin_only' => 0, |
|
1005 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1006 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1007 | + 'QST_deleted' => 0, |
|
1008 | + ); |
|
1009 | + break; |
|
1010 | + case 'email': |
|
1011 | + $QST_values = array( |
|
1012 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
1013 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
1014 | + 'QST_system' => 'email', |
|
1015 | + 'QST_type' => 'EMAIL', |
|
1016 | + 'QST_required' => 1, |
|
1017 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1018 | + 'QST_order' => 3, |
|
1019 | + 'QST_admin_only' => 0, |
|
1020 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1021 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1022 | + 'QST_deleted' => 0, |
|
1023 | + ); |
|
1024 | + break; |
|
1025 | + case 'address': |
|
1026 | + $QST_values = array( |
|
1027 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
1028 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
1029 | + 'QST_system' => 'address', |
|
1030 | + 'QST_type' => 'TEXT', |
|
1031 | + 'QST_required' => 0, |
|
1032 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1033 | + 'QST_order' => 4, |
|
1034 | + 'QST_admin_only' => 0, |
|
1035 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1036 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1037 | + 'QST_deleted' => 0, |
|
1038 | + ); |
|
1039 | + break; |
|
1040 | + case 'address2': |
|
1041 | + $QST_values = array( |
|
1042 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
1043 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
1044 | + 'QST_system' => 'address2', |
|
1045 | + 'QST_type' => 'TEXT', |
|
1046 | + 'QST_required' => 0, |
|
1047 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1048 | + 'QST_order' => 5, |
|
1049 | + 'QST_admin_only' => 0, |
|
1050 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1051 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1052 | + 'QST_deleted' => 0, |
|
1053 | + ); |
|
1054 | + break; |
|
1055 | + case 'city': |
|
1056 | + $QST_values = array( |
|
1057 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1058 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1059 | + 'QST_system' => 'city', |
|
1060 | + 'QST_type' => 'TEXT', |
|
1061 | + 'QST_required' => 0, |
|
1062 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1063 | + 'QST_order' => 6, |
|
1064 | + 'QST_admin_only' => 0, |
|
1065 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1066 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1067 | + 'QST_deleted' => 0, |
|
1068 | + ); |
|
1069 | + break; |
|
1070 | + case 'country': |
|
1071 | + $QST_values = array( |
|
1072 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1073 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1074 | + 'QST_system' => 'country', |
|
1075 | + 'QST_type' => 'COUNTRY', |
|
1076 | + 'QST_required' => 0, |
|
1077 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1078 | + 'QST_order' => 7, |
|
1079 | + 'QST_admin_only' => 0, |
|
1080 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1081 | + 'QST_deleted' => 0, |
|
1082 | + ); |
|
1083 | + break; |
|
1084 | + case 'state': |
|
1085 | + $QST_values = array( |
|
1086 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1087 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1088 | + 'QST_system' => 'state', |
|
1089 | + 'QST_type' => 'STATE', |
|
1090 | + 'QST_required' => 0, |
|
1091 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1092 | + 'QST_order' => 8, |
|
1093 | + 'QST_admin_only' => 0, |
|
1094 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1095 | + 'QST_deleted' => 0, |
|
1096 | + ); |
|
1097 | + break; |
|
1098 | + case 'zip': |
|
1099 | + $QST_values = array( |
|
1100 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1101 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1102 | + 'QST_system' => 'zip', |
|
1103 | + 'QST_type' => 'TEXT', |
|
1104 | + 'QST_required' => 0, |
|
1105 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1106 | + 'QST_order' => 9, |
|
1107 | + 'QST_admin_only' => 0, |
|
1108 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1109 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1110 | + 'QST_deleted' => 0, |
|
1111 | + ); |
|
1112 | + break; |
|
1113 | + case 'phone': |
|
1114 | + $QST_values = array( |
|
1115 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1116 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1117 | + 'QST_system' => 'phone', |
|
1118 | + 'QST_type' => 'TEXT', |
|
1119 | + 'QST_required' => 0, |
|
1120 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1121 | + 'QST_order' => 10, |
|
1122 | + 'QST_admin_only' => 0, |
|
1123 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1124 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1125 | + 'QST_deleted' => 0, |
|
1126 | + ); |
|
1127 | + break; |
|
1128 | + } |
|
1129 | + if (! empty($QST_values)) { |
|
1130 | + // insert system question |
|
1131 | + $wpdb->insert( |
|
1132 | + $table_name, |
|
1133 | + $QST_values, |
|
1134 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1135 | + ); |
|
1136 | + $QST_ID = $wpdb->insert_id; |
|
1137 | + // QUESTION GROUP QUESTIONS |
|
1138 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1139 | + $system_question_we_want = EEM_Question_Group::system_personal; |
|
1140 | + } else { |
|
1141 | + $system_question_we_want = EEM_Question_Group::system_address; |
|
1142 | + } |
|
1143 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1144 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1145 | + } else { |
|
1146 | + $id_col = EEM_Question_Group::instance() |
|
1147 | + ->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1148 | + if (is_array($id_col)) { |
|
1149 | + $QSG_ID = reset($id_col); |
|
1150 | + } else { |
|
1151 | + //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
|
1152 | + EE_Log::instance()->log( |
|
1153 | + __FILE__, |
|
1154 | + __FUNCTION__, |
|
1155 | + sprintf( |
|
1156 | + __( |
|
1157 | + 'Could not associate question %1$s to a question group because no system question |
|
1158 | 1158 | group existed', |
1159 | - 'event_espresso' |
|
1160 | - ), |
|
1161 | - $QST_ID), |
|
1162 | - 'error'); |
|
1163 | - continue; |
|
1164 | - } |
|
1165 | - } |
|
1166 | - // add system questions to groups |
|
1167 | - $wpdb->insert( |
|
1168 | - \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'), |
|
1169 | - array( |
|
1170 | - 'QSG_ID' => $QSG_ID, |
|
1171 | - 'QST_ID' => $QST_ID, |
|
1172 | - 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++, |
|
1173 | - ), |
|
1174 | - array('%d', '%d', '%d') |
|
1175 | - ); |
|
1176 | - } |
|
1177 | - } |
|
1178 | - } |
|
1179 | - } |
|
1180 | - |
|
1181 | - |
|
1182 | - /** |
|
1183 | - * Makes sure the default payment method (Invoice) is active. |
|
1184 | - * This used to be done automatically as part of constructing the old gateways config |
|
1185 | - * |
|
1186 | - * @throws \EE_Error |
|
1187 | - */ |
|
1188 | - public static function insert_default_payment_methods() |
|
1189 | - { |
|
1190 | - if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1191 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1192 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1193 | - } else { |
|
1194 | - EEM_Payment_Method::instance()->verify_button_urls(); |
|
1195 | - } |
|
1196 | - } |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * insert_default_status_codes |
|
1200 | - * |
|
1201 | - * @access public |
|
1202 | - * @static |
|
1203 | - * @return void |
|
1204 | - */ |
|
1205 | - public static function insert_default_status_codes() |
|
1206 | - { |
|
1207 | - |
|
1208 | - global $wpdb; |
|
1209 | - |
|
1210 | - if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) { |
|
1211 | - |
|
1212 | - $table_name = EEM_Status::instance()->table(); |
|
1213 | - |
|
1214 | - $SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );"; |
|
1215 | - $wpdb->query($SQL); |
|
1216 | - |
|
1217 | - $SQL = "INSERT INTO $table_name |
|
1159 | + 'event_espresso' |
|
1160 | + ), |
|
1161 | + $QST_ID), |
|
1162 | + 'error'); |
|
1163 | + continue; |
|
1164 | + } |
|
1165 | + } |
|
1166 | + // add system questions to groups |
|
1167 | + $wpdb->insert( |
|
1168 | + \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'), |
|
1169 | + array( |
|
1170 | + 'QSG_ID' => $QSG_ID, |
|
1171 | + 'QST_ID' => $QST_ID, |
|
1172 | + 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++, |
|
1173 | + ), |
|
1174 | + array('%d', '%d', '%d') |
|
1175 | + ); |
|
1176 | + } |
|
1177 | + } |
|
1178 | + } |
|
1179 | + } |
|
1180 | + |
|
1181 | + |
|
1182 | + /** |
|
1183 | + * Makes sure the default payment method (Invoice) is active. |
|
1184 | + * This used to be done automatically as part of constructing the old gateways config |
|
1185 | + * |
|
1186 | + * @throws \EE_Error |
|
1187 | + */ |
|
1188 | + public static function insert_default_payment_methods() |
|
1189 | + { |
|
1190 | + if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1191 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1192 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1193 | + } else { |
|
1194 | + EEM_Payment_Method::instance()->verify_button_urls(); |
|
1195 | + } |
|
1196 | + } |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * insert_default_status_codes |
|
1200 | + * |
|
1201 | + * @access public |
|
1202 | + * @static |
|
1203 | + * @return void |
|
1204 | + */ |
|
1205 | + public static function insert_default_status_codes() |
|
1206 | + { |
|
1207 | + |
|
1208 | + global $wpdb; |
|
1209 | + |
|
1210 | + if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) { |
|
1211 | + |
|
1212 | + $table_name = EEM_Status::instance()->table(); |
|
1213 | + |
|
1214 | + $SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );"; |
|
1215 | + $wpdb->query($SQL); |
|
1216 | + |
|
1217 | + $SQL = "INSERT INTO $table_name |
|
1218 | 1218 | (STS_ID, STS_code, STS_type, STS_can_edit, STS_desc, STS_open) VALUES |
1219 | 1219 | ('ACT', 'ACTIVE', 'event', 0, NULL, 1), |
1220 | 1220 | ('NAC', 'NOT_ACTIVE', 'event', 0, NULL, 0), |
@@ -1254,521 +1254,521 @@ discard block |
||
1254 | 1254 | ('MID', 'IDLE', 'message', 0, NULL, 1), |
1255 | 1255 | ('MRS', 'RESEND', 'message', 0, NULL, 1), |
1256 | 1256 | ('MIC', 'INCOMPLETE', 'message', 0, NULL, 0);"; |
1257 | - $wpdb->query($SQL); |
|
1258 | - |
|
1259 | - } |
|
1260 | - |
|
1261 | - } |
|
1262 | - |
|
1263 | - |
|
1264 | - /** |
|
1265 | - * create_upload_directories |
|
1266 | - * Creates folders in the uploads directory to facilitate addons and templates |
|
1267 | - * |
|
1268 | - * @access public |
|
1269 | - * @static |
|
1270 | - * @return boolean success of verifying upload directories exist |
|
1271 | - */ |
|
1272 | - public static function create_upload_directories() |
|
1273 | - { |
|
1274 | - // Create the required folders |
|
1275 | - $folders = array( |
|
1276 | - EVENT_ESPRESSO_TEMPLATE_DIR, |
|
1277 | - EVENT_ESPRESSO_GATEWAY_DIR, |
|
1278 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1279 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1280 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/', |
|
1281 | - ); |
|
1282 | - foreach ($folders as $folder) { |
|
1283 | - try { |
|
1284 | - EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1285 | - @ chmod($folder, 0755); |
|
1286 | - } catch (EE_Error $e) { |
|
1287 | - EE_Error::add_error( |
|
1288 | - sprintf( |
|
1289 | - __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1290 | - $folder, |
|
1291 | - '<br />' . $e->getMessage() |
|
1292 | - ), |
|
1293 | - __FILE__, __FUNCTION__, __LINE__ |
|
1294 | - ); |
|
1295 | - //indicate we'll need to fix this later |
|
1296 | - update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1297 | - return false; |
|
1298 | - } |
|
1299 | - } |
|
1300 | - //just add the .htaccess file to the logs directory to begin with. Even if logging |
|
1301 | - //is disabled, there might be activation errors recorded in there |
|
1302 | - EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/'); |
|
1303 | - //remember EE's folders are all good |
|
1304 | - delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1305 | - return true; |
|
1306 | - } |
|
1307 | - |
|
1308 | - /** |
|
1309 | - * Whether the upload directories need to be fixed or not. |
|
1310 | - * If EE is installed but filesystem access isn't initially available, |
|
1311 | - * we need to get the user's filesystem credentials and THEN create them, |
|
1312 | - * so there might be period of time when EE is installed but its |
|
1313 | - * upload directories aren't available. This indicates such a state |
|
1314 | - * |
|
1315 | - * @return boolean |
|
1316 | - */ |
|
1317 | - public static function upload_directories_incomplete() |
|
1318 | - { |
|
1319 | - return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1320 | - } |
|
1321 | - |
|
1322 | - |
|
1323 | - /** |
|
1324 | - * generate_default_message_templates |
|
1325 | - * |
|
1326 | - * @static |
|
1327 | - * @throws EE_Error |
|
1328 | - * @return bool true means new templates were created. |
|
1329 | - * false means no templates were created. |
|
1330 | - * This is NOT an error flag. To check for errors you will want |
|
1331 | - * to use either EE_Error or a try catch for an EE_Error exception. |
|
1332 | - */ |
|
1333 | - public static function generate_default_message_templates() |
|
1334 | - { |
|
1335 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1336 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1337 | - /* |
|
1257 | + $wpdb->query($SQL); |
|
1258 | + |
|
1259 | + } |
|
1260 | + |
|
1261 | + } |
|
1262 | + |
|
1263 | + |
|
1264 | + /** |
|
1265 | + * create_upload_directories |
|
1266 | + * Creates folders in the uploads directory to facilitate addons and templates |
|
1267 | + * |
|
1268 | + * @access public |
|
1269 | + * @static |
|
1270 | + * @return boolean success of verifying upload directories exist |
|
1271 | + */ |
|
1272 | + public static function create_upload_directories() |
|
1273 | + { |
|
1274 | + // Create the required folders |
|
1275 | + $folders = array( |
|
1276 | + EVENT_ESPRESSO_TEMPLATE_DIR, |
|
1277 | + EVENT_ESPRESSO_GATEWAY_DIR, |
|
1278 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1279 | + EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1280 | + EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/', |
|
1281 | + ); |
|
1282 | + foreach ($folders as $folder) { |
|
1283 | + try { |
|
1284 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1285 | + @ chmod($folder, 0755); |
|
1286 | + } catch (EE_Error $e) { |
|
1287 | + EE_Error::add_error( |
|
1288 | + sprintf( |
|
1289 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1290 | + $folder, |
|
1291 | + '<br />' . $e->getMessage() |
|
1292 | + ), |
|
1293 | + __FILE__, __FUNCTION__, __LINE__ |
|
1294 | + ); |
|
1295 | + //indicate we'll need to fix this later |
|
1296 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1297 | + return false; |
|
1298 | + } |
|
1299 | + } |
|
1300 | + //just add the .htaccess file to the logs directory to begin with. Even if logging |
|
1301 | + //is disabled, there might be activation errors recorded in there |
|
1302 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/'); |
|
1303 | + //remember EE's folders are all good |
|
1304 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1305 | + return true; |
|
1306 | + } |
|
1307 | + |
|
1308 | + /** |
|
1309 | + * Whether the upload directories need to be fixed or not. |
|
1310 | + * If EE is installed but filesystem access isn't initially available, |
|
1311 | + * we need to get the user's filesystem credentials and THEN create them, |
|
1312 | + * so there might be period of time when EE is installed but its |
|
1313 | + * upload directories aren't available. This indicates such a state |
|
1314 | + * |
|
1315 | + * @return boolean |
|
1316 | + */ |
|
1317 | + public static function upload_directories_incomplete() |
|
1318 | + { |
|
1319 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1320 | + } |
|
1321 | + |
|
1322 | + |
|
1323 | + /** |
|
1324 | + * generate_default_message_templates |
|
1325 | + * |
|
1326 | + * @static |
|
1327 | + * @throws EE_Error |
|
1328 | + * @return bool true means new templates were created. |
|
1329 | + * false means no templates were created. |
|
1330 | + * This is NOT an error flag. To check for errors you will want |
|
1331 | + * to use either EE_Error or a try catch for an EE_Error exception. |
|
1332 | + */ |
|
1333 | + public static function generate_default_message_templates() |
|
1334 | + { |
|
1335 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1336 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1337 | + /* |
|
1338 | 1338 | * This first method is taking care of ensuring any default messengers |
1339 | 1339 | * that should be made active and have templates generated are done. |
1340 | 1340 | */ |
1341 | - $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates( |
|
1342 | - $message_resource_manager |
|
1343 | - ); |
|
1344 | - /** |
|
1345 | - * This method is verifying there are no NEW default message types |
|
1346 | - * for ACTIVE messengers that need activated (and corresponding templates setup). |
|
1347 | - */ |
|
1348 | - $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1349 | - $message_resource_manager |
|
1350 | - ); |
|
1351 | - //after all is done, let's persist these changes to the db. |
|
1352 | - $message_resource_manager->update_has_activated_messengers_option(); |
|
1353 | - $message_resource_manager->update_active_messengers_option(); |
|
1354 | - // will return true if either of these are true. Otherwise will return false. |
|
1355 | - return $new_templates_created_for_message_type || $new_templates_created_for_messenger; |
|
1356 | - } |
|
1357 | - |
|
1358 | - |
|
1359 | - |
|
1360 | - /** |
|
1361 | - * @param \EE_Message_Resource_Manager $message_resource_manager |
|
1362 | - * @return array|bool |
|
1363 | - * @throws \EE_Error |
|
1364 | - */ |
|
1365 | - protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1366 | - EE_Message_Resource_Manager $message_resource_manager |
|
1367 | - ) { |
|
1368 | - /** @type EE_messenger[] $active_messengers */ |
|
1369 | - $active_messengers = $message_resource_manager->active_messengers(); |
|
1370 | - $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1371 | - $templates_created = false; |
|
1372 | - foreach ($active_messengers as $active_messenger) { |
|
1373 | - $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
|
1374 | - $default_message_type_names_to_activate = array(); |
|
1375 | - // looping through each default message type reported by the messenger |
|
1376 | - // and setup the actual message types to activate. |
|
1377 | - foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1378 | - // if already active or has already been activated before we skip |
|
1379 | - // (otherwise we might reactivate something user's intentionally deactivated.) |
|
1380 | - // we also skip if the message type is not installed. |
|
1381 | - if ( |
|
1382 | - $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1383 | - $default_message_type_name_for_messenger, |
|
1384 | - $active_messenger->name |
|
1385 | - ) |
|
1386 | - || $message_resource_manager->is_message_type_active_for_messenger( |
|
1387 | - $active_messenger->name, |
|
1388 | - $default_message_type_name_for_messenger |
|
1389 | - ) |
|
1390 | - || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1391 | - ) { |
|
1392 | - continue; |
|
1393 | - } |
|
1394 | - $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger; |
|
1395 | - } |
|
1396 | - //let's activate! |
|
1397 | - $message_resource_manager->ensure_message_types_are_active( |
|
1398 | - $default_message_type_names_to_activate, |
|
1399 | - $active_messenger->name, |
|
1400 | - false |
|
1401 | - ); |
|
1402 | - //activate the templates for these message types |
|
1403 | - if ( ! empty($default_message_type_names_to_activate)) { |
|
1404 | - $templates_created = EEH_MSG_Template::generate_new_templates( |
|
1405 | - $active_messenger->name, |
|
1406 | - $default_message_type_names_for_messenger, |
|
1407 | - '', |
|
1408 | - true |
|
1409 | - ); |
|
1410 | - } |
|
1411 | - } |
|
1412 | - return $templates_created; |
|
1413 | - } |
|
1414 | - |
|
1415 | - |
|
1416 | - |
|
1417 | - /** |
|
1418 | - * This will activate and generate default messengers and default message types for those messengers. |
|
1419 | - * |
|
1420 | - * @param EE_message_Resource_Manager $message_resource_manager |
|
1421 | - * @return array|bool True means there were default messengers and message type templates generated. |
|
1422 | - * False means that there were no templates generated |
|
1423 | - * (which could simply mean there are no default message types for a messenger). |
|
1424 | - * @throws EE_Error |
|
1425 | - */ |
|
1426 | - protected static function _activate_and_generate_default_messengers_and_message_templates( |
|
1427 | - EE_Message_Resource_Manager $message_resource_manager |
|
1428 | - ) { |
|
1429 | - /** @type EE_messenger[] $messengers_to_generate */ |
|
1430 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1431 | - $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1432 | - $templates_generated = false; |
|
1433 | - foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1434 | - $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
|
1435 | - //verify the default message types match an installed message type. |
|
1436 | - foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1437 | - if ( |
|
1438 | - ! isset($installed_message_types[$name]) |
|
1439 | - || $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1440 | - $name, |
|
1441 | - $messenger_to_generate->name |
|
1442 | - ) |
|
1443 | - ) { |
|
1444 | - unset($default_message_type_names_for_messenger[$key]); |
|
1445 | - } |
|
1446 | - } |
|
1447 | - // in previous iterations, the active_messengers option in the db |
|
1448 | - // needed updated before calling create templates. however with the changes this may not be necessary. |
|
1449 | - // This comment is left here just in case we discover that we _do_ need to update before |
|
1450 | - // passing off to create templates (after the refactor is done). |
|
1451 | - // @todo remove this comment when determined not necessary. |
|
1452 | - $message_resource_manager->activate_messenger( |
|
1453 | - $messenger_to_generate->name, |
|
1454 | - $default_message_type_names_for_messenger, |
|
1455 | - false |
|
1456 | - ); |
|
1457 | - //create any templates needing created (or will reactivate templates already generated as necessary). |
|
1458 | - if ( ! empty($default_message_type_names_for_messenger)) { |
|
1459 | - $templates_generated = EEH_MSG_Template::generate_new_templates( |
|
1460 | - $messenger_to_generate->name, |
|
1461 | - $default_message_type_names_for_messenger, |
|
1462 | - '', |
|
1463 | - true |
|
1464 | - ); |
|
1465 | - } |
|
1466 | - } |
|
1467 | - return $templates_generated; |
|
1468 | - } |
|
1469 | - |
|
1470 | - |
|
1471 | - /** |
|
1472 | - * This returns the default messengers to generate templates for on activation of EE. |
|
1473 | - * It considers: |
|
1474 | - * - whether a messenger is already active in the db. |
|
1475 | - * - whether a messenger has been made active at any time in the past. |
|
1476 | - * |
|
1477 | - * @static |
|
1478 | - * @param EE_Message_Resource_Manager $message_resource_manager |
|
1479 | - * @return EE_messenger[] |
|
1480 | - */ |
|
1481 | - protected static function _get_default_messengers_to_generate_on_activation( |
|
1482 | - EE_Message_Resource_Manager $message_resource_manager |
|
1483 | - ) { |
|
1484 | - $active_messengers = $message_resource_manager->active_messengers(); |
|
1485 | - $installed_messengers = $message_resource_manager->installed_messengers(); |
|
1486 | - $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
|
1487 | - |
|
1488 | - $messengers_to_generate = array(); |
|
1489 | - foreach ($installed_messengers as $installed_messenger) { |
|
1490 | - //if installed messenger is a messenger that should be activated on install |
|
1491 | - //and is not already active |
|
1492 | - //and has never been activated |
|
1493 | - if ( |
|
1494 | - ! $installed_messenger->activate_on_install |
|
1495 | - || isset($active_messengers[$installed_messenger->name]) |
|
1496 | - || isset($has_activated[$installed_messenger->name]) |
|
1497 | - ) { |
|
1498 | - continue; |
|
1499 | - } |
|
1500 | - $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1501 | - } |
|
1502 | - return $messengers_to_generate; |
|
1503 | - } |
|
1504 | - |
|
1505 | - |
|
1506 | - /** |
|
1507 | - * This simply validates active message types to ensure they actually match installed |
|
1508 | - * message types. If there's a mismatch then we deactivate the message type and ensure all related db |
|
1509 | - * rows are set inactive. |
|
1510 | - * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever |
|
1511 | - * EE_Messenger_Resource_Manager is constructed. Message Types are a bit more resource heavy for validation so they |
|
1512 | - * are still handled in here. |
|
1513 | - * |
|
1514 | - * @since 4.3.1 |
|
1515 | - * @return void |
|
1516 | - */ |
|
1517 | - public static function validate_messages_system() |
|
1518 | - { |
|
1519 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1520 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1521 | - $message_resource_manager->validate_active_message_types_are_installed(); |
|
1522 | - do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1523 | - } |
|
1524 | - |
|
1525 | - |
|
1526 | - /** |
|
1527 | - * create_no_ticket_prices_array |
|
1528 | - * |
|
1529 | - * @access public |
|
1530 | - * @static |
|
1531 | - * @return void |
|
1532 | - */ |
|
1533 | - public static function create_no_ticket_prices_array() |
|
1534 | - { |
|
1535 | - // this creates an array for tracking events that have no active ticket prices created |
|
1536 | - // this allows us to warn admins of the situation so that it can be corrected |
|
1537 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false); |
|
1538 | - if (! $espresso_no_ticket_prices) { |
|
1539 | - add_option('ee_no_ticket_prices', array(), '', false); |
|
1540 | - } |
|
1541 | - } |
|
1542 | - |
|
1543 | - |
|
1544 | - /** |
|
1545 | - * plugin_deactivation |
|
1546 | - * |
|
1547 | - * @access public |
|
1548 | - * @static |
|
1549 | - * @return void |
|
1550 | - */ |
|
1551 | - public static function plugin_deactivation() |
|
1552 | - { |
|
1553 | - } |
|
1554 | - |
|
1555 | - |
|
1556 | - /** |
|
1557 | - * Finds all our EE4 custom post types, and deletes them and their associated data |
|
1558 | - * (like post meta or term relations) |
|
1559 | - * |
|
1560 | - * @global wpdb $wpdb |
|
1561 | - * @throws \EE_Error |
|
1562 | - */ |
|
1563 | - public static function delete_all_espresso_cpt_data() |
|
1564 | - { |
|
1565 | - global $wpdb; |
|
1566 | - //get all the CPT post_types |
|
1567 | - $ee_post_types = array(); |
|
1568 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1569 | - if (method_exists($model_name, 'instance')) { |
|
1570 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
1571 | - if ($model_obj instanceof EEM_CPT_Base) { |
|
1572 | - $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1573 | - } |
|
1574 | - } |
|
1575 | - } |
|
1576 | - //get all our CPTs |
|
1577 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")"; |
|
1578 | - $cpt_ids = $wpdb->get_col($query); |
|
1579 | - //delete each post meta and term relations too |
|
1580 | - foreach ($cpt_ids as $post_id) { |
|
1581 | - wp_delete_post($post_id, true); |
|
1582 | - } |
|
1583 | - } |
|
1584 | - |
|
1585 | - /** |
|
1586 | - * Deletes all EE custom tables |
|
1587 | - * |
|
1588 | - * @return array |
|
1589 | - */ |
|
1590 | - public static function drop_espresso_tables() |
|
1591 | - { |
|
1592 | - $tables = array(); |
|
1593 | - // load registry |
|
1594 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1595 | - if (method_exists($model_name, 'instance')) { |
|
1596 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
1597 | - if ($model_obj instanceof EEM_Base) { |
|
1598 | - foreach ($model_obj->get_tables() as $table) { |
|
1599 | - if (strpos($table->get_table_name(), 'esp_') |
|
1600 | - && |
|
1601 | - ( |
|
1602 | - is_main_site()//main site? nuke them all |
|
1603 | - || ! $table->is_global()//not main site,but not global either. nuke it |
|
1604 | - ) |
|
1605 | - ) { |
|
1606 | - $tables[] = $table->get_table_name(); |
|
1607 | - } |
|
1608 | - } |
|
1609 | - } |
|
1610 | - } |
|
1611 | - } |
|
1612 | - |
|
1613 | - //there are some tables whose models were removed. |
|
1614 | - //they should be removed when removing all EE core's data |
|
1615 | - $tables_without_models = array( |
|
1616 | - 'esp_promotion', |
|
1617 | - 'esp_promotion_applied', |
|
1618 | - 'esp_promotion_object', |
|
1619 | - 'esp_promotion_rule', |
|
1620 | - 'esp_rule', |
|
1621 | - ); |
|
1622 | - foreach ($tables_without_models as $table) { |
|
1623 | - $tables[] = $table; |
|
1624 | - } |
|
1625 | - return \EEH_Activation::getTableManager()->dropTables($tables); |
|
1626 | - } |
|
1627 | - |
|
1628 | - |
|
1629 | - |
|
1630 | - /** |
|
1631 | - * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
1632 | - * each table name provided has a wpdb prefix attached, and that it exists. |
|
1633 | - * Returns the list actually deleted |
|
1634 | - * |
|
1635 | - * @deprecated in 4.9.13. Instead use TableManager::dropTables() |
|
1636 | - * @global WPDB $wpdb |
|
1637 | - * @param array $table_names |
|
1638 | - * @return array of table names which we deleted |
|
1639 | - */ |
|
1640 | - public static function drop_tables($table_names) |
|
1641 | - { |
|
1642 | - return \EEH_Activation::getTableManager()->dropTables($table_names); |
|
1643 | - } |
|
1644 | - |
|
1645 | - |
|
1646 | - |
|
1647 | - /** |
|
1648 | - * plugin_uninstall |
|
1649 | - * |
|
1650 | - * @access public |
|
1651 | - * @static |
|
1652 | - * @param bool $remove_all |
|
1653 | - * @return void |
|
1654 | - */ |
|
1655 | - public static function delete_all_espresso_tables_and_data($remove_all = true) |
|
1656 | - { |
|
1657 | - global $wpdb; |
|
1658 | - self::drop_espresso_tables(); |
|
1659 | - $wp_options_to_delete = array( |
|
1660 | - 'ee_no_ticket_prices' => true, |
|
1661 | - 'ee_active_messengers' => true, |
|
1662 | - 'ee_has_activated_messenger' => true, |
|
1663 | - 'ee_flush_rewrite_rules' => true, |
|
1664 | - 'ee_config' => false, |
|
1665 | - 'ee_data_migration_current_db_state' => true, |
|
1666 | - 'ee_data_migration_mapping_' => false, |
|
1667 | - 'ee_data_migration_script_' => false, |
|
1668 | - 'ee_data_migrations' => true, |
|
1669 | - 'ee_dms_map' => false, |
|
1670 | - 'ee_notices' => true, |
|
1671 | - 'lang_file_check_' => false, |
|
1672 | - 'ee_maintenance_mode' => true, |
|
1673 | - 'ee_ueip_optin' => true, |
|
1674 | - 'ee_ueip_has_notified' => true, |
|
1675 | - 'ee_plugin_activation_errors' => true, |
|
1676 | - 'ee_id_mapping_from' => false, |
|
1677 | - 'espresso_persistent_admin_notices' => true, |
|
1678 | - 'ee_encryption_key' => true, |
|
1679 | - 'pue_force_upgrade_' => false, |
|
1680 | - 'pue_json_error_' => false, |
|
1681 | - 'pue_install_key_' => false, |
|
1682 | - 'pue_verification_error_' => false, |
|
1683 | - 'pu_dismissed_upgrade_' => false, |
|
1684 | - 'external_updates-' => false, |
|
1685 | - 'ee_extra_data' => true, |
|
1686 | - 'ee_ssn_' => false, |
|
1687 | - 'ee_rss_' => false, |
|
1688 | - 'ee_rte_n_tx_' => false, |
|
1689 | - 'ee_pers_admin_notices' => true, |
|
1690 | - 'ee_job_parameters_' => false, |
|
1691 | - 'ee_upload_directories_incomplete' => true, |
|
1692 | - 'ee_verified_db_collations' => true, |
|
1693 | - ); |
|
1694 | - if (is_main_site()) { |
|
1695 | - $wp_options_to_delete['ee_network_config'] = true; |
|
1696 | - } |
|
1697 | - $undeleted_options = array(); |
|
1698 | - foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1699 | - if ($no_wildcard) { |
|
1700 | - if ( ! delete_option($option_name)) { |
|
1701 | - $undeleted_options[] = $option_name; |
|
1702 | - } |
|
1703 | - } else { |
|
1704 | - $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1705 | - foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1706 | - if ( ! delete_option($option_name_from_wildcard)) { |
|
1707 | - $undeleted_options[] = $option_name_from_wildcard; |
|
1708 | - } |
|
1709 | - } |
|
1710 | - } |
|
1711 | - } |
|
1712 | - //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1713 | - remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1714 | - if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1715 | - $db_update_sans_ee4 = array(); |
|
1716 | - foreach ($espresso_db_update as $version => $times_activated) { |
|
1717 | - if ((string)$version[0] === '3') {//if its NON EE4 |
|
1718 | - $db_update_sans_ee4[$version] = $times_activated; |
|
1719 | - } |
|
1720 | - } |
|
1721 | - update_option('espresso_db_update', $db_update_sans_ee4); |
|
1722 | - } |
|
1723 | - $errors = ''; |
|
1724 | - if ( ! empty($undeleted_options)) { |
|
1725 | - $errors .= sprintf( |
|
1726 | - __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1727 | - '<br/>', |
|
1728 | - implode(',<br/>', $undeleted_options) |
|
1729 | - ); |
|
1730 | - } |
|
1731 | - if ( ! empty($errors)) { |
|
1732 | - EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1733 | - } |
|
1734 | - } |
|
1735 | - |
|
1736 | - /** |
|
1737 | - * Gets the mysql error code from the last used query by wpdb |
|
1738 | - * |
|
1739 | - * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html |
|
1740 | - */ |
|
1741 | - public static function last_wpdb_error_code() |
|
1742 | - { |
|
1743 | - global $wpdb; |
|
1744 | - if ($wpdb->use_mysqli) { |
|
1745 | - return mysqli_errno($wpdb->dbh); |
|
1746 | - } else { |
|
1747 | - return mysql_errno($wpdb->dbh); |
|
1748 | - } |
|
1749 | - } |
|
1750 | - |
|
1751 | - /** |
|
1752 | - * Checks that the database table exists. Also works on temporary tables (for unit tests mostly). |
|
1753 | - * |
|
1754 | - * @global wpdb $wpdb |
|
1755 | - * @deprecated instead use TableAnalysis::tableExists() |
|
1756 | - * @param string $table_name with or without $wpdb->prefix |
|
1757 | - * @return boolean |
|
1758 | - */ |
|
1759 | - public static function table_exists($table_name) |
|
1760 | - { |
|
1761 | - return \EEH_Activation::getTableAnalysis()->tableExists($table_name); |
|
1762 | - } |
|
1763 | - |
|
1764 | - /** |
|
1765 | - * Resets the cache on EEH_Activation |
|
1766 | - */ |
|
1767 | - public static function reset() |
|
1768 | - { |
|
1769 | - self::$_default_creator_id = null; |
|
1770 | - self::$_initialized_db_content_already_in_this_request = false; |
|
1771 | - } |
|
1341 | + $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates( |
|
1342 | + $message_resource_manager |
|
1343 | + ); |
|
1344 | + /** |
|
1345 | + * This method is verifying there are no NEW default message types |
|
1346 | + * for ACTIVE messengers that need activated (and corresponding templates setup). |
|
1347 | + */ |
|
1348 | + $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1349 | + $message_resource_manager |
|
1350 | + ); |
|
1351 | + //after all is done, let's persist these changes to the db. |
|
1352 | + $message_resource_manager->update_has_activated_messengers_option(); |
|
1353 | + $message_resource_manager->update_active_messengers_option(); |
|
1354 | + // will return true if either of these are true. Otherwise will return false. |
|
1355 | + return $new_templates_created_for_message_type || $new_templates_created_for_messenger; |
|
1356 | + } |
|
1357 | + |
|
1358 | + |
|
1359 | + |
|
1360 | + /** |
|
1361 | + * @param \EE_Message_Resource_Manager $message_resource_manager |
|
1362 | + * @return array|bool |
|
1363 | + * @throws \EE_Error |
|
1364 | + */ |
|
1365 | + protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1366 | + EE_Message_Resource_Manager $message_resource_manager |
|
1367 | + ) { |
|
1368 | + /** @type EE_messenger[] $active_messengers */ |
|
1369 | + $active_messengers = $message_resource_manager->active_messengers(); |
|
1370 | + $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1371 | + $templates_created = false; |
|
1372 | + foreach ($active_messengers as $active_messenger) { |
|
1373 | + $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
|
1374 | + $default_message_type_names_to_activate = array(); |
|
1375 | + // looping through each default message type reported by the messenger |
|
1376 | + // and setup the actual message types to activate. |
|
1377 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1378 | + // if already active or has already been activated before we skip |
|
1379 | + // (otherwise we might reactivate something user's intentionally deactivated.) |
|
1380 | + // we also skip if the message type is not installed. |
|
1381 | + if ( |
|
1382 | + $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1383 | + $default_message_type_name_for_messenger, |
|
1384 | + $active_messenger->name |
|
1385 | + ) |
|
1386 | + || $message_resource_manager->is_message_type_active_for_messenger( |
|
1387 | + $active_messenger->name, |
|
1388 | + $default_message_type_name_for_messenger |
|
1389 | + ) |
|
1390 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1391 | + ) { |
|
1392 | + continue; |
|
1393 | + } |
|
1394 | + $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger; |
|
1395 | + } |
|
1396 | + //let's activate! |
|
1397 | + $message_resource_manager->ensure_message_types_are_active( |
|
1398 | + $default_message_type_names_to_activate, |
|
1399 | + $active_messenger->name, |
|
1400 | + false |
|
1401 | + ); |
|
1402 | + //activate the templates for these message types |
|
1403 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
1404 | + $templates_created = EEH_MSG_Template::generate_new_templates( |
|
1405 | + $active_messenger->name, |
|
1406 | + $default_message_type_names_for_messenger, |
|
1407 | + '', |
|
1408 | + true |
|
1409 | + ); |
|
1410 | + } |
|
1411 | + } |
|
1412 | + return $templates_created; |
|
1413 | + } |
|
1414 | + |
|
1415 | + |
|
1416 | + |
|
1417 | + /** |
|
1418 | + * This will activate and generate default messengers and default message types for those messengers. |
|
1419 | + * |
|
1420 | + * @param EE_message_Resource_Manager $message_resource_manager |
|
1421 | + * @return array|bool True means there were default messengers and message type templates generated. |
|
1422 | + * False means that there were no templates generated |
|
1423 | + * (which could simply mean there are no default message types for a messenger). |
|
1424 | + * @throws EE_Error |
|
1425 | + */ |
|
1426 | + protected static function _activate_and_generate_default_messengers_and_message_templates( |
|
1427 | + EE_Message_Resource_Manager $message_resource_manager |
|
1428 | + ) { |
|
1429 | + /** @type EE_messenger[] $messengers_to_generate */ |
|
1430 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1431 | + $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1432 | + $templates_generated = false; |
|
1433 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1434 | + $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
|
1435 | + //verify the default message types match an installed message type. |
|
1436 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1437 | + if ( |
|
1438 | + ! isset($installed_message_types[$name]) |
|
1439 | + || $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1440 | + $name, |
|
1441 | + $messenger_to_generate->name |
|
1442 | + ) |
|
1443 | + ) { |
|
1444 | + unset($default_message_type_names_for_messenger[$key]); |
|
1445 | + } |
|
1446 | + } |
|
1447 | + // in previous iterations, the active_messengers option in the db |
|
1448 | + // needed updated before calling create templates. however with the changes this may not be necessary. |
|
1449 | + // This comment is left here just in case we discover that we _do_ need to update before |
|
1450 | + // passing off to create templates (after the refactor is done). |
|
1451 | + // @todo remove this comment when determined not necessary. |
|
1452 | + $message_resource_manager->activate_messenger( |
|
1453 | + $messenger_to_generate->name, |
|
1454 | + $default_message_type_names_for_messenger, |
|
1455 | + false |
|
1456 | + ); |
|
1457 | + //create any templates needing created (or will reactivate templates already generated as necessary). |
|
1458 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
1459 | + $templates_generated = EEH_MSG_Template::generate_new_templates( |
|
1460 | + $messenger_to_generate->name, |
|
1461 | + $default_message_type_names_for_messenger, |
|
1462 | + '', |
|
1463 | + true |
|
1464 | + ); |
|
1465 | + } |
|
1466 | + } |
|
1467 | + return $templates_generated; |
|
1468 | + } |
|
1469 | + |
|
1470 | + |
|
1471 | + /** |
|
1472 | + * This returns the default messengers to generate templates for on activation of EE. |
|
1473 | + * It considers: |
|
1474 | + * - whether a messenger is already active in the db. |
|
1475 | + * - whether a messenger has been made active at any time in the past. |
|
1476 | + * |
|
1477 | + * @static |
|
1478 | + * @param EE_Message_Resource_Manager $message_resource_manager |
|
1479 | + * @return EE_messenger[] |
|
1480 | + */ |
|
1481 | + protected static function _get_default_messengers_to_generate_on_activation( |
|
1482 | + EE_Message_Resource_Manager $message_resource_manager |
|
1483 | + ) { |
|
1484 | + $active_messengers = $message_resource_manager->active_messengers(); |
|
1485 | + $installed_messengers = $message_resource_manager->installed_messengers(); |
|
1486 | + $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
|
1487 | + |
|
1488 | + $messengers_to_generate = array(); |
|
1489 | + foreach ($installed_messengers as $installed_messenger) { |
|
1490 | + //if installed messenger is a messenger that should be activated on install |
|
1491 | + //and is not already active |
|
1492 | + //and has never been activated |
|
1493 | + if ( |
|
1494 | + ! $installed_messenger->activate_on_install |
|
1495 | + || isset($active_messengers[$installed_messenger->name]) |
|
1496 | + || isset($has_activated[$installed_messenger->name]) |
|
1497 | + ) { |
|
1498 | + continue; |
|
1499 | + } |
|
1500 | + $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1501 | + } |
|
1502 | + return $messengers_to_generate; |
|
1503 | + } |
|
1504 | + |
|
1505 | + |
|
1506 | + /** |
|
1507 | + * This simply validates active message types to ensure they actually match installed |
|
1508 | + * message types. If there's a mismatch then we deactivate the message type and ensure all related db |
|
1509 | + * rows are set inactive. |
|
1510 | + * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever |
|
1511 | + * EE_Messenger_Resource_Manager is constructed. Message Types are a bit more resource heavy for validation so they |
|
1512 | + * are still handled in here. |
|
1513 | + * |
|
1514 | + * @since 4.3.1 |
|
1515 | + * @return void |
|
1516 | + */ |
|
1517 | + public static function validate_messages_system() |
|
1518 | + { |
|
1519 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1520 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1521 | + $message_resource_manager->validate_active_message_types_are_installed(); |
|
1522 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1523 | + } |
|
1524 | + |
|
1525 | + |
|
1526 | + /** |
|
1527 | + * create_no_ticket_prices_array |
|
1528 | + * |
|
1529 | + * @access public |
|
1530 | + * @static |
|
1531 | + * @return void |
|
1532 | + */ |
|
1533 | + public static function create_no_ticket_prices_array() |
|
1534 | + { |
|
1535 | + // this creates an array for tracking events that have no active ticket prices created |
|
1536 | + // this allows us to warn admins of the situation so that it can be corrected |
|
1537 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false); |
|
1538 | + if (! $espresso_no_ticket_prices) { |
|
1539 | + add_option('ee_no_ticket_prices', array(), '', false); |
|
1540 | + } |
|
1541 | + } |
|
1542 | + |
|
1543 | + |
|
1544 | + /** |
|
1545 | + * plugin_deactivation |
|
1546 | + * |
|
1547 | + * @access public |
|
1548 | + * @static |
|
1549 | + * @return void |
|
1550 | + */ |
|
1551 | + public static function plugin_deactivation() |
|
1552 | + { |
|
1553 | + } |
|
1554 | + |
|
1555 | + |
|
1556 | + /** |
|
1557 | + * Finds all our EE4 custom post types, and deletes them and their associated data |
|
1558 | + * (like post meta or term relations) |
|
1559 | + * |
|
1560 | + * @global wpdb $wpdb |
|
1561 | + * @throws \EE_Error |
|
1562 | + */ |
|
1563 | + public static function delete_all_espresso_cpt_data() |
|
1564 | + { |
|
1565 | + global $wpdb; |
|
1566 | + //get all the CPT post_types |
|
1567 | + $ee_post_types = array(); |
|
1568 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1569 | + if (method_exists($model_name, 'instance')) { |
|
1570 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1571 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1572 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1573 | + } |
|
1574 | + } |
|
1575 | + } |
|
1576 | + //get all our CPTs |
|
1577 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")"; |
|
1578 | + $cpt_ids = $wpdb->get_col($query); |
|
1579 | + //delete each post meta and term relations too |
|
1580 | + foreach ($cpt_ids as $post_id) { |
|
1581 | + wp_delete_post($post_id, true); |
|
1582 | + } |
|
1583 | + } |
|
1584 | + |
|
1585 | + /** |
|
1586 | + * Deletes all EE custom tables |
|
1587 | + * |
|
1588 | + * @return array |
|
1589 | + */ |
|
1590 | + public static function drop_espresso_tables() |
|
1591 | + { |
|
1592 | + $tables = array(); |
|
1593 | + // load registry |
|
1594 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1595 | + if (method_exists($model_name, 'instance')) { |
|
1596 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1597 | + if ($model_obj instanceof EEM_Base) { |
|
1598 | + foreach ($model_obj->get_tables() as $table) { |
|
1599 | + if (strpos($table->get_table_name(), 'esp_') |
|
1600 | + && |
|
1601 | + ( |
|
1602 | + is_main_site()//main site? nuke them all |
|
1603 | + || ! $table->is_global()//not main site,but not global either. nuke it |
|
1604 | + ) |
|
1605 | + ) { |
|
1606 | + $tables[] = $table->get_table_name(); |
|
1607 | + } |
|
1608 | + } |
|
1609 | + } |
|
1610 | + } |
|
1611 | + } |
|
1612 | + |
|
1613 | + //there are some tables whose models were removed. |
|
1614 | + //they should be removed when removing all EE core's data |
|
1615 | + $tables_without_models = array( |
|
1616 | + 'esp_promotion', |
|
1617 | + 'esp_promotion_applied', |
|
1618 | + 'esp_promotion_object', |
|
1619 | + 'esp_promotion_rule', |
|
1620 | + 'esp_rule', |
|
1621 | + ); |
|
1622 | + foreach ($tables_without_models as $table) { |
|
1623 | + $tables[] = $table; |
|
1624 | + } |
|
1625 | + return \EEH_Activation::getTableManager()->dropTables($tables); |
|
1626 | + } |
|
1627 | + |
|
1628 | + |
|
1629 | + |
|
1630 | + /** |
|
1631 | + * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
1632 | + * each table name provided has a wpdb prefix attached, and that it exists. |
|
1633 | + * Returns the list actually deleted |
|
1634 | + * |
|
1635 | + * @deprecated in 4.9.13. Instead use TableManager::dropTables() |
|
1636 | + * @global WPDB $wpdb |
|
1637 | + * @param array $table_names |
|
1638 | + * @return array of table names which we deleted |
|
1639 | + */ |
|
1640 | + public static function drop_tables($table_names) |
|
1641 | + { |
|
1642 | + return \EEH_Activation::getTableManager()->dropTables($table_names); |
|
1643 | + } |
|
1644 | + |
|
1645 | + |
|
1646 | + |
|
1647 | + /** |
|
1648 | + * plugin_uninstall |
|
1649 | + * |
|
1650 | + * @access public |
|
1651 | + * @static |
|
1652 | + * @param bool $remove_all |
|
1653 | + * @return void |
|
1654 | + */ |
|
1655 | + public static function delete_all_espresso_tables_and_data($remove_all = true) |
|
1656 | + { |
|
1657 | + global $wpdb; |
|
1658 | + self::drop_espresso_tables(); |
|
1659 | + $wp_options_to_delete = array( |
|
1660 | + 'ee_no_ticket_prices' => true, |
|
1661 | + 'ee_active_messengers' => true, |
|
1662 | + 'ee_has_activated_messenger' => true, |
|
1663 | + 'ee_flush_rewrite_rules' => true, |
|
1664 | + 'ee_config' => false, |
|
1665 | + 'ee_data_migration_current_db_state' => true, |
|
1666 | + 'ee_data_migration_mapping_' => false, |
|
1667 | + 'ee_data_migration_script_' => false, |
|
1668 | + 'ee_data_migrations' => true, |
|
1669 | + 'ee_dms_map' => false, |
|
1670 | + 'ee_notices' => true, |
|
1671 | + 'lang_file_check_' => false, |
|
1672 | + 'ee_maintenance_mode' => true, |
|
1673 | + 'ee_ueip_optin' => true, |
|
1674 | + 'ee_ueip_has_notified' => true, |
|
1675 | + 'ee_plugin_activation_errors' => true, |
|
1676 | + 'ee_id_mapping_from' => false, |
|
1677 | + 'espresso_persistent_admin_notices' => true, |
|
1678 | + 'ee_encryption_key' => true, |
|
1679 | + 'pue_force_upgrade_' => false, |
|
1680 | + 'pue_json_error_' => false, |
|
1681 | + 'pue_install_key_' => false, |
|
1682 | + 'pue_verification_error_' => false, |
|
1683 | + 'pu_dismissed_upgrade_' => false, |
|
1684 | + 'external_updates-' => false, |
|
1685 | + 'ee_extra_data' => true, |
|
1686 | + 'ee_ssn_' => false, |
|
1687 | + 'ee_rss_' => false, |
|
1688 | + 'ee_rte_n_tx_' => false, |
|
1689 | + 'ee_pers_admin_notices' => true, |
|
1690 | + 'ee_job_parameters_' => false, |
|
1691 | + 'ee_upload_directories_incomplete' => true, |
|
1692 | + 'ee_verified_db_collations' => true, |
|
1693 | + ); |
|
1694 | + if (is_main_site()) { |
|
1695 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1696 | + } |
|
1697 | + $undeleted_options = array(); |
|
1698 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1699 | + if ($no_wildcard) { |
|
1700 | + if ( ! delete_option($option_name)) { |
|
1701 | + $undeleted_options[] = $option_name; |
|
1702 | + } |
|
1703 | + } else { |
|
1704 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1705 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1706 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1707 | + $undeleted_options[] = $option_name_from_wildcard; |
|
1708 | + } |
|
1709 | + } |
|
1710 | + } |
|
1711 | + } |
|
1712 | + //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1713 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1714 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1715 | + $db_update_sans_ee4 = array(); |
|
1716 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1717 | + if ((string)$version[0] === '3') {//if its NON EE4 |
|
1718 | + $db_update_sans_ee4[$version] = $times_activated; |
|
1719 | + } |
|
1720 | + } |
|
1721 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1722 | + } |
|
1723 | + $errors = ''; |
|
1724 | + if ( ! empty($undeleted_options)) { |
|
1725 | + $errors .= sprintf( |
|
1726 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1727 | + '<br/>', |
|
1728 | + implode(',<br/>', $undeleted_options) |
|
1729 | + ); |
|
1730 | + } |
|
1731 | + if ( ! empty($errors)) { |
|
1732 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1733 | + } |
|
1734 | + } |
|
1735 | + |
|
1736 | + /** |
|
1737 | + * Gets the mysql error code from the last used query by wpdb |
|
1738 | + * |
|
1739 | + * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html |
|
1740 | + */ |
|
1741 | + public static function last_wpdb_error_code() |
|
1742 | + { |
|
1743 | + global $wpdb; |
|
1744 | + if ($wpdb->use_mysqli) { |
|
1745 | + return mysqli_errno($wpdb->dbh); |
|
1746 | + } else { |
|
1747 | + return mysql_errno($wpdb->dbh); |
|
1748 | + } |
|
1749 | + } |
|
1750 | + |
|
1751 | + /** |
|
1752 | + * Checks that the database table exists. Also works on temporary tables (for unit tests mostly). |
|
1753 | + * |
|
1754 | + * @global wpdb $wpdb |
|
1755 | + * @deprecated instead use TableAnalysis::tableExists() |
|
1756 | + * @param string $table_name with or without $wpdb->prefix |
|
1757 | + * @return boolean |
|
1758 | + */ |
|
1759 | + public static function table_exists($table_name) |
|
1760 | + { |
|
1761 | + return \EEH_Activation::getTableAnalysis()->tableExists($table_name); |
|
1762 | + } |
|
1763 | + |
|
1764 | + /** |
|
1765 | + * Resets the cache on EEH_Activation |
|
1766 | + */ |
|
1767 | + public static function reset() |
|
1768 | + { |
|
1769 | + self::$_default_creator_id = null; |
|
1770 | + self::$_initialized_db_content_already_in_this_request = false; |
|
1771 | + } |
|
1772 | 1772 | } |
1773 | 1773 | // End of file EEH_Activation.helper.php |
1774 | 1774 | // Location: /helpers/EEH_Activation.core.php |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public static function getTableAnalysis() |
63 | 63 | { |
64 | - if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
64 | + if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
65 | 65 | self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
66 | 66 | } |
67 | 67 | return self::$table_analysis; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public static function getTableManager() |
75 | 75 | { |
76 | - if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
76 | + if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
77 | 77 | self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
78 | 78 | } |
79 | 79 | return self::$table_manager; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | if ($which_to_include === 'old') { |
190 | 190 | $cron_tasks = array_filter( |
191 | 191 | $cron_tasks, |
192 | - function ($value) { |
|
192 | + function($value) { |
|
193 | 193 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
194 | 194 | } |
195 | 195 | ); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | { |
220 | 220 | |
221 | 221 | foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
222 | - if (! wp_next_scheduled($hook_name)) { |
|
222 | + if ( ! wp_next_scheduled($hook_name)) { |
|
223 | 223 | wp_schedule_event(time(), $frequency, $hook_name); |
224 | 224 | } |
225 | 225 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | 3 |
313 | 313 | ); |
314 | 314 | //EE_Config::reset(); |
315 | - if (! EE_Config::logging_enabled()) { |
|
315 | + if ( ! EE_Config::logging_enabled()) { |
|
316 | 316 | delete_option(EE_Config::LOG_NAME); |
317 | 317 | } |
318 | 318 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | public static function load_calendar_config() |
328 | 328 | { |
329 | 329 | // grab array of all plugin folders and loop thru it |
330 | - $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR); |
|
330 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
331 | 331 | if (empty($plugins)) { |
332 | 332 | return; |
333 | 333 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | || strpos($plugin, 'calendar') !== false |
345 | 345 | ) { |
346 | 346 | // this is what we are looking for |
347 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
347 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
348 | 348 | // does it exist in this folder ? |
349 | 349 | if (is_readable($calendar_config)) { |
350 | 350 | // YEAH! let's load it |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | ) { |
478 | 478 | //update Config with post ID |
479 | 479 | $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
480 | - if (! EE_Config::instance()->update_espresso_config(false, false)) { |
|
480 | + if ( ! EE_Config::instance()->update_espresso_config(false, false)) { |
|
481 | 481 | $msg = __( |
482 | 482 | 'The Event Espresso critical page configuration settings could not be updated.', |
483 | 483 | 'event_espresso' |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | public static function get_page_by_ee_shortcode($ee_shortcode) |
527 | 527 | { |
528 | 528 | global $wpdb; |
529 | - $shortcode_and_opening_bracket = '[' . $ee_shortcode; |
|
529 | + $shortcode_and_opening_bracket = '['.$ee_shortcode; |
|
530 | 530 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
531 | 531 | if ($post_id) { |
532 | 532 | return get_post($post_id); |
@@ -552,11 +552,11 @@ discard block |
||
552 | 552 | 'post_status' => 'publish', |
553 | 553 | 'post_type' => 'page', |
554 | 554 | 'comment_status' => 'closed', |
555 | - 'post_content' => '[' . $critical_page['code'] . ']', |
|
555 | + 'post_content' => '['.$critical_page['code'].']', |
|
556 | 556 | ); |
557 | 557 | |
558 | 558 | $post_id = wp_insert_post($post_args); |
559 | - if (! $post_id) { |
|
559 | + if ( ! $post_id) { |
|
560 | 560 | $msg = sprintf( |
561 | 561 | __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
562 | 562 | $critical_page['name'] |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | return $critical_page; |
566 | 566 | } |
567 | 567 | // get newly created post's details |
568 | - if (! $critical_page['post'] = get_post($post_id)) { |
|
568 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
569 | 569 | $msg = sprintf( |
570 | 570 | __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
571 | 571 | $critical_page['name'] |
@@ -652,17 +652,17 @@ discard block |
||
652 | 652 | $role_to_check |
653 | 653 | ); |
654 | 654 | if ($pre_filtered_id !== false) { |
655 | - return (int)$pre_filtered_id; |
|
655 | + return (int) $pre_filtered_id; |
|
656 | 656 | } |
657 | 657 | $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities'); |
658 | 658 | $query = $wpdb->prepare( |
659 | 659 | "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", |
660 | - '%' . $role_to_check . '%' |
|
660 | + '%'.$role_to_check.'%' |
|
661 | 661 | ); |
662 | 662 | $user_id = $wpdb->get_var($query); |
663 | 663 | $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
664 | - if ($user_id && (int)$user_id) { |
|
665 | - self::$_default_creator_id = (int)$user_id; |
|
664 | + if ($user_id && (int) $user_id) { |
|
665 | + self::$_default_creator_id = (int) $user_id; |
|
666 | 666 | return self::$_default_creator_id; |
667 | 667 | } else { |
668 | 668 | return null; |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | } |
698 | 698 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
699 | 699 | if ( ! function_exists('dbDelta')) { |
700 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
700 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
701 | 701 | } |
702 | 702 | $tableAnalysis = \EEH_Activation::getTableAnalysis(); |
703 | 703 | $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name); |
@@ -908,13 +908,13 @@ discard block |
||
908 | 908 | // reset values array |
909 | 909 | $QSG_values = array(); |
910 | 910 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
911 | - if (! in_array("$QSG_system", $question_groups)) { |
|
911 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
912 | 912 | // add it |
913 | 913 | switch ($QSG_system) { |
914 | 914 | case 1: |
915 | 915 | $QSG_values = array( |
916 | 916 | 'QSG_name' => __('Personal Information', 'event_espresso'), |
917 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
917 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
918 | 918 | 'QSG_desc' => '', |
919 | 919 | 'QSG_order' => 1, |
920 | 920 | 'QSG_show_group_name' => 1, |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | case 2: |
927 | 927 | $QSG_values = array( |
928 | 928 | 'QSG_name' => __('Address Information', 'event_espresso'), |
929 | - 'QSG_identifier' => 'address-information-' . time(), |
|
929 | + 'QSG_identifier' => 'address-information-'.time(), |
|
930 | 930 | 'QSG_desc' => '', |
931 | 931 | 'QSG_order' => 2, |
932 | 932 | 'QSG_show_group_name' => 1, |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | break; |
938 | 938 | } |
939 | 939 | // make sure we have some values before inserting them |
940 | - if (! empty($QSG_values)) { |
|
940 | + if ( ! empty($QSG_values)) { |
|
941 | 941 | // insert system question |
942 | 942 | $wpdb->insert( |
943 | 943 | $table_name, |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | // reset values array |
975 | 975 | $QST_values = array(); |
976 | 976 | // if we don't have what we should have |
977 | - if (! in_array($QST_system, $questions)) { |
|
977 | + if ( ! in_array($QST_system, $questions)) { |
|
978 | 978 | // add it |
979 | 979 | switch ($QST_system) { |
980 | 980 | case 'fname': |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | ); |
1127 | 1127 | break; |
1128 | 1128 | } |
1129 | - if (! empty($QST_values)) { |
|
1129 | + if ( ! empty($QST_values)) { |
|
1130 | 1130 | // insert system question |
1131 | 1131 | $wpdb->insert( |
1132 | 1132 | $table_name, |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | */ |
1188 | 1188 | public static function insert_default_payment_methods() |
1189 | 1189 | { |
1190 | - if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1190 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1191 | 1191 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
1192 | 1192 | EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
1193 | 1193 | } else { |
@@ -1275,9 +1275,9 @@ discard block |
||
1275 | 1275 | $folders = array( |
1276 | 1276 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1277 | 1277 | EVENT_ESPRESSO_GATEWAY_DIR, |
1278 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1279 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1280 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/', |
|
1278 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1279 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1280 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/', |
|
1281 | 1281 | ); |
1282 | 1282 | foreach ($folders as $folder) { |
1283 | 1283 | try { |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | sprintf( |
1289 | 1289 | __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
1290 | 1290 | $folder, |
1291 | - '<br />' . $e->getMessage() |
|
1291 | + '<br />'.$e->getMessage() |
|
1292 | 1292 | ), |
1293 | 1293 | __FILE__, __FUNCTION__, __LINE__ |
1294 | 1294 | ); |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | } |
1300 | 1300 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1301 | 1301 | //is disabled, there might be activation errors recorded in there |
1302 | - EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/'); |
|
1302 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1303 | 1303 | //remember EE's folders are all good |
1304 | 1304 | delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
1305 | 1305 | return true; |
@@ -1535,7 +1535,7 @@ discard block |
||
1535 | 1535 | // this creates an array for tracking events that have no active ticket prices created |
1536 | 1536 | // this allows us to warn admins of the situation so that it can be corrected |
1537 | 1537 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false); |
1538 | - if (! $espresso_no_ticket_prices) { |
|
1538 | + if ( ! $espresso_no_ticket_prices) { |
|
1539 | 1539 | add_option('ee_no_ticket_prices', array(), '', false); |
1540 | 1540 | } |
1541 | 1541 | } |
@@ -1574,7 +1574,7 @@ discard block |
||
1574 | 1574 | } |
1575 | 1575 | } |
1576 | 1576 | //get all our CPTs |
1577 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")"; |
|
1577 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1578 | 1578 | $cpt_ids = $wpdb->get_col($query); |
1579 | 1579 | //delete each post meta and term relations too |
1580 | 1580 | foreach ($cpt_ids as $post_id) { |
@@ -1714,7 +1714,7 @@ discard block |
||
1714 | 1714 | if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
1715 | 1715 | $db_update_sans_ee4 = array(); |
1716 | 1716 | foreach ($espresso_db_update as $version => $times_activated) { |
1717 | - if ((string)$version[0] === '3') {//if its NON EE4 |
|
1717 | + if ((string) $version[0] === '3') {//if its NON EE4 |
|
1718 | 1718 | $db_update_sans_ee4[$version] = $times_activated; |
1719 | 1719 | } |
1720 | 1720 | } |
@@ -1,3 +1,3 @@ |
||
1 | 1 | <h2><?php esc_html_e('What is the Event Espresso Messages System?', 'event_espresso'); ?></h2> |
2 | -<p><?php printf( esc_html__('The Event Espresso Messages system is a powerful framework that Event Espresso uses to prepare %1$smessages%2$s for different types of use (message types) and delivered by different %1$smessengers%2$s.', 'event_espresso'), '<strong>', '</strong>' ); ?></p> |
|
2 | +<p><?php printf(esc_html__('The Event Espresso Messages system is a powerful framework that Event Espresso uses to prepare %1$smessages%2$s for different types of use (message types) and delivered by different %1$smessengers%2$s.', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
3 | 3 | <p><?php esc_html_e('We\'ve intentionally created this framework so that we have as much flexibility as possible for future ideas that we think of (or customers think of) for the kinds of messages that get sent out related to your events.', 'event_espresso'); ?></p> |
4 | 4 | \ No newline at end of file |
@@ -31,35 +31,35 @@ discard block |
||
31 | 31 | <tbody> |
32 | 32 | <tr> |
33 | 33 | <td> |
34 | - <h2><?php printf( esc_html__( 'Hello, %s:', 'event_espresso' ), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]' ); ?></h2> |
|
35 | - <p class="lead"><?php printf( esc_html__( 'Your payment was %1$sCANCELLED%2$s for the following transaction and ticket purchases:', 'event_espresso' ), '<strong>', '</strong>'); ?></p> |
|
36 | - <h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3> |
|
34 | + <h2><?php printf(esc_html__('Hello, %s:', 'event_espresso'), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]'); ?></h2> |
|
35 | + <p class="lead"><?php printf(esc_html__('Your payment was %1$sCANCELLED%2$s for the following transaction and ticket purchases:', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
36 | + <h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3> |
|
37 | 37 | <ul> |
38 | 38 | <li> |
39 | - <strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS] |
|
39 | + <strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS] |
|
40 | 40 | </li> |
41 | 41 | <li> |
42 | - <strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> [TXN_ID] |
|
42 | + <strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> [TXN_ID] |
|
43 | 43 | </li> |
44 | 44 | <li> |
45 | - <strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST] |
|
45 | + <strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST] |
|
46 | 46 | </li> |
47 | 47 | <li> |
48 | - <strong><?php esc_html_e( 'Payment Method:', 'event_espresso' ); ?></strong> [PAYMENT_GATEWAY] |
|
48 | + <strong><?php esc_html_e('Payment Method:', 'event_espresso'); ?></strong> [PAYMENT_GATEWAY] |
|
49 | 49 | </li> |
50 | 50 | <li> |
51 | - <strong><?php esc_html_e( 'Payment Amount:', 'event_espresso' ); ?></strong> [AMOUNT_PAID] |
|
51 | + <strong><?php esc_html_e('Payment Amount:', 'event_espresso'); ?></strong> [AMOUNT_PAID] |
|
52 | 52 | </li> |
53 | 53 | <li> |
54 | - <strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING] |
|
54 | + <strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING] |
|
55 | 55 | </li> |
56 | 56 | </ul> |
57 | 57 | <p class="callout"> |
58 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
58 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
59 | 59 | </p> |
60 | 60 | [EVENT_LIST] |
61 | 61 | <p class="callout"> |
62 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
62 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
63 | 63 | </p> |
64 | 64 | </td> |
65 | 65 | </tr> |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | <tbody> |
85 | 85 | <tr> |
86 | 86 | <td> |
87 | - <h3><?php esc_html_e( 'Connect with Us:', 'event_espresso' ); ?></h3> |
|
88 | - <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e( 'Facebook', 'event_espresso' ); ?></a> |
|
89 | - <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e( 'Twitter', 'event_espresso' ); ?></a> |
|
90 | - <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e( 'Google+', 'event_espresso' ); ?></a> |
|
87 | + <h3><?php esc_html_e('Connect with Us:', 'event_espresso'); ?></h3> |
|
88 | + <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e('Facebook', 'event_espresso'); ?></a> |
|
89 | + <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e('Twitter', 'event_espresso'); ?></a> |
|
90 | + <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e('Google+', 'event_espresso'); ?></a> |
|
91 | 91 | </td> |
92 | 92 | </tr> |
93 | 93 | </tbody> |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | <tbody> |
98 | 98 | <tr> |
99 | 99 | <td> |
100 | - <h3><?php esc_html_e( 'Contact Info:', 'event_espresso' ); ?></h3> |
|
101 | - <?php esc_html_e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong> |
|
102 | - <?php esc_html_e( 'Email:', 'event_espresso' ); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
|
100 | + <h3><?php esc_html_e('Contact Info:', 'event_espresso'); ?></h3> |
|
101 | + <?php esc_html_e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong> |
|
102 | + <?php esc_html_e('Email:', 'event_espresso'); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
|
103 | 103 | </td> |
104 | 104 | </tr> |
105 | 105 | </tbody> |
@@ -31,35 +31,35 @@ discard block |
||
31 | 31 | <tbody> |
32 | 32 | <tr> |
33 | 33 | <td> |
34 | - <h2><?php printf( esc_html__( 'Hello, %s:', 'event_espresso' ), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]' ); ?></h2> |
|
35 | - <p class="lead"><?php printf( esc_html__( 'Your payment was %1$sDECLINED%2$s for the following transaction and ticket purchases:', 'event_espresso' ), '<strong>', '</strong>') ?></p> |
|
36 | - <h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3> |
|
34 | + <h2><?php printf(esc_html__('Hello, %s:', 'event_espresso'), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]'); ?></h2> |
|
35 | + <p class="lead"><?php printf(esc_html__('Your payment was %1$sDECLINED%2$s for the following transaction and ticket purchases:', 'event_espresso'), '<strong>', '</strong>') ?></p> |
|
36 | + <h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3> |
|
37 | 37 | <ul> |
38 | 38 | <li> |
39 | - <strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS] |
|
39 | + <strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS] |
|
40 | 40 | </li> |
41 | 41 | <li> |
42 | - <strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> [TXN_ID] |
|
42 | + <strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> [TXN_ID] |
|
43 | 43 | </li> |
44 | 44 | <li> |
45 | - <strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST] |
|
45 | + <strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST] |
|
46 | 46 | </li> |
47 | 47 | <li> |
48 | - <strong><?php esc_html_e( 'Payment Method:', 'event_espresso' ); ?></strong> [PAYMENT_GATEWAY] |
|
48 | + <strong><?php esc_html_e('Payment Method:', 'event_espresso'); ?></strong> [PAYMENT_GATEWAY] |
|
49 | 49 | </li> |
50 | 50 | <li> |
51 | - <strong><?php esc_html_e( 'Payment Amount:', 'event_espresso' ); ?></strong> [AMOUNT_PAID] |
|
51 | + <strong><?php esc_html_e('Payment Amount:', 'event_espresso'); ?></strong> [AMOUNT_PAID] |
|
52 | 52 | </li> |
53 | 53 | <li> |
54 | - <strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING] |
|
54 | + <strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING] |
|
55 | 55 | </li> |
56 | 56 | </ul> |
57 | 57 | <p class="callout"> |
58 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
58 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
59 | 59 | </p> |
60 | 60 | [EVENT_LIST] |
61 | 61 | <p class="callout"> |
62 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
62 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
63 | 63 | </p> |
64 | 64 | </td> |
65 | 65 | </tr> |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | <tbody> |
85 | 85 | <tr> |
86 | 86 | <td> |
87 | - <h3><?php esc_html_e( 'Connect with Us:', 'event_espresso' ); ?></h3> |
|
88 | - <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e( 'Facebook', 'event_espresso' ); ?></a> |
|
89 | - <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e( 'Twitter', 'event_espresso' ); ?></a> |
|
90 | - <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e( 'Google+', 'event_espresso' ); ?></a> |
|
87 | + <h3><?php esc_html_e('Connect with Us:', 'event_espresso'); ?></h3> |
|
88 | + <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e('Facebook', 'event_espresso'); ?></a> |
|
89 | + <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e('Twitter', 'event_espresso'); ?></a> |
|
90 | + <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e('Google+', 'event_espresso'); ?></a> |
|
91 | 91 | </td> |
92 | 92 | </tr> |
93 | 93 | </tbody> |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | <tbody> |
98 | 98 | <tr> |
99 | 99 | <td> |
100 | - <h3><?php esc_html_e( 'Contact Info:', 'event_espresso' ); ?></h3> |
|
101 | - <?php esc_html_e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong> |
|
102 | - <?php esc_html_e( 'Email:', 'event_espresso' ); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
|
100 | + <h3><?php esc_html_e('Contact Info:', 'event_espresso'); ?></h3> |
|
101 | + <?php esc_html_e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong> |
|
102 | + <?php esc_html_e('Email:', 'event_espresso'); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
|
103 | 103 | </td> |
104 | 104 | </tr> |
105 | 105 | </tbody> |
@@ -402,21 +402,21 @@ |
||
402 | 402 | $class_name = $this->_get_classname_for_admin_init_page( $page ); |
403 | 403 | EE_Registry::instance()->load_file( $path, $class_name, 'core' ); |
404 | 404 | if ( ! class_exists( $class_name )) { |
405 | - $inner_error_msg = '<br />' . sprintf( |
|
406 | - esc_html__( |
|
407 | - 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
408 | - 'event_espresso' |
|
409 | - ), |
|
410 | - '<strong>' . $class_name . '</strong>' |
|
411 | - ); |
|
405 | + $inner_error_msg = '<br />' . sprintf( |
|
406 | + esc_html__( |
|
407 | + 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
408 | + 'event_espresso' |
|
409 | + ), |
|
410 | + '<strong>' . $class_name . '</strong>' |
|
411 | + ); |
|
412 | 412 | $error_msg[] = sprintf( __('Something went wrong with loading the %s admin page.', 'event_espresso' ), $page); |
413 | 413 | $error_msg[] = $error_msg[0] |
414 | - . "\r\n" |
|
415 | - . sprintf( |
|
416 | - esc_html__( 'There is no Init class in place for the %s admin page.', 'event_espresso'), |
|
417 | - $page |
|
418 | - ) |
|
419 | - . $inner_error_msg; |
|
414 | + . "\r\n" |
|
415 | + . sprintf( |
|
416 | + esc_html__( 'There is no Init class in place for the %s admin page.', 'event_espresso'), |
|
417 | + $page |
|
418 | + ) |
|
419 | + . $inner_error_msg; |
|
420 | 420 | throw new EE_Error( implode( '||', $error_msg )); |
421 | 421 | } |
422 | 422 | $a = new ReflectionClass($class_name); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | //let's do a scan and see what installed pages we have |
120 | 120 | $this->_get_installed_pages(); |
121 | 121 | //set menus (has to be done on every load - we're not actually loading the page just setting the menus and where they point to). |
122 | - add_action('admin_menu', array( $this, 'set_menus' )); |
|
123 | - add_action( 'network_admin_menu', array( $this, 'set_network_menus' ) ); |
|
122 | + add_action('admin_menu', array($this, 'set_menus')); |
|
123 | + add_action('network_admin_menu', array($this, 'set_network_menus')); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | * @return void |
134 | 134 | */ |
135 | 135 | private function _define_caffeinated_constants() { |
136 | - if ( ! defined( 'EE_CORE_CAF_ADMIN' ) ) { |
|
137 | - define( 'EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/'); |
|
138 | - define( 'EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/'); |
|
139 | - define( 'EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/'); |
|
140 | - define( 'EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/'); |
|
141 | - define( 'EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/'); |
|
142 | - define( 'EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/'); |
|
136 | + if ( ! defined('EE_CORE_CAF_ADMIN')) { |
|
137 | + define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH.'caffeinated/admin/'); |
|
138 | + define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL.'caffeinated/admin/'); |
|
139 | + define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN.'new/'); |
|
140 | + define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN.'extend/'); |
|
141 | + define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL.'extend/'); |
|
142 | + define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN.'hooks/'); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | //set array of EE_Admin_Page_Menu_Group objects |
160 | 160 | $groups = array( |
161 | - 'main' => new EE_Admin_Page_Menu_Group( array( |
|
161 | + 'main' => new EE_Admin_Page_Menu_Group(array( |
|
162 | 162 | 'menu_label' => __('Main', 'event_espresso'), |
163 | 163 | 'show_on_menu' => EE_Admin_Page_Menu_Map::NONE, |
164 | 164 | 'menu_slug' => 'main', |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | 'menu_order' => 0, |
167 | 167 | 'parent_slug' => 'espresso_events', |
168 | 168 | )), |
169 | - 'management' => new EE_Admin_Page_Menu_Group( array( |
|
169 | + 'management' => new EE_Admin_Page_Menu_Group(array( |
|
170 | 170 | 'menu_label' => __('Management', 'event_espresso'), |
171 | 171 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
172 | 172 | 'menu_slug' => 'management', |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | 'menu_order' => 10, |
175 | 175 | 'parent_slug' => 'espresso_events' |
176 | 176 | )), |
177 | - 'settings' => new EE_Admin_Page_Menu_Group( array( |
|
177 | + 'settings' => new EE_Admin_Page_Menu_Group(array( |
|
178 | 178 | 'menu_label' => __('Settings', 'event_espresso'), |
179 | 179 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
180 | 180 | 'menu_slug' => 'settings', |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 'menu_order' => 30, |
183 | 183 | 'parent_slug' => 'espresso_events' |
184 | 184 | )), |
185 | - 'templates' => new EE_Admin_Page_Menu_Group( array( |
|
185 | + 'templates' => new EE_Admin_Page_Menu_Group(array( |
|
186 | 186 | 'menu_label' => __('Templates', 'event_espresso'), |
187 | 187 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
188 | 188 | 'menu_slug' => 'templates', |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | 'menu_order' => 40, |
191 | 191 | 'parent_slug' => 'espresso_events' |
192 | 192 | )), |
193 | - 'extras' => new EE_Admin_Page_Menu_Group( array( |
|
193 | + 'extras' => new EE_Admin_Page_Menu_Group(array( |
|
194 | 194 | 'menu_label' => __('Extras', 'event_espresso'), |
195 | 195 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN, |
196 | 196 | 'menu_slug' => 'extras', |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | 'parent_slug' => 'espresso_events', |
200 | 200 | 'maintenance_mode_parent' => 'espresso_maintenance_settings' |
201 | 201 | )), |
202 | - 'tools' => new EE_Admin_Page_Menu_Group( array( |
|
202 | + 'tools' => new EE_Admin_Page_Menu_Group(array( |
|
203 | 203 | 'menu_label' => __("Tools", "event_espresso"), |
204 | 204 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
205 | 205 | 'menu_slug' => 'tools', |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | 'menu_order' => 60, |
208 | 208 | 'parent_slug' => 'espresso_events' |
209 | 209 | )), |
210 | - 'addons' => new EE_Admin_Page_Menu_Group( array( |
|
210 | + 'addons' => new EE_Admin_Page_Menu_Group(array( |
|
211 | 211 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN, |
212 | 212 | 'menu_label' => __('Add-ons', 'event_espresso'), |
213 | 213 | 'menu_slug' => 'addons', |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | )) |
218 | 218 | ); |
219 | 219 | |
220 | - $this->_admin_menu_groups = apply_filters( 'FHEE__EE_Admin_Page_Loader___set_menu_groups__admin_menu_groups', $groups ); |
|
220 | + $this->_admin_menu_groups = apply_filters('FHEE__EE_Admin_Page_Loader___set_menu_groups__admin_menu_groups', $groups); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | private function _rearrange_menu_groups() { |
236 | 236 | $groups = array(); |
237 | 237 | //first let's order the menu groups by their internal menu order (note usort type hinting to ensure the incoming array is EE_Admin_Page_Menu_Map objects ) |
238 | - usort( $this->_admin_menu_groups, array( $this, '_sort_menu_maps' ) ); |
|
239 | - foreach ( $this->_admin_menu_groups as $group ) { |
|
240 | - if ( ! $group instanceof EE_Admin_Page_Menu_Group ) |
|
241 | - throw new EE_Error( sprintf( __('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups. All values in this array are required to be a EE_Admin_Page_Menu_Group object. Instead there was: %s', 'event_espresso'), print_r($group, TRUE) ) ); |
|
238 | + usort($this->_admin_menu_groups, array($this, '_sort_menu_maps')); |
|
239 | + foreach ($this->_admin_menu_groups as $group) { |
|
240 | + if ( ! $group instanceof EE_Admin_Page_Menu_Group) |
|
241 | + throw new EE_Error(sprintf(__('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups. All values in this array are required to be a EE_Admin_Page_Menu_Group object. Instead there was: %s', 'event_espresso'), print_r($group, TRUE))); |
|
242 | 242 | $groups[$group->menu_slug] = $group; |
243 | 243 | } |
244 | 244 | return $groups; |
@@ -256,48 +256,48 @@ discard block |
||
256 | 256 | */ |
257 | 257 | private function _get_installed_pages() { |
258 | 258 | $installed_refs = array(); |
259 | - $exclude = array( 'assets', 'templates' ); |
|
259 | + $exclude = array('assets', 'templates'); |
|
260 | 260 | // grab everything in the admin core directory |
261 | - $admin_screens = glob( EE_ADMIN_PAGES . '*', GLOB_ONLYDIR ); |
|
262 | - if ( $admin_screens ) { |
|
263 | - foreach( $admin_screens as $admin_screen ) { |
|
261 | + $admin_screens = glob(EE_ADMIN_PAGES.'*', GLOB_ONLYDIR); |
|
262 | + if ($admin_screens) { |
|
263 | + foreach ($admin_screens as $admin_screen) { |
|
264 | 264 | // files and anything in the exclude array need not apply |
265 | - if ( is_dir( $admin_screen ) && ! in_array( basename( $admin_screen ), $exclude )) { |
|
265 | + if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) { |
|
266 | 266 | // these folders represent the different EE admin pages |
267 | - $installed_refs[ basename( $admin_screen ) ] = $admin_screen; |
|
267 | + $installed_refs[basename($admin_screen)] = $admin_screen; |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
272 | - if ( empty( $installed_refs ) ) { |
|
272 | + if (empty($installed_refs)) { |
|
273 | 273 | $error_msg[] = __('There are no EE_Admin pages detected, it looks like EE did not install properly', 'event_espresso'); |
274 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf( __('Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.', 'event_espresso'), EE_ADMIN_PAGES ); |
|
275 | - throw new EE_Error( implode( '||', $error_msg )); |
|
274 | + $error_msg[] = $error_msg[0]."\r\n".sprintf(__('Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.', 'event_espresso'), EE_ADMIN_PAGES); |
|
275 | + throw new EE_Error(implode('||', $error_msg)); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | //this just checks the caffeinated folder and takes care of setting up any caffeinated stuff. |
279 | 279 | $installed_refs = $this->_set_caffeinated($installed_refs); |
280 | 280 | //allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.; |
281 | - $installed_refs = apply_filters( 'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', $installed_refs ); |
|
282 | - $this->_caffeinated_extends = apply_filters( 'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends', $this->_caffeinated_extends ); |
|
281 | + $installed_refs = apply_filters('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', $installed_refs); |
|
282 | + $this->_caffeinated_extends = apply_filters('FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends', $this->_caffeinated_extends); |
|
283 | 283 | |
284 | 284 | //loop through admin pages and setup the $_installed_pages array. |
285 | 285 | $hooks_ref = array(); |
286 | - foreach ( $installed_refs as $page => $path ) { |
|
286 | + foreach ($installed_refs as $page => $path) { |
|
287 | 287 | // set autoloaders for our admin page classes based on included path information |
288 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $path ); |
|
288 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($path); |
|
289 | 289 | // build list of installed pages |
290 | - $this->_installed_pages[$page] = $this->_load_admin_page( $page, $path ); |
|
290 | + $this->_installed_pages[$page] = $this->_load_admin_page($page, $path); |
|
291 | 291 | // verify returned object |
292 | - if ( $this->_installed_pages[$page] instanceof EE_Admin_Page_Init ) { |
|
293 | - if ( ! $this->_installed_pages[$page]->get_menu_map() instanceof EE_Admin_Page_Menu_Map ) { |
|
292 | + if ($this->_installed_pages[$page] instanceof EE_Admin_Page_Init) { |
|
293 | + if ( ! $this->_installed_pages[$page]->get_menu_map() instanceof EE_Admin_Page_Menu_Map) { |
|
294 | 294 | continue; |
295 | 295 | } |
296 | 296 | |
297 | 297 | //skip if in full maintenance mode and maintenance_mode_parent is set |
298 | 298 | $maintenance_mode_parent = $this->_installed_pages[$page]->get_menu_map()->maintenance_mode_parent; |
299 | - if ( empty( $maintenance_mode_parent ) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
300 | - unset( $installed_refs[$page] ); |
|
299 | + if (empty($maintenance_mode_parent) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
300 | + unset($installed_refs[$page]); |
|
301 | 301 | continue; |
302 | 302 | } |
303 | 303 | |
@@ -305,45 +305,45 @@ discard block |
||
305 | 305 | //flag for register hooks on extended pages b/c extended pages use the default INIT. |
306 | 306 | $extend = FALSE; |
307 | 307 | //now that we've got the admin_init objects... lets see if there are any caffeinated pages extending the originals. If there are then let's hook into the init admin filter and load our extend instead. |
308 | - if ( isset( $this->_caffeinated_extends[$page] ) ) { |
|
308 | + if (isset($this->_caffeinated_extends[$page])) { |
|
309 | 309 | $this->_current_caf_extend_slug = $page; |
310 | - $path_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__' . $this->_installed_pages[$page]->get_menu_map()->menu_slug . '_' . $this->_installed_pages[$page]->get_admin_page_name(); |
|
311 | - $path_runtime = 'return "' . $this->_caffeinated_extends[$this->_current_caf_extend_slug]["path"] . '";'; |
|
312 | - $page_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__' . $this->_installed_pages[$page]->get_menu_map()->menu_slug . '_' . $this->_installed_pages[$page]->get_admin_page_name(); |
|
313 | - $page_runtime = 'return "' . $this->_caffeinated_extends[$this->_current_caf_extend_slug]["admin_page"] . '";'; |
|
310 | + $path_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__'.$this->_installed_pages[$page]->get_menu_map()->menu_slug.'_'.$this->_installed_pages[$page]->get_admin_page_name(); |
|
311 | + $path_runtime = 'return "'.$this->_caffeinated_extends[$this->_current_caf_extend_slug]["path"].'";'; |
|
312 | + $page_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__'.$this->_installed_pages[$page]->get_menu_map()->menu_slug.'_'.$this->_installed_pages[$page]->get_admin_page_name(); |
|
313 | + $page_runtime = 'return "'.$this->_caffeinated_extends[$this->_current_caf_extend_slug]["admin_page"].'";'; |
|
314 | 314 | |
315 | - $hook_function_path = create_function( '$path_to_file', $path_runtime); |
|
316 | - $hook_function_page = create_function( '$admin_page', $page_runtime ); |
|
315 | + $hook_function_path = create_function('$path_to_file', $path_runtime); |
|
316 | + $hook_function_page = create_function('$admin_page', $page_runtime); |
|
317 | 317 | |
318 | - add_filter( $path_hook, $hook_function_path ); |
|
319 | - add_filter( $page_hook, $hook_function_page ); |
|
318 | + add_filter($path_hook, $hook_function_path); |
|
319 | + add_filter($page_hook, $hook_function_page); |
|
320 | 320 | $extend = TRUE; |
321 | 321 | } |
322 | 322 | //let's do the registered hooks |
323 | - $extended_hooks = $this->_installed_pages[$page]->register_hooks( $extend ); |
|
323 | + $extended_hooks = $this->_installed_pages[$page]->register_hooks($extend); |
|
324 | 324 | $hooks_ref = array_merge($hooks_ref, $extended_hooks); |
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
328 | 328 | //the hooks_ref is all the pages where we have $extended _Hooks files that will extend a class in a different folder. So we want to make sure we load the file for the parent. |
329 | 329 | //first make sure we've got unique values |
330 | - $hooks_ref = array_unique( $hooks_ref ); |
|
330 | + $hooks_ref = array_unique($hooks_ref); |
|
331 | 331 | //now let's loop and require! |
332 | - foreach ( $hooks_ref as $path ) { |
|
333 | - require_once( $path ); |
|
332 | + foreach ($hooks_ref as $path) { |
|
333 | + require_once($path); |
|
334 | 334 | } |
335 | 335 | //make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested. |
336 | 336 | global $ee_menu_slugs; |
337 | 337 | $ee_menu_slugs = $this->_menu_slugs; |
338 | 338 | |
339 | 339 | //we need to loop again to run any early code |
340 | - foreach ( $installed_refs as $page => $path ) { |
|
341 | - if ( $this->_installed_pages[$page] instanceof EE_Admin_Page_Init ) { |
|
340 | + foreach ($installed_refs as $page => $path) { |
|
341 | + if ($this->_installed_pages[$page] instanceof EE_Admin_Page_Init) { |
|
342 | 342 | $this->_installed_pages[$page]->do_initial_loads(); |
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | - do_action( 'AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages ); |
|
346 | + do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 | |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | * @param string $page_slug |
356 | 356 | * @return EE_Admin_Page |
357 | 357 | */ |
358 | - public function get_admin_page_object( $page_slug = '' ) { |
|
359 | - if ( isset( $this->_installed_pages[ $page_slug ] )) { |
|
360 | - return $this->_installed_pages[ $page_slug ]->loaded_page_object(); |
|
358 | + public function get_admin_page_object($page_slug = '') { |
|
359 | + if (isset($this->_installed_pages[$page_slug])) { |
|
360 | + return $this->_installed_pages[$page_slug]->loaded_page_object(); |
|
361 | 361 | } |
362 | 362 | return NULL; |
363 | 363 | } |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | * @param $dir_name |
371 | 371 | * @return string |
372 | 372 | */ |
373 | - private function _get_classname_for_admin_page( $dir_name = '' ) { |
|
374 | - $class_name = str_replace( '_', ' ', strtolower( $dir_name )); |
|
375 | - return str_replace( ' ', '_', ucwords( $class_name )) . '_Admin_Page'; |
|
373 | + private function _get_classname_for_admin_page($dir_name = '') { |
|
374 | + $class_name = str_replace('_', ' ', strtolower($dir_name)); |
|
375 | + return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page'; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -383,9 +383,9 @@ discard block |
||
383 | 383 | * @param $dir_name |
384 | 384 | * @return string |
385 | 385 | */ |
386 | - private function _get_classname_for_admin_init_page( $dir_name = '' ) { |
|
387 | - $class_name = str_replace( '_', ' ', strtolower( $dir_name )); |
|
388 | - return str_replace( ' ', '_', ucwords( $class_name )) . '_Admin_Page_Init'; |
|
386 | + private function _get_classname_for_admin_init_page($dir_name = '') { |
|
387 | + $class_name = str_replace('_', ' ', strtolower($dir_name)); |
|
388 | + return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page_Init'; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | |
@@ -398,26 +398,26 @@ discard block |
||
398 | 398 | * @throws EE_Error |
399 | 399 | * @return object|bool return page object if valid, bool false if not. |
400 | 400 | */ |
401 | - private function _load_admin_page( $page = '', $path = '' ) { |
|
402 | - $class_name = $this->_get_classname_for_admin_init_page( $page ); |
|
403 | - EE_Registry::instance()->load_file( $path, $class_name, 'core' ); |
|
404 | - if ( ! class_exists( $class_name )) { |
|
405 | - $inner_error_msg = '<br />' . sprintf( |
|
401 | + private function _load_admin_page($page = '', $path = '') { |
|
402 | + $class_name = $this->_get_classname_for_admin_init_page($page); |
|
403 | + EE_Registry::instance()->load_file($path, $class_name, 'core'); |
|
404 | + if ( ! class_exists($class_name)) { |
|
405 | + $inner_error_msg = '<br />'.sprintf( |
|
406 | 406 | esc_html__( |
407 | 407 | 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
408 | 408 | 'event_espresso' |
409 | 409 | ), |
410 | - '<strong>' . $class_name . '</strong>' |
|
410 | + '<strong>'.$class_name.'</strong>' |
|
411 | 411 | ); |
412 | - $error_msg[] = sprintf( __('Something went wrong with loading the %s admin page.', 'event_espresso' ), $page); |
|
412 | + $error_msg[] = sprintf(__('Something went wrong with loading the %s admin page.', 'event_espresso'), $page); |
|
413 | 413 | $error_msg[] = $error_msg[0] |
414 | 414 | . "\r\n" |
415 | 415 | . sprintf( |
416 | - esc_html__( 'There is no Init class in place for the %s admin page.', 'event_espresso'), |
|
416 | + esc_html__('There is no Init class in place for the %s admin page.', 'event_espresso'), |
|
417 | 417 | $page |
418 | 418 | ) |
419 | 419 | . $inner_error_msg; |
420 | - throw new EE_Error( implode( '||', $error_msg )); |
|
420 | + throw new EE_Error(implode('||', $error_msg)); |
|
421 | 421 | } |
422 | 422 | $a = new ReflectionClass($class_name); |
423 | 423 | return $a->newInstance(); |
@@ -436,9 +436,9 @@ discard block |
||
436 | 436 | public function set_menus() { |
437 | 437 | //prep the menu pages (sort, group.) |
438 | 438 | $this->_prep_pages(); |
439 | - foreach( $this->_prepped_menu_maps as $menu_map ) { |
|
440 | - if ( EE_Registry::instance()->CAP->current_user_can( $menu_map->capability, $menu_map->menu_slug ) ) { |
|
441 | - $menu_map->add_menu_page( FALSE ); |
|
439 | + foreach ($this->_prepped_menu_maps as $menu_map) { |
|
440 | + if (EE_Registry::instance()->CAP->current_user_can($menu_map->capability, $menu_map->menu_slug)) { |
|
441 | + $menu_map->add_menu_page(FALSE); |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | } |
@@ -451,11 +451,11 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return void |
453 | 453 | */ |
454 | - public function set_network_menus(){ |
|
454 | + public function set_network_menus() { |
|
455 | 455 | $this->_prep_pages(); |
456 | - foreach( $this->_prepped_menu_maps as $menu_map ) { |
|
457 | - if ( EE_Registry::instance()->CAP->current_user_can( $menu_map->capability, $menu_map->menu_slug ) ) { |
|
458 | - $menu_map->add_menu_page( TRUE ); |
|
456 | + foreach ($this->_prepped_menu_maps as $menu_map) { |
|
457 | + if (EE_Registry::instance()->CAP->current_user_can($menu_map->capability, $menu_map->menu_slug)) { |
|
458 | + $menu_map->add_menu_page(TRUE); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
@@ -476,22 +476,22 @@ discard block |
||
476 | 476 | //rearrange _admin_menu_groups to be indexed by group slug. |
477 | 477 | $menu_groups = $this->_rearrange_menu_groups(); |
478 | 478 | |
479 | - foreach( $this->_installed_pages as $page ) { |
|
480 | - if ( $page instanceof EE_Admin_page_Init ) { |
|
479 | + foreach ($this->_installed_pages as $page) { |
|
480 | + if ($page instanceof EE_Admin_page_Init) { |
|
481 | 481 | $page_map = $page->get_menu_map(); |
482 | 482 | //if we've got an array then the menu map is in the old format so let's throw a persistent notice that the admin system isn't setup correctly for this item. |
483 | - if ( is_array( $page_map ) || empty( $page_map ) ) { |
|
484 | - EE_Error::add_persistent_admin_notice( 'menu_map_warning_' . str_replace(' ', '_', $page->label) . '_' . EVENT_ESPRESSO_VERSION, sprintf( __('The admin page for %s was not correctly setup because it is using an older method for integrating with Event Espresso Core. This means that full functionality for this component is not available. This error message usually appears with an Add-on that is out of date. Make sure you update all your Event Espresso 4 add-ons to the latest version to ensure they have necessary compatibility updates in place.', 'event_espresso' ), $page->label ) ); |
|
483 | + if (is_array($page_map) || empty($page_map)) { |
|
484 | + EE_Error::add_persistent_admin_notice('menu_map_warning_'.str_replace(' ', '_', $page->label).'_'.EVENT_ESPRESSO_VERSION, sprintf(__('The admin page for %s was not correctly setup because it is using an older method for integrating with Event Espresso Core. This means that full functionality for this component is not available. This error message usually appears with an Add-on that is out of date. Make sure you update all your Event Espresso 4 add-ons to the latest version to ensure they have necessary compatibility updates in place.', 'event_espresso'), $page->label)); |
|
485 | 485 | continue; |
486 | 486 | } |
487 | 487 | |
488 | 488 | //if page map is NOT a EE_Admin_Page_Menu_Map object then throw error. |
489 | - if ( ! $page_map instanceof EE_Admin_Page_Menu_Map ) { |
|
490 | - throw new EE_Error( sprintf( __('The menu map for %s must be an EE_Admin_Page_Menu_Map object. Instead it is %s. Please double check that the menu map has been configured correctly.', 'event_espresso'), $page->label, $page_map ) ); |
|
489 | + if ( ! $page_map instanceof EE_Admin_Page_Menu_Map) { |
|
490 | + throw new EE_Error(sprintf(__('The menu map for %s must be an EE_Admin_Page_Menu_Map object. Instead it is %s. Please double check that the menu map has been configured correctly.', 'event_espresso'), $page->label, $page_map)); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | //use the maintenance_mode_parent property and maintenance mode status to determine if this page even gets added to array. |
494 | - if ( empty( $page_map->maintenance_mode_parent ) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
494 | + if (empty($page_map->maintenance_mode_parent) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
495 | 495 | continue; |
496 | 496 | } |
497 | 497 | |
@@ -500,21 +500,21 @@ discard block |
||
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
503 | - if ( empty( $pages_array )) { |
|
504 | - throw new EE_Error(__('Something went wrong when prepping the admin pages', 'event_espresso') ); |
|
503 | + if (empty($pages_array)) { |
|
504 | + throw new EE_Error(__('Something went wrong when prepping the admin pages', 'event_espresso')); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | //let's sort the groups, make sure it's a valid group, add header (if to show). |
508 | - foreach ( $pages_array as $group => $menu_maps ) { |
|
508 | + foreach ($pages_array as $group => $menu_maps) { |
|
509 | 509 | //valid_group? |
510 | - if ( ! array_key_exists( $group, $menu_groups ) ) |
|
510 | + if ( ! array_key_exists($group, $menu_groups)) |
|
511 | 511 | continue; |
512 | 512 | |
513 | 513 | //sort pages. |
514 | - usort( $menu_maps, array( $this, '_sort_menu_maps' ) ); |
|
514 | + usort($menu_maps, array($this, '_sort_menu_maps')); |
|
515 | 515 | |
516 | 516 | //prepend header |
517 | - array_unshift( $menu_maps, $menu_groups[$group] ); |
|
517 | + array_unshift($menu_maps, $menu_groups[$group]); |
|
518 | 518 | |
519 | 519 | //reset $pages_array with prepped data |
520 | 520 | $pages_array[$group] = $menu_maps; |
@@ -522,9 +522,9 @@ discard block |
||
522 | 522 | |
523 | 523 | |
524 | 524 | //now let's setup the _prepped_menu_maps property |
525 | - foreach ( $menu_groups as $group => $group_objs ) { |
|
526 | - if ( isset( $pages_array[$group] ) ) |
|
527 | - $this->_prepped_menu_maps = array_merge( $this->_prepped_menu_maps, $pages_array[$group] ); |
|
525 | + foreach ($menu_groups as $group => $group_objs) { |
|
526 | + if (isset($pages_array[$group])) |
|
527 | + $this->_prepped_menu_maps = array_merge($this->_prepped_menu_maps, $pages_array[$group]); |
|
528 | 528 | }/**/ |
529 | 529 | |
530 | 530 | } |
@@ -544,10 +544,10 @@ discard block |
||
544 | 544 | * @param array $installed_refs the original installed_refs array that may contain our NEW EE_Admin_Pages to be loaded. |
545 | 545 | * @return array |
546 | 546 | */ |
547 | - private function _set_caffeinated( $installed_refs ) { |
|
547 | + private function _set_caffeinated($installed_refs) { |
|
548 | 548 | |
549 | 549 | //first let's check if there IS a caffeinated folder. If there is not then lets get out. |
550 | - if ( ! is_dir( EE_PLUGIN_DIR_PATH . 'caffeinated' . DS . 'admin' ) || ( defined( 'EE_DECAF' ) && EE_DECAF )) { |
|
550 | + if ( ! is_dir(EE_PLUGIN_DIR_PATH.'caffeinated'.DS.'admin') || (defined('EE_DECAF') && EE_DECAF)) { |
|
551 | 551 | return $installed_refs; |
552 | 552 | } |
553 | 553 | |
@@ -556,15 +556,15 @@ discard block |
||
556 | 556 | $exclude = array('tickets'); |
557 | 557 | |
558 | 558 | //okay let's setup an "New" pages first (we'll return installed refs later) |
559 | - $new_admin_screens = glob( EE_CORE_CAF_ADMIN . 'new/*', GLOB_ONLYDIR ); |
|
560 | - if ( $new_admin_screens ) { |
|
561 | - foreach( $new_admin_screens as $admin_screen ) { |
|
559 | + $new_admin_screens = glob(EE_CORE_CAF_ADMIN.'new/*', GLOB_ONLYDIR); |
|
560 | + if ($new_admin_screens) { |
|
561 | + foreach ($new_admin_screens as $admin_screen) { |
|
562 | 562 | // files and anything in the exclude array need not apply |
563 | - if ( is_dir( $admin_screen ) && ! in_array( basename( $admin_screen ), $exclude )) { |
|
563 | + if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) { |
|
564 | 564 | // these folders represent the different NEW EE admin pages |
565 | - $installed_refs[ basename( $admin_screen ) ] = $admin_screen; |
|
565 | + $installed_refs[basename($admin_screen)] = $admin_screen; |
|
566 | 566 | // set autoloaders for our admin page classes based on included path information |
567 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $admin_screen ); |
|
567 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($admin_screen); |
|
568 | 568 | // $this->_caf_autoloader[] = array( |
569 | 569 | // 'dir' => 'new', |
570 | 570 | // 'folder' => basename( $admin_screen ) |
@@ -574,18 +574,18 @@ discard block |
||
574 | 574 | } |
575 | 575 | |
576 | 576 | //let's see if there are any EXTENDS to setup in the $_caffeinated_extends array (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page) |
577 | - $extends = glob( EE_CORE_CAF_ADMIN . 'extend/*', GLOB_ONLYDIR ); |
|
578 | - if ( $extends ) { |
|
579 | - foreach( $extends as $extend ) { |
|
580 | - if ( is_dir( $extend ) ) { |
|
581 | - $extend_ref = basename( $extend ); |
|
577 | + $extends = glob(EE_CORE_CAF_ADMIN.'extend/*', GLOB_ONLYDIR); |
|
578 | + if ($extends) { |
|
579 | + foreach ($extends as $extend) { |
|
580 | + if (is_dir($extend)) { |
|
581 | + $extend_ref = basename($extend); |
|
582 | 582 | //now let's make sure there is a file that matches the expected format |
583 | - $filename = str_replace(' ', '_', ucwords( str_replace('_', ' ', $extend_ref ) ) ); |
|
584 | - $filename = 'Extend_' . $filename . '_Admin_Page'; |
|
585 | - $this->_caffeinated_extends[$extend_ref]['path'] = str_replace( array( '\\', '/' ), DS, EE_CORE_CAF_ADMIN . 'extend' . DS . $extend_ref . DS . $filename . '.core.php' ); |
|
583 | + $filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $extend_ref))); |
|
584 | + $filename = 'Extend_'.$filename.'_Admin_Page'; |
|
585 | + $this->_caffeinated_extends[$extend_ref]['path'] = str_replace(array('\\', '/'), DS, EE_CORE_CAF_ADMIN.'extend'.DS.$extend_ref.DS.$filename.'.core.php'); |
|
586 | 586 | $this->_caffeinated_extends[$extend_ref]['admin_page'] = $filename; |
587 | 587 | // set autoloaders for our admin page classes based on included path information |
588 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $extend ); |
|
588 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($extend); |
|
589 | 589 | // $this->_caf_autoloader[] = array( |
590 | 590 | // 'dir' => 'extend', |
591 | 591 | // 'folder' => $extend_ref |
@@ -596,22 +596,22 @@ discard block |
||
596 | 596 | |
597 | 597 | //let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!). |
598 | 598 | $ee_admin_hooks = array(); |
599 | - $hooks = glob( EE_CORE_CAF_ADMIN . 'hooks/*.class.php' ); |
|
600 | - if ( $hooks ) { |
|
601 | - foreach ( $hooks as $hook ) { |
|
602 | - if ( is_readable( $hook ) ) { |
|
599 | + $hooks = glob(EE_CORE_CAF_ADMIN.'hooks/*.class.php'); |
|
600 | + if ($hooks) { |
|
601 | + foreach ($hooks as $hook) { |
|
602 | + if (is_readable($hook)) { |
|
603 | 603 | require_once $hook; |
604 | - $classname = str_replace( EE_CORE_CAF_ADMIN . 'hooks/', '', $hook ); |
|
604 | + $classname = str_replace(EE_CORE_CAF_ADMIN.'hooks/', '', $hook); |
|
605 | 605 | $classname = str_replace('.class.php', '', $classname); |
606 | - if ( class_exists( $classname ) ) { |
|
607 | - $a = new ReflectionClass( $classname ); |
|
606 | + if (class_exists($classname)) { |
|
607 | + $a = new ReflectionClass($classname); |
|
608 | 608 | $ee_admin_hooks[] = $a->newInstance(); |
609 | 609 | } |
610 | 610 | } |
611 | 611 | } |
612 | 612 | }/**/ |
613 | 613 | |
614 | - $ee_admin_hooks = apply_filters( 'FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks ); |
|
614 | + $ee_admin_hooks = apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks); |
|
615 | 615 | |
616 | 616 | return $installed_refs; |
617 | 617 | |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | * @param EE_Admin_Page_Menu_Map $b being compared to |
667 | 667 | * @return int sort order |
668 | 668 | */ |
669 | - private function _sort_menu_maps( EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b ) { |
|
670 | - if ( $a->menu_order == $b->menu_order ) |
|
669 | + private function _sort_menu_maps(EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b) { |
|
670 | + if ($a->menu_order == $b->menu_order) |
|
671 | 671 | return 0; |
672 | 672 | return ($a->menu_order < $b->menu_order) ? -1 : 1; |
673 | 673 | } |