@@ -27,58 +27,58 @@ |
||
27 | 27 | class RestApiSpoofer |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * @var Read |
|
32 | - */ |
|
33 | - protected $rest_api; |
|
30 | + /** |
|
31 | + * @var Read |
|
32 | + */ |
|
33 | + protected $rest_api; |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * RestApiSpoofer constructor. |
|
38 | - * |
|
39 | - * @param Read $rest_api |
|
40 | - * @param string $api_version |
|
41 | - */ |
|
42 | - public function __construct(Read $rest_api, $api_version = '4.8.36') |
|
43 | - { |
|
44 | - $this->rest_api = $rest_api; |
|
45 | - $this->rest_api->setRequestedVersion($api_version); |
|
46 | - } |
|
36 | + /** |
|
37 | + * RestApiSpoofer constructor. |
|
38 | + * |
|
39 | + * @param Read $rest_api |
|
40 | + * @param string $api_version |
|
41 | + */ |
|
42 | + public function __construct(Read $rest_api, $api_version = '4.8.36') |
|
43 | + { |
|
44 | + $this->rest_api = $rest_api; |
|
45 | + $this->rest_api->setRequestedVersion($api_version); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * @param EEM_Base $model |
|
51 | - * @param array $query_params |
|
52 | - * @param string $include |
|
53 | - * @return array |
|
54 | - * @throws EE_Error |
|
55 | - * @throws InvalidArgumentException |
|
56 | - * @throws InvalidDataTypeException |
|
57 | - * @throws InvalidInterfaceException |
|
58 | - * @throws ModelConfigurationException |
|
59 | - * @throws ReflectionException |
|
60 | - * @throws RestException |
|
61 | - * @throws RestPasswordIncorrectException |
|
62 | - * @throws RestPasswordRequiredException |
|
63 | - * @throws UnexpectedEntityException |
|
64 | - * @since $VID:$ |
|
65 | - */ |
|
66 | - public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
|
67 | - { |
|
68 | - /** @type array $results */ |
|
69 | - $results = $model->get_all_wpdb_results($query_params); |
|
70 | - $rest_request = new WP_REST_Request(); |
|
71 | - $rest_request->set_param('include', $include); |
|
72 | - $rest_request->set_param('caps', 'edit'); |
|
73 | - $nice_results = array(); |
|
74 | - foreach ($results as $result) { |
|
75 | - $nice_results[] = $this->rest_api->createEntityFromWpdbResult( |
|
76 | - $model, |
|
77 | - $result, |
|
78 | - $rest_request |
|
79 | - ); |
|
80 | - } |
|
81 | - return $nice_results; |
|
82 | - } |
|
49 | + /** |
|
50 | + * @param EEM_Base $model |
|
51 | + * @param array $query_params |
|
52 | + * @param string $include |
|
53 | + * @return array |
|
54 | + * @throws EE_Error |
|
55 | + * @throws InvalidArgumentException |
|
56 | + * @throws InvalidDataTypeException |
|
57 | + * @throws InvalidInterfaceException |
|
58 | + * @throws ModelConfigurationException |
|
59 | + * @throws ReflectionException |
|
60 | + * @throws RestException |
|
61 | + * @throws RestPasswordIncorrectException |
|
62 | + * @throws RestPasswordRequiredException |
|
63 | + * @throws UnexpectedEntityException |
|
64 | + * @since $VID:$ |
|
65 | + */ |
|
66 | + public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
|
67 | + { |
|
68 | + /** @type array $results */ |
|
69 | + $results = $model->get_all_wpdb_results($query_params); |
|
70 | + $rest_request = new WP_REST_Request(); |
|
71 | + $rest_request->set_param('include', $include); |
|
72 | + $rest_request->set_param('caps', 'edit'); |
|
73 | + $nice_results = array(); |
|
74 | + foreach ($results as $result) { |
|
75 | + $nice_results[] = $this->rest_api->createEntityFromWpdbResult( |
|
76 | + $model, |
|
77 | + $result, |
|
78 | + $rest_request |
|
79 | + ); |
|
80 | + } |
|
81 | + return $nice_results; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | \ No newline at end of file |
@@ -31,85 +31,85 @@ |
||
31 | 31 | class EventEditorDataResolver extends ResolverBase |
32 | 32 | { |
33 | 33 | |
34 | - /** |
|
35 | - * @var EEM_Datetime $datetime_model |
|
36 | - */ |
|
37 | - protected $datetime_model; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var RestApiSpoofer $converter |
|
41 | - */ |
|
42 | - protected $spoofer; |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * EventEditorEntities constructor. |
|
47 | - * |
|
48 | - * @param EEM_Datetime $datetime_model |
|
49 | - * @param RestApiSpoofer $spoofer |
|
50 | - */ |
|
51 | - public function __construct(EEM_Datetime $datetime_model, RestApiSpoofer $spoofer) |
|
52 | - { |
|
53 | - $this->datetime_model = $datetime_model; |
|
54 | - $this->spoofer = $spoofer; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @return string |
|
60 | - * @since $VID:$ |
|
61 | - */ |
|
62 | - public function query() |
|
63 | - { |
|
64 | - return 'Event'; |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * @return string |
|
70 | - * @since $VID:$ |
|
71 | - */ |
|
72 | - public function field() |
|
73 | - { |
|
74 | - return 'eventDates'; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @return string |
|
80 | - * @since $VID:$ |
|
81 | - */ |
|
82 | - public function type() |
|
83 | - { |
|
84 | - return 'String'; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @param Post $post |
|
90 | - * @param array $args |
|
91 | - * @param AppContext $context |
|
92 | - * @param ResolveInfo $info |
|
93 | - * @return string |
|
94 | - * @throws EE_Error |
|
95 | - * @throws InvalidArgumentException |
|
96 | - * @throws InvalidDataTypeException |
|
97 | - * @throws InvalidInterfaceException |
|
98 | - * @throws ReflectionException |
|
99 | - * @throws ModelConfigurationException |
|
100 | - * @throws RestPasswordIncorrectException |
|
101 | - * @throws RestPasswordRequiredException |
|
102 | - * @throws UnexpectedEntityException |
|
103 | - * @throws RestException |
|
104 | - * @since $VID:$ |
|
105 | - */ |
|
106 | - public function resolve($post, array $args, AppContext $context, ResolveInfo $info) |
|
107 | - { |
|
108 | - return $post instanceof Post |
|
109 | - ? wp_json_encode($this->spoofer->getApiResults( |
|
110 | - $this->datetime_model, |
|
111 | - [['EVT_ID' => $post->ID]] |
|
112 | - )) |
|
113 | - : '[]'; |
|
114 | - } |
|
34 | + /** |
|
35 | + * @var EEM_Datetime $datetime_model |
|
36 | + */ |
|
37 | + protected $datetime_model; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var RestApiSpoofer $converter |
|
41 | + */ |
|
42 | + protected $spoofer; |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * EventEditorEntities constructor. |
|
47 | + * |
|
48 | + * @param EEM_Datetime $datetime_model |
|
49 | + * @param RestApiSpoofer $spoofer |
|
50 | + */ |
|
51 | + public function __construct(EEM_Datetime $datetime_model, RestApiSpoofer $spoofer) |
|
52 | + { |
|
53 | + $this->datetime_model = $datetime_model; |
|
54 | + $this->spoofer = $spoofer; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @return string |
|
60 | + * @since $VID:$ |
|
61 | + */ |
|
62 | + public function query() |
|
63 | + { |
|
64 | + return 'Event'; |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * @return string |
|
70 | + * @since $VID:$ |
|
71 | + */ |
|
72 | + public function field() |
|
73 | + { |
|
74 | + return 'eventDates'; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @return string |
|
80 | + * @since $VID:$ |
|
81 | + */ |
|
82 | + public function type() |
|
83 | + { |
|
84 | + return 'String'; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @param Post $post |
|
90 | + * @param array $args |
|
91 | + * @param AppContext $context |
|
92 | + * @param ResolveInfo $info |
|
93 | + * @return string |
|
94 | + * @throws EE_Error |
|
95 | + * @throws InvalidArgumentException |
|
96 | + * @throws InvalidDataTypeException |
|
97 | + * @throws InvalidInterfaceException |
|
98 | + * @throws ReflectionException |
|
99 | + * @throws ModelConfigurationException |
|
100 | + * @throws RestPasswordIncorrectException |
|
101 | + * @throws RestPasswordRequiredException |
|
102 | + * @throws UnexpectedEntityException |
|
103 | + * @throws RestException |
|
104 | + * @since $VID:$ |
|
105 | + */ |
|
106 | + public function resolve($post, array $args, AppContext $context, ResolveInfo $info) |
|
107 | + { |
|
108 | + return $post instanceof Post |
|
109 | + ? wp_json_encode($this->spoofer->getApiResults( |
|
110 | + $this->datetime_model, |
|
111 | + [['EVT_ID' => $post->ID]] |
|
112 | + )) |
|
113 | + : '[]'; |
|
114 | + } |
|
115 | 115 | } |
116 | 116 | \ No newline at end of file |
@@ -15,1374 +15,1374 @@ |
||
15 | 15 | class Extend_Events_Admin_Page extends Events_Admin_Page |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var EE_Admin_Config |
|
20 | - */ |
|
21 | - protected $admin_config; |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * Extend_Events_Admin_Page constructor. |
|
26 | - * |
|
27 | - * @param bool $routing |
|
28 | - */ |
|
29 | - public function __construct($routing = true) |
|
30 | - { |
|
31 | - parent::__construct($routing); |
|
32 | - if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
33 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
34 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
35 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
36 | - } |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * Sets routes. |
|
42 | - */ |
|
43 | - protected function _extend_page_config() |
|
44 | - { |
|
45 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
46 | - // is there a evt_id in the request? |
|
47 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
48 | - ? $this->_req_data['EVT_ID'] |
|
49 | - : 0; |
|
50 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
51 | - // tkt_id? |
|
52 | - $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) |
|
53 | - ? $this->_req_data['TKT_ID'] |
|
54 | - : 0; |
|
55 | - $new_page_routes = array( |
|
56 | - 'duplicate_event' => array( |
|
57 | - 'func' => '_duplicate_event', |
|
58 | - 'capability' => 'ee_edit_event', |
|
59 | - 'obj_id' => $evt_id, |
|
60 | - 'noheader' => true, |
|
61 | - ), |
|
62 | - 'ticket_list_table' => array( |
|
63 | - 'func' => '_tickets_overview_list_table', |
|
64 | - 'capability' => 'ee_read_default_tickets', |
|
65 | - ), |
|
66 | - 'trash_ticket' => array( |
|
67 | - 'func' => '_trash_or_restore_ticket', |
|
68 | - 'capability' => 'ee_delete_default_ticket', |
|
69 | - 'obj_id' => $tkt_id, |
|
70 | - 'noheader' => true, |
|
71 | - 'args' => array('trash' => true), |
|
72 | - ), |
|
73 | - 'trash_tickets' => array( |
|
74 | - 'func' => '_trash_or_restore_ticket', |
|
75 | - 'capability' => 'ee_delete_default_tickets', |
|
76 | - 'noheader' => true, |
|
77 | - 'args' => array('trash' => true), |
|
78 | - ), |
|
79 | - 'restore_ticket' => array( |
|
80 | - 'func' => '_trash_or_restore_ticket', |
|
81 | - 'capability' => 'ee_delete_default_ticket', |
|
82 | - 'obj_id' => $tkt_id, |
|
83 | - 'noheader' => true, |
|
84 | - ), |
|
85 | - 'restore_tickets' => array( |
|
86 | - 'func' => '_trash_or_restore_ticket', |
|
87 | - 'capability' => 'ee_delete_default_tickets', |
|
88 | - 'noheader' => true, |
|
89 | - ), |
|
90 | - 'delete_ticket' => array( |
|
91 | - 'func' => '_delete_ticket', |
|
92 | - 'capability' => 'ee_delete_default_ticket', |
|
93 | - 'obj_id' => $tkt_id, |
|
94 | - 'noheader' => true, |
|
95 | - ), |
|
96 | - 'delete_tickets' => array( |
|
97 | - 'func' => '_delete_ticket', |
|
98 | - 'capability' => 'ee_delete_default_tickets', |
|
99 | - 'noheader' => true, |
|
100 | - ), |
|
101 | - 'import_page' => array( |
|
102 | - 'func' => '_import_page', |
|
103 | - 'capability' => 'import', |
|
104 | - ), |
|
105 | - 'import' => array( |
|
106 | - 'func' => '_import_events', |
|
107 | - 'capability' => 'import', |
|
108 | - 'noheader' => true, |
|
109 | - ), |
|
110 | - 'import_events' => array( |
|
111 | - 'func' => '_import_events', |
|
112 | - 'capability' => 'import', |
|
113 | - 'noheader' => true, |
|
114 | - ), |
|
115 | - 'export_events' => array( |
|
116 | - 'func' => '_events_export', |
|
117 | - 'capability' => 'export', |
|
118 | - 'noheader' => true, |
|
119 | - ), |
|
120 | - 'export_categories' => array( |
|
121 | - 'func' => '_categories_export', |
|
122 | - 'capability' => 'export', |
|
123 | - 'noheader' => true, |
|
124 | - ), |
|
125 | - 'sample_export_file' => array( |
|
126 | - 'func' => '_sample_export_file', |
|
127 | - 'capability' => 'export', |
|
128 | - 'noheader' => true, |
|
129 | - ), |
|
130 | - 'update_template_settings' => array( |
|
131 | - 'func' => '_update_template_settings', |
|
132 | - 'capability' => 'manage_options', |
|
133 | - 'noheader' => true, |
|
134 | - ), |
|
135 | - ); |
|
136 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
137 | - // partial route/config override |
|
138 | - $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
139 | - $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
140 | - $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
141 | - $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
142 | - $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
143 | - $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
144 | - // add tickets tab but only if there are more than one default ticket! |
|
145 | - $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
146 | - array(array('TKT_is_default' => 1)), |
|
147 | - 'TKT_ID', |
|
148 | - true |
|
149 | - ); |
|
150 | - if ($tkt_count > 1) { |
|
151 | - $new_page_config = array( |
|
152 | - 'ticket_list_table' => array( |
|
153 | - 'nav' => array( |
|
154 | - 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
155 | - 'order' => 60, |
|
156 | - ), |
|
157 | - 'list_table' => 'Tickets_List_Table', |
|
158 | - 'require_nonce' => false, |
|
159 | - ), |
|
160 | - ); |
|
161 | - } |
|
162 | - // template settings |
|
163 | - $new_page_config['template_settings'] = array( |
|
164 | - 'nav' => array( |
|
165 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
166 | - 'order' => 30, |
|
167 | - ), |
|
168 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
169 | - 'help_tabs' => array( |
|
170 | - 'general_settings_templates_help_tab' => array( |
|
171 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
172 | - 'filename' => 'general_settings_templates', |
|
173 | - ), |
|
174 | - ), |
|
175 | - 'help_tour' => array('Templates_Help_Tour'), |
|
176 | - 'require_nonce' => false, |
|
177 | - ); |
|
178 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
179 | - // add filters and actions |
|
180 | - // modifying _views |
|
181 | - add_filter( |
|
182 | - 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
183 | - array($this, 'add_additional_datetime_button'), |
|
184 | - 10, |
|
185 | - 2 |
|
186 | - ); |
|
187 | - add_filter( |
|
188 | - 'FHEE_event_datetime_metabox_clone_button_template', |
|
189 | - array($this, 'add_datetime_clone_button'), |
|
190 | - 10, |
|
191 | - 2 |
|
192 | - ); |
|
193 | - add_filter( |
|
194 | - 'FHEE_event_datetime_metabox_timezones_template', |
|
195 | - array($this, 'datetime_timezones_template'), |
|
196 | - 10, |
|
197 | - 2 |
|
198 | - ); |
|
199 | - // filters for event list table |
|
200 | - add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
201 | - add_filter( |
|
202 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
203 | - array($this, 'extra_list_table_actions'), |
|
204 | - 10, |
|
205 | - 2 |
|
206 | - ); |
|
207 | - // legend item |
|
208 | - add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
209 | - add_action('admin_init', array($this, 'admin_init')); |
|
210 | - $this->admin_config = EE_Registry::instance()->CFG->admin; |
|
211 | - add_filter( |
|
212 | - 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections', |
|
213 | - [$this, 'advancedEditorAdminFormSection'] |
|
214 | - ); |
|
215 | - add_action( |
|
216 | - 'AHEE__Events_Admin_Page___update_default_event_settings', |
|
217 | - [$this, 'updateAdvancedEditorAdminFormSettings'], |
|
218 | - 10, |
|
219 | - 2 |
|
220 | - ); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * admin_init |
|
226 | - */ |
|
227 | - public function admin_init() |
|
228 | - { |
|
229 | - EE_Registry::$i18n_js_strings = array_merge( |
|
230 | - EE_Registry::$i18n_js_strings, |
|
231 | - array( |
|
232 | - 'image_confirm' => esc_html__( |
|
233 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
234 | - 'event_espresso' |
|
235 | - ), |
|
236 | - 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
237 | - 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
238 | - 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
239 | - 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
240 | - 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
241 | - ) |
|
242 | - ); |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * Add per page screen options to the default ticket list table view. |
|
248 | - */ |
|
249 | - protected function _add_screen_options_ticket_list_table() |
|
250 | - { |
|
251 | - $this->_per_page_screen_option(); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * @param string $return |
|
257 | - * @param int $id |
|
258 | - * @param string $new_title |
|
259 | - * @param string $new_slug |
|
260 | - * @return string |
|
261 | - */ |
|
262 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
263 | - { |
|
264 | - $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
265 | - // make sure this is only when editing |
|
266 | - if (! empty($id)) { |
|
267 | - $href = EE_Admin_Page::add_query_args_and_nonce( |
|
268 | - array('action' => 'duplicate_event', 'EVT_ID' => $id), |
|
269 | - $this->_admin_base_url |
|
270 | - ); |
|
271 | - $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
272 | - $return .= '<a href="' |
|
273 | - . $href |
|
274 | - . '" title="' |
|
275 | - . $title |
|
276 | - . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
277 | - . $title |
|
278 | - . '</a>'; |
|
279 | - } |
|
280 | - return $return; |
|
281 | - } |
|
282 | - |
|
283 | - |
|
284 | - /** |
|
285 | - * Set the list table views for the default ticket list table view. |
|
286 | - */ |
|
287 | - public function _set_list_table_views_ticket_list_table() |
|
288 | - { |
|
289 | - $this->_views = array( |
|
290 | - 'all' => array( |
|
291 | - 'slug' => 'all', |
|
292 | - 'label' => esc_html__('All', 'event_espresso'), |
|
293 | - 'count' => 0, |
|
294 | - 'bulk_action' => array( |
|
295 | - 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
296 | - ), |
|
297 | - ), |
|
298 | - 'trashed' => array( |
|
299 | - 'slug' => 'trashed', |
|
300 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
301 | - 'count' => 0, |
|
302 | - 'bulk_action' => array( |
|
303 | - 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
304 | - 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
305 | - ), |
|
306 | - ), |
|
307 | - ); |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * Enqueue scripts and styles for the event editor. |
|
313 | - */ |
|
314 | - public function load_scripts_styles_edit() |
|
315 | - { |
|
316 | - wp_register_script( |
|
317 | - 'ee-event-editor-heartbeat', |
|
318 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
319 | - array('ee_admin_js', 'heartbeat'), |
|
320 | - EVENT_ESPRESSO_VERSION, |
|
321 | - true |
|
322 | - ); |
|
323 | - wp_enqueue_script('ee-accounting'); |
|
324 | - // styles |
|
325 | - wp_enqueue_style('espresso-ui-theme'); |
|
326 | - wp_enqueue_script('event_editor_js'); |
|
327 | - wp_enqueue_script('ee-event-editor-heartbeat'); |
|
328 | - if ($this->admin_config->useAdvancedEditor()) { |
|
329 | - add_action( |
|
330 | - 'admin_footer', |
|
331 | - function () { |
|
332 | - $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
333 | - $graphqlEndpoint = class_exists( 'WPGraphQL' ) ? trailingslashit( site_url() ) . \WPGraphQL\Router::$route : ''; |
|
334 | - if ($eventId) { |
|
335 | - echo ' |
|
18 | + /** |
|
19 | + * @var EE_Admin_Config |
|
20 | + */ |
|
21 | + protected $admin_config; |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * Extend_Events_Admin_Page constructor. |
|
26 | + * |
|
27 | + * @param bool $routing |
|
28 | + */ |
|
29 | + public function __construct($routing = true) |
|
30 | + { |
|
31 | + parent::__construct($routing); |
|
32 | + if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
33 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
34 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
35 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
36 | + } |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * Sets routes. |
|
42 | + */ |
|
43 | + protected function _extend_page_config() |
|
44 | + { |
|
45 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
46 | + // is there a evt_id in the request? |
|
47 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
48 | + ? $this->_req_data['EVT_ID'] |
|
49 | + : 0; |
|
50 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
51 | + // tkt_id? |
|
52 | + $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) |
|
53 | + ? $this->_req_data['TKT_ID'] |
|
54 | + : 0; |
|
55 | + $new_page_routes = array( |
|
56 | + 'duplicate_event' => array( |
|
57 | + 'func' => '_duplicate_event', |
|
58 | + 'capability' => 'ee_edit_event', |
|
59 | + 'obj_id' => $evt_id, |
|
60 | + 'noheader' => true, |
|
61 | + ), |
|
62 | + 'ticket_list_table' => array( |
|
63 | + 'func' => '_tickets_overview_list_table', |
|
64 | + 'capability' => 'ee_read_default_tickets', |
|
65 | + ), |
|
66 | + 'trash_ticket' => array( |
|
67 | + 'func' => '_trash_or_restore_ticket', |
|
68 | + 'capability' => 'ee_delete_default_ticket', |
|
69 | + 'obj_id' => $tkt_id, |
|
70 | + 'noheader' => true, |
|
71 | + 'args' => array('trash' => true), |
|
72 | + ), |
|
73 | + 'trash_tickets' => array( |
|
74 | + 'func' => '_trash_or_restore_ticket', |
|
75 | + 'capability' => 'ee_delete_default_tickets', |
|
76 | + 'noheader' => true, |
|
77 | + 'args' => array('trash' => true), |
|
78 | + ), |
|
79 | + 'restore_ticket' => array( |
|
80 | + 'func' => '_trash_or_restore_ticket', |
|
81 | + 'capability' => 'ee_delete_default_ticket', |
|
82 | + 'obj_id' => $tkt_id, |
|
83 | + 'noheader' => true, |
|
84 | + ), |
|
85 | + 'restore_tickets' => array( |
|
86 | + 'func' => '_trash_or_restore_ticket', |
|
87 | + 'capability' => 'ee_delete_default_tickets', |
|
88 | + 'noheader' => true, |
|
89 | + ), |
|
90 | + 'delete_ticket' => array( |
|
91 | + 'func' => '_delete_ticket', |
|
92 | + 'capability' => 'ee_delete_default_ticket', |
|
93 | + 'obj_id' => $tkt_id, |
|
94 | + 'noheader' => true, |
|
95 | + ), |
|
96 | + 'delete_tickets' => array( |
|
97 | + 'func' => '_delete_ticket', |
|
98 | + 'capability' => 'ee_delete_default_tickets', |
|
99 | + 'noheader' => true, |
|
100 | + ), |
|
101 | + 'import_page' => array( |
|
102 | + 'func' => '_import_page', |
|
103 | + 'capability' => 'import', |
|
104 | + ), |
|
105 | + 'import' => array( |
|
106 | + 'func' => '_import_events', |
|
107 | + 'capability' => 'import', |
|
108 | + 'noheader' => true, |
|
109 | + ), |
|
110 | + 'import_events' => array( |
|
111 | + 'func' => '_import_events', |
|
112 | + 'capability' => 'import', |
|
113 | + 'noheader' => true, |
|
114 | + ), |
|
115 | + 'export_events' => array( |
|
116 | + 'func' => '_events_export', |
|
117 | + 'capability' => 'export', |
|
118 | + 'noheader' => true, |
|
119 | + ), |
|
120 | + 'export_categories' => array( |
|
121 | + 'func' => '_categories_export', |
|
122 | + 'capability' => 'export', |
|
123 | + 'noheader' => true, |
|
124 | + ), |
|
125 | + 'sample_export_file' => array( |
|
126 | + 'func' => '_sample_export_file', |
|
127 | + 'capability' => 'export', |
|
128 | + 'noheader' => true, |
|
129 | + ), |
|
130 | + 'update_template_settings' => array( |
|
131 | + 'func' => '_update_template_settings', |
|
132 | + 'capability' => 'manage_options', |
|
133 | + 'noheader' => true, |
|
134 | + ), |
|
135 | + ); |
|
136 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
137 | + // partial route/config override |
|
138 | + $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
139 | + $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
140 | + $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
141 | + $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
142 | + $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
143 | + $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
144 | + // add tickets tab but only if there are more than one default ticket! |
|
145 | + $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
146 | + array(array('TKT_is_default' => 1)), |
|
147 | + 'TKT_ID', |
|
148 | + true |
|
149 | + ); |
|
150 | + if ($tkt_count > 1) { |
|
151 | + $new_page_config = array( |
|
152 | + 'ticket_list_table' => array( |
|
153 | + 'nav' => array( |
|
154 | + 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
155 | + 'order' => 60, |
|
156 | + ), |
|
157 | + 'list_table' => 'Tickets_List_Table', |
|
158 | + 'require_nonce' => false, |
|
159 | + ), |
|
160 | + ); |
|
161 | + } |
|
162 | + // template settings |
|
163 | + $new_page_config['template_settings'] = array( |
|
164 | + 'nav' => array( |
|
165 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
166 | + 'order' => 30, |
|
167 | + ), |
|
168 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
169 | + 'help_tabs' => array( |
|
170 | + 'general_settings_templates_help_tab' => array( |
|
171 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
172 | + 'filename' => 'general_settings_templates', |
|
173 | + ), |
|
174 | + ), |
|
175 | + 'help_tour' => array('Templates_Help_Tour'), |
|
176 | + 'require_nonce' => false, |
|
177 | + ); |
|
178 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
179 | + // add filters and actions |
|
180 | + // modifying _views |
|
181 | + add_filter( |
|
182 | + 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
183 | + array($this, 'add_additional_datetime_button'), |
|
184 | + 10, |
|
185 | + 2 |
|
186 | + ); |
|
187 | + add_filter( |
|
188 | + 'FHEE_event_datetime_metabox_clone_button_template', |
|
189 | + array($this, 'add_datetime_clone_button'), |
|
190 | + 10, |
|
191 | + 2 |
|
192 | + ); |
|
193 | + add_filter( |
|
194 | + 'FHEE_event_datetime_metabox_timezones_template', |
|
195 | + array($this, 'datetime_timezones_template'), |
|
196 | + 10, |
|
197 | + 2 |
|
198 | + ); |
|
199 | + // filters for event list table |
|
200 | + add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
201 | + add_filter( |
|
202 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
203 | + array($this, 'extra_list_table_actions'), |
|
204 | + 10, |
|
205 | + 2 |
|
206 | + ); |
|
207 | + // legend item |
|
208 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
209 | + add_action('admin_init', array($this, 'admin_init')); |
|
210 | + $this->admin_config = EE_Registry::instance()->CFG->admin; |
|
211 | + add_filter( |
|
212 | + 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections', |
|
213 | + [$this, 'advancedEditorAdminFormSection'] |
|
214 | + ); |
|
215 | + add_action( |
|
216 | + 'AHEE__Events_Admin_Page___update_default_event_settings', |
|
217 | + [$this, 'updateAdvancedEditorAdminFormSettings'], |
|
218 | + 10, |
|
219 | + 2 |
|
220 | + ); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * admin_init |
|
226 | + */ |
|
227 | + public function admin_init() |
|
228 | + { |
|
229 | + EE_Registry::$i18n_js_strings = array_merge( |
|
230 | + EE_Registry::$i18n_js_strings, |
|
231 | + array( |
|
232 | + 'image_confirm' => esc_html__( |
|
233 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
234 | + 'event_espresso' |
|
235 | + ), |
|
236 | + 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
237 | + 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
238 | + 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
239 | + 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
240 | + 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
241 | + ) |
|
242 | + ); |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * Add per page screen options to the default ticket list table view. |
|
248 | + */ |
|
249 | + protected function _add_screen_options_ticket_list_table() |
|
250 | + { |
|
251 | + $this->_per_page_screen_option(); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * @param string $return |
|
257 | + * @param int $id |
|
258 | + * @param string $new_title |
|
259 | + * @param string $new_slug |
|
260 | + * @return string |
|
261 | + */ |
|
262 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
263 | + { |
|
264 | + $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
265 | + // make sure this is only when editing |
|
266 | + if (! empty($id)) { |
|
267 | + $href = EE_Admin_Page::add_query_args_and_nonce( |
|
268 | + array('action' => 'duplicate_event', 'EVT_ID' => $id), |
|
269 | + $this->_admin_base_url |
|
270 | + ); |
|
271 | + $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
272 | + $return .= '<a href="' |
|
273 | + . $href |
|
274 | + . '" title="' |
|
275 | + . $title |
|
276 | + . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
277 | + . $title |
|
278 | + . '</a>'; |
|
279 | + } |
|
280 | + return $return; |
|
281 | + } |
|
282 | + |
|
283 | + |
|
284 | + /** |
|
285 | + * Set the list table views for the default ticket list table view. |
|
286 | + */ |
|
287 | + public function _set_list_table_views_ticket_list_table() |
|
288 | + { |
|
289 | + $this->_views = array( |
|
290 | + 'all' => array( |
|
291 | + 'slug' => 'all', |
|
292 | + 'label' => esc_html__('All', 'event_espresso'), |
|
293 | + 'count' => 0, |
|
294 | + 'bulk_action' => array( |
|
295 | + 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
296 | + ), |
|
297 | + ), |
|
298 | + 'trashed' => array( |
|
299 | + 'slug' => 'trashed', |
|
300 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
301 | + 'count' => 0, |
|
302 | + 'bulk_action' => array( |
|
303 | + 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
304 | + 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
305 | + ), |
|
306 | + ), |
|
307 | + ); |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * Enqueue scripts and styles for the event editor. |
|
313 | + */ |
|
314 | + public function load_scripts_styles_edit() |
|
315 | + { |
|
316 | + wp_register_script( |
|
317 | + 'ee-event-editor-heartbeat', |
|
318 | + EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
319 | + array('ee_admin_js', 'heartbeat'), |
|
320 | + EVENT_ESPRESSO_VERSION, |
|
321 | + true |
|
322 | + ); |
|
323 | + wp_enqueue_script('ee-accounting'); |
|
324 | + // styles |
|
325 | + wp_enqueue_style('espresso-ui-theme'); |
|
326 | + wp_enqueue_script('event_editor_js'); |
|
327 | + wp_enqueue_script('ee-event-editor-heartbeat'); |
|
328 | + if ($this->admin_config->useAdvancedEditor()) { |
|
329 | + add_action( |
|
330 | + 'admin_footer', |
|
331 | + function () { |
|
332 | + $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
333 | + $graphqlEndpoint = class_exists( 'WPGraphQL' ) ? trailingslashit( site_url() ) . \WPGraphQL\Router::$route : ''; |
|
334 | + if ($eventId) { |
|
335 | + echo ' |
|
336 | 336 | <script type="text/javascript"> |
337 | 337 | /* <![CDATA[ */ |
338 | 338 | var eeEditorEventId = ' . $eventId . '; |
339 | 339 | var graphqlEndpoint = \'' . esc_url($graphqlEndpoint) . '\'; |
340 | 340 | /* ]]> */ |
341 | 341 | </script>'; |
342 | - } |
|
343 | - } |
|
344 | - ); |
|
345 | - } |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * Returns template for the additional datetime. |
|
351 | - * |
|
352 | - * @param $template |
|
353 | - * @param $template_args |
|
354 | - * @return mixed |
|
355 | - * @throws DomainException |
|
356 | - */ |
|
357 | - public function add_additional_datetime_button($template, $template_args) |
|
358 | - { |
|
359 | - return EEH_Template::display_template( |
|
360 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
361 | - $template_args, |
|
362 | - true |
|
363 | - ); |
|
364 | - } |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * Returns the template for cloning a datetime. |
|
369 | - * |
|
370 | - * @param $template |
|
371 | - * @param $template_args |
|
372 | - * @return mixed |
|
373 | - * @throws DomainException |
|
374 | - */ |
|
375 | - public function add_datetime_clone_button($template, $template_args) |
|
376 | - { |
|
377 | - return EEH_Template::display_template( |
|
378 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
379 | - $template_args, |
|
380 | - true |
|
381 | - ); |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * Returns the template for datetime timezones. |
|
387 | - * |
|
388 | - * @param $template |
|
389 | - * @param $template_args |
|
390 | - * @return mixed |
|
391 | - * @throws DomainException |
|
392 | - */ |
|
393 | - public function datetime_timezones_template($template, $template_args) |
|
394 | - { |
|
395 | - return EEH_Template::display_template( |
|
396 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
397 | - $template_args, |
|
398 | - true |
|
399 | - ); |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * Sets the views for the default list table view. |
|
405 | - */ |
|
406 | - protected function _set_list_table_views_default() |
|
407 | - { |
|
408 | - parent::_set_list_table_views_default(); |
|
409 | - $new_views = array( |
|
410 | - 'today' => array( |
|
411 | - 'slug' => 'today', |
|
412 | - 'label' => esc_html__('Today', 'event_espresso'), |
|
413 | - 'count' => $this->total_events_today(), |
|
414 | - 'bulk_action' => array( |
|
415 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
416 | - ), |
|
417 | - ), |
|
418 | - 'month' => array( |
|
419 | - 'slug' => 'month', |
|
420 | - 'label' => esc_html__('This Month', 'event_espresso'), |
|
421 | - 'count' => $this->total_events_this_month(), |
|
422 | - 'bulk_action' => array( |
|
423 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
424 | - ), |
|
425 | - ), |
|
426 | - ); |
|
427 | - $this->_views = array_merge($this->_views, $new_views); |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - /** |
|
432 | - * Returns the extra action links for the default list table view. |
|
433 | - * |
|
434 | - * @param array $action_links |
|
435 | - * @param \EE_Event $event |
|
436 | - * @return array |
|
437 | - * @throws EE_Error |
|
438 | - */ |
|
439 | - public function extra_list_table_actions(array $action_links, \EE_Event $event) |
|
440 | - { |
|
441 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
442 | - 'ee_read_registrations', |
|
443 | - 'espresso_registrations_reports', |
|
444 | - $event->ID() |
|
445 | - ) |
|
446 | - ) { |
|
447 | - $reports_query_args = array( |
|
448 | - 'action' => 'reports', |
|
449 | - 'EVT_ID' => $event->ID(), |
|
450 | - ); |
|
451 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
452 | - $action_links[] = '<a href="' |
|
453 | - . $reports_link |
|
454 | - . '" title="' |
|
455 | - . esc_attr__('View Report', 'event_espresso') |
|
456 | - . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
457 | - . "\n\t"; |
|
458 | - } |
|
459 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
460 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
461 | - $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
462 | - 'see_notifications_for', |
|
463 | - null, |
|
464 | - array('EVT_ID' => $event->ID()) |
|
465 | - ); |
|
466 | - } |
|
467 | - return $action_links; |
|
468 | - } |
|
469 | - |
|
470 | - |
|
471 | - /** |
|
472 | - * @param $items |
|
473 | - * @return mixed |
|
474 | - */ |
|
475 | - public function additional_legend_items($items) |
|
476 | - { |
|
477 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
478 | - 'ee_read_registrations', |
|
479 | - 'espresso_registrations_reports' |
|
480 | - ) |
|
481 | - ) { |
|
482 | - $items['reports'] = array( |
|
483 | - 'class' => 'dashicons dashicons-chart-bar', |
|
484 | - 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
485 | - ); |
|
486 | - } |
|
487 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
488 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
489 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
490 | - $items['view_related_messages'] = array( |
|
491 | - 'class' => $related_for_icon['css_class'], |
|
492 | - 'desc' => $related_for_icon['label'], |
|
493 | - ); |
|
494 | - } |
|
495 | - } |
|
496 | - return $items; |
|
497 | - } |
|
498 | - |
|
499 | - |
|
500 | - /** |
|
501 | - * This is the callback method for the duplicate event route |
|
502 | - * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
503 | - * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
504 | - * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
505 | - * After duplication the redirect is to the new event edit page. |
|
506 | - * |
|
507 | - * @return void |
|
508 | - * @access protected |
|
509 | - * @throws EE_Error If EE_Event is not available with given ID |
|
510 | - */ |
|
511 | - protected function _duplicate_event() |
|
512 | - { |
|
513 | - // first make sure the ID for the event is in the request. |
|
514 | - // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
515 | - if (! isset($this->_req_data['EVT_ID'])) { |
|
516 | - EE_Error::add_error( |
|
517 | - esc_html__( |
|
518 | - 'In order to duplicate an event an Event ID is required. None was given.', |
|
519 | - 'event_espresso' |
|
520 | - ), |
|
521 | - __FILE__, |
|
522 | - __FUNCTION__, |
|
523 | - __LINE__ |
|
524 | - ); |
|
525 | - $this->_redirect_after_action(false, '', '', array(), true); |
|
526 | - return; |
|
527 | - } |
|
528 | - // k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
529 | - $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
530 | - if (! $orig_event instanceof EE_Event) { |
|
531 | - throw new EE_Error( |
|
532 | - sprintf( |
|
533 | - esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
534 | - $this->_req_data['EVT_ID'] |
|
535 | - ) |
|
536 | - ); |
|
537 | - } |
|
538 | - // k now let's clone the $orig_event before getting relations |
|
539 | - $new_event = clone $orig_event; |
|
540 | - // original datetimes |
|
541 | - $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
542 | - // other original relations |
|
543 | - $orig_ven = $orig_event->get_many_related('Venue'); |
|
544 | - // reset the ID and modify other details to make it clear this is a dupe |
|
545 | - $new_event->set('EVT_ID', 0); |
|
546 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
547 | - $new_event->set('EVT_name', $new_name); |
|
548 | - $new_event->set( |
|
549 | - 'EVT_slug', |
|
550 | - wp_unique_post_slug( |
|
551 | - sanitize_title($orig_event->name()), |
|
552 | - 0, |
|
553 | - 'publish', |
|
554 | - 'espresso_events', |
|
555 | - 0 |
|
556 | - ) |
|
557 | - ); |
|
558 | - $new_event->set('status', 'draft'); |
|
559 | - // duplicate discussion settings |
|
560 | - $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
561 | - $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
562 | - // save the new event |
|
563 | - $new_event->save(); |
|
564 | - // venues |
|
565 | - foreach ($orig_ven as $ven) { |
|
566 | - $new_event->_add_relation_to($ven, 'Venue'); |
|
567 | - } |
|
568 | - $new_event->save(); |
|
569 | - // now we need to get the question group relations and handle that |
|
570 | - // first primary question groups |
|
571 | - $orig_primary_qgs = $orig_event->get_many_related( |
|
572 | - 'Question_Group', |
|
573 | - [['Event_Question_Group.EQG_primary' => true]] |
|
574 | - ); |
|
575 | - if (! empty($orig_primary_qgs)) { |
|
576 | - foreach ($orig_primary_qgs as $id => $obj) { |
|
577 | - if ($obj instanceof EE_Question_Group) { |
|
578 | - $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
|
579 | - } |
|
580 | - } |
|
581 | - } |
|
582 | - // next additional attendee question groups |
|
583 | - $orig_additional_qgs = $orig_event->get_many_related( |
|
584 | - 'Question_Group', |
|
585 | - [['Event_Question_Group.EQG_additional' => true]] |
|
586 | - ); |
|
587 | - if (! empty($orig_additional_qgs)) { |
|
588 | - foreach ($orig_additional_qgs as $id => $obj) { |
|
589 | - if ($obj instanceof EE_Question_Group) { |
|
590 | - $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
|
591 | - } |
|
592 | - } |
|
593 | - } |
|
594 | - |
|
595 | - $new_event->save(); |
|
596 | - |
|
597 | - // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
598 | - $cloned_tickets = array(); |
|
599 | - foreach ($orig_datetimes as $orig_dtt) { |
|
600 | - if (! $orig_dtt instanceof EE_Datetime) { |
|
601 | - continue; |
|
602 | - } |
|
603 | - $new_dtt = clone $orig_dtt; |
|
604 | - $orig_tkts = $orig_dtt->tickets(); |
|
605 | - // save new dtt then add to event |
|
606 | - $new_dtt->set('DTT_ID', 0); |
|
607 | - $new_dtt->set('DTT_sold', 0); |
|
608 | - $new_dtt->set_reserved(0); |
|
609 | - $new_dtt->save(); |
|
610 | - $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
611 | - $new_event->save(); |
|
612 | - // now let's get the ticket relations setup. |
|
613 | - foreach ((array) $orig_tkts as $orig_tkt) { |
|
614 | - // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
615 | - if (! $orig_tkt instanceof EE_Ticket) { |
|
616 | - continue; |
|
617 | - } |
|
618 | - // is this ticket archived? If it is then let's skip |
|
619 | - if ($orig_tkt->get('TKT_deleted')) { |
|
620 | - continue; |
|
621 | - } |
|
622 | - // does this original ticket already exist in the clone_tickets cache? |
|
623 | - // If so we'll just use the new ticket from it. |
|
624 | - if (isset($cloned_tickets[ $orig_tkt->ID() ])) { |
|
625 | - $new_tkt = $cloned_tickets[ $orig_tkt->ID() ]; |
|
626 | - } else { |
|
627 | - $new_tkt = clone $orig_tkt; |
|
628 | - // get relations on the $orig_tkt that we need to setup. |
|
629 | - $orig_prices = $orig_tkt->prices(); |
|
630 | - $new_tkt->set('TKT_ID', 0); |
|
631 | - $new_tkt->set('TKT_sold', 0); |
|
632 | - $new_tkt->set('TKT_reserved', 0); |
|
633 | - $new_tkt->save(); // make sure new ticket has ID. |
|
634 | - // price relations on new ticket need to be setup. |
|
635 | - foreach ($orig_prices as $orig_price) { |
|
636 | - $new_price = clone $orig_price; |
|
637 | - $new_price->set('PRC_ID', 0); |
|
638 | - $new_price->save(); |
|
639 | - $new_tkt->_add_relation_to($new_price, 'Price'); |
|
640 | - $new_tkt->save(); |
|
641 | - } |
|
642 | - |
|
643 | - do_action( |
|
644 | - 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
645 | - $orig_tkt, |
|
646 | - $new_tkt, |
|
647 | - $orig_prices, |
|
648 | - $orig_event, |
|
649 | - $orig_dtt, |
|
650 | - $new_dtt |
|
651 | - ); |
|
652 | - } |
|
653 | - // k now we can add the new ticket as a relation to the new datetime |
|
654 | - // and make sure its added to our cached $cloned_tickets array |
|
655 | - // for use with later datetimes that have the same ticket. |
|
656 | - $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
|
657 | - $new_dtt->save(); |
|
658 | - $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt; |
|
659 | - } |
|
660 | - } |
|
661 | - // clone taxonomy information |
|
662 | - $taxonomies_to_clone_with = apply_filters( |
|
663 | - 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
664 | - array('espresso_event_categories', 'espresso_event_type', 'post_tag') |
|
665 | - ); |
|
666 | - // get terms for original event (notice) |
|
667 | - $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
668 | - // loop through terms and add them to new event. |
|
669 | - foreach ($orig_terms as $term) { |
|
670 | - wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
671 | - } |
|
672 | - |
|
673 | - // duplicate other core WP_Post items for this event. |
|
674 | - // post thumbnail (feature image). |
|
675 | - $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
676 | - if ($feature_image_id) { |
|
677 | - update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
678 | - } |
|
679 | - |
|
680 | - // duplicate page_template setting |
|
681 | - $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
682 | - if ($page_template) { |
|
683 | - update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
684 | - } |
|
685 | - |
|
686 | - do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
687 | - // now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
688 | - if ($new_event->ID()) { |
|
689 | - $redirect_args = array( |
|
690 | - 'post' => $new_event->ID(), |
|
691 | - 'action' => 'edit', |
|
692 | - ); |
|
693 | - EE_Error::add_success( |
|
694 | - esc_html__( |
|
695 | - 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
696 | - 'event_espresso' |
|
697 | - ) |
|
698 | - ); |
|
699 | - } else { |
|
700 | - $redirect_args = array( |
|
701 | - 'action' => 'default', |
|
702 | - ); |
|
703 | - EE_Error::add_error( |
|
704 | - esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
705 | - __FILE__, |
|
706 | - __FUNCTION__, |
|
707 | - __LINE__ |
|
708 | - ); |
|
709 | - } |
|
710 | - $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
711 | - } |
|
712 | - |
|
713 | - |
|
714 | - /** |
|
715 | - * Generates output for the import page. |
|
716 | - * |
|
717 | - * @throws DomainException |
|
718 | - */ |
|
719 | - protected function _import_page() |
|
720 | - { |
|
721 | - $title = esc_html__('Import', 'event_espresso'); |
|
722 | - $intro = esc_html__( |
|
723 | - 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
724 | - 'event_espresso' |
|
725 | - ); |
|
726 | - $form_url = EVENTS_ADMIN_URL; |
|
727 | - $action = 'import_events'; |
|
728 | - $type = 'csv'; |
|
729 | - $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
730 | - $title, |
|
731 | - $intro, |
|
732 | - $form_url, |
|
733 | - $action, |
|
734 | - $type |
|
735 | - ); |
|
736 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
737 | - array('action' => 'sample_export_file'), |
|
738 | - $this->_admin_base_url |
|
739 | - ); |
|
740 | - $content = EEH_Template::display_template( |
|
741 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
742 | - $this->_template_args, |
|
743 | - true |
|
744 | - ); |
|
745 | - $this->_template_args['admin_page_content'] = $content; |
|
746 | - $this->display_admin_page_with_sidebar(); |
|
747 | - } |
|
748 | - |
|
749 | - |
|
750 | - /** |
|
751 | - * _import_events |
|
752 | - * This handles displaying the screen and running imports for importing events. |
|
753 | - * |
|
754 | - * @return void |
|
755 | - */ |
|
756 | - protected function _import_events() |
|
757 | - { |
|
758 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
759 | - $success = EE_Import::instance()->import(); |
|
760 | - $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
761 | - } |
|
762 | - |
|
763 | - |
|
764 | - /** |
|
765 | - * _events_export |
|
766 | - * Will export all (or just the given event) to a Excel compatible file. |
|
767 | - * |
|
768 | - * @access protected |
|
769 | - * @return void |
|
770 | - */ |
|
771 | - protected function _events_export() |
|
772 | - { |
|
773 | - if (isset($this->_req_data['EVT_ID'])) { |
|
774 | - $event_ids = $this->_req_data['EVT_ID']; |
|
775 | - } elseif (isset($this->_req_data['EVT_IDs'])) { |
|
776 | - $event_ids = $this->_req_data['EVT_IDs']; |
|
777 | - } else { |
|
778 | - $event_ids = null; |
|
779 | - } |
|
780 | - // todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
781 | - $new_request_args = array( |
|
782 | - 'export' => 'report', |
|
783 | - 'action' => 'all_event_data', |
|
784 | - 'EVT_ID' => $event_ids, |
|
785 | - ); |
|
786 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
787 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
788 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
789 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
790 | - $EE_Export->export(); |
|
791 | - } |
|
792 | - } |
|
793 | - |
|
794 | - |
|
795 | - /** |
|
796 | - * handle category exports() |
|
797 | - * |
|
798 | - * @return void |
|
799 | - */ |
|
800 | - protected function _categories_export() |
|
801 | - { |
|
802 | - // todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
803 | - $new_request_args = array( |
|
804 | - 'export' => 'report', |
|
805 | - 'action' => 'categories', |
|
806 | - 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
|
807 | - ); |
|
808 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
809 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
810 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
811 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
812 | - $EE_Export->export(); |
|
813 | - } |
|
814 | - } |
|
815 | - |
|
816 | - |
|
817 | - /** |
|
818 | - * Creates a sample CSV file for importing |
|
819 | - */ |
|
820 | - protected function _sample_export_file() |
|
821 | - { |
|
822 | - // require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
823 | - EE_Export::instance()->export_sample(); |
|
824 | - } |
|
825 | - |
|
826 | - |
|
827 | - /************* Template Settings *************/ |
|
828 | - /** |
|
829 | - * Generates template settings page output |
|
830 | - * |
|
831 | - * @throws DomainException |
|
832 | - * @throws EE_Error |
|
833 | - */ |
|
834 | - protected function _template_settings() |
|
835 | - { |
|
836 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
837 | - /** |
|
838 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
839 | - * from General_Settings_Admin_Page to here. |
|
840 | - */ |
|
841 | - $this->_template_args = apply_filters( |
|
842 | - 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
843 | - $this->_template_args |
|
844 | - ); |
|
845 | - $this->_set_add_edit_form_tags('update_template_settings'); |
|
846 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
847 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
848 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
849 | - $this->_template_args, |
|
850 | - true |
|
851 | - ); |
|
852 | - $this->display_admin_page_with_sidebar(); |
|
853 | - } |
|
854 | - |
|
855 | - |
|
856 | - /** |
|
857 | - * Handler for updating template settings. |
|
858 | - * |
|
859 | - * @throws InvalidInterfaceException |
|
860 | - * @throws InvalidDataTypeException |
|
861 | - * @throws InvalidArgumentException |
|
862 | - */ |
|
863 | - protected function _update_template_settings() |
|
864 | - { |
|
865 | - /** |
|
866 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
867 | - * from General_Settings_Admin_Page to here. |
|
868 | - */ |
|
869 | - EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
870 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
871 | - EE_Registry::instance()->CFG->template_settings, |
|
872 | - $this->_req_data |
|
873 | - ); |
|
874 | - // update custom post type slugs and detect if we need to flush rewrite rules |
|
875 | - $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
876 | - EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) |
|
877 | - ? EE_Registry::instance()->CFG->core->event_cpt_slug |
|
878 | - : EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events'); |
|
879 | - $what = 'Template Settings'; |
|
880 | - $success = $this->_update_espresso_configuration( |
|
881 | - $what, |
|
882 | - EE_Registry::instance()->CFG->template_settings, |
|
883 | - __FILE__, |
|
884 | - __FUNCTION__, |
|
885 | - __LINE__ |
|
886 | - ); |
|
887 | - if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
888 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
889 | - $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
890 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
891 | - ); |
|
892 | - $rewrite_rules->flush(); |
|
893 | - } |
|
894 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
895 | - } |
|
896 | - |
|
897 | - |
|
898 | - /** |
|
899 | - * _premium_event_editor_meta_boxes |
|
900 | - * add all metaboxes related to the event_editor |
|
901 | - * |
|
902 | - * @access protected |
|
903 | - * @return void |
|
904 | - * @throws EE_Error |
|
905 | - */ |
|
906 | - protected function _premium_event_editor_meta_boxes() |
|
907 | - { |
|
908 | - $this->verify_cpt_object(); |
|
909 | - add_meta_box( |
|
910 | - 'espresso_event_editor_event_options', |
|
911 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
912 | - array($this, 'registration_options_meta_box'), |
|
913 | - $this->page_slug, |
|
914 | - 'side', |
|
915 | - 'core' |
|
916 | - ); |
|
917 | - } |
|
918 | - |
|
919 | - |
|
920 | - /** |
|
921 | - * override caf metabox |
|
922 | - * |
|
923 | - * @return void |
|
924 | - * @throws DomainException |
|
925 | - */ |
|
926 | - public function registration_options_meta_box() |
|
927 | - { |
|
928 | - $yes_no_values = array( |
|
929 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
930 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
931 | - ); |
|
932 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
933 | - array( |
|
934 | - EEM_Registration::status_id_cancelled, |
|
935 | - EEM_Registration::status_id_declined, |
|
936 | - EEM_Registration::status_id_incomplete, |
|
937 | - EEM_Registration::status_id_wait_list, |
|
938 | - ), |
|
939 | - true |
|
940 | - ); |
|
941 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
942 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
943 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
944 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
945 | - 'default_reg_status', |
|
946 | - $default_reg_status_values, |
|
947 | - $this->_cpt_model_obj->default_registration_status() |
|
948 | - ); |
|
949 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
950 | - 'display_desc', |
|
951 | - $yes_no_values, |
|
952 | - $this->_cpt_model_obj->display_description() |
|
953 | - ); |
|
954 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
955 | - 'display_ticket_selector', |
|
956 | - $yes_no_values, |
|
957 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
958 | - '', |
|
959 | - '', |
|
960 | - false |
|
961 | - ); |
|
962 | - $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
963 | - 'EVT_default_registration_status', |
|
964 | - $default_reg_status_values, |
|
965 | - $this->_cpt_model_obj->default_registration_status() |
|
966 | - ); |
|
967 | - $template_args['additional_registration_options'] = apply_filters( |
|
968 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
969 | - '', |
|
970 | - $template_args, |
|
971 | - $yes_no_values, |
|
972 | - $default_reg_status_values |
|
973 | - ); |
|
974 | - EEH_Template::display_template( |
|
975 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
976 | - $template_args |
|
977 | - ); |
|
978 | - } |
|
979 | - |
|
980 | - |
|
981 | - |
|
982 | - /** |
|
983 | - * wp_list_table_mods for caf |
|
984 | - * ============================ |
|
985 | - */ |
|
986 | - /** |
|
987 | - * hook into list table filters and provide filters for caffeinated list table |
|
988 | - * |
|
989 | - * @param array $old_filters any existing filters present |
|
990 | - * @param array $list_table_obj the list table object |
|
991 | - * @return array new filters |
|
992 | - */ |
|
993 | - public function list_table_filters($old_filters, $list_table_obj) |
|
994 | - { |
|
995 | - $filters = array(); |
|
996 | - // first month/year filters |
|
997 | - $filters[] = $this->espresso_event_months_dropdown(); |
|
998 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
999 | - // active status dropdown |
|
1000 | - if ($status !== 'draft') { |
|
1001 | - $filters[] = $this->active_status_dropdown( |
|
1002 | - isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '' |
|
1003 | - ); |
|
1004 | - $filters[] = $this->venuesDropdown( |
|
1005 | - isset($this->_req_data['venue']) ? $this->_req_data['venue'] : '' |
|
1006 | - ); |
|
1007 | - } |
|
1008 | - // category filter |
|
1009 | - $filters[] = $this->category_dropdown(); |
|
1010 | - return array_merge($old_filters, $filters); |
|
1011 | - } |
|
1012 | - |
|
1013 | - |
|
1014 | - /** |
|
1015 | - * espresso_event_months_dropdown |
|
1016 | - * |
|
1017 | - * @access public |
|
1018 | - * @return string dropdown listing month/year selections for events. |
|
1019 | - */ |
|
1020 | - public function espresso_event_months_dropdown() |
|
1021 | - { |
|
1022 | - // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
1023 | - // Note we need to include any other filters that are set! |
|
1024 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1025 | - // categories? |
|
1026 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1027 | - ? $this->_req_data['EVT_CAT'] |
|
1028 | - : null; |
|
1029 | - // active status? |
|
1030 | - $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null; |
|
1031 | - $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
1032 | - return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
1033 | - } |
|
1034 | - |
|
1035 | - |
|
1036 | - /** |
|
1037 | - * returns a list of "active" statuses on the event |
|
1038 | - * |
|
1039 | - * @param string $current_value whatever the current active status is |
|
1040 | - * @return string |
|
1041 | - */ |
|
1042 | - public function active_status_dropdown($current_value = '') |
|
1043 | - { |
|
1044 | - $select_name = 'active_status'; |
|
1045 | - $values = array( |
|
1046 | - 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
1047 | - 'active' => esc_html__('Active', 'event_espresso'), |
|
1048 | - 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
1049 | - 'expired' => esc_html__('Expired', 'event_espresso'), |
|
1050 | - 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
1051 | - ); |
|
1052 | - |
|
1053 | - return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide'); |
|
1054 | - } |
|
1055 | - |
|
1056 | - /** |
|
1057 | - * returns a list of "venues" |
|
1058 | - * |
|
1059 | - * @param string $current_value whatever the current active status is |
|
1060 | - * @return string |
|
1061 | - */ |
|
1062 | - protected function venuesDropdown($current_value = '') |
|
1063 | - { |
|
1064 | - $select_name = 'venue'; |
|
1065 | - $values = array( |
|
1066 | - '' => esc_html__('All Venues', 'event_espresso'), |
|
1067 | - ); |
|
1068 | - // populate the list of venues. |
|
1069 | - $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1070 | - $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC'))); |
|
1071 | - |
|
1072 | - foreach ($venues as $venue) { |
|
1073 | - $values[ $venue->ID() ] = $venue->name(); |
|
1074 | - } |
|
1075 | - |
|
1076 | - return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide'); |
|
1077 | - } |
|
1078 | - |
|
1079 | - |
|
1080 | - /** |
|
1081 | - * output a dropdown of the categories for the category filter on the event admin list table |
|
1082 | - * |
|
1083 | - * @access public |
|
1084 | - * @return string html |
|
1085 | - */ |
|
1086 | - public function category_dropdown() |
|
1087 | - { |
|
1088 | - $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
1089 | - return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
1090 | - } |
|
1091 | - |
|
1092 | - |
|
1093 | - /** |
|
1094 | - * get total number of events today |
|
1095 | - * |
|
1096 | - * @access public |
|
1097 | - * @return int |
|
1098 | - * @throws EE_Error |
|
1099 | - */ |
|
1100 | - public function total_events_today() |
|
1101 | - { |
|
1102 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1103 | - 'DTT_EVT_start', |
|
1104 | - date('Y-m-d') . ' 00:00:00', |
|
1105 | - 'Y-m-d H:i:s', |
|
1106 | - 'UTC' |
|
1107 | - ); |
|
1108 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1109 | - 'DTT_EVT_start', |
|
1110 | - date('Y-m-d') . ' 23:59:59', |
|
1111 | - 'Y-m-d H:i:s', |
|
1112 | - 'UTC' |
|
1113 | - ); |
|
1114 | - $where = array( |
|
1115 | - 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1116 | - ); |
|
1117 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1118 | - return $count; |
|
1119 | - } |
|
1120 | - |
|
1121 | - |
|
1122 | - /** |
|
1123 | - * get total number of events this month |
|
1124 | - * |
|
1125 | - * @access public |
|
1126 | - * @return int |
|
1127 | - * @throws EE_Error |
|
1128 | - */ |
|
1129 | - public function total_events_this_month() |
|
1130 | - { |
|
1131 | - // Dates |
|
1132 | - $this_year_r = date('Y'); |
|
1133 | - $this_month_r = date('m'); |
|
1134 | - $days_this_month = date('t'); |
|
1135 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1136 | - 'DTT_EVT_start', |
|
1137 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1138 | - 'Y-m-d H:i:s', |
|
1139 | - 'UTC' |
|
1140 | - ); |
|
1141 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1142 | - 'DTT_EVT_start', |
|
1143 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1144 | - 'Y-m-d H:i:s', |
|
1145 | - 'UTC' |
|
1146 | - ); |
|
1147 | - $where = array( |
|
1148 | - 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1149 | - ); |
|
1150 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1151 | - return $count; |
|
1152 | - } |
|
1153 | - |
|
1154 | - |
|
1155 | - /** DEFAULT TICKETS STUFF **/ |
|
1156 | - |
|
1157 | - /** |
|
1158 | - * Output default tickets list table view. |
|
1159 | - */ |
|
1160 | - public function _tickets_overview_list_table() |
|
1161 | - { |
|
1162 | - $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1163 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1164 | - } |
|
1165 | - |
|
1166 | - |
|
1167 | - /** |
|
1168 | - * @param int $per_page |
|
1169 | - * @param bool $count |
|
1170 | - * @param bool $trashed |
|
1171 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
1172 | - */ |
|
1173 | - public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
1174 | - { |
|
1175 | - $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1176 | - $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1177 | - switch ($orderby) { |
|
1178 | - case 'TKT_name': |
|
1179 | - $orderby = array('TKT_name' => $order); |
|
1180 | - break; |
|
1181 | - case 'TKT_price': |
|
1182 | - $orderby = array('TKT_price' => $order); |
|
1183 | - break; |
|
1184 | - case 'TKT_uses': |
|
1185 | - $orderby = array('TKT_uses' => $order); |
|
1186 | - break; |
|
1187 | - case 'TKT_min': |
|
1188 | - $orderby = array('TKT_min' => $order); |
|
1189 | - break; |
|
1190 | - case 'TKT_max': |
|
1191 | - $orderby = array('TKT_max' => $order); |
|
1192 | - break; |
|
1193 | - case 'TKT_qty': |
|
1194 | - $orderby = array('TKT_qty' => $order); |
|
1195 | - break; |
|
1196 | - } |
|
1197 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
1198 | - ? $this->_req_data['paged'] |
|
1199 | - : 1; |
|
1200 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
1201 | - ? $this->_req_data['perpage'] |
|
1202 | - : $per_page; |
|
1203 | - $_where = array( |
|
1204 | - 'TKT_is_default' => 1, |
|
1205 | - 'TKT_deleted' => $trashed, |
|
1206 | - ); |
|
1207 | - $offset = ($current_page - 1) * $per_page; |
|
1208 | - $limit = array($offset, $per_page); |
|
1209 | - if (isset($this->_req_data['s'])) { |
|
1210 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1211 | - $_where['OR'] = array( |
|
1212 | - 'TKT_name' => array('LIKE', $sstr), |
|
1213 | - 'TKT_description' => array('LIKE', $sstr), |
|
1214 | - ); |
|
1215 | - } |
|
1216 | - $query_params = array( |
|
1217 | - $_where, |
|
1218 | - 'order_by' => $orderby, |
|
1219 | - 'limit' => $limit, |
|
1220 | - 'group_by' => 'TKT_ID', |
|
1221 | - ); |
|
1222 | - if ($count) { |
|
1223 | - return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
1224 | - } else { |
|
1225 | - return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
1226 | - } |
|
1227 | - } |
|
1228 | - |
|
1229 | - |
|
1230 | - /** |
|
1231 | - * @param bool $trash |
|
1232 | - * @throws EE_Error |
|
1233 | - */ |
|
1234 | - protected function _trash_or_restore_ticket($trash = false) |
|
1235 | - { |
|
1236 | - $success = 1; |
|
1237 | - $TKT = EEM_Ticket::instance(); |
|
1238 | - // checkboxes? |
|
1239 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1240 | - // if array has more than one element then success message should be plural |
|
1241 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1242 | - // cycle thru the boxes |
|
1243 | - while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1244 | - if ($trash) { |
|
1245 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1246 | - $success = 0; |
|
1247 | - } |
|
1248 | - } else { |
|
1249 | - if (! $TKT->restore_by_ID($TKT_ID)) { |
|
1250 | - $success = 0; |
|
1251 | - } |
|
1252 | - } |
|
1253 | - } |
|
1254 | - } else { |
|
1255 | - // grab single id and trash |
|
1256 | - $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1257 | - if ($trash) { |
|
1258 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1259 | - $success = 0; |
|
1260 | - } |
|
1261 | - } else { |
|
1262 | - if (! $TKT->restore_by_ID($TKT_ID)) { |
|
1263 | - $success = 0; |
|
1264 | - } |
|
1265 | - } |
|
1266 | - } |
|
1267 | - $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1268 | - $query_args = array( |
|
1269 | - 'action' => 'ticket_list_table', |
|
1270 | - 'status' => $trash ? '' : 'trashed', |
|
1271 | - ); |
|
1272 | - $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1273 | - } |
|
1274 | - |
|
1275 | - |
|
1276 | - /** |
|
1277 | - * Handles trashing default ticket. |
|
1278 | - */ |
|
1279 | - protected function _delete_ticket() |
|
1280 | - { |
|
1281 | - $success = 1; |
|
1282 | - // checkboxes? |
|
1283 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1284 | - // if array has more than one element then success message should be plural |
|
1285 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1286 | - // cycle thru the boxes |
|
1287 | - while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1288 | - // delete |
|
1289 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1290 | - $success = 0; |
|
1291 | - } |
|
1292 | - } |
|
1293 | - } else { |
|
1294 | - // grab single id and trash |
|
1295 | - $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1296 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1297 | - $success = 0; |
|
1298 | - } |
|
1299 | - } |
|
1300 | - $action_desc = 'deleted'; |
|
1301 | - $query_args = array( |
|
1302 | - 'action' => 'ticket_list_table', |
|
1303 | - 'status' => 'trashed', |
|
1304 | - ); |
|
1305 | - // fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1306 | - if (EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1307 | - array(array('TKT_is_default' => 1)), |
|
1308 | - 'TKT_ID', |
|
1309 | - true |
|
1310 | - ) |
|
1311 | - ) { |
|
1312 | - $query_args = array(); |
|
1313 | - } |
|
1314 | - $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1315 | - } |
|
1316 | - |
|
1317 | - |
|
1318 | - /** |
|
1319 | - * @param int $TKT_ID |
|
1320 | - * @return bool|int |
|
1321 | - * @throws EE_Error |
|
1322 | - */ |
|
1323 | - protected function _delete_the_ticket($TKT_ID) |
|
1324 | - { |
|
1325 | - $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1326 | - $tkt->_remove_relations('Datetime'); |
|
1327 | - // delete all related prices first |
|
1328 | - $tkt->delete_related_permanently('Price'); |
|
1329 | - return $tkt->delete_permanently(); |
|
1330 | - } |
|
1331 | - |
|
1332 | - |
|
1333 | - /** |
|
1334 | - * @param array $default_event_settings_form_subsections |
|
1335 | - * @return array |
|
1336 | - * @since $VID:$ |
|
1337 | - */ |
|
1338 | - public function advancedEditorAdminFormSection(array $default_event_settings_form_subsections) |
|
1339 | - { |
|
1340 | - return [ |
|
1341 | - 'use_advanced_editor' => new EE_Select_Input( |
|
1342 | - apply_filters( |
|
1343 | - 'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_answer_options', |
|
1344 | - [ |
|
1345 | - esc_html__('Legacy Editor', 'event_espresso'), |
|
1346 | - esc_html__('Advanced Editor', 'event_espresso'), |
|
1347 | - ] |
|
1348 | - ), |
|
1349 | - apply_filters( |
|
1350 | - 'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_settings', |
|
1351 | - [ |
|
1352 | - 'default' => $this->admin_config->useAdvancedEditor(), |
|
1353 | - 'html_label_text' => esc_html__('Activate Advanced Editor?', 'event_espresso'), |
|
1354 | - 'html_help_text' => sprintf( |
|
1355 | - esc_html__( |
|
1356 | - 'Controls whether the Event Espresso Event Editor continues to use the existing legacy editor that functions like the typical older WordPress admin you are used to,%1$sor uses the new Advanced Editor with a more powerful and easier to use interface. This may be automatically turned on in order to utilize advanced features from new addons.', |
|
1357 | - 'event_espresso' |
|
1358 | - ), |
|
1359 | - '<br />' |
|
1360 | - ), |
|
1361 | - ] |
|
1362 | - ) |
|
1363 | - ), |
|
1364 | - 'defaults_section_header' => new EE_Form_Section_HTML( |
|
1365 | - EEH_HTML::h2( |
|
1366 | - esc_html__('Default Settings', 'event_espresso'), |
|
1367 | - '', |
|
1368 | - 'ee-admin-settings-hdr' |
|
1369 | - ) |
|
1370 | - ), |
|
1371 | - ] + $default_event_settings_form_subsections; |
|
1372 | - } |
|
1373 | - |
|
1374 | - |
|
1375 | - /** |
|
1376 | - * @param array $valid_data |
|
1377 | - * @param EE_Config $config |
|
1378 | - * @since $VID:$ |
|
1379 | - */ |
|
1380 | - public function updateAdvancedEditorAdminFormSettings(array $valid_data, EE_Config $config) |
|
1381 | - { |
|
1382 | - $config->admin->setUseAdvancedEditor( |
|
1383 | - isset($valid_data['use_advanced_editor']) |
|
1384 | - ? $valid_data['use_advanced_editor'] |
|
1385 | - : false |
|
1386 | - ); |
|
1387 | - } |
|
342 | + } |
|
343 | + } |
|
344 | + ); |
|
345 | + } |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * Returns template for the additional datetime. |
|
351 | + * |
|
352 | + * @param $template |
|
353 | + * @param $template_args |
|
354 | + * @return mixed |
|
355 | + * @throws DomainException |
|
356 | + */ |
|
357 | + public function add_additional_datetime_button($template, $template_args) |
|
358 | + { |
|
359 | + return EEH_Template::display_template( |
|
360 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
361 | + $template_args, |
|
362 | + true |
|
363 | + ); |
|
364 | + } |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * Returns the template for cloning a datetime. |
|
369 | + * |
|
370 | + * @param $template |
|
371 | + * @param $template_args |
|
372 | + * @return mixed |
|
373 | + * @throws DomainException |
|
374 | + */ |
|
375 | + public function add_datetime_clone_button($template, $template_args) |
|
376 | + { |
|
377 | + return EEH_Template::display_template( |
|
378 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
379 | + $template_args, |
|
380 | + true |
|
381 | + ); |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * Returns the template for datetime timezones. |
|
387 | + * |
|
388 | + * @param $template |
|
389 | + * @param $template_args |
|
390 | + * @return mixed |
|
391 | + * @throws DomainException |
|
392 | + */ |
|
393 | + public function datetime_timezones_template($template, $template_args) |
|
394 | + { |
|
395 | + return EEH_Template::display_template( |
|
396 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
397 | + $template_args, |
|
398 | + true |
|
399 | + ); |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * Sets the views for the default list table view. |
|
405 | + */ |
|
406 | + protected function _set_list_table_views_default() |
|
407 | + { |
|
408 | + parent::_set_list_table_views_default(); |
|
409 | + $new_views = array( |
|
410 | + 'today' => array( |
|
411 | + 'slug' => 'today', |
|
412 | + 'label' => esc_html__('Today', 'event_espresso'), |
|
413 | + 'count' => $this->total_events_today(), |
|
414 | + 'bulk_action' => array( |
|
415 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
416 | + ), |
|
417 | + ), |
|
418 | + 'month' => array( |
|
419 | + 'slug' => 'month', |
|
420 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
421 | + 'count' => $this->total_events_this_month(), |
|
422 | + 'bulk_action' => array( |
|
423 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
424 | + ), |
|
425 | + ), |
|
426 | + ); |
|
427 | + $this->_views = array_merge($this->_views, $new_views); |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + /** |
|
432 | + * Returns the extra action links for the default list table view. |
|
433 | + * |
|
434 | + * @param array $action_links |
|
435 | + * @param \EE_Event $event |
|
436 | + * @return array |
|
437 | + * @throws EE_Error |
|
438 | + */ |
|
439 | + public function extra_list_table_actions(array $action_links, \EE_Event $event) |
|
440 | + { |
|
441 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
442 | + 'ee_read_registrations', |
|
443 | + 'espresso_registrations_reports', |
|
444 | + $event->ID() |
|
445 | + ) |
|
446 | + ) { |
|
447 | + $reports_query_args = array( |
|
448 | + 'action' => 'reports', |
|
449 | + 'EVT_ID' => $event->ID(), |
|
450 | + ); |
|
451 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
452 | + $action_links[] = '<a href="' |
|
453 | + . $reports_link |
|
454 | + . '" title="' |
|
455 | + . esc_attr__('View Report', 'event_espresso') |
|
456 | + . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
457 | + . "\n\t"; |
|
458 | + } |
|
459 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
460 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
461 | + $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
462 | + 'see_notifications_for', |
|
463 | + null, |
|
464 | + array('EVT_ID' => $event->ID()) |
|
465 | + ); |
|
466 | + } |
|
467 | + return $action_links; |
|
468 | + } |
|
469 | + |
|
470 | + |
|
471 | + /** |
|
472 | + * @param $items |
|
473 | + * @return mixed |
|
474 | + */ |
|
475 | + public function additional_legend_items($items) |
|
476 | + { |
|
477 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
478 | + 'ee_read_registrations', |
|
479 | + 'espresso_registrations_reports' |
|
480 | + ) |
|
481 | + ) { |
|
482 | + $items['reports'] = array( |
|
483 | + 'class' => 'dashicons dashicons-chart-bar', |
|
484 | + 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
485 | + ); |
|
486 | + } |
|
487 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
488 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
489 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
490 | + $items['view_related_messages'] = array( |
|
491 | + 'class' => $related_for_icon['css_class'], |
|
492 | + 'desc' => $related_for_icon['label'], |
|
493 | + ); |
|
494 | + } |
|
495 | + } |
|
496 | + return $items; |
|
497 | + } |
|
498 | + |
|
499 | + |
|
500 | + /** |
|
501 | + * This is the callback method for the duplicate event route |
|
502 | + * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
503 | + * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
504 | + * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
505 | + * After duplication the redirect is to the new event edit page. |
|
506 | + * |
|
507 | + * @return void |
|
508 | + * @access protected |
|
509 | + * @throws EE_Error If EE_Event is not available with given ID |
|
510 | + */ |
|
511 | + protected function _duplicate_event() |
|
512 | + { |
|
513 | + // first make sure the ID for the event is in the request. |
|
514 | + // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
515 | + if (! isset($this->_req_data['EVT_ID'])) { |
|
516 | + EE_Error::add_error( |
|
517 | + esc_html__( |
|
518 | + 'In order to duplicate an event an Event ID is required. None was given.', |
|
519 | + 'event_espresso' |
|
520 | + ), |
|
521 | + __FILE__, |
|
522 | + __FUNCTION__, |
|
523 | + __LINE__ |
|
524 | + ); |
|
525 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
526 | + return; |
|
527 | + } |
|
528 | + // k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
529 | + $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
530 | + if (! $orig_event instanceof EE_Event) { |
|
531 | + throw new EE_Error( |
|
532 | + sprintf( |
|
533 | + esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
534 | + $this->_req_data['EVT_ID'] |
|
535 | + ) |
|
536 | + ); |
|
537 | + } |
|
538 | + // k now let's clone the $orig_event before getting relations |
|
539 | + $new_event = clone $orig_event; |
|
540 | + // original datetimes |
|
541 | + $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
542 | + // other original relations |
|
543 | + $orig_ven = $orig_event->get_many_related('Venue'); |
|
544 | + // reset the ID and modify other details to make it clear this is a dupe |
|
545 | + $new_event->set('EVT_ID', 0); |
|
546 | + $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
547 | + $new_event->set('EVT_name', $new_name); |
|
548 | + $new_event->set( |
|
549 | + 'EVT_slug', |
|
550 | + wp_unique_post_slug( |
|
551 | + sanitize_title($orig_event->name()), |
|
552 | + 0, |
|
553 | + 'publish', |
|
554 | + 'espresso_events', |
|
555 | + 0 |
|
556 | + ) |
|
557 | + ); |
|
558 | + $new_event->set('status', 'draft'); |
|
559 | + // duplicate discussion settings |
|
560 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
561 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
562 | + // save the new event |
|
563 | + $new_event->save(); |
|
564 | + // venues |
|
565 | + foreach ($orig_ven as $ven) { |
|
566 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
567 | + } |
|
568 | + $new_event->save(); |
|
569 | + // now we need to get the question group relations and handle that |
|
570 | + // first primary question groups |
|
571 | + $orig_primary_qgs = $orig_event->get_many_related( |
|
572 | + 'Question_Group', |
|
573 | + [['Event_Question_Group.EQG_primary' => true]] |
|
574 | + ); |
|
575 | + if (! empty($orig_primary_qgs)) { |
|
576 | + foreach ($orig_primary_qgs as $id => $obj) { |
|
577 | + if ($obj instanceof EE_Question_Group) { |
|
578 | + $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
|
579 | + } |
|
580 | + } |
|
581 | + } |
|
582 | + // next additional attendee question groups |
|
583 | + $orig_additional_qgs = $orig_event->get_many_related( |
|
584 | + 'Question_Group', |
|
585 | + [['Event_Question_Group.EQG_additional' => true]] |
|
586 | + ); |
|
587 | + if (! empty($orig_additional_qgs)) { |
|
588 | + foreach ($orig_additional_qgs as $id => $obj) { |
|
589 | + if ($obj instanceof EE_Question_Group) { |
|
590 | + $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + |
|
595 | + $new_event->save(); |
|
596 | + |
|
597 | + // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
598 | + $cloned_tickets = array(); |
|
599 | + foreach ($orig_datetimes as $orig_dtt) { |
|
600 | + if (! $orig_dtt instanceof EE_Datetime) { |
|
601 | + continue; |
|
602 | + } |
|
603 | + $new_dtt = clone $orig_dtt; |
|
604 | + $orig_tkts = $orig_dtt->tickets(); |
|
605 | + // save new dtt then add to event |
|
606 | + $new_dtt->set('DTT_ID', 0); |
|
607 | + $new_dtt->set('DTT_sold', 0); |
|
608 | + $new_dtt->set_reserved(0); |
|
609 | + $new_dtt->save(); |
|
610 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
611 | + $new_event->save(); |
|
612 | + // now let's get the ticket relations setup. |
|
613 | + foreach ((array) $orig_tkts as $orig_tkt) { |
|
614 | + // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
615 | + if (! $orig_tkt instanceof EE_Ticket) { |
|
616 | + continue; |
|
617 | + } |
|
618 | + // is this ticket archived? If it is then let's skip |
|
619 | + if ($orig_tkt->get('TKT_deleted')) { |
|
620 | + continue; |
|
621 | + } |
|
622 | + // does this original ticket already exist in the clone_tickets cache? |
|
623 | + // If so we'll just use the new ticket from it. |
|
624 | + if (isset($cloned_tickets[ $orig_tkt->ID() ])) { |
|
625 | + $new_tkt = $cloned_tickets[ $orig_tkt->ID() ]; |
|
626 | + } else { |
|
627 | + $new_tkt = clone $orig_tkt; |
|
628 | + // get relations on the $orig_tkt that we need to setup. |
|
629 | + $orig_prices = $orig_tkt->prices(); |
|
630 | + $new_tkt->set('TKT_ID', 0); |
|
631 | + $new_tkt->set('TKT_sold', 0); |
|
632 | + $new_tkt->set('TKT_reserved', 0); |
|
633 | + $new_tkt->save(); // make sure new ticket has ID. |
|
634 | + // price relations on new ticket need to be setup. |
|
635 | + foreach ($orig_prices as $orig_price) { |
|
636 | + $new_price = clone $orig_price; |
|
637 | + $new_price->set('PRC_ID', 0); |
|
638 | + $new_price->save(); |
|
639 | + $new_tkt->_add_relation_to($new_price, 'Price'); |
|
640 | + $new_tkt->save(); |
|
641 | + } |
|
642 | + |
|
643 | + do_action( |
|
644 | + 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
645 | + $orig_tkt, |
|
646 | + $new_tkt, |
|
647 | + $orig_prices, |
|
648 | + $orig_event, |
|
649 | + $orig_dtt, |
|
650 | + $new_dtt |
|
651 | + ); |
|
652 | + } |
|
653 | + // k now we can add the new ticket as a relation to the new datetime |
|
654 | + // and make sure its added to our cached $cloned_tickets array |
|
655 | + // for use with later datetimes that have the same ticket. |
|
656 | + $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
|
657 | + $new_dtt->save(); |
|
658 | + $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt; |
|
659 | + } |
|
660 | + } |
|
661 | + // clone taxonomy information |
|
662 | + $taxonomies_to_clone_with = apply_filters( |
|
663 | + 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
664 | + array('espresso_event_categories', 'espresso_event_type', 'post_tag') |
|
665 | + ); |
|
666 | + // get terms for original event (notice) |
|
667 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
668 | + // loop through terms and add them to new event. |
|
669 | + foreach ($orig_terms as $term) { |
|
670 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
671 | + } |
|
672 | + |
|
673 | + // duplicate other core WP_Post items for this event. |
|
674 | + // post thumbnail (feature image). |
|
675 | + $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
676 | + if ($feature_image_id) { |
|
677 | + update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
678 | + } |
|
679 | + |
|
680 | + // duplicate page_template setting |
|
681 | + $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
682 | + if ($page_template) { |
|
683 | + update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
684 | + } |
|
685 | + |
|
686 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
687 | + // now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
688 | + if ($new_event->ID()) { |
|
689 | + $redirect_args = array( |
|
690 | + 'post' => $new_event->ID(), |
|
691 | + 'action' => 'edit', |
|
692 | + ); |
|
693 | + EE_Error::add_success( |
|
694 | + esc_html__( |
|
695 | + 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
696 | + 'event_espresso' |
|
697 | + ) |
|
698 | + ); |
|
699 | + } else { |
|
700 | + $redirect_args = array( |
|
701 | + 'action' => 'default', |
|
702 | + ); |
|
703 | + EE_Error::add_error( |
|
704 | + esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
705 | + __FILE__, |
|
706 | + __FUNCTION__, |
|
707 | + __LINE__ |
|
708 | + ); |
|
709 | + } |
|
710 | + $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
711 | + } |
|
712 | + |
|
713 | + |
|
714 | + /** |
|
715 | + * Generates output for the import page. |
|
716 | + * |
|
717 | + * @throws DomainException |
|
718 | + */ |
|
719 | + protected function _import_page() |
|
720 | + { |
|
721 | + $title = esc_html__('Import', 'event_espresso'); |
|
722 | + $intro = esc_html__( |
|
723 | + 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
724 | + 'event_espresso' |
|
725 | + ); |
|
726 | + $form_url = EVENTS_ADMIN_URL; |
|
727 | + $action = 'import_events'; |
|
728 | + $type = 'csv'; |
|
729 | + $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
730 | + $title, |
|
731 | + $intro, |
|
732 | + $form_url, |
|
733 | + $action, |
|
734 | + $type |
|
735 | + ); |
|
736 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
737 | + array('action' => 'sample_export_file'), |
|
738 | + $this->_admin_base_url |
|
739 | + ); |
|
740 | + $content = EEH_Template::display_template( |
|
741 | + EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
742 | + $this->_template_args, |
|
743 | + true |
|
744 | + ); |
|
745 | + $this->_template_args['admin_page_content'] = $content; |
|
746 | + $this->display_admin_page_with_sidebar(); |
|
747 | + } |
|
748 | + |
|
749 | + |
|
750 | + /** |
|
751 | + * _import_events |
|
752 | + * This handles displaying the screen and running imports for importing events. |
|
753 | + * |
|
754 | + * @return void |
|
755 | + */ |
|
756 | + protected function _import_events() |
|
757 | + { |
|
758 | + require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
759 | + $success = EE_Import::instance()->import(); |
|
760 | + $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
761 | + } |
|
762 | + |
|
763 | + |
|
764 | + /** |
|
765 | + * _events_export |
|
766 | + * Will export all (or just the given event) to a Excel compatible file. |
|
767 | + * |
|
768 | + * @access protected |
|
769 | + * @return void |
|
770 | + */ |
|
771 | + protected function _events_export() |
|
772 | + { |
|
773 | + if (isset($this->_req_data['EVT_ID'])) { |
|
774 | + $event_ids = $this->_req_data['EVT_ID']; |
|
775 | + } elseif (isset($this->_req_data['EVT_IDs'])) { |
|
776 | + $event_ids = $this->_req_data['EVT_IDs']; |
|
777 | + } else { |
|
778 | + $event_ids = null; |
|
779 | + } |
|
780 | + // todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
781 | + $new_request_args = array( |
|
782 | + 'export' => 'report', |
|
783 | + 'action' => 'all_event_data', |
|
784 | + 'EVT_ID' => $event_ids, |
|
785 | + ); |
|
786 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
787 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
788 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
789 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
790 | + $EE_Export->export(); |
|
791 | + } |
|
792 | + } |
|
793 | + |
|
794 | + |
|
795 | + /** |
|
796 | + * handle category exports() |
|
797 | + * |
|
798 | + * @return void |
|
799 | + */ |
|
800 | + protected function _categories_export() |
|
801 | + { |
|
802 | + // todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
803 | + $new_request_args = array( |
|
804 | + 'export' => 'report', |
|
805 | + 'action' => 'categories', |
|
806 | + 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
|
807 | + ); |
|
808 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
809 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
810 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
811 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
812 | + $EE_Export->export(); |
|
813 | + } |
|
814 | + } |
|
815 | + |
|
816 | + |
|
817 | + /** |
|
818 | + * Creates a sample CSV file for importing |
|
819 | + */ |
|
820 | + protected function _sample_export_file() |
|
821 | + { |
|
822 | + // require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
823 | + EE_Export::instance()->export_sample(); |
|
824 | + } |
|
825 | + |
|
826 | + |
|
827 | + /************* Template Settings *************/ |
|
828 | + /** |
|
829 | + * Generates template settings page output |
|
830 | + * |
|
831 | + * @throws DomainException |
|
832 | + * @throws EE_Error |
|
833 | + */ |
|
834 | + protected function _template_settings() |
|
835 | + { |
|
836 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
837 | + /** |
|
838 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
839 | + * from General_Settings_Admin_Page to here. |
|
840 | + */ |
|
841 | + $this->_template_args = apply_filters( |
|
842 | + 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
843 | + $this->_template_args |
|
844 | + ); |
|
845 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
846 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
847 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
848 | + EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
849 | + $this->_template_args, |
|
850 | + true |
|
851 | + ); |
|
852 | + $this->display_admin_page_with_sidebar(); |
|
853 | + } |
|
854 | + |
|
855 | + |
|
856 | + /** |
|
857 | + * Handler for updating template settings. |
|
858 | + * |
|
859 | + * @throws InvalidInterfaceException |
|
860 | + * @throws InvalidDataTypeException |
|
861 | + * @throws InvalidArgumentException |
|
862 | + */ |
|
863 | + protected function _update_template_settings() |
|
864 | + { |
|
865 | + /** |
|
866 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
867 | + * from General_Settings_Admin_Page to here. |
|
868 | + */ |
|
869 | + EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
870 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
871 | + EE_Registry::instance()->CFG->template_settings, |
|
872 | + $this->_req_data |
|
873 | + ); |
|
874 | + // update custom post type slugs and detect if we need to flush rewrite rules |
|
875 | + $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
876 | + EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) |
|
877 | + ? EE_Registry::instance()->CFG->core->event_cpt_slug |
|
878 | + : EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events'); |
|
879 | + $what = 'Template Settings'; |
|
880 | + $success = $this->_update_espresso_configuration( |
|
881 | + $what, |
|
882 | + EE_Registry::instance()->CFG->template_settings, |
|
883 | + __FILE__, |
|
884 | + __FUNCTION__, |
|
885 | + __LINE__ |
|
886 | + ); |
|
887 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
888 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
889 | + $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
890 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
891 | + ); |
|
892 | + $rewrite_rules->flush(); |
|
893 | + } |
|
894 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
895 | + } |
|
896 | + |
|
897 | + |
|
898 | + /** |
|
899 | + * _premium_event_editor_meta_boxes |
|
900 | + * add all metaboxes related to the event_editor |
|
901 | + * |
|
902 | + * @access protected |
|
903 | + * @return void |
|
904 | + * @throws EE_Error |
|
905 | + */ |
|
906 | + protected function _premium_event_editor_meta_boxes() |
|
907 | + { |
|
908 | + $this->verify_cpt_object(); |
|
909 | + add_meta_box( |
|
910 | + 'espresso_event_editor_event_options', |
|
911 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
912 | + array($this, 'registration_options_meta_box'), |
|
913 | + $this->page_slug, |
|
914 | + 'side', |
|
915 | + 'core' |
|
916 | + ); |
|
917 | + } |
|
918 | + |
|
919 | + |
|
920 | + /** |
|
921 | + * override caf metabox |
|
922 | + * |
|
923 | + * @return void |
|
924 | + * @throws DomainException |
|
925 | + */ |
|
926 | + public function registration_options_meta_box() |
|
927 | + { |
|
928 | + $yes_no_values = array( |
|
929 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
930 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
931 | + ); |
|
932 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
933 | + array( |
|
934 | + EEM_Registration::status_id_cancelled, |
|
935 | + EEM_Registration::status_id_declined, |
|
936 | + EEM_Registration::status_id_incomplete, |
|
937 | + EEM_Registration::status_id_wait_list, |
|
938 | + ), |
|
939 | + true |
|
940 | + ); |
|
941 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
942 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
943 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
944 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
945 | + 'default_reg_status', |
|
946 | + $default_reg_status_values, |
|
947 | + $this->_cpt_model_obj->default_registration_status() |
|
948 | + ); |
|
949 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
950 | + 'display_desc', |
|
951 | + $yes_no_values, |
|
952 | + $this->_cpt_model_obj->display_description() |
|
953 | + ); |
|
954 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
955 | + 'display_ticket_selector', |
|
956 | + $yes_no_values, |
|
957 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
958 | + '', |
|
959 | + '', |
|
960 | + false |
|
961 | + ); |
|
962 | + $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
963 | + 'EVT_default_registration_status', |
|
964 | + $default_reg_status_values, |
|
965 | + $this->_cpt_model_obj->default_registration_status() |
|
966 | + ); |
|
967 | + $template_args['additional_registration_options'] = apply_filters( |
|
968 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
969 | + '', |
|
970 | + $template_args, |
|
971 | + $yes_no_values, |
|
972 | + $default_reg_status_values |
|
973 | + ); |
|
974 | + EEH_Template::display_template( |
|
975 | + EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
976 | + $template_args |
|
977 | + ); |
|
978 | + } |
|
979 | + |
|
980 | + |
|
981 | + |
|
982 | + /** |
|
983 | + * wp_list_table_mods for caf |
|
984 | + * ============================ |
|
985 | + */ |
|
986 | + /** |
|
987 | + * hook into list table filters and provide filters for caffeinated list table |
|
988 | + * |
|
989 | + * @param array $old_filters any existing filters present |
|
990 | + * @param array $list_table_obj the list table object |
|
991 | + * @return array new filters |
|
992 | + */ |
|
993 | + public function list_table_filters($old_filters, $list_table_obj) |
|
994 | + { |
|
995 | + $filters = array(); |
|
996 | + // first month/year filters |
|
997 | + $filters[] = $this->espresso_event_months_dropdown(); |
|
998 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
999 | + // active status dropdown |
|
1000 | + if ($status !== 'draft') { |
|
1001 | + $filters[] = $this->active_status_dropdown( |
|
1002 | + isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '' |
|
1003 | + ); |
|
1004 | + $filters[] = $this->venuesDropdown( |
|
1005 | + isset($this->_req_data['venue']) ? $this->_req_data['venue'] : '' |
|
1006 | + ); |
|
1007 | + } |
|
1008 | + // category filter |
|
1009 | + $filters[] = $this->category_dropdown(); |
|
1010 | + return array_merge($old_filters, $filters); |
|
1011 | + } |
|
1012 | + |
|
1013 | + |
|
1014 | + /** |
|
1015 | + * espresso_event_months_dropdown |
|
1016 | + * |
|
1017 | + * @access public |
|
1018 | + * @return string dropdown listing month/year selections for events. |
|
1019 | + */ |
|
1020 | + public function espresso_event_months_dropdown() |
|
1021 | + { |
|
1022 | + // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
1023 | + // Note we need to include any other filters that are set! |
|
1024 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1025 | + // categories? |
|
1026 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1027 | + ? $this->_req_data['EVT_CAT'] |
|
1028 | + : null; |
|
1029 | + // active status? |
|
1030 | + $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null; |
|
1031 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
1032 | + return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
1033 | + } |
|
1034 | + |
|
1035 | + |
|
1036 | + /** |
|
1037 | + * returns a list of "active" statuses on the event |
|
1038 | + * |
|
1039 | + * @param string $current_value whatever the current active status is |
|
1040 | + * @return string |
|
1041 | + */ |
|
1042 | + public function active_status_dropdown($current_value = '') |
|
1043 | + { |
|
1044 | + $select_name = 'active_status'; |
|
1045 | + $values = array( |
|
1046 | + 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
1047 | + 'active' => esc_html__('Active', 'event_espresso'), |
|
1048 | + 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
1049 | + 'expired' => esc_html__('Expired', 'event_espresso'), |
|
1050 | + 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
1051 | + ); |
|
1052 | + |
|
1053 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide'); |
|
1054 | + } |
|
1055 | + |
|
1056 | + /** |
|
1057 | + * returns a list of "venues" |
|
1058 | + * |
|
1059 | + * @param string $current_value whatever the current active status is |
|
1060 | + * @return string |
|
1061 | + */ |
|
1062 | + protected function venuesDropdown($current_value = '') |
|
1063 | + { |
|
1064 | + $select_name = 'venue'; |
|
1065 | + $values = array( |
|
1066 | + '' => esc_html__('All Venues', 'event_espresso'), |
|
1067 | + ); |
|
1068 | + // populate the list of venues. |
|
1069 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1070 | + $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC'))); |
|
1071 | + |
|
1072 | + foreach ($venues as $venue) { |
|
1073 | + $values[ $venue->ID() ] = $venue->name(); |
|
1074 | + } |
|
1075 | + |
|
1076 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide'); |
|
1077 | + } |
|
1078 | + |
|
1079 | + |
|
1080 | + /** |
|
1081 | + * output a dropdown of the categories for the category filter on the event admin list table |
|
1082 | + * |
|
1083 | + * @access public |
|
1084 | + * @return string html |
|
1085 | + */ |
|
1086 | + public function category_dropdown() |
|
1087 | + { |
|
1088 | + $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
1089 | + return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
1090 | + } |
|
1091 | + |
|
1092 | + |
|
1093 | + /** |
|
1094 | + * get total number of events today |
|
1095 | + * |
|
1096 | + * @access public |
|
1097 | + * @return int |
|
1098 | + * @throws EE_Error |
|
1099 | + */ |
|
1100 | + public function total_events_today() |
|
1101 | + { |
|
1102 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1103 | + 'DTT_EVT_start', |
|
1104 | + date('Y-m-d') . ' 00:00:00', |
|
1105 | + 'Y-m-d H:i:s', |
|
1106 | + 'UTC' |
|
1107 | + ); |
|
1108 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1109 | + 'DTT_EVT_start', |
|
1110 | + date('Y-m-d') . ' 23:59:59', |
|
1111 | + 'Y-m-d H:i:s', |
|
1112 | + 'UTC' |
|
1113 | + ); |
|
1114 | + $where = array( |
|
1115 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1116 | + ); |
|
1117 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1118 | + return $count; |
|
1119 | + } |
|
1120 | + |
|
1121 | + |
|
1122 | + /** |
|
1123 | + * get total number of events this month |
|
1124 | + * |
|
1125 | + * @access public |
|
1126 | + * @return int |
|
1127 | + * @throws EE_Error |
|
1128 | + */ |
|
1129 | + public function total_events_this_month() |
|
1130 | + { |
|
1131 | + // Dates |
|
1132 | + $this_year_r = date('Y'); |
|
1133 | + $this_month_r = date('m'); |
|
1134 | + $days_this_month = date('t'); |
|
1135 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1136 | + 'DTT_EVT_start', |
|
1137 | + $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1138 | + 'Y-m-d H:i:s', |
|
1139 | + 'UTC' |
|
1140 | + ); |
|
1141 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1142 | + 'DTT_EVT_start', |
|
1143 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1144 | + 'Y-m-d H:i:s', |
|
1145 | + 'UTC' |
|
1146 | + ); |
|
1147 | + $where = array( |
|
1148 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1149 | + ); |
|
1150 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1151 | + return $count; |
|
1152 | + } |
|
1153 | + |
|
1154 | + |
|
1155 | + /** DEFAULT TICKETS STUFF **/ |
|
1156 | + |
|
1157 | + /** |
|
1158 | + * Output default tickets list table view. |
|
1159 | + */ |
|
1160 | + public function _tickets_overview_list_table() |
|
1161 | + { |
|
1162 | + $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1163 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1164 | + } |
|
1165 | + |
|
1166 | + |
|
1167 | + /** |
|
1168 | + * @param int $per_page |
|
1169 | + * @param bool $count |
|
1170 | + * @param bool $trashed |
|
1171 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
1172 | + */ |
|
1173 | + public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
1174 | + { |
|
1175 | + $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1176 | + $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1177 | + switch ($orderby) { |
|
1178 | + case 'TKT_name': |
|
1179 | + $orderby = array('TKT_name' => $order); |
|
1180 | + break; |
|
1181 | + case 'TKT_price': |
|
1182 | + $orderby = array('TKT_price' => $order); |
|
1183 | + break; |
|
1184 | + case 'TKT_uses': |
|
1185 | + $orderby = array('TKT_uses' => $order); |
|
1186 | + break; |
|
1187 | + case 'TKT_min': |
|
1188 | + $orderby = array('TKT_min' => $order); |
|
1189 | + break; |
|
1190 | + case 'TKT_max': |
|
1191 | + $orderby = array('TKT_max' => $order); |
|
1192 | + break; |
|
1193 | + case 'TKT_qty': |
|
1194 | + $orderby = array('TKT_qty' => $order); |
|
1195 | + break; |
|
1196 | + } |
|
1197 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
1198 | + ? $this->_req_data['paged'] |
|
1199 | + : 1; |
|
1200 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
1201 | + ? $this->_req_data['perpage'] |
|
1202 | + : $per_page; |
|
1203 | + $_where = array( |
|
1204 | + 'TKT_is_default' => 1, |
|
1205 | + 'TKT_deleted' => $trashed, |
|
1206 | + ); |
|
1207 | + $offset = ($current_page - 1) * $per_page; |
|
1208 | + $limit = array($offset, $per_page); |
|
1209 | + if (isset($this->_req_data['s'])) { |
|
1210 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1211 | + $_where['OR'] = array( |
|
1212 | + 'TKT_name' => array('LIKE', $sstr), |
|
1213 | + 'TKT_description' => array('LIKE', $sstr), |
|
1214 | + ); |
|
1215 | + } |
|
1216 | + $query_params = array( |
|
1217 | + $_where, |
|
1218 | + 'order_by' => $orderby, |
|
1219 | + 'limit' => $limit, |
|
1220 | + 'group_by' => 'TKT_ID', |
|
1221 | + ); |
|
1222 | + if ($count) { |
|
1223 | + return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
1224 | + } else { |
|
1225 | + return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
1226 | + } |
|
1227 | + } |
|
1228 | + |
|
1229 | + |
|
1230 | + /** |
|
1231 | + * @param bool $trash |
|
1232 | + * @throws EE_Error |
|
1233 | + */ |
|
1234 | + protected function _trash_or_restore_ticket($trash = false) |
|
1235 | + { |
|
1236 | + $success = 1; |
|
1237 | + $TKT = EEM_Ticket::instance(); |
|
1238 | + // checkboxes? |
|
1239 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1240 | + // if array has more than one element then success message should be plural |
|
1241 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1242 | + // cycle thru the boxes |
|
1243 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1244 | + if ($trash) { |
|
1245 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1246 | + $success = 0; |
|
1247 | + } |
|
1248 | + } else { |
|
1249 | + if (! $TKT->restore_by_ID($TKT_ID)) { |
|
1250 | + $success = 0; |
|
1251 | + } |
|
1252 | + } |
|
1253 | + } |
|
1254 | + } else { |
|
1255 | + // grab single id and trash |
|
1256 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1257 | + if ($trash) { |
|
1258 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1259 | + $success = 0; |
|
1260 | + } |
|
1261 | + } else { |
|
1262 | + if (! $TKT->restore_by_ID($TKT_ID)) { |
|
1263 | + $success = 0; |
|
1264 | + } |
|
1265 | + } |
|
1266 | + } |
|
1267 | + $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1268 | + $query_args = array( |
|
1269 | + 'action' => 'ticket_list_table', |
|
1270 | + 'status' => $trash ? '' : 'trashed', |
|
1271 | + ); |
|
1272 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1273 | + } |
|
1274 | + |
|
1275 | + |
|
1276 | + /** |
|
1277 | + * Handles trashing default ticket. |
|
1278 | + */ |
|
1279 | + protected function _delete_ticket() |
|
1280 | + { |
|
1281 | + $success = 1; |
|
1282 | + // checkboxes? |
|
1283 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1284 | + // if array has more than one element then success message should be plural |
|
1285 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1286 | + // cycle thru the boxes |
|
1287 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1288 | + // delete |
|
1289 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1290 | + $success = 0; |
|
1291 | + } |
|
1292 | + } |
|
1293 | + } else { |
|
1294 | + // grab single id and trash |
|
1295 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1296 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1297 | + $success = 0; |
|
1298 | + } |
|
1299 | + } |
|
1300 | + $action_desc = 'deleted'; |
|
1301 | + $query_args = array( |
|
1302 | + 'action' => 'ticket_list_table', |
|
1303 | + 'status' => 'trashed', |
|
1304 | + ); |
|
1305 | + // fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1306 | + if (EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1307 | + array(array('TKT_is_default' => 1)), |
|
1308 | + 'TKT_ID', |
|
1309 | + true |
|
1310 | + ) |
|
1311 | + ) { |
|
1312 | + $query_args = array(); |
|
1313 | + } |
|
1314 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1315 | + } |
|
1316 | + |
|
1317 | + |
|
1318 | + /** |
|
1319 | + * @param int $TKT_ID |
|
1320 | + * @return bool|int |
|
1321 | + * @throws EE_Error |
|
1322 | + */ |
|
1323 | + protected function _delete_the_ticket($TKT_ID) |
|
1324 | + { |
|
1325 | + $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1326 | + $tkt->_remove_relations('Datetime'); |
|
1327 | + // delete all related prices first |
|
1328 | + $tkt->delete_related_permanently('Price'); |
|
1329 | + return $tkt->delete_permanently(); |
|
1330 | + } |
|
1331 | + |
|
1332 | + |
|
1333 | + /** |
|
1334 | + * @param array $default_event_settings_form_subsections |
|
1335 | + * @return array |
|
1336 | + * @since $VID:$ |
|
1337 | + */ |
|
1338 | + public function advancedEditorAdminFormSection(array $default_event_settings_form_subsections) |
|
1339 | + { |
|
1340 | + return [ |
|
1341 | + 'use_advanced_editor' => new EE_Select_Input( |
|
1342 | + apply_filters( |
|
1343 | + 'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_answer_options', |
|
1344 | + [ |
|
1345 | + esc_html__('Legacy Editor', 'event_espresso'), |
|
1346 | + esc_html__('Advanced Editor', 'event_espresso'), |
|
1347 | + ] |
|
1348 | + ), |
|
1349 | + apply_filters( |
|
1350 | + 'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_settings', |
|
1351 | + [ |
|
1352 | + 'default' => $this->admin_config->useAdvancedEditor(), |
|
1353 | + 'html_label_text' => esc_html__('Activate Advanced Editor?', 'event_espresso'), |
|
1354 | + 'html_help_text' => sprintf( |
|
1355 | + esc_html__( |
|
1356 | + 'Controls whether the Event Espresso Event Editor continues to use the existing legacy editor that functions like the typical older WordPress admin you are used to,%1$sor uses the new Advanced Editor with a more powerful and easier to use interface. This may be automatically turned on in order to utilize advanced features from new addons.', |
|
1357 | + 'event_espresso' |
|
1358 | + ), |
|
1359 | + '<br />' |
|
1360 | + ), |
|
1361 | + ] |
|
1362 | + ) |
|
1363 | + ), |
|
1364 | + 'defaults_section_header' => new EE_Form_Section_HTML( |
|
1365 | + EEH_HTML::h2( |
|
1366 | + esc_html__('Default Settings', 'event_espresso'), |
|
1367 | + '', |
|
1368 | + 'ee-admin-settings-hdr' |
|
1369 | + ) |
|
1370 | + ), |
|
1371 | + ] + $default_event_settings_form_subsections; |
|
1372 | + } |
|
1373 | + |
|
1374 | + |
|
1375 | + /** |
|
1376 | + * @param array $valid_data |
|
1377 | + * @param EE_Config $config |
|
1378 | + * @since $VID:$ |
|
1379 | + */ |
|
1380 | + public function updateAdvancedEditorAdminFormSettings(array $valid_data, EE_Config $config) |
|
1381 | + { |
|
1382 | + $config->admin->setUseAdvancedEditor( |
|
1383 | + isset($valid_data['use_advanced_editor']) |
|
1384 | + ? $valid_data['use_advanced_editor'] |
|
1385 | + : false |
|
1386 | + ); |
|
1387 | + } |
|
1388 | 1388 | } |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | public function __construct($routing = true) |
30 | 30 | { |
31 | 31 | parent::__construct($routing); |
32 | - if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
33 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
34 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
35 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
32 | + if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
33 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/'); |
|
34 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/'); |
|
35 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/'); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | protected function _extend_page_config() |
44 | 44 | { |
45 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
45 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events'; |
|
46 | 46 | // is there a evt_id in the request? |
47 | 47 | $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
48 | 48 | ? $this->_req_data['EVT_ID'] |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | { |
264 | 264 | $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
265 | 265 | // make sure this is only when editing |
266 | - if (! empty($id)) { |
|
266 | + if ( ! empty($id)) { |
|
267 | 267 | $href = EE_Admin_Page::add_query_args_and_nonce( |
268 | 268 | array('action' => 'duplicate_event', 'EVT_ID' => $id), |
269 | 269 | $this->_admin_base_url |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | { |
316 | 316 | wp_register_script( |
317 | 317 | 'ee-event-editor-heartbeat', |
318 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
318 | + EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js', |
|
319 | 319 | array('ee_admin_js', 'heartbeat'), |
320 | 320 | EVENT_ESPRESSO_VERSION, |
321 | 321 | true |
@@ -328,15 +328,15 @@ discard block |
||
328 | 328 | if ($this->admin_config->useAdvancedEditor()) { |
329 | 329 | add_action( |
330 | 330 | 'admin_footer', |
331 | - function () { |
|
331 | + function() { |
|
332 | 332 | $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
333 | - $graphqlEndpoint = class_exists( 'WPGraphQL' ) ? trailingslashit( site_url() ) . \WPGraphQL\Router::$route : ''; |
|
333 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()).\WPGraphQL\Router::$route : ''; |
|
334 | 334 | if ($eventId) { |
335 | 335 | echo ' |
336 | 336 | <script type="text/javascript"> |
337 | 337 | /* <![CDATA[ */ |
338 | - var eeEditorEventId = ' . $eventId . '; |
|
339 | - var graphqlEndpoint = \'' . esc_url($graphqlEndpoint) . '\'; |
|
338 | + var eeEditorEventId = ' . $eventId.'; |
|
339 | + var graphqlEndpoint = \'' . esc_url($graphqlEndpoint).'\'; |
|
340 | 340 | /* ]]> */ |
341 | 341 | </script>'; |
342 | 342 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | public function add_additional_datetime_button($template, $template_args) |
358 | 358 | { |
359 | 359 | return EEH_Template::display_template( |
360 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
360 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php', |
|
361 | 361 | $template_args, |
362 | 362 | true |
363 | 363 | ); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | public function add_datetime_clone_button($template, $template_args) |
376 | 376 | { |
377 | 377 | return EEH_Template::display_template( |
378 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
378 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php', |
|
379 | 379 | $template_args, |
380 | 380 | true |
381 | 381 | ); |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | public function datetime_timezones_template($template, $template_args) |
394 | 394 | { |
395 | 395 | return EEH_Template::display_template( |
396 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
396 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php', |
|
397 | 397 | $template_args, |
398 | 398 | true |
399 | 399 | ); |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | { |
513 | 513 | // first make sure the ID for the event is in the request. |
514 | 514 | // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
515 | - if (! isset($this->_req_data['EVT_ID'])) { |
|
515 | + if ( ! isset($this->_req_data['EVT_ID'])) { |
|
516 | 516 | EE_Error::add_error( |
517 | 517 | esc_html__( |
518 | 518 | 'In order to duplicate an event an Event ID is required. None was given.', |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | } |
528 | 528 | // k we've got EVT_ID so let's use that to get the event we'll duplicate |
529 | 529 | $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
530 | - if (! $orig_event instanceof EE_Event) { |
|
530 | + if ( ! $orig_event instanceof EE_Event) { |
|
531 | 531 | throw new EE_Error( |
532 | 532 | sprintf( |
533 | 533 | esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | $orig_ven = $orig_event->get_many_related('Venue'); |
544 | 544 | // reset the ID and modify other details to make it clear this is a dupe |
545 | 545 | $new_event->set('EVT_ID', 0); |
546 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
546 | + $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso'); |
|
547 | 547 | $new_event->set('EVT_name', $new_name); |
548 | 548 | $new_event->set( |
549 | 549 | 'EVT_slug', |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | 'Question_Group', |
573 | 573 | [['Event_Question_Group.EQG_primary' => true]] |
574 | 574 | ); |
575 | - if (! empty($orig_primary_qgs)) { |
|
575 | + if ( ! empty($orig_primary_qgs)) { |
|
576 | 576 | foreach ($orig_primary_qgs as $id => $obj) { |
577 | 577 | if ($obj instanceof EE_Question_Group) { |
578 | 578 | $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | 'Question_Group', |
585 | 585 | [['Event_Question_Group.EQG_additional' => true]] |
586 | 586 | ); |
587 | - if (! empty($orig_additional_qgs)) { |
|
587 | + if ( ! empty($orig_additional_qgs)) { |
|
588 | 588 | foreach ($orig_additional_qgs as $id => $obj) { |
589 | 589 | if ($obj instanceof EE_Question_Group) { |
590 | 590 | $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
598 | 598 | $cloned_tickets = array(); |
599 | 599 | foreach ($orig_datetimes as $orig_dtt) { |
600 | - if (! $orig_dtt instanceof EE_Datetime) { |
|
600 | + if ( ! $orig_dtt instanceof EE_Datetime) { |
|
601 | 601 | continue; |
602 | 602 | } |
603 | 603 | $new_dtt = clone $orig_dtt; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | // now let's get the ticket relations setup. |
613 | 613 | foreach ((array) $orig_tkts as $orig_tkt) { |
614 | 614 | // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
615 | - if (! $orig_tkt instanceof EE_Ticket) { |
|
615 | + if ( ! $orig_tkt instanceof EE_Ticket) { |
|
616 | 616 | continue; |
617 | 617 | } |
618 | 618 | // is this ticket archived? If it is then let's skip |
@@ -621,8 +621,8 @@ discard block |
||
621 | 621 | } |
622 | 622 | // does this original ticket already exist in the clone_tickets cache? |
623 | 623 | // If so we'll just use the new ticket from it. |
624 | - if (isset($cloned_tickets[ $orig_tkt->ID() ])) { |
|
625 | - $new_tkt = $cloned_tickets[ $orig_tkt->ID() ]; |
|
624 | + if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
625 | + $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
|
626 | 626 | } else { |
627 | 627 | $new_tkt = clone $orig_tkt; |
628 | 628 | // get relations on the $orig_tkt that we need to setup. |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | // for use with later datetimes that have the same ticket. |
656 | 656 | $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
657 | 657 | $new_dtt->save(); |
658 | - $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt; |
|
658 | + $cloned_tickets[$orig_tkt->ID()] = $new_tkt; |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | // clone taxonomy information |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | $this->_admin_base_url |
739 | 739 | ); |
740 | 740 | $content = EEH_Template::display_template( |
741 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
741 | + EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php', |
|
742 | 742 | $this->_template_args, |
743 | 743 | true |
744 | 744 | ); |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | */ |
756 | 756 | protected function _import_events() |
757 | 757 | { |
758 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
758 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
759 | 759 | $success = EE_Import::instance()->import(); |
760 | 760 | $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
761 | 761 | } |
@@ -784,8 +784,8 @@ discard block |
||
784 | 784 | 'EVT_ID' => $event_ids, |
785 | 785 | ); |
786 | 786 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
787 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
788 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
787 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
788 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
789 | 789 | $EE_Export = EE_Export::instance($this->_req_data); |
790 | 790 | $EE_Export->export(); |
791 | 791 | } |
@@ -806,8 +806,8 @@ discard block |
||
806 | 806 | 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
807 | 807 | ); |
808 | 808 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
809 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
810 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
809 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
810 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
811 | 811 | $EE_Export = EE_Export::instance($this->_req_data); |
812 | 812 | $EE_Export->export(); |
813 | 813 | } |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | $this->_set_add_edit_form_tags('update_template_settings'); |
846 | 846 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
847 | 847 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
848 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
848 | + EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php', |
|
849 | 849 | $this->_template_args, |
850 | 850 | true |
851 | 851 | ); |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | $default_reg_status_values |
973 | 973 | ); |
974 | 974 | EEH_Template::display_template( |
975 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
975 | + EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php', |
|
976 | 976 | $template_args |
977 | 977 | ); |
978 | 978 | } |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC'))); |
1071 | 1071 | |
1072 | 1072 | foreach ($venues as $venue) { |
1073 | - $values[ $venue->ID() ] = $venue->name(); |
|
1073 | + $values[$venue->ID()] = $venue->name(); |
|
1074 | 1074 | } |
1075 | 1075 | |
1076 | 1076 | return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide'); |
@@ -1101,13 +1101,13 @@ discard block |
||
1101 | 1101 | { |
1102 | 1102 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
1103 | 1103 | 'DTT_EVT_start', |
1104 | - date('Y-m-d') . ' 00:00:00', |
|
1104 | + date('Y-m-d').' 00:00:00', |
|
1105 | 1105 | 'Y-m-d H:i:s', |
1106 | 1106 | 'UTC' |
1107 | 1107 | ); |
1108 | 1108 | $end = EEM_Datetime::instance()->convert_datetime_for_query( |
1109 | 1109 | 'DTT_EVT_start', |
1110 | - date('Y-m-d') . ' 23:59:59', |
|
1110 | + date('Y-m-d').' 23:59:59', |
|
1111 | 1111 | 'Y-m-d H:i:s', |
1112 | 1112 | 'UTC' |
1113 | 1113 | ); |
@@ -1134,13 +1134,13 @@ discard block |
||
1134 | 1134 | $days_this_month = date('t'); |
1135 | 1135 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
1136 | 1136 | 'DTT_EVT_start', |
1137 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1137 | + $this_year_r.'-'.$this_month_r.'-01 00:00:00', |
|
1138 | 1138 | 'Y-m-d H:i:s', |
1139 | 1139 | 'UTC' |
1140 | 1140 | ); |
1141 | 1141 | $end = EEM_Datetime::instance()->convert_datetime_for_query( |
1142 | 1142 | 'DTT_EVT_start', |
1143 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1143 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59', |
|
1144 | 1144 | 'Y-m-d H:i:s', |
1145 | 1145 | 'UTC' |
1146 | 1146 | ); |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | $offset = ($current_page - 1) * $per_page; |
1208 | 1208 | $limit = array($offset, $per_page); |
1209 | 1209 | if (isset($this->_req_data['s'])) { |
1210 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1210 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1211 | 1211 | $_where['OR'] = array( |
1212 | 1212 | 'TKT_name' => array('LIKE', $sstr), |
1213 | 1213 | 'TKT_description' => array('LIKE', $sstr), |
@@ -1236,17 +1236,17 @@ discard block |
||
1236 | 1236 | $success = 1; |
1237 | 1237 | $TKT = EEM_Ticket::instance(); |
1238 | 1238 | // checkboxes? |
1239 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1239 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1240 | 1240 | // if array has more than one element then success message should be plural |
1241 | 1241 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
1242 | 1242 | // cycle thru the boxes |
1243 | 1243 | while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
1244 | 1244 | if ($trash) { |
1245 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1245 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1246 | 1246 | $success = 0; |
1247 | 1247 | } |
1248 | 1248 | } else { |
1249 | - if (! $TKT->restore_by_ID($TKT_ID)) { |
|
1249 | + if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1250 | 1250 | $success = 0; |
1251 | 1251 | } |
1252 | 1252 | } |
@@ -1255,11 +1255,11 @@ discard block |
||
1255 | 1255 | // grab single id and trash |
1256 | 1256 | $TKT_ID = absint($this->_req_data['TKT_ID']); |
1257 | 1257 | if ($trash) { |
1258 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1258 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1259 | 1259 | $success = 0; |
1260 | 1260 | } |
1261 | 1261 | } else { |
1262 | - if (! $TKT->restore_by_ID($TKT_ID)) { |
|
1262 | + if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1263 | 1263 | $success = 0; |
1264 | 1264 | } |
1265 | 1265 | } |
@@ -1280,20 +1280,20 @@ discard block |
||
1280 | 1280 | { |
1281 | 1281 | $success = 1; |
1282 | 1282 | // checkboxes? |
1283 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1283 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1284 | 1284 | // if array has more than one element then success message should be plural |
1285 | 1285 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
1286 | 1286 | // cycle thru the boxes |
1287 | 1287 | while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
1288 | 1288 | // delete |
1289 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1289 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1290 | 1290 | $success = 0; |
1291 | 1291 | } |
1292 | 1292 | } |
1293 | 1293 | } else { |
1294 | 1294 | // grab single id and trash |
1295 | 1295 | $TKT_ID = absint($this->_req_data['TKT_ID']); |
1296 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1296 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1297 | 1297 | $success = 0; |
1298 | 1298 | } |
1299 | 1299 | } |