Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Events_Admin_Page often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Events_Admin_Page, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
30 | class Events_Admin_Page extends EE_Admin_Page_CPT { |
||
31 | |||
32 | /** |
||
33 | * _event |
||
34 | * This will hold the event object for event_details screen. |
||
35 | * |
||
36 | * @access protected |
||
37 | * @var object |
||
38 | */ |
||
39 | protected $_event; |
||
40 | |||
41 | |||
42 | /** |
||
43 | * This will hold the category object for category_details screen. |
||
44 | * @var object |
||
45 | */ |
||
46 | protected $_category; |
||
47 | |||
48 | |||
49 | /** |
||
50 | * This will hold the event model instance |
||
51 | * @var object |
||
52 | */ |
||
53 | protected $_event_model; |
||
54 | |||
55 | |||
56 | protected function _init_page_props() { |
||
57 | |||
58 | $this->page_slug = EVENTS_PG_SLUG; |
||
59 | $this->page_label = EVENTS_LABEL; |
||
60 | $this->_admin_base_url = EVENTS_ADMIN_URL; |
||
61 | $this->_admin_base_path = EVENTS_ADMIN; |
||
62 | $this->_cpt_model_names = array( |
||
|
|||
63 | 'create_new' => 'EEM_Event', |
||
64 | 'edit' => 'EEM_Event' |
||
65 | ); |
||
66 | $this->_cpt_edit_routes = array( |
||
67 | 'espresso_events' => 'edit' |
||
68 | ); |
||
69 | |||
70 | add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) ); |
||
71 | } |
||
72 | |||
73 | protected function _ajax_hooks() { |
||
76 | |||
77 | View Code Duplication | protected function _define_page_props() { |
|
78 | $this->_admin_page_title = EVENTS_LABEL; |
||
79 | $this->_labels = array( |
||
80 | 'buttons' => array( |
||
81 | 'add' => __('Add New Event', 'event_espresso'), |
||
82 | 'edit' => __('Edit Event', 'event_espresso'), |
||
83 | 'delete' => __('Delete Event', 'event_espresso'), |
||
84 | 'add_category' => __('Add New Category', 'event_espresso'), |
||
85 | 'edit_category' => __('Edit Category', 'event_espresso'), |
||
86 | 'delete_category' => __('Delete Category', 'event_espresso') |
||
87 | ), |
||
88 | 'editor_title' => array( |
||
89 | 'espresso_events' => __('Enter event title here', 'event_espresso') |
||
90 | ), |
||
91 | 'publishbox' => array( |
||
92 | 'create_new' => __('Save New Event', 'event_espresso'), |
||
93 | 'edit' => __('Update Event', 'event_espresso'), |
||
94 | 'add_category' => __('Save New Category', 'event_espresso'), |
||
95 | 'edit_category' => __('Update Category', 'event_espresso'), |
||
96 | 'template_settings' => __( 'Update Settings', 'event_espresso' ) |
||
97 | ) |
||
98 | ); |
||
99 | } |
||
100 | |||
101 | protected function _set_page_routes() { |
||
102 | //load formatter helper |
||
103 | EE_Registry::instance()->load_helper( 'Formatter' ); |
||
104 | //load field generator helper |
||
105 | EE_Registry::instance()->load_helper( 'Form_Fields' ); |
||
106 | |||
107 | //is there a evt_id in the request? |
||
108 | $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
||
109 | $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
||
110 | |||
111 | |||
112 | $this->_page_routes = array( |
||
113 | 'default' => array( |
||
114 | 'func' => '_events_overview_list_table', |
||
115 | 'capability' => 'ee_read_events' |
||
116 | ), |
||
117 | 'create_new' => array( |
||
118 | 'func' => '_create_new_cpt_item', |
||
119 | 'capability' => 'ee_edit_events' |
||
120 | ), |
||
121 | 'edit' => array( |
||
122 | 'func' => '_edit_cpt_item', |
||
123 | 'capability' => 'ee_edit_event', |
||
124 | 'obj_id' => $evt_id |
||
125 | ), |
||
126 | 'copy_event' => array( |
||
127 | 'func' => '_copy_events', |
||
128 | 'capability' => 'ee_edit_event', |
||
129 | 'obj_id' => $evt_id, |
||
130 | 'noheader' => true |
||
131 | ), |
||
132 | 'trash_event' => array( |
||
133 | 'func' => '_trash_or_restore_event', |
||
134 | 'args' => array('event_status' => 'trash'), |
||
135 | 'capability' => 'ee_delete_event', |
||
136 | 'obj_id' => $evt_id, |
||
137 | 'noheader' => true |
||
138 | ), |
||
139 | 'trash_events' => array( |
||
140 | 'func' => '_trash_or_restore_events', |
||
141 | 'args' => array('event_status' => 'trash'), |
||
142 | 'capability' => 'ee_delete_events', |
||
143 | 'noheader' => true |
||
144 | ), |
||
145 | 'restore_event' => array( |
||
146 | 'func' => '_trash_or_restore_event', |
||
147 | 'args' => array('event_status' => 'draft'), |
||
148 | 'capability' => 'ee_delete_event', |
||
149 | 'obj_id' => $evt_id, |
||
150 | 'noheader' => true |
||
151 | ), |
||
152 | 'restore_events' => array( |
||
153 | 'func' => '_trash_or_restore_events', |
||
154 | 'args' => array('event_status' => 'draft'), |
||
155 | 'capability' => 'ee_delete_events', |
||
156 | 'noheader' => true |
||
157 | ), |
||
158 | 'delete_event' => array( |
||
159 | 'func' => '_delete_event', |
||
160 | 'capability' => 'ee_delete_event', |
||
161 | 'obj_id' => $evt_id, |
||
162 | 'noheader' => true |
||
163 | ), |
||
164 | 'delete_events' => array( |
||
165 | 'func' => '_delete_events', |
||
166 | 'capability' => 'ee_delete_events', |
||
167 | 'noheader' => true |
||
168 | ), |
||
169 | 'view_report' => array( |
||
170 | 'func' => '_view_report', |
||
171 | 'capablity' => 'ee_edit_events' |
||
172 | ), |
||
173 | 'default_event_settings' => array( |
||
174 | 'func' => '_default_event_settings', |
||
175 | 'capability' => 'manage_options' |
||
176 | ), |
||
177 | 'update_default_event_settings' => array( |
||
178 | 'func' => '_update_default_event_settings', |
||
179 | 'capability' => 'manage_options', |
||
180 | 'noheader' => TRUE, |
||
181 | ), |
||
182 | 'template_settings' => array( |
||
183 | 'func' => '_template_settings', |
||
184 | 'capability' => 'manage_options' |
||
185 | ), |
||
186 | //event category tab related |
||
187 | 'add_category' => array( |
||
188 | 'func' => '_category_details', |
||
189 | 'capability' => 'ee_edit_event_category', |
||
190 | 'args' => array('add'), |
||
191 | ), |
||
192 | 'edit_category' => array( |
||
193 | 'func' => '_category_details', |
||
194 | 'capability' => 'ee_edit_event_category', |
||
195 | 'args' => array('edit') |
||
196 | ), |
||
197 | 'delete_categories' => array( |
||
198 | 'func' => '_delete_categories', |
||
199 | 'capability' => 'ee_delete_event_category', |
||
200 | 'noheader' => TRUE |
||
201 | ), |
||
202 | |||
203 | 'delete_category' => array( |
||
204 | 'func' => '_delete_categories', |
||
205 | 'capability' => 'ee_delete_event_category', |
||
206 | 'noheader' => TRUE |
||
207 | ), |
||
208 | |||
209 | 'insert_category' => array( |
||
210 | 'func' => '_insert_or_update_category', |
||
211 | 'args' => array('new_category' => TRUE), |
||
212 | 'capability' => 'ee_edit_event_category', |
||
213 | 'noheader' => TRUE |
||
214 | ), |
||
215 | |||
216 | 'update_category' => array( |
||
217 | 'func' => '_insert_or_update_category', |
||
218 | 'args' => array('new_category' => FALSE), |
||
219 | 'capability' => 'ee_edit_event_category', |
||
220 | 'noheader' => TRUE |
||
221 | ), |
||
222 | 'category_list' => array( |
||
223 | 'func' => '_category_list_table', |
||
224 | 'capability' => 'ee_manage_event_categories' |
||
225 | ) |
||
226 | ); |
||
227 | } |
||
228 | |||
229 | protected function _set_page_config() { |
||
230 | |||
231 | |||
232 | |||
233 | $this->_page_config = array( |
||
234 | 'default' => array( |
||
235 | 'nav' => array( |
||
236 | 'label' => __('Overview', 'event_espresso'), |
||
237 | 'order' => 10 |
||
238 | ), |
||
239 | 'list_table' => 'Events_Admin_List_Table', |
||
240 | 'help_tabs' => array( |
||
241 | 'events_overview_help_tab' => array( |
||
242 | 'title' => __('Events Overview', 'event_espresso'), |
||
243 | 'filename' => 'events_overview' |
||
244 | ), |
||
245 | 'events_overview_table_column_headings_help_tab' => array( |
||
246 | 'title' => __('Events Overview Table Column Headings', 'event_espresso'), |
||
247 | 'filename' => 'events_overview_table_column_headings' |
||
248 | ), |
||
249 | 'events_overview_filters_help_tab' => array( |
||
250 | 'title' => __('Events Overview Filters', 'event_espresso'), |
||
251 | 'filename' => 'events_overview_filters' |
||
252 | ), |
||
253 | 'events_overview_view_help_tab' => array( |
||
254 | 'title' => __('Events Overview Views', 'event_espresso'), |
||
255 | 'filename' => 'events_overview_views' |
||
256 | ), |
||
257 | 'events_overview_other_help_tab' => array( |
||
258 | 'title' => __('Events Overview Other', 'event_espresso'), |
||
259 | 'filename' => 'events_overview_other' |
||
260 | ) |
||
261 | ), |
||
262 | 'help_tour' => array( |
||
263 | 'Event_Overview_Help_Tour', |
||
264 | //'New_Features_Test_Help_Tour' for testing multiple help tour |
||
265 | ), |
||
266 | 'qtips' => array( |
||
267 | 'EE_Event_List_Table_Tips' |
||
268 | ), |
||
269 | 'require_nonce' => FALSE |
||
270 | ), |
||
271 | 'create_new' => array( |
||
272 | 'nav' => array( |
||
273 | 'label' => __('Add Event', 'event_espresso'), |
||
274 | 'order' => 5, |
||
275 | 'persistent' => false |
||
276 | ), |
||
277 | 'metaboxes' => array('_register_event_editor_meta_boxes'), |
||
278 | 'help_tabs' => array( |
||
279 | 'event_editor_help_tab' => array( |
||
280 | 'title' => __('Event Editor', 'event_espresso'), |
||
281 | 'filename' => 'event_editor' |
||
282 | ), |
||
283 | 'event_editor_title_richtexteditor_help_tab' => array( |
||
284 | 'title' => __('Event Title & Rich Text Editor', 'event_espresso'), |
||
285 | 'filename' => 'event_editor_title_richtexteditor' |
||
286 | ), |
||
287 | 'event_editor_venue_details_help_tab' => array( |
||
288 | 'title' => __('Event Venue Details', 'event_espresso'), |
||
289 | 'filename' => 'event_editor_venue_details' |
||
290 | ), |
||
291 | 'event_editor_event_datetimes_help_tab' => array( |
||
292 | 'title' => __('Event Datetimes', 'event_espresso'), |
||
293 | 'filename' => 'event_editor_event_datetimes' |
||
294 | ), |
||
295 | 'event_editor_event_tickets_help_tab' => array( |
||
296 | 'title' => __('Event Tickets', 'event_espresso'), |
||
297 | 'filename' => 'event_editor_event_tickets' |
||
298 | ), |
||
299 | 'event_editor_event_registration_options_help_tab' => array( |
||
300 | 'title' => __('Event Registration Options', 'event_espresso'), |
||
301 | 'filename' => 'event_editor_event_registration_options' |
||
302 | ), |
||
303 | 'event_editor_tags_categories_help_tab' => array( |
||
304 | 'title' => __('Event Tags & Categories', 'event_espresso'), |
||
305 | 'filename' => 'event_editor_tags_categories' |
||
306 | ), |
||
307 | 'event_editor_questions_registrants_help_tab' => array( |
||
308 | 'title' => __('Questions for Registrants', 'event_espresso'), |
||
309 | 'filename' => 'event_editor_questions_registrants' |
||
310 | ), |
||
311 | 'event_editor_save_new_event_help_tab' => array( |
||
312 | 'title' => __('Save New Event', 'event_espresso'), |
||
313 | 'filename' => 'event_editor_save_new_event' |
||
314 | ), |
||
315 | 'event_editor_other_help_tab' => array( |
||
316 | 'title' => __('Event Other', 'event_espresso'), |
||
317 | 'filename' => 'event_editor_other' |
||
318 | ) |
||
319 | ), |
||
320 | 'help_tour' => array( |
||
321 | 'Event_Editor_Help_Tour' |
||
322 | ), |
||
323 | 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
||
324 | 'require_nonce' => FALSE |
||
325 | ), |
||
326 | 'edit' => array( |
||
327 | 'nav' => array( |
||
328 | 'label' => __('Edit Event', 'event_espresso'), |
||
329 | 'order' => 5, |
||
330 | 'persistent' => false, |
||
331 | 'url' => isset($this->_req_data['post']) ? EE_Admin_Page::add_query_args_and_nonce(array('post' => $this->_req_data['post'], 'action' => 'edit'), $this->_current_page_view_url) : $this->_admin_base_url |
||
332 | ), |
||
333 | 'metaboxes' => array('_register_event_editor_meta_boxes'), |
||
334 | 'help_tabs' => array( |
||
335 | 'event_editor_help_tab' => array( |
||
336 | 'title' => __('Event Editor', 'event_espresso'), |
||
337 | 'filename' => 'event_editor' |
||
338 | ), |
||
339 | 'event_editor_title_richtexteditor_help_tab' => array( |
||
340 | 'title' => __('Event Title & Rich Text Editor', 'event_espresso'), |
||
341 | 'filename' => 'event_editor_title_richtexteditor' |
||
342 | ), |
||
343 | 'event_editor_venue_details_help_tab' => array( |
||
344 | 'title' => __('Event Venue Details', 'event_espresso'), |
||
345 | 'filename' => 'event_editor_venue_details' |
||
346 | ), |
||
347 | 'event_editor_event_datetimes_help_tab' => array( |
||
348 | 'title' => __('Event Datetimes', 'event_espresso'), |
||
349 | 'filename' => 'event_editor_event_datetimes' |
||
350 | ), |
||
351 | 'event_editor_event_tickets_help_tab' => array( |
||
352 | 'title' => __('Event Tickets', 'event_espresso'), |
||
353 | 'filename' => 'event_editor_event_tickets' |
||
354 | ), |
||
355 | 'event_editor_event_registration_options_help_tab' => array( |
||
356 | 'title' => __('Event Registration Options', 'event_espresso'), |
||
357 | 'filename' => 'event_editor_event_registration_options' |
||
358 | ), |
||
359 | 'event_editor_tags_categories_help_tab' => array( |
||
360 | 'title' => __('Event Tags & Categories', 'event_espresso'), |
||
361 | 'filename' => 'event_editor_tags_categories' |
||
362 | ), |
||
363 | 'event_editor_questions_registrants_help_tab' => array( |
||
364 | 'title' => __('Questions for Registrants', 'event_espresso'), |
||
365 | 'filename' => 'event_editor_questions_registrants' |
||
366 | ), |
||
367 | 'event_editor_save_new_event_help_tab' => array( |
||
368 | 'title' => __('Save New Event', 'event_espresso'), |
||
369 | 'filename' => 'event_editor_save_new_event' |
||
370 | ), |
||
371 | 'event_editor_other_help_tab' => array( |
||
372 | 'title' => __('Event Other', 'event_espresso'), |
||
373 | 'filename' => 'event_editor_other' |
||
374 | ) |
||
375 | ), |
||
376 | 'help_tour' => array( |
||
377 | 'Event_Edit_Help_Tour' |
||
378 | ), |
||
379 | 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
||
380 | 'require_nonce' => FALSE |
||
381 | ), |
||
382 | 'default_event_settings' => array( |
||
383 | 'nav' => array( |
||
384 | 'label' => __('Default Settings', 'event_espresso'), |
||
385 | 'order' => 40 |
||
386 | ), |
||
387 | 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
||
388 | 'labels' => array( |
||
389 | 'publishbox' => __('Update Settings', 'event_espresso') |
||
390 | ), |
||
391 | 'help_tabs' => array( |
||
392 | 'default_settings_help_tab' => array( |
||
393 | 'title' => __('Default Event Settings', 'event_espresso'), |
||
394 | 'filename' => 'events_default_settings' |
||
395 | ), |
||
396 | 'default_settings_status_help_tab' => array( |
||
397 | 'title' => __('Default Registration Status', 'event_espresso'), |
||
398 | 'filename' => 'events_default_settings_status' |
||
399 | ) |
||
400 | ), |
||
401 | 'help_tour' => array( 'Event_Default_Settings_Help_Tour'), |
||
402 | 'require_nonce' => FALSE |
||
403 | ), |
||
404 | //template settings |
||
405 | 'template_settings' => array( |
||
406 | 'nav' => array( |
||
407 | 'label' => __('Templates', 'event_espresso'), |
||
408 | 'order' => 30 |
||
409 | ), |
||
410 | 'metaboxes' => $this->_default_espresso_metaboxes, |
||
411 | 'help_tabs' => array( |
||
412 | 'general_settings_templates_help_tab' => array( |
||
413 | 'title' => __('Templates', 'event_espresso'), |
||
414 | 'filename' => 'general_settings_templates' |
||
415 | ) |
||
416 | ), |
||
417 | 'help_tour' => array( 'Templates_Help_Tour' ), |
||
418 | 'require_nonce' => FALSE |
||
419 | ), |
||
420 | //event category stuff |
||
421 | 'add_category' => array( |
||
422 | 'nav' => array( |
||
423 | 'label' => __('Add Category', 'event_espresso'), |
||
424 | 'order' => 15, |
||
425 | 'persistent' => false), |
||
426 | 'help_tabs' => array( |
||
427 | 'add_category_help_tab' => array( |
||
428 | 'title' => __('Add New Event Category', 'event_espresso'), |
||
429 | 'filename' => 'events_add_category' |
||
430 | ) |
||
431 | ), |
||
432 | 'help_tour' => array('Event_Add_Category_Help_Tour'), |
||
433 | 'metaboxes' => array('_publish_post_box'), |
||
434 | 'require_nonce' => FALSE |
||
435 | ), |
||
436 | 'edit_category' => array( |
||
437 | 'nav' => array( |
||
438 | 'label' => __('Edit Category', 'event_espresso'), |
||
439 | 'order' => 15, |
||
440 | 'persistent' => FALSE, |
||
441 | 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
||
442 | ), |
||
443 | 'help_tabs' => array( |
||
444 | 'edit_category_help_tab' => array( |
||
445 | 'title' => __('Edit Event Category', 'event_espresso'), |
||
446 | 'filename' => 'events_edit_category' |
||
447 | ) |
||
448 | ), |
||
449 | 'help_tour' => array('Event_Edit_Category_Help_Tour'), |
||
450 | 'metaboxes' => array('_publish_post_box'), |
||
451 | 'require_nonce' => FALSE |
||
452 | ), |
||
453 | 'category_list' => array( |
||
454 | 'nav' => array( |
||
455 | 'label' => __('Categories', 'event_espresso'), |
||
456 | 'order' => 20 |
||
457 | ), |
||
458 | 'list_table' => 'Event_Categories_Admin_List_Table', |
||
459 | 'help_tabs' => array( |
||
460 | 'events_categories_help_tab' => array( |
||
461 | 'title' => __('Event Categories', 'event_espresso'), |
||
462 | 'filename' => 'events_categories' |
||
463 | ), |
||
464 | 'events_categories_table_column_headings_help_tab' => array( |
||
465 | 'title' => __('Event Categories Table Column Headings', 'event_espresso'), |
||
466 | 'filename' => 'events_categories_table_column_headings' |
||
467 | ), |
||
468 | 'events_categories_view_help_tab' => array( |
||
469 | 'title' => __('Event Categories Views', 'event_espresso'), |
||
470 | 'filename' => 'events_categories_views' |
||
471 | ), |
||
472 | 'events_categories_other_help_tab' => array( |
||
473 | 'title' => __('Event Categories Other', 'event_espresso'), |
||
474 | 'filename' => 'events_categories_other' |
||
475 | ) |
||
476 | ), |
||
477 | 'help_tour' => array( |
||
478 | 'Event_Categories_Help_Tour' |
||
479 | ), |
||
480 | 'metaboxes' => $this->_default_espresso_metaboxes, |
||
481 | 'require_nonce' => FALSE |
||
482 | ), |
||
483 | ); |
||
484 | } |
||
485 | |||
486 | |||
487 | protected function _add_screen_options() { |
||
490 | |||
491 | protected function _add_screen_options_default() { |
||
494 | |||
495 | View Code Duplication | protected function _add_screen_options_category_list() { |
|
496 | $page_title = $this->_admin_page_title; |
||
497 | $this->_admin_page_title = __('Categories', 'event_espresso'); |
||
498 | $this->_per_page_screen_option(); |
||
499 | $this->_admin_page_title = $page_title; |
||
500 | } |
||
501 | |||
502 | protected function _add_feature_pointers() { |
||
505 | |||
506 | |||
507 | |||
508 | |||
509 | public function load_scripts_styles() { |
||
510 | |||
511 | wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
||
512 | wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
||
513 | wp_enqueue_style('events-admin-css'); |
||
514 | wp_enqueue_style('ee-cat-admin'); |
||
515 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
||
516 | //registers for all views |
||
517 | //scripts |
||
518 | wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
||
519 | } |
||
520 | |||
521 | /** |
||
522 | * enqueuing scripts and styles specific to this view |
||
523 | * @return void |
||
524 | */ |
||
525 | public function load_scripts_styles_create_new() { |
||
528 | |||
529 | /** |
||
530 | * enqueuing scripts and styles specific to this view |
||
531 | * @return void |
||
532 | */ |
||
533 | View Code Duplication | public function load_scripts_styles_edit() { |
|
534 | //styles |
||
535 | wp_enqueue_style('espresso-ui-theme'); |
||
536 | wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
||
537 | wp_enqueue_style('event-editor-css'); |
||
538 | |||
539 | //scripts |
||
540 | wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION ); |
||
541 | wp_enqueue_script('event-datetime-metabox'); |
||
542 | |||
543 | } |
||
544 | |||
545 | |||
546 | |||
547 | public function load_scripts_styles_add_category() { |
||
550 | |||
551 | |||
552 | |||
553 | |||
554 | |||
555 | public function load_scripts_styles_edit_category() {} |
||
556 | |||
557 | |||
558 | |||
559 | View Code Duplication | protected function _set_list_table_views_category_list() { |
|
560 | $this->_views = array( |
||
561 | 'all' => array( |
||
562 | 'slug' => 'all', |
||
563 | 'label' => __('All', 'event_espresso'), |
||
564 | 'count' => 0, |
||
565 | 'bulk_action' => array( |
||
566 | 'delete_categories' => __('Delete Permanently', 'event_espresso') |
||
567 | ) |
||
568 | ) |
||
569 | ); |
||
570 | } |
||
571 | |||
572 | |||
573 | |||
574 | public function admin_init() { |
||
577 | |||
578 | |||
579 | |||
580 | //nothing needed for events with these methods. |
||
581 | public function admin_notices() {} |
||
583 | |||
584 | |||
585 | |||
586 | |||
587 | /** |
||
588 | * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a warning (via EE_Error::add_error()); |
||
589 | * |
||
590 | * @param EE_Event $event Event object |
||
591 | * @access public |
||
592 | * @return void |
||
593 | */ |
||
594 | public function verify_event_edit($event = NULL) { |
||
595 | // no event? |
||
596 | if ( empty( $event )) { |
||
597 | // set event |
||
598 | $event = $this->_cpt_model_obj; |
||
599 | } |
||
600 | // STILL no event? |
||
601 | if ( empty ( $event )) { |
||
602 | return; |
||
603 | } |
||
604 | // first check if event is active. |
||
605 | if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) { |
||
606 | return; |
||
607 | } |
||
608 | $orig_status = $event->status(); |
||
609 | //made it here so it IS active... next check that any of the tickets are sold. |
||
610 | if ( $event->is_sold_out( true ) ) { |
||
611 | View Code Duplication | if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out ) { |
|
612 | EE_Error::add_attention( |
||
613 | sprintf( |
||
614 | __( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso' ), |
||
615 | EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' ) |
||
616 | ) |
||
617 | ); |
||
618 | } |
||
619 | return; |
||
620 | View Code Duplication | } else if ( $orig_status === EEM_Event::sold_out ) { |
|
621 | EE_Error::add_attention( |
||
622 | sprintf( |
||
623 | __( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
||
624 | 'event_espresso' ), |
||
625 | EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
||
626 | ) |
||
627 | ); |
||
628 | } |
||
629 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
||
630 | if ( ! $event->tickets_on_sale() ) { |
||
631 | return; |
||
632 | } |
||
633 | //made it here so show warning |
||
634 | EE_Error::add_attention( $this->_edit_event_warning() ); |
||
635 | } |
||
636 | |||
637 | |||
638 | |||
639 | |||
640 | /** |
||
641 | * This is the text used for when an event is being edited that is public and has tickets for sale. |
||
642 | * When needed, hook this into a EE_Error::add_error() notice. |
||
643 | * |
||
644 | * @access protected |
||
645 | * @return string |
||
646 | */ |
||
647 | protected function _edit_event_warning() { |
||
650 | |||
651 | |||
652 | |||
653 | |||
654 | protected function _set_list_table_views_default() { |
||
655 | $this->_views = array( |
||
656 | 'all' => array( |
||
657 | 'slug' => 'all', |
||
658 | 'label' => __('View All Events', 'event_espresso'), |
||
659 | 'count' => 0, |
||
660 | 'bulk_action' => array( |
||
661 | 'trash_events' => __('Move to Trash', 'event_espresso') |
||
662 | ) |
||
663 | ), |
||
664 | 'draft' => array( |
||
665 | 'slug' => 'draft', |
||
666 | 'label' => __('Draft', 'event_espresso'), |
||
667 | 'count' => 0, |
||
668 | 'bulk_action' => array( |
||
669 | 'trash_events' => __('Move to Trash', 'event_espresso'), |
||
670 | ) |
||
671 | ), |
||
672 | ); |
||
673 | |||
674 | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
||
675 | $this->_views['trash'] = array( |
||
676 | 'slug' => 'trash', |
||
677 | 'label' => __('Trash', 'event_espresso'), |
||
678 | 'count' => 0, |
||
679 | 'bulk_action' => array( |
||
680 | 'restore_events' => __('Restore From Trash', 'event_espresso'), |
||
681 | 'delete_events' => __('Delete Permanently', 'event_espresso') |
||
682 | ) |
||
683 | ); |
||
684 | } |
||
685 | } |
||
686 | |||
687 | |||
688 | |||
689 | protected function _event_legend_items() { |
||
690 | $items = array( |
||
691 | 'view_details' => array( |
||
692 | 'class' => 'dashicons dashicons-search', |
||
693 | 'desc' => __('View Event', 'event_espresso') |
||
694 | ), |
||
695 | 'edit_event' => array( |
||
696 | 'class' => 'ee-icon ee-icon-calendar-edit', |
||
697 | 'desc' => __('Edit Event Details', 'event_espresso') |
||
698 | ), |
||
699 | 'view_attendees' => array( |
||
700 | 'class' => 'dashicons dashicons-groups', |
||
701 | 'desc' => __('View Registrations for Event', 'event_espresso') |
||
702 | ) |
||
703 | ); |
||
704 | $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
||
705 | $statuses = array( |
||
706 | 'sold_out_status' => array( |
||
707 | 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
||
708 | 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' ) |
||
709 | ), |
||
710 | 'active_status' => array( |
||
711 | 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
||
712 | 'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' ) |
||
713 | ), |
||
714 | 'upcoming_status' => array( |
||
715 | 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
||
716 | 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' ) |
||
717 | ), |
||
718 | 'postponed_status' => array( |
||
719 | 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
||
720 | 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' ) |
||
721 | ), |
||
722 | 'cancelled_status' => array( |
||
723 | 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
||
724 | 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' ) |
||
725 | ), |
||
726 | 'expired_status' => array( |
||
727 | 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
||
728 | 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' ) |
||
729 | ), |
||
730 | 'inactive_status' => array( |
||
731 | 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
||
732 | 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' ) |
||
733 | ) |
||
734 | ); |
||
735 | $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
||
736 | return array_merge( $items, $statuses ); |
||
737 | } |
||
738 | |||
739 | |||
740 | |||
741 | |||
742 | |||
743 | /** |
||
744 | * _event_model |
||
745 | * @return EEM_Event |
||
746 | */ |
||
747 | private function _event_model() { |
||
748 | if ( ! $this->_event_model instanceof EEM_Event ) { |
||
749 | $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
||
750 | } |
||
751 | return $this->_event_model; |
||
752 | } |
||
753 | |||
754 | |||
755 | |||
756 | |||
757 | |||
758 | /** |
||
759 | * Adds extra buttons to the WP CPT permalink field row. |
||
760 | * |
||
761 | * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
||
762 | * @param string $return the current html |
||
763 | * @param int $id the post id for the page |
||
764 | * @param string $new_title What the title is |
||
765 | * @param string $new_slug what the slug is |
||
766 | * @return string The new html string for the permalink area |
||
767 | */ |
||
768 | public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
||
769 | //make sure this is only when editing |
||
770 | if ( !empty( $id ) ) { |
||
771 | $post = get_post( $id ); |
||
772 | $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> '; |
||
773 | $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\'' . $post->ID . '\']"">'; |
||
774 | } |
||
775 | return $return; |
||
776 | } |
||
777 | |||
778 | |||
779 | |||
780 | |||
781 | /** |
||
782 | * _events_overview_list_table |
||
783 | * This contains the logic for showing the events_overview list |
||
784 | * |
||
785 | * @access protected |
||
786 | * @return string html for generated table |
||
787 | */ |
||
788 | protected function _events_overview_list_table() { |
||
789 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
||
790 | $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) . |
||
791 | $this->_display_legend($this->_event_legend_items()); |
||
792 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
||
793 | $this->display_admin_list_table_page_with_no_sidebar(); |
||
794 | } |
||
795 | |||
796 | |||
797 | /** |
||
798 | * this allows for extra misc actions in the default WP publish box |
||
799 | * @return string html to add |
||
800 | */ |
||
801 | public function extra_misc_actions_publish_box() { |
||
804 | |||
805 | |||
806 | |||
807 | |||
808 | protected function _insert_update_cpt_item( $post_id, $post ) { |
||
809 | |||
810 | if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
||
811 | //getout we're not processing an event save. |
||
812 | return; |
||
813 | } |
||
814 | |||
815 | $event_values = array( |
||
816 | 'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
||
817 | 'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
||
818 | 'EVT_additional_limit' => min( |
||
819 | apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
||
820 | !empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ), |
||
821 | 'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
||
822 | 'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0, |
||
823 | 'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
||
824 | 'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL, |
||
825 | 'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL, |
||
826 | 'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL |
||
827 | ); |
||
828 | |||
829 | //update event |
||
830 | $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
||
831 | |||
832 | |||
833 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
||
834 | $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
||
835 | $event = $this->_event_model()->get_one( array($get_one_where) ); |
||
836 | |||
837 | |||
838 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
||
839 | $event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) ); |
||
840 | |||
841 | $att_success = TRUE; |
||
842 | |||
843 | View Code Duplication | foreach ( $event_update_callbacks as $e_callback ) { |
|
844 | $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
||
845 | $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
||
846 | } |
||
847 | |||
848 | //any errors? |
||
849 | if ( $success && FALSE === $att_success ) { |
||
850 | EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
||
851 | } else if ( $success === FALSE ) { |
||
852 | EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
||
853 | } |
||
854 | } |
||
855 | |||
856 | |||
857 | |||
858 | |||
859 | /** |
||
860 | * @see parent::restore_item() |
||
861 | */ |
||
862 | protected function _restore_cpt_item( $post_id, $revision_id ) { |
||
863 | //copy existing event meta to new post |
||
864 | $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
||
865 | if ( $post_evt instanceof EE_Event ) { |
||
866 | //meta revision restore |
||
867 | $post_evt->restore_revision( $revision_id ); |
||
868 | //related objs restore |
||
869 | $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
||
870 | } |
||
871 | } |
||
872 | |||
873 | |||
874 | |||
875 | |||
876 | /** |
||
877 | * Attach the venue to the Event |
||
878 | * @param object $evtobj Event Object to add the venue to |
||
879 | * @param array $data The request data from the form |
||
880 | * @return bool Success or fail. |
||
881 | */ |
||
882 | protected function _default_venue_update( $evtobj, $data ) { |
||
883 | require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
||
884 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
||
885 | $rows_affected = NULL; |
||
886 | $venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL; |
||
887 | |||
888 | // very important. If we don't have a venue name... |
||
889 | // then we'll get out because not necessary to create empty venue |
||
890 | if ( empty( $data['venue_title'] ) ) { |
||
891 | return false; |
||
892 | } |
||
893 | |||
894 | $venue_array = array( |
||
895 | 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
||
896 | 'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL, |
||
897 | 'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL, |
||
898 | 'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL, |
||
899 | 'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL, |
||
900 | 'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL, |
||
901 | 'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL, |
||
902 | 'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL, |
||
903 | 'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL, |
||
904 | 'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL, |
||
905 | 'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL, |
||
906 | 'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL, |
||
907 | 'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL, |
||
908 | 'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL, |
||
909 | 'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
||
910 | 'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL, |
||
911 | 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
||
912 | 'status' => 'publish' |
||
913 | ); |
||
914 | |||
915 | |||
916 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
||
917 | if ( !empty( $venue_id ) ) { |
||
918 | $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
||
919 | $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
||
920 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
||
921 | $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
||
922 | return $rows_affected > 0 ? TRUE : FALSE; |
||
923 | } else { |
||
924 | //we insert the venue |
||
925 | $venue_id = $venue_model->insert( $venue_array ); |
||
926 | $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
||
927 | return !empty( $venue_id ) ? TRUE : FALSE; |
||
928 | } |
||
929 | //when we have the ancestor come in it's already been handled by the revision save. |
||
930 | } |
||
931 | |||
932 | |||
933 | |||
934 | |||
935 | /** |
||
936 | * Handles saving everything related to Tickets (datetimes, tickets, prices) |
||
937 | * @param EE_Event $evtobj The Event object we're attaching data to |
||
938 | * @param array $data The request data from the form |
||
939 | * @return bool success or fail |
||
940 | */ |
||
941 | protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
||
1159 | |||
1160 | |||
1161 | |||
1162 | /** |
||
1163 | * This attaches a list of given prices to a ticket. |
||
1164 | * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old price info and prices are automatically "archived" via the ticket. |
||
1165 | * |
||
1166 | * @access private |
||
1167 | * @param array $prices Array of prices from the form. |
||
1168 | * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
||
1169 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
||
1170 | * @return void |
||
1171 | */ |
||
1172 | private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) { |
||
1173 | foreach ( $prices as $row => $prc ) { |
||
1174 | $PRC_values = array( |
||
1175 | 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
||
1176 | 'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL, |
||
1177 | 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
||
1178 | 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
||
1179 | 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
||
1180 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
||
1181 | 'PRC_order' => $row |
||
1182 | ); |
||
1183 | |||
1184 | View Code Duplication | if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1185 | $PRC_values['PRC_ID'] = 0; |
||
1186 | $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
||
1187 | } else { |
||
1188 | $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
||
1189 | //update this price with new values |
||
1190 | foreach ( $PRC_values as $field => $newprc ) { |
||
1191 | $PRC->set( $field, $newprc ); |
||
1192 | } |
||
1193 | $PRC->save(); |
||
1194 | } |
||
1195 | |||
1196 | $ticket->_add_relation_to( $PRC, 'Price' ); |
||
1197 | } |
||
1198 | } |
||
1199 | |||
1200 | |||
1201 | |||
1202 | |||
1203 | /** |
||
1204 | * Add in our autosave ajax handlers |
||
1205 | * @return void |
||
1206 | */ |
||
1207 | protected function _ee_autosave_create_new() { |
||
1210 | |||
1211 | |||
1212 | |||
1213 | |||
1214 | |||
1215 | protected function _ee_autosave_edit() { |
||
1216 | |||
1217 | return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
||
1218 | |||
1219 | $postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL; |
||
1220 | |||
1221 | |||
1222 | //if no postid then get out cause we need it for stuff in here |
||
1223 | if ( empty( $postid ) ) return; |
||
1224 | |||
1225 | |||
1226 | //handle datetime saves |
||
1227 | $items = array(); |
||
1228 | |||
1229 | $get_one_where = array( $this->_event_model()->primary_key_name() => $postid ); |
||
1230 | $event = $this->_event_model()->get_one( array($get_one_where) ); |
||
1231 | |||
1232 | //now let's get the attached datetimes from the most recent autosave |
||
1233 | $dtts = $event->get_many_related('Datetime'); |
||
1234 | |||
1235 | $dtt_ids = array(); |
||
1236 | foreach( $dtts as $dtt ) { |
||
1237 | $dtt_ids[] = $dtt->ID(); |
||
1238 | $order = $dtt->order(); |
||
1239 | $this->_template_args['data']['items']['ID-'.$order] = $dtt->ID(); |
||
1240 | } |
||
1241 | $this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids ); |
||
1242 | |||
1243 | //handle DECAF venues |
||
1244 | //we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event. |
||
1245 | if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) { |
||
1246 | $venue = $event->get_first_related('Venue'); |
||
1247 | $this->_template_args['data']['items']['venue-id'] = $venue->ID(); |
||
1248 | } |
||
1249 | |||
1250 | |||
1251 | //handle ticket updates. |
||
1252 | $tickets = $event->get_many_related('Ticket'); |
||
1253 | |||
1254 | $ticket_ids = array(); |
||
1255 | $price_ids = array(); |
||
1256 | foreach ( $tickets as $ticket ) { |
||
1257 | $ticket_ids[] = $price->ID(); |
||
1258 | $ticket_order = $price->get('TKT_order'); |
||
1259 | $this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID(); |
||
1260 | $this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID(); |
||
1261 | |||
1262 | //now we have to make sure the prices are updated appropriately |
||
1263 | $prices = $ticket->get_many_related('Prices'); |
||
1264 | |||
1265 | foreach ( $prices as $price ) { |
||
1266 | $price_ids[] = $price->ID(); |
||
1267 | $price_order = $price->get('PRC_order'); |
||
1268 | $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID(); |
||
1269 | $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID(); |
||
1270 | $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default'); |
||
1271 | } |
||
1272 | $this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids); |
||
1273 | } |
||
1274 | $this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids); |
||
1275 | } |
||
1276 | |||
1277 | |||
1278 | |||
1279 | |||
1280 | |||
1281 | |||
1282 | /** |
||
1283 | * _generate_publish_box_extra_content |
||
1284 | * @access private |
||
1285 | * @return void |
||
1286 | */ |
||
1287 | private function _generate_publish_box_extra_content() { |
||
1288 | |||
1289 | //load formatter helper |
||
1290 | EE_Registry::instance()->load_helper( 'Formatter' ); |
||
1291 | |||
1292 | //args for getting related registrations |
||
1293 | $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
||
1294 | $not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) ); |
||
1295 | $pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) ); |
||
1296 | |||
1297 | |||
1298 | // publish box |
||
1299 | $publish_box_extra_args = array( |
||
1300 | 'view_approved_reg_url' => add_query_arg( |
||
1301 | array( |
||
1302 | 'action' => 'default', |
||
1303 | 'event_id' => $this->_cpt_model_obj->ID(), |
||
1304 | '_reg_status' => EEM_Registration::status_id_approved |
||
1305 | ), |
||
1306 | REG_ADMIN_URL |
||
1307 | ), |
||
1308 | 'view_not_approved_reg_url' => add_query_arg( |
||
1309 | array( |
||
1310 | 'action' => 'default', |
||
1311 | 'event_id' => $this->_cpt_model_obj->ID(), |
||
1312 | '_reg_status' => EEM_Registration::status_id_not_approved |
||
1313 | ), |
||
1314 | REG_ADMIN_URL |
||
1315 | ), |
||
1316 | 'view_pending_payment_reg_url' => add_query_arg( |
||
1317 | array( |
||
1318 | 'action' => 'default', |
||
1319 | 'event_id' => $this->_cpt_model_obj->ID(), |
||
1320 | '_reg_status' => EEM_Registration::status_id_pending_payment |
||
1321 | ), |
||
1322 | REG_ADMIN_URL |
||
1323 | ), |
||
1324 | 'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ), |
||
1325 | 'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ), |
||
1326 | 'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ), |
||
1327 | 'misc_pub_section_class' => apply_filters( |
||
1328 | 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
||
1329 | 'misc-pub-section' |
||
1330 | ), |
||
1331 | //'email_attendees_url' => add_query_arg( |
||
1332 | // array( |
||
1333 | // 'event_admin_reports' => 'event_newsletter', |
||
1334 | // 'event_id' => $this->_cpt_model_obj->id |
||
1335 | // ), |
||
1336 | // 'admin.php?page=espresso_registrations' |
||
1337 | //), |
||
1338 | |||
1339 | ); |
||
1340 | ob_start(); |
||
1341 | do_action( |
||
1342 | 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
||
1343 | $this->_cpt_model_obj |
||
1344 | ); |
||
1345 | $publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean(); |
||
1346 | // load template |
||
1347 | EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args ); |
||
1348 | } |
||
1349 | |||
1350 | |||
1351 | |||
1352 | |||
1353 | |||
1354 | /** |
||
1355 | * This just returns whatever is set as the _event object property |
||
1356 | * |
||
1357 | * //todo this will become obsolete once the models are in place |
||
1358 | * @return object |
||
1359 | */ |
||
1360 | public function get_event_object() { |
||
1363 | |||
1364 | |||
1365 | |||
1366 | /* * ************ */ |
||
1367 | /** METABOXES * */ |
||
1368 | |||
1369 | /** |
||
1370 | * _register_event_editor_meta_boxes |
||
1371 | * add all metaboxes related to the event_editor |
||
1372 | * |
||
1373 | * @return void |
||
1374 | */ |
||
1375 | protected function _register_event_editor_meta_boxes() { |
||
1376 | $this->verify_cpt_object(); |
||
1377 | add_meta_box( |
||
1378 | 'espresso_event_editor_tickets', |
||
1379 | __( 'Event Datetime & Ticket', 'event_espresso' ), |
||
1380 | array( $this, 'ticket_metabox' ), |
||
1381 | $this->page_slug, |
||
1382 | 'normal', |
||
1383 | 'high' |
||
1384 | ); |
||
1385 | add_meta_box( |
||
1386 | 'espresso_event_editor_event_options', |
||
1387 | __( 'Event Registration Options', 'event_espresso' ), |
||
1388 | array( $this, 'registration_options_meta_box' ), |
||
1389 | $this->page_slug, |
||
1390 | 'side', |
||
1391 | 'default' |
||
1392 | ); |
||
1393 | // NOTE: if you're looking for other metaboxes in here, |
||
1394 | // where a metabox has a related management page in the admin |
||
1395 | // you will find it setup in the related management page's "_Hooks" file. |
||
1396 | // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
||
1397 | } |
||
1398 | |||
1399 | |||
1400 | |||
1401 | |||
1402 | public function ticket_metabox() { |
||
1403 | $existing_datetime_ids = $existing_ticket_ids = array(); |
||
1404 | //defaults for template args |
||
1405 | $template_args = array( |
||
1406 | 'existing_datetime_ids' => '', |
||
1407 | 'event_datetime_help_link' => '', |
||
1408 | 'ticket_options_help_link' => '', |
||
1409 | 'time' => null, |
||
1410 | 'ticket_rows' => '', |
||
1411 | 'existing_ticket_ids' => '', |
||
1412 | 'total_ticket_rows' => 1, |
||
1413 | 'ticket_js_structure' => '', |
||
1414 | 'trash_icon' => 'ee-lock-icon', |
||
1415 | 'disabled' => '' |
||
1416 | ); |
||
1417 | |||
1418 | $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL; |
||
1419 | |||
1420 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
||
1421 | |||
1422 | /** |
||
1423 | * 1. Start with retrieving Datetimes |
||
1424 | * 2. Fore each datetime get related tickets |
||
1425 | * 3. For each ticket get related prices |
||
1426 | */ |
||
1427 | $times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id ); |
||
1428 | EE_Registry::instance()->load_helper('DTT_Helper' ); |
||
1429 | /** @type EE_Datetime $first_datetime */ |
||
1430 | $first_datetime = array_slice( $times, 0, 1 ); |
||
1431 | //do we get related tickets? |
||
1432 | if ( $first_datetime[ 0 ]->get( 'DTT_ID' ) !== 0 ) { |
||
1433 | foreach ( $times as $time ) { |
||
1434 | if ( $time instanceof EE_Datetime ) { |
||
1435 | $existing_datetime_ids[] = $time->get('DTT_ID'); |
||
1436 | $template_args['time'] = $time; |
||
1437 | $related_tickets = $time->tickets( |
||
1438 | array( |
||
1439 | array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
||
1440 | 'default_where_conditions' => 'none' |
||
1441 | ) |
||
1442 | ); |
||
1443 | |||
1444 | if ( !empty($related_tickets) ) { |
||
1445 | $template_args['total_ticket_rows'] = count($related_tickets); |
||
1446 | $row = 0; |
||
1447 | foreach ( $related_tickets as $ticket ) { |
||
1448 | $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
||
1449 | $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row ); |
||
1450 | |||
1451 | $row++; |
||
1452 | } |
||
1453 | View Code Duplication | } else { |
|
1454 | $template_args['total_ticket_rows'] = 1; |
||
1455 | /** @type EE_Ticket $ticket */ |
||
1456 | $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
||
1457 | $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
||
1458 | } |
||
1459 | } |
||
1460 | } |
||
1461 | View Code Duplication | } else { |
|
1462 | $template_args['time'] = $times[0]; |
||
1463 | /** @type EE_Ticket $ticket */ |
||
1464 | $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
||
1465 | $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
||
1466 | // NOTE: we're just sending the first default row |
||
1467 | // (decaf can't manage default tickets so this should be sufficient); |
||
1468 | } |
||
1469 | |||
1470 | $template_args['event_datetime_help_link'] = $this->_get_help_tab_link('event_editor_event_datetimes_help_tab'); |
||
1471 | $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
||
1472 | $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
||
1473 | $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
||
1474 | $template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE ); |
||
1475 | $template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' ); |
||
1476 | EEH_Template::display_template($template, $template_args); |
||
1477 | } |
||
1478 | |||
1479 | |||
1480 | |||
1481 | /** |
||
1482 | * Setup an individual ticket form for the decaf event editor page |
||
1483 | * |
||
1484 | * @access private |
||
1485 | * @param EE_Ticket $ticket the ticket object |
||
1486 | * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
||
1487 | * @param int $row |
||
1488 | * @return string generated html for the ticket row. |
||
1489 | */ |
||
1490 | private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) { |
||
1491 | $template_args = array( |
||
1492 | 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
||
1493 | 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '', |
||
1494 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
||
1495 | 'TKT_ID' => $ticket->get('TKT_ID'), |
||
1496 | 'TKT_name' => $ticket->get('TKT_name'), |
||
1497 | 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
||
1498 | 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
||
1499 | 'TKT_is_default' => $ticket->get('TKT_is_default'), |
||
1500 | 'TKT_qty' => $ticket->get_pretty('TKT_qty','input'), |
||
1501 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
||
1502 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
||
1503 | 'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
||
1504 | 'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled' |
||
1505 | ); |
||
1506 | |||
1507 | $price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object(); |
||
1508 | |||
1509 | |||
1510 | $price_args = array( |
||
1511 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
||
1512 | 'PRC_amount' => $price->get('PRC_amount'), |
||
1513 | 'PRT_ID' => $price->get('PRT_ID'), |
||
1514 | 'PRC_ID' => $price->get('PRC_ID'), |
||
1515 | 'PRC_is_default' => $price->get('PRC_is_default'), |
||
1516 | ); |
||
1517 | |||
1518 | //make sure we have default start and end dates if skeleton |
||
1519 | //handle rows that should NOT be empty |
||
1520 | if ( empty( $template_args['TKT_start_date'] ) ) { |
||
1521 | //if empty then the start date will be now. |
||
1522 | $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
||
1523 | } |
||
1524 | |||
1525 | if ( empty( $template_args['TKT_end_date'] ) ) { |
||
1526 | //get the earliest datetime (if present); |
||
1527 | $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
||
1528 | |||
1529 | if ( !empty( $earliest_dtt ) ) |
||
1530 | $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
||
1531 | else |
||
1532 | $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
||
1533 | } |
||
1534 | |||
1535 | $template_args = array_merge( $template_args, $price_args ); |
||
1536 | $template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket); |
||
1537 | return EEH_Template::display_template($template, $template_args, TRUE); |
||
1538 | } |
||
1539 | |||
1540 | |||
1541 | |||
1542 | public function registration_options_meta_box() { |
||
1543 | |||
1544 | $yes_no_values = array( |
||
1545 | array('id' => true, 'text' => __('Yes', 'event_espresso')), |
||
1546 | array('id' => false, 'text' => __('No', 'event_espresso')) |
||
1547 | ); |
||
1548 | |||
1549 | $default_reg_status_values = EEM_Registration::reg_status_array( |
||
1550 | array( |
||
1551 | EEM_Registration::status_id_cancelled, |
||
1552 | EEM_Registration::status_id_declined, |
||
1553 | EEM_Registration::status_id_incomplete |
||
1554 | ), |
||
1555 | TRUE |
||
1556 | ); |
||
1557 | |||
1558 | //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
||
1559 | $template_args['_event'] = $this->_cpt_model_obj; |
||
1560 | $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(FALSE); |
||
1561 | $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
||
1562 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
||
1563 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
||
1564 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
||
1565 | $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
||
1566 | $templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php'; |
||
1567 | EEH_Template::display_template($templatepath, $template_args); |
||
1568 | } |
||
1569 | |||
1570 | |||
1571 | |||
1572 | /** end metaboxes * */ |
||
1573 | /* * **************** * |
||
1574 | |||
1575 | |||
1576 | |||
1577 | |||
1578 | /** |
||
1579 | * _get_events() |
||
1580 | * This method simply returns all the events (for the given _view and paging) |
||
1581 | * |
||
1582 | * @access public |
||
1583 | * |
||
1584 | * @param int $per_page count of items per page (20 default); |
||
1585 | * @param int $current_page what is the current page being viewed. |
||
1586 | * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. If FALSE then we return an array of event objects that match the given _view and paging parameters. |
||
1587 | * @return array an array of event objects. |
||
1588 | */ |
||
1589 | public function get_events($per_page = 10, $current_page = 1, $count = FALSE) { |
||
1715 | |||
1716 | |||
1717 | |||
1718 | |||
1719 | //handling for WordPress CPT actions (trash, restore, delete) |
||
1720 | public function trash_cpt_item( $post_id ) { |
||
1724 | |||
1725 | |||
1726 | |||
1727 | |||
1728 | public function restore_cpt_item( $post_id ) { |
||
1732 | |||
1733 | |||
1734 | public function delete_cpt_item( $post_id ) { |
||
1738 | |||
1739 | |||
1740 | |||
1741 | /** |
||
1742 | * _trash_or_restore_event |
||
1743 | * |
||
1744 | * @access protected |
||
1745 | * @param string $event_status |
||
1746 | * @return void |
||
1747 | */ |
||
1748 | View Code Duplication | protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) { |
|
1749 | //determine the event id and set to array. |
||
1750 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE; |
||
1751 | // loop thru events |
||
1752 | if ($EVT_ID) { |
||
1753 | // clean status |
||
1754 | $event_status = sanitize_key($event_status); |
||
1755 | // grab status |
||
1756 | if (!empty($event_status)) { |
||
1757 | $success = $this->_change_event_status($EVT_ID, $event_status); |
||
1758 | } else { |
||
1759 | $success = FALSE; |
||
1760 | $msg = __('An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', 'event_espresso'); |
||
1761 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
||
1773 | |||
1774 | /** |
||
1775 | * _trash_or_restore_events |
||
1776 | * |
||
1777 | * @access protected |
||
1778 | * @param string $event_status |
||
1779 | * @return void |
||
1780 | */ |
||
1781 | View Code Duplication | protected function _trash_or_restore_events($event_status = 'trash') { |
|
1811 | |||
1812 | /** |
||
1813 | * _trash_or_restore_events |
||
1814 | * |
||
1815 | * @access private |
||
1816 | * @param int $EVT_ID |
||
1817 | * @param string $event_status |
||
1818 | * @return bool |
||
1819 | */ |
||
1820 | View Code Duplication | private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
1867 | |||
1868 | |||
1869 | |||
1870 | /** |
||
1871 | * _delete_event |
||
1872 | * |
||
1873 | * @access protected |
||
1874 | * @param bool $redirect_after |
||
1875 | */ |
||
1876 | protected function _delete_event( $redirect_after = TRUE ) { |
||
1901 | |||
1902 | /** |
||
1903 | * _delete_events |
||
1904 | * |
||
1905 | * @access protected |
||
1906 | * @return void |
||
1907 | */ |
||
1908 | protected function _delete_events() { |
||
1933 | |||
1934 | /** |
||
1935 | * _permanently_delete_event |
||
1936 | * |
||
1937 | * @access private |
||
1938 | * @param int $EVT_ID |
||
1939 | * @return bool |
||
1940 | */ |
||
1941 | private function _permanently_delete_event( $EVT_ID = 0 ) { |
||
2003 | |||
2004 | |||
2005 | |||
2006 | |||
2007 | |||
2008 | |||
2009 | /** |
||
2010 | * get total number of events |
||
2011 | * |
||
2012 | * @access public |
||
2013 | * @return int |
||
2014 | */ |
||
2015 | public function total_events() { |
||
2020 | |||
2021 | |||
2022 | |||
2023 | |||
2024 | /** |
||
2025 | * get total number of draft events |
||
2026 | * |
||
2027 | * @access public |
||
2028 | * @return int |
||
2029 | */ |
||
2030 | public function total_events_draft() { |
||
2038 | |||
2039 | |||
2040 | |||
2041 | |||
2042 | |||
2043 | /** |
||
2044 | * get total number of trashed events |
||
2045 | * |
||
2046 | * @access public |
||
2047 | * @return int |
||
2048 | */ |
||
2049 | public function total_trashed_events() { |
||
2057 | |||
2058 | |||
2059 | |||
2060 | |||
2061 | /** |
||
2062 | * _default_event_settings |
||
2063 | * |
||
2064 | * This generates the Default Settings Tab |
||
2065 | * |
||
2066 | * @return string html for the settings page |
||
2067 | */ |
||
2068 | protected function _default_event_settings() { |
||
2089 | |||
2090 | /** |
||
2091 | * _update_default_event_settings |
||
2092 | * @access protected |
||
2093 | * @return array |
||
2094 | */ |
||
2095 | protected function _update_default_event_settings() { |
||
2103 | |||
2104 | |||
2105 | |||
2106 | |||
2107 | /************* Templates *************/ |
||
2108 | |||
2109 | |||
2110 | protected function _template_settings() { |
||
2116 | |||
2117 | |||
2118 | /** Event Category Stuff **/ |
||
2119 | |||
2120 | /** |
||
2121 | * set the _category property with the category object for the loaded page. |
||
2122 | * |
||
2123 | * @access private |
||
2124 | * @return void |
||
2125 | */ |
||
2126 | View Code Duplication | private function _set_category_object() { |
|
2150 | |||
2151 | |||
2152 | |||
2153 | |||
2154 | private function _set_empty_category_object() { |
||
2159 | |||
2160 | |||
2161 | View Code Duplication | protected function _category_list_table() { |
|
2167 | |||
2168 | |||
2169 | View Code Duplication | protected function _category_details($view) { |
|
2193 | |||
2194 | |||
2195 | |||
2196 | View Code Duplication | protected function _category_details_content() { |
|
2232 | |||
2233 | |||
2234 | View Code Duplication | protected function _delete_categories() { |
|
2248 | |||
2249 | |||
2250 | |||
2251 | |||
2252 | |||
2253 | protected function _delete_category($cat_id) { |
||
2258 | |||
2259 | |||
2260 | |||
2261 | View Code Duplication | protected function _insert_or_update_category($new_category) { |
|
2277 | |||
2278 | |||
2279 | |||
2280 | private function _insert_category( $update = FALSE ) { |
||
2314 | |||
2315 | |||
2316 | |||
2317 | |||
2318 | View Code Duplication | public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
2347 | |||
2348 | |||
2349 | |||
2350 | /* end category stuff */ |
||
2351 | /**************/ |
||
2352 | |||
2353 | } |
||
2354 | //end class Events_Admin_Page |
||
2355 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..