@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.79.rc.022'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.79.rc.022'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
@@ -18,226 +18,226 @@ |
||
18 | 18 | class EE_Registration_CheckIn_List_Table extends EE_Admin_List_Table |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * EE_Registration_CheckIn_List_Table constructor. |
|
23 | - * |
|
24 | - * @param EE_Admin_Page $admin_page |
|
25 | - */ |
|
26 | - public function __construct($admin_page) |
|
27 | - { |
|
28 | - parent::__construct($admin_page); |
|
29 | - } |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @throws EE_Error |
|
34 | - */ |
|
35 | - protected function _setup_data() |
|
36 | - { |
|
37 | - $this->_data = $this->_get_checkins($this->_per_page); |
|
38 | - $this->_all_data_count = $this->_get_checkins($this->_per_page, true); |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * Sets up the properties for the list table. |
|
44 | - */ |
|
45 | - protected function _set_properties() |
|
46 | - { |
|
47 | - $this->_wp_list_args = array( |
|
48 | - 'singular' => __('check-in', 'event_espresso'), |
|
49 | - 'plural' => __('check-ins', 'event_espresso'), |
|
50 | - 'ajax' => true, |
|
51 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
52 | - ); |
|
53 | - |
|
54 | - $this->_columns = array( |
|
55 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
56 | - 'CHK_in' => __('Check-In', 'event_espresso'), |
|
57 | - 'CHK_timestamp' => __('Timestamp', 'event_espresso'), |
|
58 | - ); |
|
59 | - |
|
60 | - $this->_sortable_columns = array( |
|
61 | - 'CHK_timestamp' => array('CHK_timestamp' => true), |
|
62 | - ); |
|
63 | - |
|
64 | - $this->_primary_column = 'CHK_in'; |
|
65 | - |
|
66 | - $this->_hidden_columns = array(); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * @return array |
|
72 | - */ |
|
73 | - protected function _get_table_filters() |
|
74 | - { |
|
75 | - return []; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * Returning an empty string to remove the search box for this view. |
|
81 | - * |
|
82 | - * @param string $text |
|
83 | - * @param string $input_id |
|
84 | - * @return string |
|
85 | - */ |
|
86 | - public function search_box($text, $input_id) |
|
87 | - { |
|
88 | - return ''; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @throws EE_Error |
|
94 | - */ |
|
95 | - protected function _add_view_counts() |
|
96 | - { |
|
97 | - $this->_views['all']['count'] = $this->_get_checkins(null, true); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * @param EE_Checkin $item |
|
103 | - * @return string |
|
104 | - * @throws EE_Error |
|
105 | - * @throws InvalidArgumentException |
|
106 | - * @throws ReflectionException |
|
107 | - * @throws InvalidDataTypeException |
|
108 | - * @throws InvalidInterfaceException |
|
109 | - */ |
|
110 | - public function column_cb($item) |
|
111 | - { |
|
112 | - return sprintf('<input type="checkbox" name="checkbox[%1$s]" />', $item->ID()); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @param EE_Checkin $item |
|
118 | - * @return string |
|
119 | - * @throws EE_Error |
|
120 | - * @throws InvalidArgumentException |
|
121 | - * @throws InvalidDataTypeException |
|
122 | - * @throws InvalidInterfaceException |
|
123 | - * @throws ReflectionException |
|
124 | - */ |
|
125 | - public function column_CHK_in(EE_Checkin $item) |
|
126 | - { |
|
127 | - $checkin_status_dashicon = CheckinStatusDashicon::fromCheckin($item); |
|
128 | - return '<span class="' |
|
129 | - . $checkin_status_dashicon->cssClasses() |
|
130 | - . '"></span><span class="show-on-mobile-view-only">' |
|
131 | - . $item->get_datetime('CHK_timestamp') |
|
132 | - . '</span>'; |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * @param EE_Checkin $item |
|
138 | - * @return string |
|
139 | - * @throws EE_Error |
|
140 | - * @throws InvalidArgumentException |
|
141 | - * @throws InvalidDataTypeException |
|
142 | - * @throws InvalidInterfaceException |
|
143 | - * @throws ReflectionException |
|
144 | - */ |
|
145 | - public function column_CHK_timestamp(EE_Checkin $item) |
|
146 | - { |
|
147 | - $actions = array(); |
|
148 | - $delete_url = EE_Admin_Page::add_query_args_and_nonce( |
|
149 | - array( |
|
150 | - 'action' => 'delete_checkin_row', |
|
151 | - 'DTT_ID' => $this->_req_data['DTT_ID'], |
|
152 | - '_REG_ID' => $this->_req_data['_REG_ID'], |
|
153 | - 'CHK_ID' => $item->ID(), |
|
154 | - ) |
|
155 | - ); |
|
156 | - $actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can( |
|
157 | - 'ee_delete_checkins', |
|
158 | - 'espresso_registrations_delete_checkin_row' |
|
159 | - ) |
|
160 | - ? '<a href="' . $delete_url . '" title="' |
|
161 | - . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">' |
|
162 | - . __('Delete', 'event_espresso') . '</a>' |
|
163 | - : ''; |
|
164 | - |
|
165 | - return sprintf( |
|
166 | - '%1$s %2$s', |
|
167 | - $item->get_datetime('CHK_timestamp', '', 'H:i:s a'), |
|
168 | - $this->row_actions($actions) |
|
169 | - ); |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * This retrieves all the Check-ins for the given parameters. |
|
175 | - * experimenting with having the query for the table values within the list table. |
|
176 | - * |
|
177 | - * @param int $per_page How many to retrieve per page |
|
178 | - * @param bool $count Whether to return a count or not |
|
179 | - * @return EE_Checkin[]|int |
|
180 | - * @throws EE_Error |
|
181 | - * @throws InvalidArgumentException |
|
182 | - * @throws InvalidDataTypeException |
|
183 | - * @throws InvalidInterfaceException |
|
184 | - */ |
|
185 | - protected function _get_checkins($per_page = 10, $count = false) |
|
186 | - { |
|
187 | - $REG_ID = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : false; |
|
188 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : false; |
|
189 | - |
|
190 | - // if user does not have the capability for the checkins for this registration then get out! |
|
191 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
192 | - 'ee_read_checkin', |
|
193 | - 'espresso_registrations_registration_checkins', |
|
194 | - $REG_ID |
|
195 | - )) { |
|
196 | - return $count ? 0 : array(); |
|
197 | - } |
|
198 | - |
|
199 | - // if no reg id then get out cause need a reg id |
|
200 | - if (empty($REG_ID) || empty($DTT_ID)) { |
|
201 | - throw new EE_Error( |
|
202 | - __( |
|
203 | - 'This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)', |
|
204 | - 'event_espresso' |
|
205 | - ) |
|
206 | - ); |
|
207 | - } |
|
208 | - |
|
209 | - // set orderby |
|
210 | - // note that with this table we're only providing the option to orderby the timestamp value. |
|
211 | - $orderby = 'CHK_timestamp'; |
|
212 | - |
|
213 | - $order = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
214 | - |
|
215 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
216 | - ? $this->_req_data['paged'] |
|
217 | - : 1; |
|
218 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
219 | - ? $this->_req_data['perpage'] |
|
220 | - : $per_page; |
|
221 | - $limit = null; |
|
222 | - if (! $count) { |
|
223 | - $offset = ($current_page - 1) * $per_page; |
|
224 | - $limit = array($offset, $per_page); |
|
225 | - } |
|
226 | - |
|
227 | - $_where = array( |
|
228 | - 'REG_ID' => $REG_ID, |
|
229 | - 'DTT_ID' => $DTT_ID, |
|
230 | - ); |
|
231 | - |
|
232 | - $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
233 | - |
|
234 | - // if no per_page value then we just want to return a count of all Check-ins |
|
235 | - if ($count) { |
|
236 | - return EEM_Checkin::instance()->count(array($_where)); |
|
237 | - } |
|
238 | - |
|
239 | - return $count |
|
240 | - ? EEM_Checkin::instance()->count(array($_where)) |
|
241 | - : EEM_Checkin::instance()->get_all($query_params); |
|
242 | - } |
|
21 | + /** |
|
22 | + * EE_Registration_CheckIn_List_Table constructor. |
|
23 | + * |
|
24 | + * @param EE_Admin_Page $admin_page |
|
25 | + */ |
|
26 | + public function __construct($admin_page) |
|
27 | + { |
|
28 | + parent::__construct($admin_page); |
|
29 | + } |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @throws EE_Error |
|
34 | + */ |
|
35 | + protected function _setup_data() |
|
36 | + { |
|
37 | + $this->_data = $this->_get_checkins($this->_per_page); |
|
38 | + $this->_all_data_count = $this->_get_checkins($this->_per_page, true); |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Sets up the properties for the list table. |
|
44 | + */ |
|
45 | + protected function _set_properties() |
|
46 | + { |
|
47 | + $this->_wp_list_args = array( |
|
48 | + 'singular' => __('check-in', 'event_espresso'), |
|
49 | + 'plural' => __('check-ins', 'event_espresso'), |
|
50 | + 'ajax' => true, |
|
51 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
52 | + ); |
|
53 | + |
|
54 | + $this->_columns = array( |
|
55 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
56 | + 'CHK_in' => __('Check-In', 'event_espresso'), |
|
57 | + 'CHK_timestamp' => __('Timestamp', 'event_espresso'), |
|
58 | + ); |
|
59 | + |
|
60 | + $this->_sortable_columns = array( |
|
61 | + 'CHK_timestamp' => array('CHK_timestamp' => true), |
|
62 | + ); |
|
63 | + |
|
64 | + $this->_primary_column = 'CHK_in'; |
|
65 | + |
|
66 | + $this->_hidden_columns = array(); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * @return array |
|
72 | + */ |
|
73 | + protected function _get_table_filters() |
|
74 | + { |
|
75 | + return []; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * Returning an empty string to remove the search box for this view. |
|
81 | + * |
|
82 | + * @param string $text |
|
83 | + * @param string $input_id |
|
84 | + * @return string |
|
85 | + */ |
|
86 | + public function search_box($text, $input_id) |
|
87 | + { |
|
88 | + return ''; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @throws EE_Error |
|
94 | + */ |
|
95 | + protected function _add_view_counts() |
|
96 | + { |
|
97 | + $this->_views['all']['count'] = $this->_get_checkins(null, true); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * @param EE_Checkin $item |
|
103 | + * @return string |
|
104 | + * @throws EE_Error |
|
105 | + * @throws InvalidArgumentException |
|
106 | + * @throws ReflectionException |
|
107 | + * @throws InvalidDataTypeException |
|
108 | + * @throws InvalidInterfaceException |
|
109 | + */ |
|
110 | + public function column_cb($item) |
|
111 | + { |
|
112 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" />', $item->ID()); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @param EE_Checkin $item |
|
118 | + * @return string |
|
119 | + * @throws EE_Error |
|
120 | + * @throws InvalidArgumentException |
|
121 | + * @throws InvalidDataTypeException |
|
122 | + * @throws InvalidInterfaceException |
|
123 | + * @throws ReflectionException |
|
124 | + */ |
|
125 | + public function column_CHK_in(EE_Checkin $item) |
|
126 | + { |
|
127 | + $checkin_status_dashicon = CheckinStatusDashicon::fromCheckin($item); |
|
128 | + return '<span class="' |
|
129 | + . $checkin_status_dashicon->cssClasses() |
|
130 | + . '"></span><span class="show-on-mobile-view-only">' |
|
131 | + . $item->get_datetime('CHK_timestamp') |
|
132 | + . '</span>'; |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * @param EE_Checkin $item |
|
138 | + * @return string |
|
139 | + * @throws EE_Error |
|
140 | + * @throws InvalidArgumentException |
|
141 | + * @throws InvalidDataTypeException |
|
142 | + * @throws InvalidInterfaceException |
|
143 | + * @throws ReflectionException |
|
144 | + */ |
|
145 | + public function column_CHK_timestamp(EE_Checkin $item) |
|
146 | + { |
|
147 | + $actions = array(); |
|
148 | + $delete_url = EE_Admin_Page::add_query_args_and_nonce( |
|
149 | + array( |
|
150 | + 'action' => 'delete_checkin_row', |
|
151 | + 'DTT_ID' => $this->_req_data['DTT_ID'], |
|
152 | + '_REG_ID' => $this->_req_data['_REG_ID'], |
|
153 | + 'CHK_ID' => $item->ID(), |
|
154 | + ) |
|
155 | + ); |
|
156 | + $actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can( |
|
157 | + 'ee_delete_checkins', |
|
158 | + 'espresso_registrations_delete_checkin_row' |
|
159 | + ) |
|
160 | + ? '<a href="' . $delete_url . '" title="' |
|
161 | + . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">' |
|
162 | + . __('Delete', 'event_espresso') . '</a>' |
|
163 | + : ''; |
|
164 | + |
|
165 | + return sprintf( |
|
166 | + '%1$s %2$s', |
|
167 | + $item->get_datetime('CHK_timestamp', '', 'H:i:s a'), |
|
168 | + $this->row_actions($actions) |
|
169 | + ); |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * This retrieves all the Check-ins for the given parameters. |
|
175 | + * experimenting with having the query for the table values within the list table. |
|
176 | + * |
|
177 | + * @param int $per_page How many to retrieve per page |
|
178 | + * @param bool $count Whether to return a count or not |
|
179 | + * @return EE_Checkin[]|int |
|
180 | + * @throws EE_Error |
|
181 | + * @throws InvalidArgumentException |
|
182 | + * @throws InvalidDataTypeException |
|
183 | + * @throws InvalidInterfaceException |
|
184 | + */ |
|
185 | + protected function _get_checkins($per_page = 10, $count = false) |
|
186 | + { |
|
187 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : false; |
|
188 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : false; |
|
189 | + |
|
190 | + // if user does not have the capability for the checkins for this registration then get out! |
|
191 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
192 | + 'ee_read_checkin', |
|
193 | + 'espresso_registrations_registration_checkins', |
|
194 | + $REG_ID |
|
195 | + )) { |
|
196 | + return $count ? 0 : array(); |
|
197 | + } |
|
198 | + |
|
199 | + // if no reg id then get out cause need a reg id |
|
200 | + if (empty($REG_ID) || empty($DTT_ID)) { |
|
201 | + throw new EE_Error( |
|
202 | + __( |
|
203 | + 'This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)', |
|
204 | + 'event_espresso' |
|
205 | + ) |
|
206 | + ); |
|
207 | + } |
|
208 | + |
|
209 | + // set orderby |
|
210 | + // note that with this table we're only providing the option to orderby the timestamp value. |
|
211 | + $orderby = 'CHK_timestamp'; |
|
212 | + |
|
213 | + $order = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
214 | + |
|
215 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
216 | + ? $this->_req_data['paged'] |
|
217 | + : 1; |
|
218 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
219 | + ? $this->_req_data['perpage'] |
|
220 | + : $per_page; |
|
221 | + $limit = null; |
|
222 | + if (! $count) { |
|
223 | + $offset = ($current_page - 1) * $per_page; |
|
224 | + $limit = array($offset, $per_page); |
|
225 | + } |
|
226 | + |
|
227 | + $_where = array( |
|
228 | + 'REG_ID' => $REG_ID, |
|
229 | + 'DTT_ID' => $DTT_ID, |
|
230 | + ); |
|
231 | + |
|
232 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
233 | + |
|
234 | + // if no per_page value then we just want to return a count of all Check-ins |
|
235 | + if ($count) { |
|
236 | + return EEM_Checkin::instance()->count(array($_where)); |
|
237 | + } |
|
238 | + |
|
239 | + return $count |
|
240 | + ? EEM_Checkin::instance()->count(array($_where)) |
|
241 | + : EEM_Checkin::instance()->get_all($query_params); |
|
242 | + } |
|
243 | 243 | } |