@@ -30,2276 +30,2276 @@ discard block |
||
| 30 | 30 | class Registrations_Admin_Page extends EE_Admin_Page_CPT |
| 31 | 31 | { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var EE_Registration |
|
| 35 | - */ |
|
| 36 | - private $_registration; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var EE_Event |
|
| 40 | - */ |
|
| 41 | - private $_reg_event; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var EE_Session |
|
| 45 | - */ |
|
| 46 | - private $_session; |
|
| 47 | - |
|
| 48 | - private static $_reg_status; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Form for displaying the custom questions for this registration. |
|
| 52 | - * This gets used a few times throughout the request so its best to cache it |
|
| 53 | - * |
|
| 54 | - * @var EE_Registration_Custom_Questions_Form |
|
| 55 | - */ |
|
| 56 | - protected $_reg_custom_questions_form = null; |
|
| 57 | - |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * constructor |
|
| 61 | - * |
|
| 62 | - * @Constructor |
|
| 63 | - * @access public |
|
| 64 | - * @param bool $routing |
|
| 65 | - * @return Registrations_Admin_Page |
|
| 66 | - */ |
|
| 67 | - public function __construct($routing = true) |
|
| 68 | - { |
|
| 69 | - parent::__construct($routing); |
|
| 70 | - add_action('wp_loaded', array($this, 'wp_loaded')); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - |
|
| 74 | - public function wp_loaded() |
|
| 75 | - { |
|
| 76 | - // when adding a new registration... |
|
| 77 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
|
| 78 | - EE_System::do_not_cache(); |
|
| 79 | - if (! isset($this->_req_data['processing_registration']) |
|
| 80 | - || absint($this->_req_data['processing_registration']) !== 1 |
|
| 81 | - ) { |
|
| 82 | - // and it's NOT the attendee information reg step |
|
| 83 | - // force cookie expiration by setting time to last week |
|
| 84 | - setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
| 85 | - // and update the global |
|
| 86 | - $_COOKIE['ee_registration_added'] = 0; |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - protected function _init_page_props() |
|
| 93 | - { |
|
| 94 | - $this->page_slug = REG_PG_SLUG; |
|
| 95 | - $this->_admin_base_url = REG_ADMIN_URL; |
|
| 96 | - $this->_admin_base_path = REG_ADMIN; |
|
| 97 | - $this->page_label = esc_html__('Registrations', 'event_espresso'); |
|
| 98 | - $this->_cpt_routes = array( |
|
| 99 | - 'add_new_attendee' => 'espresso_attendees', |
|
| 100 | - 'edit_attendee' => 'espresso_attendees', |
|
| 101 | - 'insert_attendee' => 'espresso_attendees', |
|
| 102 | - 'update_attendee' => 'espresso_attendees', |
|
| 103 | - ); |
|
| 104 | - $this->_cpt_model_names = array( |
|
| 105 | - 'add_new_attendee' => 'EEM_Attendee', |
|
| 106 | - 'edit_attendee' => 'EEM_Attendee', |
|
| 107 | - ); |
|
| 108 | - $this->_cpt_edit_routes = array( |
|
| 109 | - 'espresso_attendees' => 'edit_attendee', |
|
| 110 | - ); |
|
| 111 | - $this->_pagenow_map = array( |
|
| 112 | - 'add_new_attendee' => 'post-new.php', |
|
| 113 | - 'edit_attendee' => 'post.php', |
|
| 114 | - 'trash' => 'post.php', |
|
| 115 | - ); |
|
| 116 | - add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
| 117 | - //add filters so that the comment urls don't take users to a confusing 404 page |
|
| 118 | - add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - public function clear_comment_link($link, $comment, $args) |
|
| 123 | - { |
|
| 124 | - //gotta make sure this only happens on this route |
|
| 125 | - $post_type = get_post_type($comment->comment_post_ID); |
|
| 126 | - if ($post_type === 'espresso_attendees') { |
|
| 127 | - return '#commentsdiv'; |
|
| 128 | - } |
|
| 129 | - return $link; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - protected function _ajax_hooks() |
|
| 134 | - { |
|
| 135 | - //todo: all hooks for registrations ajax goes in here |
|
| 136 | - add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - protected function _define_page_props() |
|
| 141 | - { |
|
| 142 | - $this->_admin_page_title = $this->page_label; |
|
| 143 | - $this->_labels = array( |
|
| 144 | - 'buttons' => array( |
|
| 145 | - 'add-registrant' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 146 | - 'add-attendee' => esc_html__('Add Contact', 'event_espresso'), |
|
| 147 | - 'edit' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 148 | - 'report' => esc_html__("Event Registrations CSV Report", "event_espresso"), |
|
| 149 | - 'report_all' => esc_html__('All Registrations CSV Report', 'event_espresso'), |
|
| 150 | - 'report_filtered' => esc_html__('Filtered CSV Report', 'event_espresso'), |
|
| 151 | - 'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'), |
|
| 152 | - 'contact_list_export' => esc_html__("Export Data", "event_espresso"), |
|
| 153 | - ), |
|
| 154 | - 'publishbox' => array( |
|
| 155 | - 'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'), |
|
| 156 | - 'edit_attendee' => esc_html__("Update Contact Record", 'event_espresso'), |
|
| 157 | - ), |
|
| 158 | - 'hide_add_button_on_cpt_route' => array( |
|
| 159 | - 'edit_attendee' => true, |
|
| 160 | - ), |
|
| 161 | - ); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * grab url requests and route them |
|
| 167 | - * |
|
| 168 | - * @access private |
|
| 169 | - * @return void |
|
| 170 | - */ |
|
| 171 | - public function _set_page_routes() |
|
| 172 | - { |
|
| 173 | - $this->_get_registration_status_array(); |
|
| 174 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 175 | - ? $this->_req_data['_REG_ID'] : 0; |
|
| 176 | - $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 177 | - ? $this->_req_data['reg_status_change_form']['REG_ID'] |
|
| 178 | - : $reg_id; |
|
| 179 | - $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
| 180 | - ? $this->_req_data['ATT_ID'] : 0; |
|
| 181 | - $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) |
|
| 182 | - ? $this->_req_data['post'] |
|
| 183 | - : $att_id; |
|
| 184 | - $this->_page_routes = array( |
|
| 185 | - 'default' => array( |
|
| 186 | - 'func' => '_registrations_overview_list_table', |
|
| 187 | - 'capability' => 'ee_read_registrations', |
|
| 188 | - ), |
|
| 189 | - 'view_registration' => array( |
|
| 190 | - 'func' => '_registration_details', |
|
| 191 | - 'capability' => 'ee_read_registration', |
|
| 192 | - 'obj_id' => $reg_id, |
|
| 193 | - ), |
|
| 194 | - 'edit_registration' => array( |
|
| 195 | - 'func' => '_update_attendee_registration_form', |
|
| 196 | - 'noheader' => true, |
|
| 197 | - 'headers_sent_route' => 'view_registration', |
|
| 198 | - 'capability' => 'ee_edit_registration', |
|
| 199 | - 'obj_id' => $reg_id, |
|
| 200 | - '_REG_ID' => $reg_id, |
|
| 201 | - ), |
|
| 202 | - 'trash_registrations' => array( |
|
| 203 | - 'func' => '_trash_or_restore_registrations', |
|
| 204 | - 'args' => array('trash' => true), |
|
| 205 | - 'noheader' => true, |
|
| 206 | - 'capability' => 'ee_delete_registrations', |
|
| 207 | - ), |
|
| 208 | - 'restore_registrations' => array( |
|
| 209 | - 'func' => '_trash_or_restore_registrations', |
|
| 210 | - 'args' => array('trash' => false), |
|
| 211 | - 'noheader' => true, |
|
| 212 | - 'capability' => 'ee_delete_registrations', |
|
| 213 | - ), |
|
| 214 | - 'delete_registrations' => array( |
|
| 215 | - 'func' => '_delete_registrations', |
|
| 216 | - 'noheader' => true, |
|
| 217 | - 'capability' => 'ee_delete_registrations', |
|
| 218 | - ), |
|
| 219 | - 'new_registration' => array( |
|
| 220 | - 'func' => 'new_registration', |
|
| 221 | - 'capability' => 'ee_edit_registrations', |
|
| 222 | - ), |
|
| 223 | - 'process_reg_step' => array( |
|
| 224 | - 'func' => 'process_reg_step', |
|
| 225 | - 'noheader' => true, |
|
| 226 | - 'capability' => 'ee_edit_registrations', |
|
| 227 | - ), |
|
| 228 | - 'redirect_to_txn' => array( |
|
| 229 | - 'func' => 'redirect_to_txn', |
|
| 230 | - 'noheader' => true, |
|
| 231 | - 'capability' => 'ee_edit_registrations', |
|
| 232 | - ), |
|
| 233 | - 'change_reg_status' => array( |
|
| 234 | - 'func' => '_change_reg_status', |
|
| 235 | - 'noheader' => true, |
|
| 236 | - 'capability' => 'ee_edit_registration', |
|
| 237 | - 'obj_id' => $reg_id, |
|
| 238 | - ), |
|
| 239 | - 'approve_registration' => array( |
|
| 240 | - 'func' => 'approve_registration', |
|
| 241 | - 'noheader' => true, |
|
| 242 | - 'capability' => 'ee_edit_registration', |
|
| 243 | - 'obj_id' => $reg_id, |
|
| 244 | - ), |
|
| 245 | - 'approve_and_notify_registration' => array( |
|
| 246 | - 'func' => 'approve_registration', |
|
| 247 | - 'noheader' => true, |
|
| 248 | - 'args' => array(true), |
|
| 249 | - 'capability' => 'ee_edit_registration', |
|
| 250 | - 'obj_id' => $reg_id, |
|
| 251 | - ), |
|
| 252 | - 'approve_registrations' => array( |
|
| 253 | - 'func' => 'bulk_action_on_registrations', |
|
| 254 | - 'noheader' => true, |
|
| 255 | - 'capability' => 'ee_edit_registrations', |
|
| 256 | - 'args' => array('approve') |
|
| 257 | - ), |
|
| 258 | - 'approve_and_notify_registrations' => array( |
|
| 259 | - 'func' => 'bulk_action_on_registrations', |
|
| 260 | - 'noheader' => true, |
|
| 261 | - 'capability' => 'ee_edit_registrations', |
|
| 262 | - 'args' => array('approve', true) |
|
| 263 | - ), |
|
| 264 | - 'decline_registration' => array( |
|
| 265 | - 'func' => 'decline_registration', |
|
| 266 | - 'noheader' => true, |
|
| 267 | - 'capability' => 'ee_edit_registration', |
|
| 268 | - 'obj_id' => $reg_id, |
|
| 269 | - ), |
|
| 270 | - 'decline_and_notify_registration' => array( |
|
| 271 | - 'func' => 'decline_registration', |
|
| 272 | - 'noheader' => true, |
|
| 273 | - 'args' => array(true), |
|
| 274 | - 'capability' => 'ee_edit_registration', |
|
| 275 | - 'obj_id' => $reg_id, |
|
| 276 | - ), |
|
| 277 | - 'decline_registrations' => array( |
|
| 278 | - 'func' => 'bulk_action_on_registrations', |
|
| 279 | - 'noheader' => true, |
|
| 280 | - 'capability' => 'ee_edit_registrations', |
|
| 281 | - 'args' => array('decline') |
|
| 282 | - ), |
|
| 283 | - 'decline_and_notify_registrations' => array( |
|
| 284 | - 'func' => 'bulk_action_on_registrations', |
|
| 285 | - 'noheader' => true, |
|
| 286 | - 'capability' => 'ee_edit_registrations', |
|
| 287 | - 'args' => array('decline', true) |
|
| 288 | - ), |
|
| 289 | - 'pending_registration' => array( |
|
| 290 | - 'func' => 'pending_registration', |
|
| 291 | - 'noheader' => true, |
|
| 292 | - 'capability' => 'ee_edit_registration', |
|
| 293 | - 'obj_id' => $reg_id, |
|
| 294 | - ), |
|
| 295 | - 'pending_and_notify_registration' => array( |
|
| 296 | - 'func' => 'pending_registration', |
|
| 297 | - 'noheader' => true, |
|
| 298 | - 'args' => array(true), |
|
| 299 | - 'capability' => 'ee_edit_registration', |
|
| 300 | - 'obj_id' => $reg_id, |
|
| 301 | - ), |
|
| 302 | - 'pending_registrations' => array( |
|
| 303 | - 'func' => 'bulk_action_on_registrations', |
|
| 304 | - 'noheader' => true, |
|
| 305 | - 'capability' => 'ee_edit_registrations', |
|
| 306 | - 'args' => array('pending') |
|
| 307 | - ), |
|
| 308 | - 'pending_and_notify_registrations' => array( |
|
| 309 | - 'func' => 'bulk_action_on_registrations', |
|
| 310 | - 'noheader' => true, |
|
| 311 | - 'capability' => 'ee_edit_registrations', |
|
| 312 | - 'args' => array('pending', true) |
|
| 313 | - ), |
|
| 314 | - 'no_approve_registration' => array( |
|
| 315 | - 'func' => 'not_approve_registration', |
|
| 316 | - 'noheader' => true, |
|
| 317 | - 'capability' => 'ee_edit_registration', |
|
| 318 | - 'obj_id' => $reg_id, |
|
| 319 | - ), |
|
| 320 | - 'no_approve_and_notify_registration' => array( |
|
| 321 | - 'func' => 'not_approve_registration', |
|
| 322 | - 'noheader' => true, |
|
| 323 | - 'args' => array(true), |
|
| 324 | - 'capability' => 'ee_edit_registration', |
|
| 325 | - 'obj_id' => $reg_id, |
|
| 326 | - ), |
|
| 327 | - 'no_approve_registrations' => array( |
|
| 328 | - 'func' => 'bulk_action_on_registrations', |
|
| 329 | - 'noheader' => true, |
|
| 330 | - 'capability' => 'ee_edit_registrations', |
|
| 331 | - 'args' => array('not_approve') |
|
| 332 | - ), |
|
| 333 | - 'no_approve_and_notify_registrations' => array( |
|
| 334 | - 'func' => 'bulk_action_on_registrations', |
|
| 335 | - 'noheader' => true, |
|
| 336 | - 'capability' => 'ee_edit_registrations', |
|
| 337 | - 'args' => array('not_approve', true) |
|
| 338 | - ), |
|
| 339 | - 'cancel_registration' => array( |
|
| 340 | - 'func' => 'cancel_registration', |
|
| 341 | - 'noheader' => true, |
|
| 342 | - 'capability' => 'ee_edit_registration', |
|
| 343 | - 'obj_id' => $reg_id, |
|
| 344 | - ), |
|
| 345 | - 'cancel_and_notify_registration' => array( |
|
| 346 | - 'func' => 'cancel_registration', |
|
| 347 | - 'noheader' => true, |
|
| 348 | - 'args' => array(true), |
|
| 349 | - 'capability' => 'ee_edit_registration', |
|
| 350 | - 'obj_id' => $reg_id, |
|
| 351 | - ), |
|
| 352 | - 'cancel_registrations' => array( |
|
| 353 | - 'func' => 'bulk_action_on_registrations', |
|
| 354 | - 'noheader' => true, |
|
| 355 | - 'capability' => 'ee_edit_registrations', |
|
| 356 | - 'args' => array('cancel') |
|
| 357 | - ), |
|
| 358 | - 'cancel_and_notify_registrations' => array( |
|
| 359 | - 'func' => 'bulk_action_on_registrations', |
|
| 360 | - 'noheader' => true, |
|
| 361 | - 'capability' => 'ee_edit_registrations', |
|
| 362 | - 'args' => array('cancel', true) |
|
| 363 | - ), |
|
| 364 | - 'wait_list_registration' => array( |
|
| 365 | - 'func' => 'wait_list_registration', |
|
| 366 | - 'noheader' => true, |
|
| 367 | - 'capability' => 'ee_edit_registration', |
|
| 368 | - 'obj_id' => $reg_id, |
|
| 369 | - ), |
|
| 370 | - 'wait_list_and_notify_registration' => array( |
|
| 371 | - 'func' => 'wait_list_registration', |
|
| 372 | - 'noheader' => true, |
|
| 373 | - 'args' => array(true), |
|
| 374 | - 'capability' => 'ee_edit_registration', |
|
| 375 | - 'obj_id' => $reg_id, |
|
| 376 | - ), |
|
| 377 | - 'contact_list' => array( |
|
| 378 | - 'func' => '_attendee_contact_list_table', |
|
| 379 | - 'capability' => 'ee_read_contacts', |
|
| 380 | - ), |
|
| 381 | - 'add_new_attendee' => array( |
|
| 382 | - 'func' => '_create_new_cpt_item', |
|
| 383 | - 'args' => array( |
|
| 384 | - 'new_attendee' => true, |
|
| 385 | - 'capability' => 'ee_edit_contacts', |
|
| 386 | - ), |
|
| 387 | - ), |
|
| 388 | - 'edit_attendee' => array( |
|
| 389 | - 'func' => '_edit_cpt_item', |
|
| 390 | - 'capability' => 'ee_edit_contacts', |
|
| 391 | - 'obj_id' => $att_id, |
|
| 392 | - ), |
|
| 393 | - 'duplicate_attendee' => array( |
|
| 394 | - 'func' => '_duplicate_attendee', |
|
| 395 | - 'noheader' => true, |
|
| 396 | - 'capability' => 'ee_edit_contacts', |
|
| 397 | - 'obj_id' => $att_id, |
|
| 398 | - ), |
|
| 399 | - 'insert_attendee' => array( |
|
| 400 | - 'func' => '_insert_or_update_attendee', |
|
| 401 | - 'args' => array( |
|
| 402 | - 'new_attendee' => true, |
|
| 403 | - ), |
|
| 404 | - 'noheader' => true, |
|
| 405 | - 'capability' => 'ee_edit_contacts', |
|
| 406 | - ), |
|
| 407 | - 'update_attendee' => array( |
|
| 408 | - 'func' => '_insert_or_update_attendee', |
|
| 409 | - 'args' => array( |
|
| 410 | - 'new_attendee' => false, |
|
| 411 | - ), |
|
| 412 | - 'noheader' => true, |
|
| 413 | - 'capability' => 'ee_edit_contacts', |
|
| 414 | - 'obj_id' => $att_id, |
|
| 415 | - ), |
|
| 416 | - 'trash_attendees' => array( |
|
| 417 | - 'func' => '_trash_or_restore_attendees', |
|
| 418 | - 'args' => array( |
|
| 419 | - 'trash' => 'true' |
|
| 420 | - ), |
|
| 421 | - 'noheader' => true, |
|
| 422 | - 'capability' => 'ee_delete_contacts' |
|
| 423 | - ), |
|
| 424 | - 'trash_attendee' => array( |
|
| 425 | - 'func' => '_trash_or_restore_attendees', |
|
| 426 | - 'args' => array( |
|
| 427 | - 'trash' => true, |
|
| 428 | - ), |
|
| 429 | - 'noheader' => true, |
|
| 430 | - 'capability' => 'ee_delete_contacts', |
|
| 431 | - 'obj_id' => $att_id, |
|
| 432 | - ), |
|
| 433 | - 'restore_attendees' => array( |
|
| 434 | - 'func' => '_trash_or_restore_attendees', |
|
| 435 | - 'args' => array( |
|
| 436 | - 'trash' => false, |
|
| 437 | - ), |
|
| 438 | - 'noheader' => true, |
|
| 439 | - 'capability' => 'ee_delete_contacts', |
|
| 440 | - 'obj_id' => $att_id, |
|
| 441 | - ), |
|
| 442 | - 'resend_registration' => array( |
|
| 443 | - 'func' => '_resend_registration', |
|
| 444 | - 'noheader' => true, |
|
| 445 | - 'capability' => 'ee_send_message', |
|
| 446 | - ), |
|
| 447 | - 'registrations_report' => array( |
|
| 448 | - 'func' => '_registrations_report', |
|
| 449 | - 'noheader' => true, |
|
| 450 | - 'capability' => 'ee_read_registrations', |
|
| 451 | - ), |
|
| 452 | - 'contact_list_export' => array( |
|
| 453 | - 'func' => '_contact_list_export', |
|
| 454 | - 'noheader' => true, |
|
| 455 | - 'capability' => 'export', |
|
| 456 | - ), |
|
| 457 | - 'contact_list_report' => array( |
|
| 458 | - 'func' => '_contact_list_report', |
|
| 459 | - 'noheader' => true, |
|
| 460 | - 'capability' => 'ee_read_contacts', |
|
| 461 | - ), |
|
| 462 | - ); |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - |
|
| 466 | - protected function _set_page_config() |
|
| 467 | - { |
|
| 468 | - $this->_page_config = array( |
|
| 469 | - 'default' => array( |
|
| 470 | - 'nav' => array( |
|
| 471 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 472 | - 'order' => 5, |
|
| 473 | - ), |
|
| 474 | - 'help_tabs' => array( |
|
| 475 | - 'registrations_overview_help_tab' => array( |
|
| 476 | - 'title' => esc_html__('Registrations Overview', 'event_espresso'), |
|
| 477 | - 'filename' => 'registrations_overview', |
|
| 478 | - ), |
|
| 479 | - 'registrations_overview_table_column_headings_help_tab' => array( |
|
| 480 | - 'title' => esc_html__('Registrations Table Column Headings', 'event_espresso'), |
|
| 481 | - 'filename' => 'registrations_overview_table_column_headings', |
|
| 482 | - ), |
|
| 483 | - 'registrations_overview_filters_help_tab' => array( |
|
| 484 | - 'title' => esc_html__('Registration Filters', 'event_espresso'), |
|
| 485 | - 'filename' => 'registrations_overview_filters', |
|
| 486 | - ), |
|
| 487 | - 'registrations_overview_views_help_tab' => array( |
|
| 488 | - 'title' => esc_html__('Registration Views', 'event_espresso'), |
|
| 489 | - 'filename' => 'registrations_overview_views', |
|
| 490 | - ), |
|
| 491 | - 'registrations_regoverview_other_help_tab' => array( |
|
| 492 | - 'title' => esc_html__('Registrations Other', 'event_espresso'), |
|
| 493 | - 'filename' => 'registrations_overview_other', |
|
| 494 | - ), |
|
| 495 | - ), |
|
| 496 | - 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
| 497 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
| 498 | - 'list_table' => 'EE_Registrations_List_Table', |
|
| 499 | - 'require_nonce' => false, |
|
| 500 | - ), |
|
| 501 | - 'view_registration' => array( |
|
| 502 | - 'nav' => array( |
|
| 503 | - 'label' => esc_html__('REG Details', 'event_espresso'), |
|
| 504 | - 'order' => 15, |
|
| 505 | - 'url' => isset($this->_req_data['_REG_ID']) |
|
| 506 | - ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
| 507 | - : $this->_admin_base_url, |
|
| 508 | - 'persistent' => false, |
|
| 509 | - ), |
|
| 510 | - 'help_tabs' => array( |
|
| 511 | - 'registrations_details_help_tab' => array( |
|
| 512 | - 'title' => esc_html__('Registration Details', 'event_espresso'), |
|
| 513 | - 'filename' => 'registrations_details', |
|
| 514 | - ), |
|
| 515 | - 'registrations_details_table_help_tab' => array( |
|
| 516 | - 'title' => esc_html__('Registration Details Table', 'event_espresso'), |
|
| 517 | - 'filename' => 'registrations_details_table', |
|
| 518 | - ), |
|
| 519 | - 'registrations_details_form_answers_help_tab' => array( |
|
| 520 | - 'title' => esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 521 | - 'filename' => 'registrations_details_form_answers', |
|
| 522 | - ), |
|
| 523 | - 'registrations_details_registrant_details_help_tab' => array( |
|
| 524 | - 'title' => esc_html__('Contact Details', 'event_espresso'), |
|
| 525 | - 'filename' => 'registrations_details_registrant_details', |
|
| 526 | - ), |
|
| 527 | - ), |
|
| 528 | - 'help_tour' => array('Registration_Details_Help_Tour'), |
|
| 529 | - 'metaboxes' => array_merge( |
|
| 530 | - $this->_default_espresso_metaboxes, |
|
| 531 | - array('_registration_details_metaboxes') |
|
| 532 | - ), |
|
| 533 | - 'require_nonce' => false, |
|
| 534 | - ), |
|
| 535 | - 'new_registration' => array( |
|
| 536 | - 'nav' => array( |
|
| 537 | - 'label' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 538 | - 'url' => '#', |
|
| 539 | - 'order' => 15, |
|
| 540 | - 'persistent' => false, |
|
| 541 | - ), |
|
| 542 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 543 | - 'labels' => array( |
|
| 544 | - 'publishbox' => esc_html__('Save Registration', 'event_espresso'), |
|
| 545 | - ), |
|
| 546 | - 'require_nonce' => false, |
|
| 547 | - ), |
|
| 548 | - 'add_new_attendee' => array( |
|
| 549 | - 'nav' => array( |
|
| 550 | - 'label' => esc_html__('Add Contact', 'event_espresso'), |
|
| 551 | - 'order' => 15, |
|
| 552 | - 'persistent' => false, |
|
| 553 | - ), |
|
| 554 | - 'metaboxes' => array_merge( |
|
| 555 | - $this->_default_espresso_metaboxes, |
|
| 556 | - array('_publish_post_box', 'attendee_editor_metaboxes') |
|
| 557 | - ), |
|
| 558 | - 'require_nonce' => false, |
|
| 559 | - ), |
|
| 560 | - 'edit_attendee' => array( |
|
| 561 | - 'nav' => array( |
|
| 562 | - 'label' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 563 | - 'order' => 15, |
|
| 564 | - 'persistent' => false, |
|
| 565 | - 'url' => isset($this->_req_data['ATT_ID']) |
|
| 566 | - ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
| 567 | - : $this->_admin_base_url, |
|
| 568 | - ), |
|
| 569 | - 'metaboxes' => array('attendee_editor_metaboxes'), |
|
| 570 | - 'require_nonce' => false, |
|
| 571 | - ), |
|
| 572 | - 'contact_list' => array( |
|
| 573 | - 'nav' => array( |
|
| 574 | - 'label' => esc_html__('Contact List', 'event_espresso'), |
|
| 575 | - 'order' => 20, |
|
| 576 | - ), |
|
| 577 | - 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
| 578 | - 'help_tabs' => array( |
|
| 579 | - 'registrations_contact_list_help_tab' => array( |
|
| 580 | - 'title' => esc_html__('Registrations Contact List', 'event_espresso'), |
|
| 581 | - 'filename' => 'registrations_contact_list', |
|
| 582 | - ), |
|
| 583 | - 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
| 584 | - 'title' => esc_html__('Contact List Table Column Headings', 'event_espresso'), |
|
| 585 | - 'filename' => 'registrations_contact_list_table_column_headings', |
|
| 586 | - ), |
|
| 587 | - 'registrations_contact_list_views_help_tab' => array( |
|
| 588 | - 'title' => esc_html__('Contact List Views', 'event_espresso'), |
|
| 589 | - 'filename' => 'registrations_contact_list_views', |
|
| 590 | - ), |
|
| 591 | - 'registrations_contact_list_other_help_tab' => array( |
|
| 592 | - 'title' => esc_html__('Contact List Other', 'event_espresso'), |
|
| 593 | - 'filename' => 'registrations_contact_list_other', |
|
| 594 | - ), |
|
| 595 | - ), |
|
| 596 | - 'help_tour' => array('Contact_List_Help_Tour'), |
|
| 597 | - 'metaboxes' => array(), |
|
| 598 | - 'require_nonce' => false, |
|
| 599 | - ), |
|
| 600 | - //override default cpt routes |
|
| 601 | - 'create_new' => '', |
|
| 602 | - 'edit' => '', |
|
| 603 | - ); |
|
| 604 | - } |
|
| 605 | - |
|
| 606 | - |
|
| 607 | - /** |
|
| 608 | - * The below methods aren't used by this class currently |
|
| 609 | - */ |
|
| 610 | - protected function _add_screen_options() |
|
| 611 | - { |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - |
|
| 615 | - protected function _add_feature_pointers() |
|
| 616 | - { |
|
| 617 | - } |
|
| 618 | - |
|
| 619 | - |
|
| 620 | - public function admin_init() |
|
| 621 | - { |
|
| 622 | - EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__( |
|
| 623 | - 'click "Update Registration Questions" to save your changes', |
|
| 624 | - 'event_espresso' |
|
| 625 | - ); |
|
| 626 | - } |
|
| 627 | - |
|
| 628 | - |
|
| 629 | - public function admin_notices() |
|
| 630 | - { |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - |
|
| 634 | - public function admin_footer_scripts() |
|
| 635 | - { |
|
| 636 | - } |
|
| 637 | - |
|
| 638 | - |
|
| 639 | - /** |
|
| 640 | - * get list of registration statuses |
|
| 641 | - * |
|
| 642 | - * @access private |
|
| 643 | - * @return void |
|
| 644 | - */ |
|
| 645 | - private function _get_registration_status_array() |
|
| 646 | - { |
|
| 647 | - self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - |
|
| 651 | - protected function _add_screen_options_default() |
|
| 652 | - { |
|
| 653 | - $this->_per_page_screen_option(); |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - |
|
| 657 | - protected function _add_screen_options_contact_list() |
|
| 658 | - { |
|
| 659 | - $page_title = $this->_admin_page_title; |
|
| 660 | - $this->_admin_page_title = esc_html__("Contacts", 'event_espresso'); |
|
| 661 | - $this->_per_page_screen_option(); |
|
| 662 | - $this->_admin_page_title = $page_title; |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - |
|
| 666 | - public function load_scripts_styles() |
|
| 667 | - { |
|
| 668 | - //style |
|
| 669 | - wp_register_style( |
|
| 670 | - 'espresso_reg', |
|
| 671 | - REG_ASSETS_URL . 'espresso_registrations_admin.css', |
|
| 672 | - array('ee-admin-css'), |
|
| 673 | - EVENT_ESPRESSO_VERSION |
|
| 674 | - ); |
|
| 675 | - wp_enqueue_style('espresso_reg'); |
|
| 676 | - //script |
|
| 677 | - wp_register_script( |
|
| 678 | - 'espresso_reg', |
|
| 679 | - REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 680 | - array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), |
|
| 681 | - EVENT_ESPRESSO_VERSION, |
|
| 682 | - true |
|
| 683 | - ); |
|
| 684 | - wp_enqueue_script('espresso_reg'); |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - |
|
| 688 | - public function load_scripts_styles_edit_attendee() |
|
| 689 | - { |
|
| 690 | - //stuff to only show up on our attendee edit details page. |
|
| 691 | - $attendee_details_translations = array( |
|
| 692 | - 'att_publish_text' => sprintf( |
|
| 693 | - esc_html__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
| 694 | - $this->_cpt_model_obj->get_datetime('ATT_created') |
|
| 695 | - ), |
|
| 696 | - ); |
|
| 697 | - wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
| 698 | - wp_enqueue_script('jquery-validate'); |
|
| 699 | - } |
|
| 700 | - |
|
| 701 | - |
|
| 702 | - public function load_scripts_styles_view_registration() |
|
| 703 | - { |
|
| 704 | - //styles |
|
| 705 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 706 | - //scripts |
|
| 707 | - $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 708 | - $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
| 709 | - } |
|
| 710 | - |
|
| 711 | - |
|
| 712 | - public function load_scripts_styles_contact_list() |
|
| 713 | - { |
|
| 714 | - wp_deregister_style('espresso_reg'); |
|
| 715 | - wp_register_style( |
|
| 716 | - 'espresso_att', |
|
| 717 | - REG_ASSETS_URL . 'espresso_attendees_admin.css', |
|
| 718 | - array('ee-admin-css'), |
|
| 719 | - EVENT_ESPRESSO_VERSION |
|
| 720 | - ); |
|
| 721 | - wp_enqueue_style('espresso_att'); |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - |
|
| 725 | - public function load_scripts_styles_new_registration() |
|
| 726 | - { |
|
| 727 | - wp_register_script( |
|
| 728 | - 'ee-spco-for-admin', |
|
| 729 | - REG_ASSETS_URL . 'spco_for_admin.js', |
|
| 730 | - array('underscore', 'jquery'), |
|
| 731 | - EVENT_ESPRESSO_VERSION, |
|
| 732 | - true |
|
| 733 | - ); |
|
| 734 | - wp_enqueue_script('ee-spco-for-admin'); |
|
| 735 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 736 | - EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
| 737 | - EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
| 738 | - EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
| 739 | - } |
|
| 740 | - |
|
| 741 | - |
|
| 742 | - public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
| 743 | - { |
|
| 744 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - |
|
| 748 | - public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
| 749 | - { |
|
| 750 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - |
|
| 754 | - protected function _set_list_table_views_default() |
|
| 755 | - { |
|
| 756 | - //for notification related bulk actions we need to make sure only active messengers have an option. |
|
| 757 | - EED_Messages::set_autoloaders(); |
|
| 758 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 759 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 760 | - $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
| 761 | - //key= bulk_action_slug, value= message type. |
|
| 762 | - $match_array = array( |
|
| 763 | - 'approve_registrations' => 'registration', |
|
| 764 | - 'decline_registrations' => 'declined_registration', |
|
| 765 | - 'pending_registrations' => 'pending_approval', |
|
| 766 | - 'no_approve_registrations' => 'not_approved_registration', |
|
| 767 | - 'cancel_registrations' => 'cancelled_registration', |
|
| 768 | - ); |
|
| 769 | - $can_send = EE_Registry::instance()->CAP->current_user_can( |
|
| 770 | - 'ee_send_message', |
|
| 771 | - 'batch_send_messages' |
|
| 772 | - ); |
|
| 773 | - /** setup reg status bulk actions **/ |
|
| 774 | - $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso'); |
|
| 775 | - if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) { |
|
| 776 | - $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__( |
|
| 777 | - 'Approve and Notify Registrations', |
|
| 778 | - 'event_espresso' |
|
| 779 | - ); |
|
| 780 | - } |
|
| 781 | - $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso'); |
|
| 782 | - if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) { |
|
| 783 | - $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__( |
|
| 784 | - 'Decline and Notify Registrations', |
|
| 785 | - 'event_espresso' |
|
| 786 | - ); |
|
| 787 | - } |
|
| 788 | - $def_reg_status_actions['pending_registrations'] = esc_html__( |
|
| 789 | - 'Set Registrations to Pending Payment', |
|
| 790 | - 'event_espresso' |
|
| 791 | - ); |
|
| 792 | - if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) { |
|
| 793 | - $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__( |
|
| 794 | - 'Set Registrations to Pending Payment and Notify', |
|
| 795 | - 'event_espresso' |
|
| 796 | - ); |
|
| 797 | - } |
|
| 798 | - $def_reg_status_actions['no_approve_registrations'] = esc_html__( |
|
| 799 | - 'Set Registrations to Not Approved', |
|
| 800 | - 'event_espresso' |
|
| 801 | - ); |
|
| 802 | - if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) { |
|
| 803 | - $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__( |
|
| 804 | - 'Set Registrations to Not Approved and Notify', |
|
| 805 | - 'event_espresso' |
|
| 806 | - ); |
|
| 807 | - } |
|
| 808 | - $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso'); |
|
| 809 | - if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) { |
|
| 810 | - $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__( |
|
| 811 | - 'Cancel Registrations and Notify', |
|
| 812 | - 'event_espresso' |
|
| 813 | - ); |
|
| 814 | - } |
|
| 815 | - $def_reg_status_actions = apply_filters( |
|
| 816 | - 'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array', |
|
| 817 | - $def_reg_status_actions, |
|
| 818 | - $active_mts, |
|
| 819 | - $can_send |
|
| 820 | - ); |
|
| 821 | - |
|
| 822 | - $this->_views = array( |
|
| 823 | - 'all' => array( |
|
| 824 | - 'slug' => 'all', |
|
| 825 | - 'label' => esc_html__('View All Registrations', 'event_espresso'), |
|
| 826 | - 'count' => 0, |
|
| 827 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 828 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 829 | - )), |
|
| 830 | - ), |
|
| 831 | - 'month' => array( |
|
| 832 | - 'slug' => 'month', |
|
| 833 | - 'label' => esc_html__('This Month', 'event_espresso'), |
|
| 834 | - 'count' => 0, |
|
| 835 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 836 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 837 | - )), |
|
| 838 | - ), |
|
| 839 | - 'today' => array( |
|
| 840 | - 'slug' => 'today', |
|
| 841 | - 'label' => sprintf( |
|
| 842 | - esc_html__('Today - %s', 'event_espresso'), |
|
| 843 | - date('M d, Y', current_time('timestamp')) |
|
| 844 | - ), |
|
| 845 | - 'count' => 0, |
|
| 846 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 847 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 848 | - )), |
|
| 849 | - ), |
|
| 850 | - ); |
|
| 851 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 852 | - 'ee_delete_registrations', |
|
| 853 | - 'espresso_registrations_delete_registration' |
|
| 854 | - )) { |
|
| 855 | - $this->_views['incomplete'] = array( |
|
| 856 | - 'slug' => 'incomplete', |
|
| 857 | - 'label' => esc_html__('Incomplete', 'event_espresso'), |
|
| 858 | - 'count' => 0, |
|
| 859 | - 'bulk_action' => array( |
|
| 860 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 861 | - ), |
|
| 862 | - ); |
|
| 863 | - $this->_views['trash'] = array( |
|
| 864 | - 'slug' => 'trash', |
|
| 865 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 866 | - 'count' => 0, |
|
| 867 | - 'bulk_action' => array( |
|
| 868 | - 'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'), |
|
| 869 | - 'delete_registrations' => esc_html__('Delete Registrations Permanently', 'event_espresso'), |
|
| 870 | - ), |
|
| 871 | - ); |
|
| 872 | - } |
|
| 873 | - } |
|
| 874 | - |
|
| 875 | - |
|
| 876 | - protected function _set_list_table_views_contact_list() |
|
| 877 | - { |
|
| 878 | - $this->_views = array( |
|
| 879 | - 'in_use' => array( |
|
| 880 | - 'slug' => 'in_use', |
|
| 881 | - 'label' => esc_html__('In Use', 'event_espresso'), |
|
| 882 | - 'count' => 0, |
|
| 883 | - 'bulk_action' => array( |
|
| 884 | - 'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 885 | - ), |
|
| 886 | - ), |
|
| 887 | - ); |
|
| 888 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
| 889 | - 'espresso_registrations_trash_attendees') |
|
| 890 | - ) { |
|
| 891 | - $this->_views['trash'] = array( |
|
| 892 | - 'slug' => 'trash', |
|
| 893 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 894 | - 'count' => 0, |
|
| 895 | - 'bulk_action' => array( |
|
| 896 | - 'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 897 | - ), |
|
| 898 | - ); |
|
| 899 | - } |
|
| 900 | - } |
|
| 901 | - |
|
| 902 | - |
|
| 903 | - protected function _registration_legend_items() |
|
| 904 | - { |
|
| 905 | - $fc_items = array( |
|
| 906 | - 'star-icon' => array( |
|
| 907 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 908 | - 'desc' => esc_html__('This is the Primary Registrant', 'event_espresso'), |
|
| 909 | - ), |
|
| 910 | - 'view_details' => array( |
|
| 911 | - 'class' => 'dashicons dashicons-clipboard', |
|
| 912 | - 'desc' => esc_html__('View Registration Details', 'event_espresso'), |
|
| 913 | - ), |
|
| 914 | - 'edit_attendee' => array( |
|
| 915 | - 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
| 916 | - 'desc' => esc_html__('Edit Contact Details', 'event_espresso'), |
|
| 917 | - ), |
|
| 918 | - 'view_transaction' => array( |
|
| 919 | - 'class' => 'dashicons dashicons-cart', |
|
| 920 | - 'desc' => esc_html__('View Transaction Details', 'event_espresso'), |
|
| 921 | - ), |
|
| 922 | - 'view_invoice' => array( |
|
| 923 | - 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 924 | - 'desc' => esc_html__('View Transaction Invoice', 'event_espresso'), |
|
| 925 | - ), |
|
| 926 | - ); |
|
| 927 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 928 | - 'ee_send_message', |
|
| 929 | - 'espresso_registrations_resend_registration' |
|
| 930 | - )) { |
|
| 931 | - $fc_items['resend_registration'] = array( |
|
| 932 | - 'class' => 'dashicons dashicons-email-alt', |
|
| 933 | - 'desc' => esc_html__('Resend Registration Details', 'event_espresso'), |
|
| 934 | - ); |
|
| 935 | - } else { |
|
| 936 | - $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
| 937 | - } |
|
| 938 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 939 | - 'ee_read_global_messages', |
|
| 940 | - 'view_filtered_messages' |
|
| 941 | - )) { |
|
| 942 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 943 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 944 | - $fc_items['view_related_messages'] = array( |
|
| 945 | - 'class' => $related_for_icon['css_class'], |
|
| 946 | - 'desc' => $related_for_icon['label'], |
|
| 947 | - ); |
|
| 948 | - } |
|
| 949 | - } |
|
| 950 | - $sc_items = array( |
|
| 951 | - 'approved_status' => array( |
|
| 952 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 953 | - 'desc' => EEH_Template::pretty_status( |
|
| 954 | - EEM_Registration::status_id_approved, |
|
| 955 | - false, |
|
| 956 | - 'sentence' |
|
| 957 | - ), |
|
| 958 | - ), |
|
| 959 | - 'pending_status' => array( |
|
| 960 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 961 | - 'desc' => EEH_Template::pretty_status( |
|
| 962 | - EEM_Registration::status_id_pending_payment, |
|
| 963 | - false, |
|
| 964 | - 'sentence' |
|
| 965 | - ), |
|
| 966 | - ), |
|
| 967 | - 'wait_list' => array( |
|
| 968 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 969 | - 'desc' => EEH_Template::pretty_status( |
|
| 970 | - EEM_Registration::status_id_wait_list, |
|
| 971 | - false, |
|
| 972 | - 'sentence' |
|
| 973 | - ), |
|
| 974 | - ), |
|
| 975 | - 'incomplete_status' => array( |
|
| 976 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 977 | - 'desc' => EEH_Template::pretty_status( |
|
| 978 | - EEM_Registration::status_id_incomplete, |
|
| 979 | - false, |
|
| 980 | - 'sentence' |
|
| 981 | - ), |
|
| 982 | - ), |
|
| 983 | - 'not_approved' => array( |
|
| 984 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 985 | - 'desc' => EEH_Template::pretty_status( |
|
| 986 | - EEM_Registration::status_id_not_approved, |
|
| 987 | - false, |
|
| 988 | - 'sentence' |
|
| 989 | - ), |
|
| 990 | - ), |
|
| 991 | - 'declined_status' => array( |
|
| 992 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 993 | - 'desc' => EEH_Template::pretty_status( |
|
| 994 | - EEM_Registration::status_id_declined, |
|
| 995 | - false, |
|
| 996 | - 'sentence' |
|
| 997 | - ), |
|
| 998 | - ), |
|
| 999 | - 'cancelled_status' => array( |
|
| 1000 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1001 | - 'desc' => EEH_Template::pretty_status( |
|
| 1002 | - EEM_Registration::status_id_cancelled, |
|
| 1003 | - false, |
|
| 1004 | - 'sentence' |
|
| 1005 | - ), |
|
| 1006 | - ), |
|
| 1007 | - ); |
|
| 1008 | - return array_merge($fc_items, $sc_items); |
|
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - |
|
| 1012 | - |
|
| 1013 | - /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
| 1014 | - /** |
|
| 1015 | - * @throws \EE_Error |
|
| 1016 | - */ |
|
| 1017 | - protected function _registrations_overview_list_table() |
|
| 1018 | - { |
|
| 1019 | - $this->_template_args['admin_page_header'] = ''; |
|
| 1020 | - $EVT_ID = ! empty($this->_req_data['event_id']) |
|
| 1021 | - ? absint($this->_req_data['event_id']) |
|
| 1022 | - : 0; |
|
| 1023 | - if ($EVT_ID) { |
|
| 1024 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 1025 | - 'ee_edit_registrations', |
|
| 1026 | - 'espresso_registrations_new_registration', |
|
| 1027 | - $EVT_ID |
|
| 1028 | - )) { |
|
| 1029 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 1030 | - 'new_registration', |
|
| 1031 | - 'add-registrant', |
|
| 1032 | - array('event_id' => $EVT_ID), |
|
| 1033 | - 'add-new-h2' |
|
| 1034 | - ); |
|
| 1035 | - } |
|
| 1036 | - $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 1037 | - if ($event instanceof EE_Event) { |
|
| 1038 | - $this->_template_args['admin_page_header'] = sprintf( |
|
| 1039 | - esc_html__( |
|
| 1040 | - '%s Viewing registrations for the event: %s%s', |
|
| 1041 | - 'event_espresso' |
|
| 1042 | - ), |
|
| 1043 | - '<h3 style="line-height:1.5em;">', |
|
| 1044 | - '<br /><a href="' |
|
| 1045 | - . EE_Admin_Page::add_query_args_and_nonce( |
|
| 1046 | - array( |
|
| 1047 | - 'action' => 'edit', |
|
| 1048 | - 'post' => $event->ID(), |
|
| 1049 | - ), |
|
| 1050 | - EVENTS_ADMIN_URL |
|
| 1051 | - ) |
|
| 1052 | - . '"> ' |
|
| 1053 | - . $event->get('EVT_name') |
|
| 1054 | - . ' </a> ', |
|
| 1055 | - '</h3>' |
|
| 1056 | - ); |
|
| 1057 | - } |
|
| 1058 | - $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
| 1059 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1060 | - if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
| 1061 | - $this->_template_args['admin_page_header'] = substr( |
|
| 1062 | - $this->_template_args['admin_page_header'], |
|
| 1063 | - 0, |
|
| 1064 | - -5 |
|
| 1065 | - ); |
|
| 1066 | - $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
| 1067 | - $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1068 | - $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
| 1069 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 1070 | - $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
| 1071 | - } |
|
| 1072 | - } |
|
| 1073 | - $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
| 1074 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1075 | - } |
|
| 1076 | - |
|
| 1077 | - |
|
| 1078 | - /** |
|
| 1079 | - * This sets the _registration property for the registration details screen |
|
| 1080 | - * |
|
| 1081 | - * @access private |
|
| 1082 | - * @return bool |
|
| 1083 | - */ |
|
| 1084 | - private function _set_registration_object() |
|
| 1085 | - { |
|
| 1086 | - //get out if we've already set the object |
|
| 1087 | - if ($this->_registration instanceof EE_Registration) { |
|
| 1088 | - return true; |
|
| 1089 | - } |
|
| 1090 | - $REG = EEM_Registration::instance(); |
|
| 1091 | - $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 1092 | - if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
| 1093 | - return true; |
|
| 1094 | - } else { |
|
| 1095 | - $error_msg = sprintf( |
|
| 1096 | - esc_html__( |
|
| 1097 | - 'An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
| 1098 | - 'event_espresso' |
|
| 1099 | - ), |
|
| 1100 | - $REG_ID |
|
| 1101 | - ); |
|
| 1102 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1103 | - $this->_registration = null; |
|
| 1104 | - return false; |
|
| 1105 | - } |
|
| 1106 | - } |
|
| 1107 | - |
|
| 1108 | - |
|
| 1109 | - /** |
|
| 1110 | - * Used to retrieve registrations for the list table. |
|
| 1111 | - * |
|
| 1112 | - * @param int $per_page |
|
| 1113 | - * @param bool $count |
|
| 1114 | - * @param bool $this_month |
|
| 1115 | - * @param bool $today |
|
| 1116 | - * @return EE_Registration[]|int |
|
| 1117 | - * @throws EE_Error |
|
| 1118 | - */ |
|
| 1119 | - public function get_registrations( |
|
| 1120 | - $per_page = 10, |
|
| 1121 | - $count = false, |
|
| 1122 | - $this_month = false, |
|
| 1123 | - $today = false |
|
| 1124 | - ) { |
|
| 1125 | - if ($this_month) { |
|
| 1126 | - $this->_req_data['status'] = 'month'; |
|
| 1127 | - } |
|
| 1128 | - if ($today) { |
|
| 1129 | - $this->_req_data['status'] = 'today'; |
|
| 1130 | - } |
|
| 1131 | - $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
|
| 1132 | - /** |
|
| 1133 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1134 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1135 | - * @see EEM_Base::get_all() |
|
| 1136 | - */ |
|
| 1137 | - $query_params['group_by'] = ''; |
|
| 1138 | - |
|
| 1139 | - return $count |
|
| 1140 | - ? EEM_Registration::instance()->count($query_params) |
|
| 1141 | - /** @type EE_Registration[] */ |
|
| 1142 | - : EEM_Registration::instance()->get_all($query_params); |
|
| 1143 | - } |
|
| 1144 | - |
|
| 1145 | - |
|
| 1146 | - |
|
| 1147 | - /** |
|
| 1148 | - * Retrieves the query parameters to be used by the Registration model for getting registrations. |
|
| 1149 | - * Note: this listens to values on the request for some of the query parameters. |
|
| 1150 | - * |
|
| 1151 | - * @param array $request |
|
| 1152 | - * @param int $per_page |
|
| 1153 | - * @param bool $count |
|
| 1154 | - * @return array |
|
| 1155 | - */ |
|
| 1156 | - protected function _get_registration_query_parameters( |
|
| 1157 | - $request = array(), |
|
| 1158 | - $per_page = 10, |
|
| 1159 | - $count = false |
|
| 1160 | - ) { |
|
| 1161 | - |
|
| 1162 | - $query_params = array( |
|
| 1163 | - 0 => $this->_get_where_conditions_for_registrations_query( |
|
| 1164 | - $request |
|
| 1165 | - ), |
|
| 1166 | - 'caps' => EEM_Registration::caps_read_admin, |
|
| 1167 | - 'default_where_conditions' => 'this_model_only', |
|
| 1168 | - ); |
|
| 1169 | - if (! $count) { |
|
| 1170 | - $query_params = array_merge( |
|
| 1171 | - $query_params, |
|
| 1172 | - $this->_get_orderby_for_registrations_query(), |
|
| 1173 | - $this->_get_limit($per_page) |
|
| 1174 | - ); |
|
| 1175 | - } |
|
| 1176 | - |
|
| 1177 | - return $query_params; |
|
| 1178 | - } |
|
| 1179 | - |
|
| 1180 | - |
|
| 1181 | - /** |
|
| 1182 | - * This will add EVT_ID to the provided $where array for EE model query parameters. |
|
| 1183 | - * |
|
| 1184 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1185 | - * @return array |
|
| 1186 | - */ |
|
| 1187 | - protected function _add_event_id_to_where_conditions(array $request) |
|
| 1188 | - { |
|
| 1189 | - $where = array(); |
|
| 1190 | - if (! empty($request['event_id'])) { |
|
| 1191 | - $where['EVT_ID'] = absint($request['event_id']); |
|
| 1192 | - } |
|
| 1193 | - return $where; |
|
| 1194 | - } |
|
| 1195 | - |
|
| 1196 | - |
|
| 1197 | - /** |
|
| 1198 | - * Adds category ID if it exists in the request to the where conditions for the registrations query. |
|
| 1199 | - * |
|
| 1200 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1201 | - * @return array |
|
| 1202 | - */ |
|
| 1203 | - protected function _add_category_id_to_where_conditions(array $request) |
|
| 1204 | - { |
|
| 1205 | - $where = array(); |
|
| 1206 | - if (! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 1207 | - $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
|
| 1208 | - } |
|
| 1209 | - return $where; |
|
| 1210 | - } |
|
| 1211 | - |
|
| 1212 | - |
|
| 1213 | - /** |
|
| 1214 | - * Adds the datetime ID if it exists in the request to the where conditions for the registrations query. |
|
| 1215 | - * |
|
| 1216 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1217 | - * @return array |
|
| 1218 | - */ |
|
| 1219 | - protected function _add_datetime_id_to_where_conditions(array $request) |
|
| 1220 | - { |
|
| 1221 | - $where = array(); |
|
| 1222 | - if (! empty($request['datetime_id'])) { |
|
| 1223 | - $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
|
| 1224 | - } |
|
| 1225 | - if (! empty($request['DTT_ID'])) { |
|
| 1226 | - $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
|
| 1227 | - } |
|
| 1228 | - return $where; |
|
| 1229 | - } |
|
| 1230 | - |
|
| 1231 | - |
|
| 1232 | - /** |
|
| 1233 | - * Adds the correct registration status to the where conditions for the registrations query. |
|
| 1234 | - * |
|
| 1235 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1236 | - * @return array |
|
| 1237 | - */ |
|
| 1238 | - protected function _add_registration_status_to_where_conditions(array $request) |
|
| 1239 | - { |
|
| 1240 | - $where = array(); |
|
| 1241 | - $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1242 | - $registration_status = ! empty($request['_reg_status']) |
|
| 1243 | - ? sanitize_text_field($request['_reg_status']) |
|
| 1244 | - : ''; |
|
| 1245 | - |
|
| 1246 | - /* |
|
| 33 | + /** |
|
| 34 | + * @var EE_Registration |
|
| 35 | + */ |
|
| 36 | + private $_registration; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var EE_Event |
|
| 40 | + */ |
|
| 41 | + private $_reg_event; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var EE_Session |
|
| 45 | + */ |
|
| 46 | + private $_session; |
|
| 47 | + |
|
| 48 | + private static $_reg_status; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Form for displaying the custom questions for this registration. |
|
| 52 | + * This gets used a few times throughout the request so its best to cache it |
|
| 53 | + * |
|
| 54 | + * @var EE_Registration_Custom_Questions_Form |
|
| 55 | + */ |
|
| 56 | + protected $_reg_custom_questions_form = null; |
|
| 57 | + |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * constructor |
|
| 61 | + * |
|
| 62 | + * @Constructor |
|
| 63 | + * @access public |
|
| 64 | + * @param bool $routing |
|
| 65 | + * @return Registrations_Admin_Page |
|
| 66 | + */ |
|
| 67 | + public function __construct($routing = true) |
|
| 68 | + { |
|
| 69 | + parent::__construct($routing); |
|
| 70 | + add_action('wp_loaded', array($this, 'wp_loaded')); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + |
|
| 74 | + public function wp_loaded() |
|
| 75 | + { |
|
| 76 | + // when adding a new registration... |
|
| 77 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
|
| 78 | + EE_System::do_not_cache(); |
|
| 79 | + if (! isset($this->_req_data['processing_registration']) |
|
| 80 | + || absint($this->_req_data['processing_registration']) !== 1 |
|
| 81 | + ) { |
|
| 82 | + // and it's NOT the attendee information reg step |
|
| 83 | + // force cookie expiration by setting time to last week |
|
| 84 | + setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
| 85 | + // and update the global |
|
| 86 | + $_COOKIE['ee_registration_added'] = 0; |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + protected function _init_page_props() |
|
| 93 | + { |
|
| 94 | + $this->page_slug = REG_PG_SLUG; |
|
| 95 | + $this->_admin_base_url = REG_ADMIN_URL; |
|
| 96 | + $this->_admin_base_path = REG_ADMIN; |
|
| 97 | + $this->page_label = esc_html__('Registrations', 'event_espresso'); |
|
| 98 | + $this->_cpt_routes = array( |
|
| 99 | + 'add_new_attendee' => 'espresso_attendees', |
|
| 100 | + 'edit_attendee' => 'espresso_attendees', |
|
| 101 | + 'insert_attendee' => 'espresso_attendees', |
|
| 102 | + 'update_attendee' => 'espresso_attendees', |
|
| 103 | + ); |
|
| 104 | + $this->_cpt_model_names = array( |
|
| 105 | + 'add_new_attendee' => 'EEM_Attendee', |
|
| 106 | + 'edit_attendee' => 'EEM_Attendee', |
|
| 107 | + ); |
|
| 108 | + $this->_cpt_edit_routes = array( |
|
| 109 | + 'espresso_attendees' => 'edit_attendee', |
|
| 110 | + ); |
|
| 111 | + $this->_pagenow_map = array( |
|
| 112 | + 'add_new_attendee' => 'post-new.php', |
|
| 113 | + 'edit_attendee' => 'post.php', |
|
| 114 | + 'trash' => 'post.php', |
|
| 115 | + ); |
|
| 116 | + add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
| 117 | + //add filters so that the comment urls don't take users to a confusing 404 page |
|
| 118 | + add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + public function clear_comment_link($link, $comment, $args) |
|
| 123 | + { |
|
| 124 | + //gotta make sure this only happens on this route |
|
| 125 | + $post_type = get_post_type($comment->comment_post_ID); |
|
| 126 | + if ($post_type === 'espresso_attendees') { |
|
| 127 | + return '#commentsdiv'; |
|
| 128 | + } |
|
| 129 | + return $link; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + protected function _ajax_hooks() |
|
| 134 | + { |
|
| 135 | + //todo: all hooks for registrations ajax goes in here |
|
| 136 | + add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + protected function _define_page_props() |
|
| 141 | + { |
|
| 142 | + $this->_admin_page_title = $this->page_label; |
|
| 143 | + $this->_labels = array( |
|
| 144 | + 'buttons' => array( |
|
| 145 | + 'add-registrant' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 146 | + 'add-attendee' => esc_html__('Add Contact', 'event_espresso'), |
|
| 147 | + 'edit' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 148 | + 'report' => esc_html__("Event Registrations CSV Report", "event_espresso"), |
|
| 149 | + 'report_all' => esc_html__('All Registrations CSV Report', 'event_espresso'), |
|
| 150 | + 'report_filtered' => esc_html__('Filtered CSV Report', 'event_espresso'), |
|
| 151 | + 'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'), |
|
| 152 | + 'contact_list_export' => esc_html__("Export Data", "event_espresso"), |
|
| 153 | + ), |
|
| 154 | + 'publishbox' => array( |
|
| 155 | + 'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'), |
|
| 156 | + 'edit_attendee' => esc_html__("Update Contact Record", 'event_espresso'), |
|
| 157 | + ), |
|
| 158 | + 'hide_add_button_on_cpt_route' => array( |
|
| 159 | + 'edit_attendee' => true, |
|
| 160 | + ), |
|
| 161 | + ); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * grab url requests and route them |
|
| 167 | + * |
|
| 168 | + * @access private |
|
| 169 | + * @return void |
|
| 170 | + */ |
|
| 171 | + public function _set_page_routes() |
|
| 172 | + { |
|
| 173 | + $this->_get_registration_status_array(); |
|
| 174 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 175 | + ? $this->_req_data['_REG_ID'] : 0; |
|
| 176 | + $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 177 | + ? $this->_req_data['reg_status_change_form']['REG_ID'] |
|
| 178 | + : $reg_id; |
|
| 179 | + $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
| 180 | + ? $this->_req_data['ATT_ID'] : 0; |
|
| 181 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) |
|
| 182 | + ? $this->_req_data['post'] |
|
| 183 | + : $att_id; |
|
| 184 | + $this->_page_routes = array( |
|
| 185 | + 'default' => array( |
|
| 186 | + 'func' => '_registrations_overview_list_table', |
|
| 187 | + 'capability' => 'ee_read_registrations', |
|
| 188 | + ), |
|
| 189 | + 'view_registration' => array( |
|
| 190 | + 'func' => '_registration_details', |
|
| 191 | + 'capability' => 'ee_read_registration', |
|
| 192 | + 'obj_id' => $reg_id, |
|
| 193 | + ), |
|
| 194 | + 'edit_registration' => array( |
|
| 195 | + 'func' => '_update_attendee_registration_form', |
|
| 196 | + 'noheader' => true, |
|
| 197 | + 'headers_sent_route' => 'view_registration', |
|
| 198 | + 'capability' => 'ee_edit_registration', |
|
| 199 | + 'obj_id' => $reg_id, |
|
| 200 | + '_REG_ID' => $reg_id, |
|
| 201 | + ), |
|
| 202 | + 'trash_registrations' => array( |
|
| 203 | + 'func' => '_trash_or_restore_registrations', |
|
| 204 | + 'args' => array('trash' => true), |
|
| 205 | + 'noheader' => true, |
|
| 206 | + 'capability' => 'ee_delete_registrations', |
|
| 207 | + ), |
|
| 208 | + 'restore_registrations' => array( |
|
| 209 | + 'func' => '_trash_or_restore_registrations', |
|
| 210 | + 'args' => array('trash' => false), |
|
| 211 | + 'noheader' => true, |
|
| 212 | + 'capability' => 'ee_delete_registrations', |
|
| 213 | + ), |
|
| 214 | + 'delete_registrations' => array( |
|
| 215 | + 'func' => '_delete_registrations', |
|
| 216 | + 'noheader' => true, |
|
| 217 | + 'capability' => 'ee_delete_registrations', |
|
| 218 | + ), |
|
| 219 | + 'new_registration' => array( |
|
| 220 | + 'func' => 'new_registration', |
|
| 221 | + 'capability' => 'ee_edit_registrations', |
|
| 222 | + ), |
|
| 223 | + 'process_reg_step' => array( |
|
| 224 | + 'func' => 'process_reg_step', |
|
| 225 | + 'noheader' => true, |
|
| 226 | + 'capability' => 'ee_edit_registrations', |
|
| 227 | + ), |
|
| 228 | + 'redirect_to_txn' => array( |
|
| 229 | + 'func' => 'redirect_to_txn', |
|
| 230 | + 'noheader' => true, |
|
| 231 | + 'capability' => 'ee_edit_registrations', |
|
| 232 | + ), |
|
| 233 | + 'change_reg_status' => array( |
|
| 234 | + 'func' => '_change_reg_status', |
|
| 235 | + 'noheader' => true, |
|
| 236 | + 'capability' => 'ee_edit_registration', |
|
| 237 | + 'obj_id' => $reg_id, |
|
| 238 | + ), |
|
| 239 | + 'approve_registration' => array( |
|
| 240 | + 'func' => 'approve_registration', |
|
| 241 | + 'noheader' => true, |
|
| 242 | + 'capability' => 'ee_edit_registration', |
|
| 243 | + 'obj_id' => $reg_id, |
|
| 244 | + ), |
|
| 245 | + 'approve_and_notify_registration' => array( |
|
| 246 | + 'func' => 'approve_registration', |
|
| 247 | + 'noheader' => true, |
|
| 248 | + 'args' => array(true), |
|
| 249 | + 'capability' => 'ee_edit_registration', |
|
| 250 | + 'obj_id' => $reg_id, |
|
| 251 | + ), |
|
| 252 | + 'approve_registrations' => array( |
|
| 253 | + 'func' => 'bulk_action_on_registrations', |
|
| 254 | + 'noheader' => true, |
|
| 255 | + 'capability' => 'ee_edit_registrations', |
|
| 256 | + 'args' => array('approve') |
|
| 257 | + ), |
|
| 258 | + 'approve_and_notify_registrations' => array( |
|
| 259 | + 'func' => 'bulk_action_on_registrations', |
|
| 260 | + 'noheader' => true, |
|
| 261 | + 'capability' => 'ee_edit_registrations', |
|
| 262 | + 'args' => array('approve', true) |
|
| 263 | + ), |
|
| 264 | + 'decline_registration' => array( |
|
| 265 | + 'func' => 'decline_registration', |
|
| 266 | + 'noheader' => true, |
|
| 267 | + 'capability' => 'ee_edit_registration', |
|
| 268 | + 'obj_id' => $reg_id, |
|
| 269 | + ), |
|
| 270 | + 'decline_and_notify_registration' => array( |
|
| 271 | + 'func' => 'decline_registration', |
|
| 272 | + 'noheader' => true, |
|
| 273 | + 'args' => array(true), |
|
| 274 | + 'capability' => 'ee_edit_registration', |
|
| 275 | + 'obj_id' => $reg_id, |
|
| 276 | + ), |
|
| 277 | + 'decline_registrations' => array( |
|
| 278 | + 'func' => 'bulk_action_on_registrations', |
|
| 279 | + 'noheader' => true, |
|
| 280 | + 'capability' => 'ee_edit_registrations', |
|
| 281 | + 'args' => array('decline') |
|
| 282 | + ), |
|
| 283 | + 'decline_and_notify_registrations' => array( |
|
| 284 | + 'func' => 'bulk_action_on_registrations', |
|
| 285 | + 'noheader' => true, |
|
| 286 | + 'capability' => 'ee_edit_registrations', |
|
| 287 | + 'args' => array('decline', true) |
|
| 288 | + ), |
|
| 289 | + 'pending_registration' => array( |
|
| 290 | + 'func' => 'pending_registration', |
|
| 291 | + 'noheader' => true, |
|
| 292 | + 'capability' => 'ee_edit_registration', |
|
| 293 | + 'obj_id' => $reg_id, |
|
| 294 | + ), |
|
| 295 | + 'pending_and_notify_registration' => array( |
|
| 296 | + 'func' => 'pending_registration', |
|
| 297 | + 'noheader' => true, |
|
| 298 | + 'args' => array(true), |
|
| 299 | + 'capability' => 'ee_edit_registration', |
|
| 300 | + 'obj_id' => $reg_id, |
|
| 301 | + ), |
|
| 302 | + 'pending_registrations' => array( |
|
| 303 | + 'func' => 'bulk_action_on_registrations', |
|
| 304 | + 'noheader' => true, |
|
| 305 | + 'capability' => 'ee_edit_registrations', |
|
| 306 | + 'args' => array('pending') |
|
| 307 | + ), |
|
| 308 | + 'pending_and_notify_registrations' => array( |
|
| 309 | + 'func' => 'bulk_action_on_registrations', |
|
| 310 | + 'noheader' => true, |
|
| 311 | + 'capability' => 'ee_edit_registrations', |
|
| 312 | + 'args' => array('pending', true) |
|
| 313 | + ), |
|
| 314 | + 'no_approve_registration' => array( |
|
| 315 | + 'func' => 'not_approve_registration', |
|
| 316 | + 'noheader' => true, |
|
| 317 | + 'capability' => 'ee_edit_registration', |
|
| 318 | + 'obj_id' => $reg_id, |
|
| 319 | + ), |
|
| 320 | + 'no_approve_and_notify_registration' => array( |
|
| 321 | + 'func' => 'not_approve_registration', |
|
| 322 | + 'noheader' => true, |
|
| 323 | + 'args' => array(true), |
|
| 324 | + 'capability' => 'ee_edit_registration', |
|
| 325 | + 'obj_id' => $reg_id, |
|
| 326 | + ), |
|
| 327 | + 'no_approve_registrations' => array( |
|
| 328 | + 'func' => 'bulk_action_on_registrations', |
|
| 329 | + 'noheader' => true, |
|
| 330 | + 'capability' => 'ee_edit_registrations', |
|
| 331 | + 'args' => array('not_approve') |
|
| 332 | + ), |
|
| 333 | + 'no_approve_and_notify_registrations' => array( |
|
| 334 | + 'func' => 'bulk_action_on_registrations', |
|
| 335 | + 'noheader' => true, |
|
| 336 | + 'capability' => 'ee_edit_registrations', |
|
| 337 | + 'args' => array('not_approve', true) |
|
| 338 | + ), |
|
| 339 | + 'cancel_registration' => array( |
|
| 340 | + 'func' => 'cancel_registration', |
|
| 341 | + 'noheader' => true, |
|
| 342 | + 'capability' => 'ee_edit_registration', |
|
| 343 | + 'obj_id' => $reg_id, |
|
| 344 | + ), |
|
| 345 | + 'cancel_and_notify_registration' => array( |
|
| 346 | + 'func' => 'cancel_registration', |
|
| 347 | + 'noheader' => true, |
|
| 348 | + 'args' => array(true), |
|
| 349 | + 'capability' => 'ee_edit_registration', |
|
| 350 | + 'obj_id' => $reg_id, |
|
| 351 | + ), |
|
| 352 | + 'cancel_registrations' => array( |
|
| 353 | + 'func' => 'bulk_action_on_registrations', |
|
| 354 | + 'noheader' => true, |
|
| 355 | + 'capability' => 'ee_edit_registrations', |
|
| 356 | + 'args' => array('cancel') |
|
| 357 | + ), |
|
| 358 | + 'cancel_and_notify_registrations' => array( |
|
| 359 | + 'func' => 'bulk_action_on_registrations', |
|
| 360 | + 'noheader' => true, |
|
| 361 | + 'capability' => 'ee_edit_registrations', |
|
| 362 | + 'args' => array('cancel', true) |
|
| 363 | + ), |
|
| 364 | + 'wait_list_registration' => array( |
|
| 365 | + 'func' => 'wait_list_registration', |
|
| 366 | + 'noheader' => true, |
|
| 367 | + 'capability' => 'ee_edit_registration', |
|
| 368 | + 'obj_id' => $reg_id, |
|
| 369 | + ), |
|
| 370 | + 'wait_list_and_notify_registration' => array( |
|
| 371 | + 'func' => 'wait_list_registration', |
|
| 372 | + 'noheader' => true, |
|
| 373 | + 'args' => array(true), |
|
| 374 | + 'capability' => 'ee_edit_registration', |
|
| 375 | + 'obj_id' => $reg_id, |
|
| 376 | + ), |
|
| 377 | + 'contact_list' => array( |
|
| 378 | + 'func' => '_attendee_contact_list_table', |
|
| 379 | + 'capability' => 'ee_read_contacts', |
|
| 380 | + ), |
|
| 381 | + 'add_new_attendee' => array( |
|
| 382 | + 'func' => '_create_new_cpt_item', |
|
| 383 | + 'args' => array( |
|
| 384 | + 'new_attendee' => true, |
|
| 385 | + 'capability' => 'ee_edit_contacts', |
|
| 386 | + ), |
|
| 387 | + ), |
|
| 388 | + 'edit_attendee' => array( |
|
| 389 | + 'func' => '_edit_cpt_item', |
|
| 390 | + 'capability' => 'ee_edit_contacts', |
|
| 391 | + 'obj_id' => $att_id, |
|
| 392 | + ), |
|
| 393 | + 'duplicate_attendee' => array( |
|
| 394 | + 'func' => '_duplicate_attendee', |
|
| 395 | + 'noheader' => true, |
|
| 396 | + 'capability' => 'ee_edit_contacts', |
|
| 397 | + 'obj_id' => $att_id, |
|
| 398 | + ), |
|
| 399 | + 'insert_attendee' => array( |
|
| 400 | + 'func' => '_insert_or_update_attendee', |
|
| 401 | + 'args' => array( |
|
| 402 | + 'new_attendee' => true, |
|
| 403 | + ), |
|
| 404 | + 'noheader' => true, |
|
| 405 | + 'capability' => 'ee_edit_contacts', |
|
| 406 | + ), |
|
| 407 | + 'update_attendee' => array( |
|
| 408 | + 'func' => '_insert_or_update_attendee', |
|
| 409 | + 'args' => array( |
|
| 410 | + 'new_attendee' => false, |
|
| 411 | + ), |
|
| 412 | + 'noheader' => true, |
|
| 413 | + 'capability' => 'ee_edit_contacts', |
|
| 414 | + 'obj_id' => $att_id, |
|
| 415 | + ), |
|
| 416 | + 'trash_attendees' => array( |
|
| 417 | + 'func' => '_trash_or_restore_attendees', |
|
| 418 | + 'args' => array( |
|
| 419 | + 'trash' => 'true' |
|
| 420 | + ), |
|
| 421 | + 'noheader' => true, |
|
| 422 | + 'capability' => 'ee_delete_contacts' |
|
| 423 | + ), |
|
| 424 | + 'trash_attendee' => array( |
|
| 425 | + 'func' => '_trash_or_restore_attendees', |
|
| 426 | + 'args' => array( |
|
| 427 | + 'trash' => true, |
|
| 428 | + ), |
|
| 429 | + 'noheader' => true, |
|
| 430 | + 'capability' => 'ee_delete_contacts', |
|
| 431 | + 'obj_id' => $att_id, |
|
| 432 | + ), |
|
| 433 | + 'restore_attendees' => array( |
|
| 434 | + 'func' => '_trash_or_restore_attendees', |
|
| 435 | + 'args' => array( |
|
| 436 | + 'trash' => false, |
|
| 437 | + ), |
|
| 438 | + 'noheader' => true, |
|
| 439 | + 'capability' => 'ee_delete_contacts', |
|
| 440 | + 'obj_id' => $att_id, |
|
| 441 | + ), |
|
| 442 | + 'resend_registration' => array( |
|
| 443 | + 'func' => '_resend_registration', |
|
| 444 | + 'noheader' => true, |
|
| 445 | + 'capability' => 'ee_send_message', |
|
| 446 | + ), |
|
| 447 | + 'registrations_report' => array( |
|
| 448 | + 'func' => '_registrations_report', |
|
| 449 | + 'noheader' => true, |
|
| 450 | + 'capability' => 'ee_read_registrations', |
|
| 451 | + ), |
|
| 452 | + 'contact_list_export' => array( |
|
| 453 | + 'func' => '_contact_list_export', |
|
| 454 | + 'noheader' => true, |
|
| 455 | + 'capability' => 'export', |
|
| 456 | + ), |
|
| 457 | + 'contact_list_report' => array( |
|
| 458 | + 'func' => '_contact_list_report', |
|
| 459 | + 'noheader' => true, |
|
| 460 | + 'capability' => 'ee_read_contacts', |
|
| 461 | + ), |
|
| 462 | + ); |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + |
|
| 466 | + protected function _set_page_config() |
|
| 467 | + { |
|
| 468 | + $this->_page_config = array( |
|
| 469 | + 'default' => array( |
|
| 470 | + 'nav' => array( |
|
| 471 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 472 | + 'order' => 5, |
|
| 473 | + ), |
|
| 474 | + 'help_tabs' => array( |
|
| 475 | + 'registrations_overview_help_tab' => array( |
|
| 476 | + 'title' => esc_html__('Registrations Overview', 'event_espresso'), |
|
| 477 | + 'filename' => 'registrations_overview', |
|
| 478 | + ), |
|
| 479 | + 'registrations_overview_table_column_headings_help_tab' => array( |
|
| 480 | + 'title' => esc_html__('Registrations Table Column Headings', 'event_espresso'), |
|
| 481 | + 'filename' => 'registrations_overview_table_column_headings', |
|
| 482 | + ), |
|
| 483 | + 'registrations_overview_filters_help_tab' => array( |
|
| 484 | + 'title' => esc_html__('Registration Filters', 'event_espresso'), |
|
| 485 | + 'filename' => 'registrations_overview_filters', |
|
| 486 | + ), |
|
| 487 | + 'registrations_overview_views_help_tab' => array( |
|
| 488 | + 'title' => esc_html__('Registration Views', 'event_espresso'), |
|
| 489 | + 'filename' => 'registrations_overview_views', |
|
| 490 | + ), |
|
| 491 | + 'registrations_regoverview_other_help_tab' => array( |
|
| 492 | + 'title' => esc_html__('Registrations Other', 'event_espresso'), |
|
| 493 | + 'filename' => 'registrations_overview_other', |
|
| 494 | + ), |
|
| 495 | + ), |
|
| 496 | + 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
| 497 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
| 498 | + 'list_table' => 'EE_Registrations_List_Table', |
|
| 499 | + 'require_nonce' => false, |
|
| 500 | + ), |
|
| 501 | + 'view_registration' => array( |
|
| 502 | + 'nav' => array( |
|
| 503 | + 'label' => esc_html__('REG Details', 'event_espresso'), |
|
| 504 | + 'order' => 15, |
|
| 505 | + 'url' => isset($this->_req_data['_REG_ID']) |
|
| 506 | + ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
| 507 | + : $this->_admin_base_url, |
|
| 508 | + 'persistent' => false, |
|
| 509 | + ), |
|
| 510 | + 'help_tabs' => array( |
|
| 511 | + 'registrations_details_help_tab' => array( |
|
| 512 | + 'title' => esc_html__('Registration Details', 'event_espresso'), |
|
| 513 | + 'filename' => 'registrations_details', |
|
| 514 | + ), |
|
| 515 | + 'registrations_details_table_help_tab' => array( |
|
| 516 | + 'title' => esc_html__('Registration Details Table', 'event_espresso'), |
|
| 517 | + 'filename' => 'registrations_details_table', |
|
| 518 | + ), |
|
| 519 | + 'registrations_details_form_answers_help_tab' => array( |
|
| 520 | + 'title' => esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 521 | + 'filename' => 'registrations_details_form_answers', |
|
| 522 | + ), |
|
| 523 | + 'registrations_details_registrant_details_help_tab' => array( |
|
| 524 | + 'title' => esc_html__('Contact Details', 'event_espresso'), |
|
| 525 | + 'filename' => 'registrations_details_registrant_details', |
|
| 526 | + ), |
|
| 527 | + ), |
|
| 528 | + 'help_tour' => array('Registration_Details_Help_Tour'), |
|
| 529 | + 'metaboxes' => array_merge( |
|
| 530 | + $this->_default_espresso_metaboxes, |
|
| 531 | + array('_registration_details_metaboxes') |
|
| 532 | + ), |
|
| 533 | + 'require_nonce' => false, |
|
| 534 | + ), |
|
| 535 | + 'new_registration' => array( |
|
| 536 | + 'nav' => array( |
|
| 537 | + 'label' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 538 | + 'url' => '#', |
|
| 539 | + 'order' => 15, |
|
| 540 | + 'persistent' => false, |
|
| 541 | + ), |
|
| 542 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 543 | + 'labels' => array( |
|
| 544 | + 'publishbox' => esc_html__('Save Registration', 'event_espresso'), |
|
| 545 | + ), |
|
| 546 | + 'require_nonce' => false, |
|
| 547 | + ), |
|
| 548 | + 'add_new_attendee' => array( |
|
| 549 | + 'nav' => array( |
|
| 550 | + 'label' => esc_html__('Add Contact', 'event_espresso'), |
|
| 551 | + 'order' => 15, |
|
| 552 | + 'persistent' => false, |
|
| 553 | + ), |
|
| 554 | + 'metaboxes' => array_merge( |
|
| 555 | + $this->_default_espresso_metaboxes, |
|
| 556 | + array('_publish_post_box', 'attendee_editor_metaboxes') |
|
| 557 | + ), |
|
| 558 | + 'require_nonce' => false, |
|
| 559 | + ), |
|
| 560 | + 'edit_attendee' => array( |
|
| 561 | + 'nav' => array( |
|
| 562 | + 'label' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 563 | + 'order' => 15, |
|
| 564 | + 'persistent' => false, |
|
| 565 | + 'url' => isset($this->_req_data['ATT_ID']) |
|
| 566 | + ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
| 567 | + : $this->_admin_base_url, |
|
| 568 | + ), |
|
| 569 | + 'metaboxes' => array('attendee_editor_metaboxes'), |
|
| 570 | + 'require_nonce' => false, |
|
| 571 | + ), |
|
| 572 | + 'contact_list' => array( |
|
| 573 | + 'nav' => array( |
|
| 574 | + 'label' => esc_html__('Contact List', 'event_espresso'), |
|
| 575 | + 'order' => 20, |
|
| 576 | + ), |
|
| 577 | + 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
| 578 | + 'help_tabs' => array( |
|
| 579 | + 'registrations_contact_list_help_tab' => array( |
|
| 580 | + 'title' => esc_html__('Registrations Contact List', 'event_espresso'), |
|
| 581 | + 'filename' => 'registrations_contact_list', |
|
| 582 | + ), |
|
| 583 | + 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
| 584 | + 'title' => esc_html__('Contact List Table Column Headings', 'event_espresso'), |
|
| 585 | + 'filename' => 'registrations_contact_list_table_column_headings', |
|
| 586 | + ), |
|
| 587 | + 'registrations_contact_list_views_help_tab' => array( |
|
| 588 | + 'title' => esc_html__('Contact List Views', 'event_espresso'), |
|
| 589 | + 'filename' => 'registrations_contact_list_views', |
|
| 590 | + ), |
|
| 591 | + 'registrations_contact_list_other_help_tab' => array( |
|
| 592 | + 'title' => esc_html__('Contact List Other', 'event_espresso'), |
|
| 593 | + 'filename' => 'registrations_contact_list_other', |
|
| 594 | + ), |
|
| 595 | + ), |
|
| 596 | + 'help_tour' => array('Contact_List_Help_Tour'), |
|
| 597 | + 'metaboxes' => array(), |
|
| 598 | + 'require_nonce' => false, |
|
| 599 | + ), |
|
| 600 | + //override default cpt routes |
|
| 601 | + 'create_new' => '', |
|
| 602 | + 'edit' => '', |
|
| 603 | + ); |
|
| 604 | + } |
|
| 605 | + |
|
| 606 | + |
|
| 607 | + /** |
|
| 608 | + * The below methods aren't used by this class currently |
|
| 609 | + */ |
|
| 610 | + protected function _add_screen_options() |
|
| 611 | + { |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + |
|
| 615 | + protected function _add_feature_pointers() |
|
| 616 | + { |
|
| 617 | + } |
|
| 618 | + |
|
| 619 | + |
|
| 620 | + public function admin_init() |
|
| 621 | + { |
|
| 622 | + EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__( |
|
| 623 | + 'click "Update Registration Questions" to save your changes', |
|
| 624 | + 'event_espresso' |
|
| 625 | + ); |
|
| 626 | + } |
|
| 627 | + |
|
| 628 | + |
|
| 629 | + public function admin_notices() |
|
| 630 | + { |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + |
|
| 634 | + public function admin_footer_scripts() |
|
| 635 | + { |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + |
|
| 639 | + /** |
|
| 640 | + * get list of registration statuses |
|
| 641 | + * |
|
| 642 | + * @access private |
|
| 643 | + * @return void |
|
| 644 | + */ |
|
| 645 | + private function _get_registration_status_array() |
|
| 646 | + { |
|
| 647 | + self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + |
|
| 651 | + protected function _add_screen_options_default() |
|
| 652 | + { |
|
| 653 | + $this->_per_page_screen_option(); |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + |
|
| 657 | + protected function _add_screen_options_contact_list() |
|
| 658 | + { |
|
| 659 | + $page_title = $this->_admin_page_title; |
|
| 660 | + $this->_admin_page_title = esc_html__("Contacts", 'event_espresso'); |
|
| 661 | + $this->_per_page_screen_option(); |
|
| 662 | + $this->_admin_page_title = $page_title; |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + |
|
| 666 | + public function load_scripts_styles() |
|
| 667 | + { |
|
| 668 | + //style |
|
| 669 | + wp_register_style( |
|
| 670 | + 'espresso_reg', |
|
| 671 | + REG_ASSETS_URL . 'espresso_registrations_admin.css', |
|
| 672 | + array('ee-admin-css'), |
|
| 673 | + EVENT_ESPRESSO_VERSION |
|
| 674 | + ); |
|
| 675 | + wp_enqueue_style('espresso_reg'); |
|
| 676 | + //script |
|
| 677 | + wp_register_script( |
|
| 678 | + 'espresso_reg', |
|
| 679 | + REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 680 | + array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), |
|
| 681 | + EVENT_ESPRESSO_VERSION, |
|
| 682 | + true |
|
| 683 | + ); |
|
| 684 | + wp_enqueue_script('espresso_reg'); |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + |
|
| 688 | + public function load_scripts_styles_edit_attendee() |
|
| 689 | + { |
|
| 690 | + //stuff to only show up on our attendee edit details page. |
|
| 691 | + $attendee_details_translations = array( |
|
| 692 | + 'att_publish_text' => sprintf( |
|
| 693 | + esc_html__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
| 694 | + $this->_cpt_model_obj->get_datetime('ATT_created') |
|
| 695 | + ), |
|
| 696 | + ); |
|
| 697 | + wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
| 698 | + wp_enqueue_script('jquery-validate'); |
|
| 699 | + } |
|
| 700 | + |
|
| 701 | + |
|
| 702 | + public function load_scripts_styles_view_registration() |
|
| 703 | + { |
|
| 704 | + //styles |
|
| 705 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 706 | + //scripts |
|
| 707 | + $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 708 | + $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
| 709 | + } |
|
| 710 | + |
|
| 711 | + |
|
| 712 | + public function load_scripts_styles_contact_list() |
|
| 713 | + { |
|
| 714 | + wp_deregister_style('espresso_reg'); |
|
| 715 | + wp_register_style( |
|
| 716 | + 'espresso_att', |
|
| 717 | + REG_ASSETS_URL . 'espresso_attendees_admin.css', |
|
| 718 | + array('ee-admin-css'), |
|
| 719 | + EVENT_ESPRESSO_VERSION |
|
| 720 | + ); |
|
| 721 | + wp_enqueue_style('espresso_att'); |
|
| 722 | + } |
|
| 723 | + |
|
| 724 | + |
|
| 725 | + public function load_scripts_styles_new_registration() |
|
| 726 | + { |
|
| 727 | + wp_register_script( |
|
| 728 | + 'ee-spco-for-admin', |
|
| 729 | + REG_ASSETS_URL . 'spco_for_admin.js', |
|
| 730 | + array('underscore', 'jquery'), |
|
| 731 | + EVENT_ESPRESSO_VERSION, |
|
| 732 | + true |
|
| 733 | + ); |
|
| 734 | + wp_enqueue_script('ee-spco-for-admin'); |
|
| 735 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 736 | + EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
| 737 | + EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
| 738 | + EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
| 739 | + } |
|
| 740 | + |
|
| 741 | + |
|
| 742 | + public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
| 743 | + { |
|
| 744 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + |
|
| 748 | + public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
| 749 | + { |
|
| 750 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + |
|
| 754 | + protected function _set_list_table_views_default() |
|
| 755 | + { |
|
| 756 | + //for notification related bulk actions we need to make sure only active messengers have an option. |
|
| 757 | + EED_Messages::set_autoloaders(); |
|
| 758 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 759 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 760 | + $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
| 761 | + //key= bulk_action_slug, value= message type. |
|
| 762 | + $match_array = array( |
|
| 763 | + 'approve_registrations' => 'registration', |
|
| 764 | + 'decline_registrations' => 'declined_registration', |
|
| 765 | + 'pending_registrations' => 'pending_approval', |
|
| 766 | + 'no_approve_registrations' => 'not_approved_registration', |
|
| 767 | + 'cancel_registrations' => 'cancelled_registration', |
|
| 768 | + ); |
|
| 769 | + $can_send = EE_Registry::instance()->CAP->current_user_can( |
|
| 770 | + 'ee_send_message', |
|
| 771 | + 'batch_send_messages' |
|
| 772 | + ); |
|
| 773 | + /** setup reg status bulk actions **/ |
|
| 774 | + $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso'); |
|
| 775 | + if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) { |
|
| 776 | + $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__( |
|
| 777 | + 'Approve and Notify Registrations', |
|
| 778 | + 'event_espresso' |
|
| 779 | + ); |
|
| 780 | + } |
|
| 781 | + $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso'); |
|
| 782 | + if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) { |
|
| 783 | + $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__( |
|
| 784 | + 'Decline and Notify Registrations', |
|
| 785 | + 'event_espresso' |
|
| 786 | + ); |
|
| 787 | + } |
|
| 788 | + $def_reg_status_actions['pending_registrations'] = esc_html__( |
|
| 789 | + 'Set Registrations to Pending Payment', |
|
| 790 | + 'event_espresso' |
|
| 791 | + ); |
|
| 792 | + if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) { |
|
| 793 | + $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__( |
|
| 794 | + 'Set Registrations to Pending Payment and Notify', |
|
| 795 | + 'event_espresso' |
|
| 796 | + ); |
|
| 797 | + } |
|
| 798 | + $def_reg_status_actions['no_approve_registrations'] = esc_html__( |
|
| 799 | + 'Set Registrations to Not Approved', |
|
| 800 | + 'event_espresso' |
|
| 801 | + ); |
|
| 802 | + if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) { |
|
| 803 | + $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__( |
|
| 804 | + 'Set Registrations to Not Approved and Notify', |
|
| 805 | + 'event_espresso' |
|
| 806 | + ); |
|
| 807 | + } |
|
| 808 | + $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso'); |
|
| 809 | + if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) { |
|
| 810 | + $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__( |
|
| 811 | + 'Cancel Registrations and Notify', |
|
| 812 | + 'event_espresso' |
|
| 813 | + ); |
|
| 814 | + } |
|
| 815 | + $def_reg_status_actions = apply_filters( |
|
| 816 | + 'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array', |
|
| 817 | + $def_reg_status_actions, |
|
| 818 | + $active_mts, |
|
| 819 | + $can_send |
|
| 820 | + ); |
|
| 821 | + |
|
| 822 | + $this->_views = array( |
|
| 823 | + 'all' => array( |
|
| 824 | + 'slug' => 'all', |
|
| 825 | + 'label' => esc_html__('View All Registrations', 'event_espresso'), |
|
| 826 | + 'count' => 0, |
|
| 827 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 828 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 829 | + )), |
|
| 830 | + ), |
|
| 831 | + 'month' => array( |
|
| 832 | + 'slug' => 'month', |
|
| 833 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
| 834 | + 'count' => 0, |
|
| 835 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 836 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 837 | + )), |
|
| 838 | + ), |
|
| 839 | + 'today' => array( |
|
| 840 | + 'slug' => 'today', |
|
| 841 | + 'label' => sprintf( |
|
| 842 | + esc_html__('Today - %s', 'event_espresso'), |
|
| 843 | + date('M d, Y', current_time('timestamp')) |
|
| 844 | + ), |
|
| 845 | + 'count' => 0, |
|
| 846 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 847 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 848 | + )), |
|
| 849 | + ), |
|
| 850 | + ); |
|
| 851 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 852 | + 'ee_delete_registrations', |
|
| 853 | + 'espresso_registrations_delete_registration' |
|
| 854 | + )) { |
|
| 855 | + $this->_views['incomplete'] = array( |
|
| 856 | + 'slug' => 'incomplete', |
|
| 857 | + 'label' => esc_html__('Incomplete', 'event_espresso'), |
|
| 858 | + 'count' => 0, |
|
| 859 | + 'bulk_action' => array( |
|
| 860 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 861 | + ), |
|
| 862 | + ); |
|
| 863 | + $this->_views['trash'] = array( |
|
| 864 | + 'slug' => 'trash', |
|
| 865 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 866 | + 'count' => 0, |
|
| 867 | + 'bulk_action' => array( |
|
| 868 | + 'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'), |
|
| 869 | + 'delete_registrations' => esc_html__('Delete Registrations Permanently', 'event_espresso'), |
|
| 870 | + ), |
|
| 871 | + ); |
|
| 872 | + } |
|
| 873 | + } |
|
| 874 | + |
|
| 875 | + |
|
| 876 | + protected function _set_list_table_views_contact_list() |
|
| 877 | + { |
|
| 878 | + $this->_views = array( |
|
| 879 | + 'in_use' => array( |
|
| 880 | + 'slug' => 'in_use', |
|
| 881 | + 'label' => esc_html__('In Use', 'event_espresso'), |
|
| 882 | + 'count' => 0, |
|
| 883 | + 'bulk_action' => array( |
|
| 884 | + 'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 885 | + ), |
|
| 886 | + ), |
|
| 887 | + ); |
|
| 888 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
| 889 | + 'espresso_registrations_trash_attendees') |
|
| 890 | + ) { |
|
| 891 | + $this->_views['trash'] = array( |
|
| 892 | + 'slug' => 'trash', |
|
| 893 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 894 | + 'count' => 0, |
|
| 895 | + 'bulk_action' => array( |
|
| 896 | + 'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 897 | + ), |
|
| 898 | + ); |
|
| 899 | + } |
|
| 900 | + } |
|
| 901 | + |
|
| 902 | + |
|
| 903 | + protected function _registration_legend_items() |
|
| 904 | + { |
|
| 905 | + $fc_items = array( |
|
| 906 | + 'star-icon' => array( |
|
| 907 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 908 | + 'desc' => esc_html__('This is the Primary Registrant', 'event_espresso'), |
|
| 909 | + ), |
|
| 910 | + 'view_details' => array( |
|
| 911 | + 'class' => 'dashicons dashicons-clipboard', |
|
| 912 | + 'desc' => esc_html__('View Registration Details', 'event_espresso'), |
|
| 913 | + ), |
|
| 914 | + 'edit_attendee' => array( |
|
| 915 | + 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
| 916 | + 'desc' => esc_html__('Edit Contact Details', 'event_espresso'), |
|
| 917 | + ), |
|
| 918 | + 'view_transaction' => array( |
|
| 919 | + 'class' => 'dashicons dashicons-cart', |
|
| 920 | + 'desc' => esc_html__('View Transaction Details', 'event_espresso'), |
|
| 921 | + ), |
|
| 922 | + 'view_invoice' => array( |
|
| 923 | + 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 924 | + 'desc' => esc_html__('View Transaction Invoice', 'event_espresso'), |
|
| 925 | + ), |
|
| 926 | + ); |
|
| 927 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 928 | + 'ee_send_message', |
|
| 929 | + 'espresso_registrations_resend_registration' |
|
| 930 | + )) { |
|
| 931 | + $fc_items['resend_registration'] = array( |
|
| 932 | + 'class' => 'dashicons dashicons-email-alt', |
|
| 933 | + 'desc' => esc_html__('Resend Registration Details', 'event_espresso'), |
|
| 934 | + ); |
|
| 935 | + } else { |
|
| 936 | + $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
| 937 | + } |
|
| 938 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 939 | + 'ee_read_global_messages', |
|
| 940 | + 'view_filtered_messages' |
|
| 941 | + )) { |
|
| 942 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 943 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 944 | + $fc_items['view_related_messages'] = array( |
|
| 945 | + 'class' => $related_for_icon['css_class'], |
|
| 946 | + 'desc' => $related_for_icon['label'], |
|
| 947 | + ); |
|
| 948 | + } |
|
| 949 | + } |
|
| 950 | + $sc_items = array( |
|
| 951 | + 'approved_status' => array( |
|
| 952 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 953 | + 'desc' => EEH_Template::pretty_status( |
|
| 954 | + EEM_Registration::status_id_approved, |
|
| 955 | + false, |
|
| 956 | + 'sentence' |
|
| 957 | + ), |
|
| 958 | + ), |
|
| 959 | + 'pending_status' => array( |
|
| 960 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 961 | + 'desc' => EEH_Template::pretty_status( |
|
| 962 | + EEM_Registration::status_id_pending_payment, |
|
| 963 | + false, |
|
| 964 | + 'sentence' |
|
| 965 | + ), |
|
| 966 | + ), |
|
| 967 | + 'wait_list' => array( |
|
| 968 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 969 | + 'desc' => EEH_Template::pretty_status( |
|
| 970 | + EEM_Registration::status_id_wait_list, |
|
| 971 | + false, |
|
| 972 | + 'sentence' |
|
| 973 | + ), |
|
| 974 | + ), |
|
| 975 | + 'incomplete_status' => array( |
|
| 976 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 977 | + 'desc' => EEH_Template::pretty_status( |
|
| 978 | + EEM_Registration::status_id_incomplete, |
|
| 979 | + false, |
|
| 980 | + 'sentence' |
|
| 981 | + ), |
|
| 982 | + ), |
|
| 983 | + 'not_approved' => array( |
|
| 984 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 985 | + 'desc' => EEH_Template::pretty_status( |
|
| 986 | + EEM_Registration::status_id_not_approved, |
|
| 987 | + false, |
|
| 988 | + 'sentence' |
|
| 989 | + ), |
|
| 990 | + ), |
|
| 991 | + 'declined_status' => array( |
|
| 992 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 993 | + 'desc' => EEH_Template::pretty_status( |
|
| 994 | + EEM_Registration::status_id_declined, |
|
| 995 | + false, |
|
| 996 | + 'sentence' |
|
| 997 | + ), |
|
| 998 | + ), |
|
| 999 | + 'cancelled_status' => array( |
|
| 1000 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1001 | + 'desc' => EEH_Template::pretty_status( |
|
| 1002 | + EEM_Registration::status_id_cancelled, |
|
| 1003 | + false, |
|
| 1004 | + 'sentence' |
|
| 1005 | + ), |
|
| 1006 | + ), |
|
| 1007 | + ); |
|
| 1008 | + return array_merge($fc_items, $sc_items); |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + |
|
| 1012 | + |
|
| 1013 | + /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
| 1014 | + /** |
|
| 1015 | + * @throws \EE_Error |
|
| 1016 | + */ |
|
| 1017 | + protected function _registrations_overview_list_table() |
|
| 1018 | + { |
|
| 1019 | + $this->_template_args['admin_page_header'] = ''; |
|
| 1020 | + $EVT_ID = ! empty($this->_req_data['event_id']) |
|
| 1021 | + ? absint($this->_req_data['event_id']) |
|
| 1022 | + : 0; |
|
| 1023 | + if ($EVT_ID) { |
|
| 1024 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 1025 | + 'ee_edit_registrations', |
|
| 1026 | + 'espresso_registrations_new_registration', |
|
| 1027 | + $EVT_ID |
|
| 1028 | + )) { |
|
| 1029 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 1030 | + 'new_registration', |
|
| 1031 | + 'add-registrant', |
|
| 1032 | + array('event_id' => $EVT_ID), |
|
| 1033 | + 'add-new-h2' |
|
| 1034 | + ); |
|
| 1035 | + } |
|
| 1036 | + $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 1037 | + if ($event instanceof EE_Event) { |
|
| 1038 | + $this->_template_args['admin_page_header'] = sprintf( |
|
| 1039 | + esc_html__( |
|
| 1040 | + '%s Viewing registrations for the event: %s%s', |
|
| 1041 | + 'event_espresso' |
|
| 1042 | + ), |
|
| 1043 | + '<h3 style="line-height:1.5em;">', |
|
| 1044 | + '<br /><a href="' |
|
| 1045 | + . EE_Admin_Page::add_query_args_and_nonce( |
|
| 1046 | + array( |
|
| 1047 | + 'action' => 'edit', |
|
| 1048 | + 'post' => $event->ID(), |
|
| 1049 | + ), |
|
| 1050 | + EVENTS_ADMIN_URL |
|
| 1051 | + ) |
|
| 1052 | + . '"> ' |
|
| 1053 | + . $event->get('EVT_name') |
|
| 1054 | + . ' </a> ', |
|
| 1055 | + '</h3>' |
|
| 1056 | + ); |
|
| 1057 | + } |
|
| 1058 | + $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
| 1059 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1060 | + if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
| 1061 | + $this->_template_args['admin_page_header'] = substr( |
|
| 1062 | + $this->_template_args['admin_page_header'], |
|
| 1063 | + 0, |
|
| 1064 | + -5 |
|
| 1065 | + ); |
|
| 1066 | + $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
| 1067 | + $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1068 | + $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
| 1069 | + $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 1070 | + $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
| 1071 | + } |
|
| 1072 | + } |
|
| 1073 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
| 1074 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1075 | + } |
|
| 1076 | + |
|
| 1077 | + |
|
| 1078 | + /** |
|
| 1079 | + * This sets the _registration property for the registration details screen |
|
| 1080 | + * |
|
| 1081 | + * @access private |
|
| 1082 | + * @return bool |
|
| 1083 | + */ |
|
| 1084 | + private function _set_registration_object() |
|
| 1085 | + { |
|
| 1086 | + //get out if we've already set the object |
|
| 1087 | + if ($this->_registration instanceof EE_Registration) { |
|
| 1088 | + return true; |
|
| 1089 | + } |
|
| 1090 | + $REG = EEM_Registration::instance(); |
|
| 1091 | + $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 1092 | + if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
| 1093 | + return true; |
|
| 1094 | + } else { |
|
| 1095 | + $error_msg = sprintf( |
|
| 1096 | + esc_html__( |
|
| 1097 | + 'An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
| 1098 | + 'event_espresso' |
|
| 1099 | + ), |
|
| 1100 | + $REG_ID |
|
| 1101 | + ); |
|
| 1102 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1103 | + $this->_registration = null; |
|
| 1104 | + return false; |
|
| 1105 | + } |
|
| 1106 | + } |
|
| 1107 | + |
|
| 1108 | + |
|
| 1109 | + /** |
|
| 1110 | + * Used to retrieve registrations for the list table. |
|
| 1111 | + * |
|
| 1112 | + * @param int $per_page |
|
| 1113 | + * @param bool $count |
|
| 1114 | + * @param bool $this_month |
|
| 1115 | + * @param bool $today |
|
| 1116 | + * @return EE_Registration[]|int |
|
| 1117 | + * @throws EE_Error |
|
| 1118 | + */ |
|
| 1119 | + public function get_registrations( |
|
| 1120 | + $per_page = 10, |
|
| 1121 | + $count = false, |
|
| 1122 | + $this_month = false, |
|
| 1123 | + $today = false |
|
| 1124 | + ) { |
|
| 1125 | + if ($this_month) { |
|
| 1126 | + $this->_req_data['status'] = 'month'; |
|
| 1127 | + } |
|
| 1128 | + if ($today) { |
|
| 1129 | + $this->_req_data['status'] = 'today'; |
|
| 1130 | + } |
|
| 1131 | + $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
|
| 1132 | + /** |
|
| 1133 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1134 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1135 | + * @see EEM_Base::get_all() |
|
| 1136 | + */ |
|
| 1137 | + $query_params['group_by'] = ''; |
|
| 1138 | + |
|
| 1139 | + return $count |
|
| 1140 | + ? EEM_Registration::instance()->count($query_params) |
|
| 1141 | + /** @type EE_Registration[] */ |
|
| 1142 | + : EEM_Registration::instance()->get_all($query_params); |
|
| 1143 | + } |
|
| 1144 | + |
|
| 1145 | + |
|
| 1146 | + |
|
| 1147 | + /** |
|
| 1148 | + * Retrieves the query parameters to be used by the Registration model for getting registrations. |
|
| 1149 | + * Note: this listens to values on the request for some of the query parameters. |
|
| 1150 | + * |
|
| 1151 | + * @param array $request |
|
| 1152 | + * @param int $per_page |
|
| 1153 | + * @param bool $count |
|
| 1154 | + * @return array |
|
| 1155 | + */ |
|
| 1156 | + protected function _get_registration_query_parameters( |
|
| 1157 | + $request = array(), |
|
| 1158 | + $per_page = 10, |
|
| 1159 | + $count = false |
|
| 1160 | + ) { |
|
| 1161 | + |
|
| 1162 | + $query_params = array( |
|
| 1163 | + 0 => $this->_get_where_conditions_for_registrations_query( |
|
| 1164 | + $request |
|
| 1165 | + ), |
|
| 1166 | + 'caps' => EEM_Registration::caps_read_admin, |
|
| 1167 | + 'default_where_conditions' => 'this_model_only', |
|
| 1168 | + ); |
|
| 1169 | + if (! $count) { |
|
| 1170 | + $query_params = array_merge( |
|
| 1171 | + $query_params, |
|
| 1172 | + $this->_get_orderby_for_registrations_query(), |
|
| 1173 | + $this->_get_limit($per_page) |
|
| 1174 | + ); |
|
| 1175 | + } |
|
| 1176 | + |
|
| 1177 | + return $query_params; |
|
| 1178 | + } |
|
| 1179 | + |
|
| 1180 | + |
|
| 1181 | + /** |
|
| 1182 | + * This will add EVT_ID to the provided $where array for EE model query parameters. |
|
| 1183 | + * |
|
| 1184 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1185 | + * @return array |
|
| 1186 | + */ |
|
| 1187 | + protected function _add_event_id_to_where_conditions(array $request) |
|
| 1188 | + { |
|
| 1189 | + $where = array(); |
|
| 1190 | + if (! empty($request['event_id'])) { |
|
| 1191 | + $where['EVT_ID'] = absint($request['event_id']); |
|
| 1192 | + } |
|
| 1193 | + return $where; |
|
| 1194 | + } |
|
| 1195 | + |
|
| 1196 | + |
|
| 1197 | + /** |
|
| 1198 | + * Adds category ID if it exists in the request to the where conditions for the registrations query. |
|
| 1199 | + * |
|
| 1200 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1201 | + * @return array |
|
| 1202 | + */ |
|
| 1203 | + protected function _add_category_id_to_where_conditions(array $request) |
|
| 1204 | + { |
|
| 1205 | + $where = array(); |
|
| 1206 | + if (! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 1207 | + $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
|
| 1208 | + } |
|
| 1209 | + return $where; |
|
| 1210 | + } |
|
| 1211 | + |
|
| 1212 | + |
|
| 1213 | + /** |
|
| 1214 | + * Adds the datetime ID if it exists in the request to the where conditions for the registrations query. |
|
| 1215 | + * |
|
| 1216 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1217 | + * @return array |
|
| 1218 | + */ |
|
| 1219 | + protected function _add_datetime_id_to_where_conditions(array $request) |
|
| 1220 | + { |
|
| 1221 | + $where = array(); |
|
| 1222 | + if (! empty($request['datetime_id'])) { |
|
| 1223 | + $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
|
| 1224 | + } |
|
| 1225 | + if (! empty($request['DTT_ID'])) { |
|
| 1226 | + $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
|
| 1227 | + } |
|
| 1228 | + return $where; |
|
| 1229 | + } |
|
| 1230 | + |
|
| 1231 | + |
|
| 1232 | + /** |
|
| 1233 | + * Adds the correct registration status to the where conditions for the registrations query. |
|
| 1234 | + * |
|
| 1235 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1236 | + * @return array |
|
| 1237 | + */ |
|
| 1238 | + protected function _add_registration_status_to_where_conditions(array $request) |
|
| 1239 | + { |
|
| 1240 | + $where = array(); |
|
| 1241 | + $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1242 | + $registration_status = ! empty($request['_reg_status']) |
|
| 1243 | + ? sanitize_text_field($request['_reg_status']) |
|
| 1244 | + : ''; |
|
| 1245 | + |
|
| 1246 | + /* |
|
| 1247 | 1247 | * If filtering by registration status, then we show registrations matching that status. |
| 1248 | 1248 | * If not filtering by specified status, then we show all registrations excluding incomplete registrations |
| 1249 | 1249 | * UNLESS viewing trashed registrations. |
| 1250 | 1250 | */ |
| 1251 | - if (! empty($registration_status)) { |
|
| 1252 | - $where['STS_ID'] = $registration_status; |
|
| 1253 | - } else { |
|
| 1254 | - //make sure we exclude incomplete registrations, but only if not trashed. |
|
| 1255 | - if ($view === 'trash') { |
|
| 1256 | - $where['REG_deleted'] = true; |
|
| 1257 | - } elseif ($view === 'incomplete') { |
|
| 1258 | - $where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 1259 | - } else { |
|
| 1260 | - $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 1261 | - } |
|
| 1262 | - } |
|
| 1263 | - return $where; |
|
| 1264 | - } |
|
| 1265 | - |
|
| 1266 | - |
|
| 1267 | - /** |
|
| 1268 | - * Adds any provided date restraints to the where conditions for the registrations query. |
|
| 1269 | - * |
|
| 1270 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1271 | - * @return array |
|
| 1272 | - * @throws EE_Error |
|
| 1273 | - */ |
|
| 1274 | - protected function _add_date_to_where_conditions(array $request) |
|
| 1275 | - { |
|
| 1276 | - $where = array(); |
|
| 1277 | - $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1278 | - $month_range = ! empty($request['month_range']) |
|
| 1279 | - ? sanitize_text_field($request['month_range']) |
|
| 1280 | - : ''; |
|
| 1281 | - $retrieve_for_today = $view === 'today'; |
|
| 1282 | - $retrieve_for_this_month = $view === 'month'; |
|
| 1283 | - |
|
| 1284 | - if ($retrieve_for_today) { |
|
| 1285 | - $now = date('Y-m-d', current_time('timestamp')); |
|
| 1286 | - $where['REG_date'] = array( |
|
| 1287 | - 'BETWEEN', |
|
| 1288 | - array( |
|
| 1289 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1290 | - 'REG_date', |
|
| 1291 | - $now . ' 00:00:00', |
|
| 1292 | - 'Y-m-d H:i:s' |
|
| 1293 | - ), |
|
| 1294 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1295 | - 'REG_date', |
|
| 1296 | - $now . ' 23:59:59', |
|
| 1297 | - 'Y-m-d H:i:s' |
|
| 1298 | - ), |
|
| 1299 | - ), |
|
| 1300 | - ); |
|
| 1301 | - } elseif ($retrieve_for_this_month) { |
|
| 1302 | - $current_year_and_month = date('Y-m', current_time('timestamp')); |
|
| 1303 | - $days_this_month = date('t', current_time('timestamp')); |
|
| 1304 | - $where['REG_date'] = array( |
|
| 1305 | - 'BETWEEN', |
|
| 1306 | - array( |
|
| 1307 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1308 | - 'REG_date', |
|
| 1309 | - $current_year_and_month . '-01 00:00:00', |
|
| 1310 | - 'Y-m-d H:i:s' |
|
| 1311 | - ), |
|
| 1312 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1313 | - 'REG_date', |
|
| 1314 | - $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1315 | - 'Y-m-d H:i:s' |
|
| 1316 | - ), |
|
| 1317 | - ), |
|
| 1318 | - ); |
|
| 1319 | - } elseif ($month_range) { |
|
| 1320 | - $pieces = explode(' ', $month_range, 3); |
|
| 1321 | - $month_requested = ! empty($pieces[0]) |
|
| 1322 | - ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) |
|
| 1323 | - : ''; |
|
| 1324 | - $year_requested = ! empty($pieces[1]) |
|
| 1325 | - ? $pieces[1] |
|
| 1326 | - : ''; |
|
| 1327 | - //if there is not a month or year then we can't go further |
|
| 1328 | - if ($month_requested && $year_requested) { |
|
| 1329 | - $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1330 | - $where['REG_date'] = array( |
|
| 1331 | - 'BETWEEN', |
|
| 1332 | - array( |
|
| 1333 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1334 | - 'REG_date', |
|
| 1335 | - $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1336 | - 'Y-m-d H:i:s' |
|
| 1337 | - ), |
|
| 1338 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1339 | - 'REG_date', |
|
| 1340 | - $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1341 | - 'Y-m-d H:i:s' |
|
| 1342 | - ), |
|
| 1343 | - ), |
|
| 1344 | - ); |
|
| 1345 | - } |
|
| 1346 | - } |
|
| 1347 | - return $where; |
|
| 1348 | - } |
|
| 1349 | - |
|
| 1350 | - |
|
| 1351 | - /** |
|
| 1352 | - * Adds any provided search restraints to the where conditions for the registrations query |
|
| 1353 | - * |
|
| 1354 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1355 | - * @return array |
|
| 1356 | - */ |
|
| 1357 | - protected function _add_search_to_where_conditions(array $request) |
|
| 1358 | - { |
|
| 1359 | - $where = array(); |
|
| 1360 | - if (! empty($request['s'])) { |
|
| 1361 | - $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1362 | - $where['OR*search_conditions'] = array( |
|
| 1363 | - 'Event.EVT_name' => array('LIKE', $search_string), |
|
| 1364 | - 'Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1365 | - 'Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1366 | - 'Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1367 | - 'Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1368 | - 'Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1369 | - 'Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1370 | - 'Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1371 | - 'Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1372 | - 'Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1373 | - 'Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1374 | - 'REG_final_price' => array('LIKE', $search_string), |
|
| 1375 | - 'REG_code' => array('LIKE', $search_string), |
|
| 1376 | - 'REG_count' => array('LIKE', $search_string), |
|
| 1377 | - 'REG_group_size' => array('LIKE', $search_string), |
|
| 1378 | - 'Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1379 | - 'Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1380 | - 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1381 | - ); |
|
| 1382 | - } |
|
| 1383 | - return $where; |
|
| 1384 | - } |
|
| 1385 | - |
|
| 1386 | - |
|
| 1387 | - /** |
|
| 1388 | - * Sets up the where conditions for the registrations query. |
|
| 1389 | - * |
|
| 1390 | - * @param array $request |
|
| 1391 | - * @return array |
|
| 1392 | - * @throws EE_Error |
|
| 1393 | - */ |
|
| 1394 | - protected function _get_where_conditions_for_registrations_query($request) |
|
| 1395 | - { |
|
| 1396 | - return apply_filters( |
|
| 1397 | - 'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query', |
|
| 1398 | - array_merge( |
|
| 1399 | - $this->_add_event_id_to_where_conditions($request), |
|
| 1400 | - $this->_add_category_id_to_where_conditions($request), |
|
| 1401 | - $this->_add_datetime_id_to_where_conditions($request), |
|
| 1402 | - $this->_add_registration_status_to_where_conditions($request), |
|
| 1403 | - $this->_add_date_to_where_conditions($request), |
|
| 1404 | - $this->_add_search_to_where_conditions($request) |
|
| 1405 | - ), |
|
| 1406 | - $request |
|
| 1407 | - ); |
|
| 1408 | - } |
|
| 1409 | - |
|
| 1410 | - |
|
| 1411 | - /** |
|
| 1412 | - * Sets up the orderby for the registrations query. |
|
| 1413 | - * |
|
| 1414 | - * @return array |
|
| 1415 | - */ |
|
| 1416 | - protected function _get_orderby_for_registrations_query() |
|
| 1417 | - { |
|
| 1418 | - $orderby_field = ! empty($this->_req_data['orderby']) |
|
| 1419 | - ? sanitize_text_field($this->_req_data['orderby']) |
|
| 1420 | - : ''; |
|
| 1421 | - switch ($orderby_field) { |
|
| 1422 | - case '_REG_ID': |
|
| 1423 | - $orderby_field = 'REG_ID'; |
|
| 1424 | - break; |
|
| 1425 | - case '_Reg_status': |
|
| 1426 | - $orderby_field = 'STS_ID'; |
|
| 1427 | - break; |
|
| 1428 | - case 'ATT_fname': |
|
| 1429 | - $orderby_field = array('Attendee.ATT_fname', 'Attendee.ATT_lname'); |
|
| 1430 | - break; |
|
| 1431 | - case 'ATT_lname': |
|
| 1432 | - $orderby_field = array('Attendee.ATT_lname', 'Attendee.ATT_fname'); |
|
| 1433 | - break; |
|
| 1434 | - case 'event_name': |
|
| 1435 | - $orderby_field = 'Event.EVT_name'; |
|
| 1436 | - break; |
|
| 1437 | - case 'DTT_EVT_start': |
|
| 1438 | - $orderby_field = 'Event.Datetime.DTT_EVT_start'; |
|
| 1439 | - break; |
|
| 1440 | - default: //'REG_date' |
|
| 1441 | - $orderby_field = 'REG_date'; |
|
| 1442 | - } |
|
| 1443 | - |
|
| 1444 | - //order |
|
| 1445 | - $order = ! empty($this->_req_data['order']) |
|
| 1446 | - ? sanitize_text_field($this->_req_data['order']) |
|
| 1447 | - : 'DESC'; |
|
| 1448 | - |
|
| 1449 | - //mutate orderby_field |
|
| 1450 | - $orderby_field = array_combine( |
|
| 1451 | - (array) $orderby_field, |
|
| 1452 | - array_fill(0, count($orderby_field), $order) |
|
| 1453 | - ); |
|
| 1454 | - //because there are many registrations with the same date, define |
|
| 1455 | - //a secondary way to order them, otherwise MySQL seems to be a bit random |
|
| 1456 | - if (empty($order['REG_ID'])) { |
|
| 1457 | - $orderby_field['REG_ID'] = $order; |
|
| 1458 | - } |
|
| 1459 | - return array('order_by' => $orderby_field); |
|
| 1460 | - } |
|
| 1461 | - |
|
| 1462 | - |
|
| 1463 | - /** |
|
| 1464 | - * Sets up the limit for the registrations query. |
|
| 1465 | - * |
|
| 1466 | - * @param $per_page |
|
| 1467 | - * @return array |
|
| 1468 | - */ |
|
| 1469 | - protected function _get_limit($per_page) |
|
| 1470 | - { |
|
| 1471 | - $current_page = ! empty($this->_req_data['paged']) |
|
| 1472 | - ? absint($this->_req_data['paged']) |
|
| 1473 | - : 1; |
|
| 1474 | - $per_page = ! empty($this->_req_data['perpage']) |
|
| 1475 | - ? $this->_req_data['perpage'] |
|
| 1476 | - : $per_page; |
|
| 1477 | - |
|
| 1478 | - //-1 means return all results so get out if that's set. |
|
| 1479 | - if ((int)$per_page === -1) { |
|
| 1480 | - return array(); |
|
| 1481 | - } |
|
| 1482 | - $per_page = absint($per_page); |
|
| 1483 | - $offset = ($current_page - 1) * $per_page; |
|
| 1484 | - return array('limit' => array($offset, $per_page)); |
|
| 1485 | - } |
|
| 1486 | - |
|
| 1487 | - |
|
| 1488 | - public function get_registration_status_array() |
|
| 1489 | - { |
|
| 1490 | - return self::$_reg_status; |
|
| 1491 | - } |
|
| 1492 | - |
|
| 1493 | - |
|
| 1494 | - |
|
| 1495 | - |
|
| 1496 | - /*************************************** REGISTRATION DETAILS ***************************************/ |
|
| 1497 | - /** |
|
| 1498 | - * generates HTML for the View Registration Details Admin page |
|
| 1499 | - * |
|
| 1500 | - * @access protected |
|
| 1501 | - * @return void |
|
| 1502 | - * @throws DomainException |
|
| 1503 | - * @throws EE_Error |
|
| 1504 | - * @throws EntityNotFoundException |
|
| 1505 | - */ |
|
| 1506 | - protected function _registration_details() |
|
| 1507 | - { |
|
| 1508 | - $this->_template_args = array(); |
|
| 1509 | - $this->_set_registration_object(); |
|
| 1510 | - if (is_object($this->_registration)) { |
|
| 1511 | - $transaction = $this->_registration->transaction() |
|
| 1512 | - ? $this->_registration->transaction() |
|
| 1513 | - : EE_Transaction::new_instance(); |
|
| 1514 | - $this->_session = $transaction->session_data(); |
|
| 1515 | - $event_id = $this->_registration->event_ID(); |
|
| 1516 | - $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
| 1517 | - $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso'); |
|
| 1518 | - $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
| 1519 | - $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
| 1520 | - $this->_template_args['grand_total'] = $transaction->total(); |
|
| 1521 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1522 | - // link back to overview |
|
| 1523 | - $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
| 1524 | - $this->_template_args['registration'] = $this->_registration; |
|
| 1525 | - $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1526 | - array( |
|
| 1527 | - 'action' => 'default', |
|
| 1528 | - 'event_id' => $event_id, |
|
| 1529 | - ), |
|
| 1530 | - REG_ADMIN_URL |
|
| 1531 | - ); |
|
| 1532 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1533 | - array( |
|
| 1534 | - 'action' => 'default', |
|
| 1535 | - 'EVT_ID' => $event_id, |
|
| 1536 | - 'page' => 'espresso_transactions', |
|
| 1537 | - ), |
|
| 1538 | - admin_url('admin.php') |
|
| 1539 | - ); |
|
| 1540 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1541 | - array( |
|
| 1542 | - 'page' => 'espresso_events', |
|
| 1543 | - 'action' => 'edit', |
|
| 1544 | - 'post' => $event_id, |
|
| 1545 | - ), |
|
| 1546 | - admin_url('admin.php') |
|
| 1547 | - ); |
|
| 1548 | - //next and previous links |
|
| 1549 | - $next_reg = $this->_registration->next( |
|
| 1550 | - null, |
|
| 1551 | - array(), |
|
| 1552 | - 'REG_ID' |
|
| 1553 | - ); |
|
| 1554 | - $this->_template_args['next_registration'] = $next_reg |
|
| 1555 | - ? $this->_next_link( |
|
| 1556 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 1557 | - array( |
|
| 1558 | - 'action' => 'view_registration', |
|
| 1559 | - '_REG_ID' => $next_reg['REG_ID'], |
|
| 1560 | - ), |
|
| 1561 | - REG_ADMIN_URL |
|
| 1562 | - ), |
|
| 1563 | - 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
| 1564 | - ) |
|
| 1565 | - : ''; |
|
| 1566 | - $previous_reg = $this->_registration->previous( |
|
| 1567 | - null, |
|
| 1568 | - array(), |
|
| 1569 | - 'REG_ID' |
|
| 1570 | - ); |
|
| 1571 | - $this->_template_args['previous_registration'] = $previous_reg |
|
| 1572 | - ? $this->_previous_link( |
|
| 1573 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 1574 | - array( |
|
| 1575 | - 'action' => 'view_registration', |
|
| 1576 | - '_REG_ID' => $previous_reg['REG_ID'], |
|
| 1577 | - ), |
|
| 1578 | - REG_ADMIN_URL |
|
| 1579 | - ), |
|
| 1580 | - 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
| 1581 | - ) |
|
| 1582 | - : ''; |
|
| 1583 | - // grab header |
|
| 1584 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1585 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1586 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( |
|
| 1587 | - $template_path, |
|
| 1588 | - $this->_template_args, |
|
| 1589 | - true |
|
| 1590 | - ); |
|
| 1591 | - } else { |
|
| 1592 | - $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
| 1593 | - } |
|
| 1594 | - // the details template wrapper |
|
| 1595 | - $this->display_admin_page_with_sidebar(); |
|
| 1596 | - } |
|
| 1597 | - |
|
| 1598 | - |
|
| 1599 | - protected function _registration_details_metaboxes() |
|
| 1600 | - { |
|
| 1601 | - do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
| 1602 | - $this->_set_registration_object(); |
|
| 1603 | - $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
| 1604 | - add_meta_box('edit-reg-status-mbox', esc_html__('Registration Status', 'event_espresso'), |
|
| 1605 | - array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1606 | - add_meta_box('edit-reg-details-mbox', esc_html__('Registration Details', 'event_espresso'), |
|
| 1607 | - array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1608 | - if ($attendee instanceof EE_Attendee |
|
| 1609 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 1610 | - 'ee_edit_registration', |
|
| 1611 | - 'edit-reg-questions-mbox', |
|
| 1612 | - $this->_registration->ID() |
|
| 1613 | - ) |
|
| 1614 | - ) { |
|
| 1615 | - add_meta_box( |
|
| 1616 | - 'edit-reg-questions-mbox', |
|
| 1617 | - esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 1618 | - array($this, '_reg_questions_meta_box'), |
|
| 1619 | - $this->wp_page_slug, |
|
| 1620 | - 'normal', |
|
| 1621 | - 'high' |
|
| 1622 | - ); |
|
| 1623 | - } |
|
| 1624 | - add_meta_box( |
|
| 1625 | - 'edit-reg-registrant-mbox', |
|
| 1626 | - esc_html__('Contact Details', 'event_espresso'), |
|
| 1627 | - array($this, '_reg_registrant_side_meta_box'), |
|
| 1628 | - $this->wp_page_slug, |
|
| 1629 | - 'side', |
|
| 1630 | - 'high' |
|
| 1631 | - ); |
|
| 1632 | - if ($this->_registration->group_size() > 1) { |
|
| 1633 | - add_meta_box( |
|
| 1634 | - 'edit-reg-attendees-mbox', |
|
| 1635 | - esc_html__('Other Registrations in this Transaction', 'event_espresso'), |
|
| 1636 | - array($this, '_reg_attendees_meta_box'), |
|
| 1637 | - $this->wp_page_slug, |
|
| 1638 | - 'normal', |
|
| 1639 | - 'high' |
|
| 1640 | - ); |
|
| 1641 | - } |
|
| 1642 | - } |
|
| 1643 | - |
|
| 1644 | - |
|
| 1645 | - /** |
|
| 1646 | - * set_reg_status_buttons_metabox |
|
| 1647 | - * |
|
| 1648 | - * @access protected |
|
| 1649 | - * @return string |
|
| 1650 | - * @throws \EE_Error |
|
| 1651 | - */ |
|
| 1652 | - public function set_reg_status_buttons_metabox() |
|
| 1653 | - { |
|
| 1654 | - $this->_set_registration_object(); |
|
| 1655 | - $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
| 1656 | - echo $change_reg_status_form->form_open( |
|
| 1657 | - self::add_query_args_and_nonce( |
|
| 1658 | - array( |
|
| 1659 | - 'action' => 'change_reg_status', |
|
| 1660 | - ), |
|
| 1661 | - REG_ADMIN_URL |
|
| 1662 | - ) |
|
| 1663 | - ); |
|
| 1664 | - echo $change_reg_status_form->get_html(); |
|
| 1665 | - echo $change_reg_status_form->form_close(); |
|
| 1666 | - } |
|
| 1667 | - |
|
| 1668 | - |
|
| 1669 | - |
|
| 1670 | - /** |
|
| 1671 | - * @return EE_Form_Section_Proper |
|
| 1672 | - * @throws EE_Error |
|
| 1673 | - */ |
|
| 1674 | - protected function _generate_reg_status_change_form() |
|
| 1675 | - { |
|
| 1676 | - return new EE_Form_Section_Proper(array( |
|
| 1677 | - 'name' => 'reg_status_change_form', |
|
| 1678 | - 'html_id' => 'reg-status-change-form', |
|
| 1679 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1680 | - 'subsections' => array( |
|
| 1681 | - 'return' => new EE_Hidden_Input(array( |
|
| 1682 | - 'name' => 'return', |
|
| 1683 | - 'default' => 'view_registration', |
|
| 1684 | - )), |
|
| 1685 | - 'REG_ID' => new EE_Hidden_Input(array( |
|
| 1686 | - 'name' => 'REG_ID', |
|
| 1687 | - 'default' => $this->_registration->ID(), |
|
| 1688 | - )), |
|
| 1689 | - 'current_status' => new EE_Form_Section_HTML( |
|
| 1690 | - EEH_HTML::tr( |
|
| 1691 | - EEH_HTML::th( |
|
| 1692 | - EEH_HTML::label( |
|
| 1693 | - EEH_HTML::strong(esc_html__('Current Registration Status', 'event_espresso') |
|
| 1694 | - ) |
|
| 1695 | - ) |
|
| 1696 | - ) |
|
| 1697 | - . EEH_HTML::td( |
|
| 1698 | - EEH_HTML::strong( |
|
| 1699 | - $this->_registration->pretty_status(), |
|
| 1700 | - '', |
|
| 1701 | - 'status-' . $this->_registration->status_ID(), |
|
| 1702 | - 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
| 1703 | - ) |
|
| 1704 | - ) |
|
| 1705 | - ) |
|
| 1706 | - ), |
|
| 1707 | - 'reg_status' => new EE_Select_Input( |
|
| 1708 | - $this->_get_reg_statuses(), |
|
| 1709 | - array( |
|
| 1710 | - 'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'), |
|
| 1711 | - 'default' => $this->_registration->status_ID(), |
|
| 1712 | - ) |
|
| 1713 | - ), |
|
| 1714 | - 'send_notifications' => new EE_Yes_No_Input( |
|
| 1715 | - array( |
|
| 1716 | - 'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'), |
|
| 1717 | - 'default' => false, |
|
| 1718 | - 'html_help_text' => esc_html__( |
|
| 1719 | - 'If set to "Yes", then the related messages will be sent to the registrant.', |
|
| 1720 | - 'event_espresso' |
|
| 1721 | - ), |
|
| 1722 | - ) |
|
| 1723 | - ), |
|
| 1724 | - 'submit' => new EE_Submit_Input( |
|
| 1725 | - array( |
|
| 1726 | - 'html_class' => 'button-primary', |
|
| 1727 | - 'html_label_text' => ' ', |
|
| 1728 | - 'default' => esc_html__('Update Registration Status', 'event_espresso'), |
|
| 1729 | - ) |
|
| 1730 | - ), |
|
| 1731 | - ), |
|
| 1732 | - )); |
|
| 1733 | - } |
|
| 1734 | - |
|
| 1735 | - |
|
| 1736 | - /** |
|
| 1737 | - * Returns an array of all the buttons for the various statuses and switch status actions |
|
| 1738 | - * |
|
| 1739 | - * @return array |
|
| 1740 | - * @throws EE_Error |
|
| 1741 | - * @throws EntityNotFoundException |
|
| 1742 | - */ |
|
| 1743 | - protected function _get_reg_statuses() |
|
| 1744 | - { |
|
| 1745 | - $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
| 1746 | - unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
| 1747 | - // get current reg status |
|
| 1748 | - $current_status = $this->_registration->status_ID(); |
|
| 1749 | - // is registration for free event? This will determine whether to display the pending payment option |
|
| 1750 | - if ( |
|
| 1751 | - $current_status !== EEM_Registration::status_id_pending_payment |
|
| 1752 | - && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00) |
|
| 1753 | - ) { |
|
| 1754 | - unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
| 1755 | - } |
|
| 1756 | - return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
| 1757 | - } |
|
| 1758 | - |
|
| 1759 | - |
|
| 1760 | - /** |
|
| 1761 | - * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
| 1762 | - * |
|
| 1763 | - * @param bool $status REG status given for changing registrations to. |
|
| 1764 | - * @param bool $notify Whether to send messages notifications or not. |
|
| 1765 | - * @return array (array with reg_id(s) updated and whether update was successful. |
|
| 1766 | - * @throws EE_Error |
|
| 1767 | - * @throws InvalidArgumentException |
|
| 1768 | - * @throws InvalidDataTypeException |
|
| 1769 | - * @throws InvalidInterfaceException |
|
| 1770 | - * @throws ReflectionException |
|
| 1771 | - * @throws RuntimeException |
|
| 1772 | - * @throws EntityNotFoundException |
|
| 1773 | - */ |
|
| 1774 | - protected function _set_registration_status_from_request($status = false, $notify = false) |
|
| 1775 | - { |
|
| 1776 | - if (isset($this->_req_data['reg_status_change_form'])) { |
|
| 1777 | - $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 1778 | - ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] |
|
| 1779 | - : array(); |
|
| 1780 | - } else { |
|
| 1781 | - $REG_IDs = isset($this->_req_data['_REG_ID']) |
|
| 1782 | - ? (array)$this->_req_data['_REG_ID'] |
|
| 1783 | - : array(); |
|
| 1784 | - } |
|
| 1785 | - // sanitize $REG_IDs |
|
| 1786 | - $REG_IDs = array_map('absint', $REG_IDs); |
|
| 1787 | - // and remove empty entries |
|
| 1788 | - $REG_IDs = array_filter($REG_IDs); |
|
| 1789 | - |
|
| 1790 | - $result = $this->_set_registration_status($REG_IDs, $status, $notify); |
|
| 1791 | - |
|
| 1792 | - /** |
|
| 1793 | - * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications. |
|
| 1794 | - * Currently this value is used downstream by the _process_resend_registration method. |
|
| 1795 | - * |
|
| 1796 | - * @param int|array $registration_ids The registration ids that have had their status changed successfully. |
|
| 1797 | - * @param bool $status The status registrations were changed to. |
|
| 1798 | - * @param bool $success If the status was changed successfully for all registrations. |
|
| 1799 | - * @param Registrations_Admin_Page $admin_page_object |
|
| 1800 | - */ |
|
| 1801 | - $this->_req_data['_REG_ID'] = apply_filters( |
|
| 1802 | - 'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs', |
|
| 1803 | - $result['REG_ID'], |
|
| 1804 | - $status, |
|
| 1805 | - $result['success'], |
|
| 1806 | - $this |
|
| 1807 | - ); |
|
| 1808 | - |
|
| 1809 | - //notify? |
|
| 1810 | - if ($notify |
|
| 1811 | - && $result['success'] |
|
| 1812 | - && ! empty($this->_req_data['_REG_ID']) |
|
| 1813 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 1814 | - 'ee_send_message', |
|
| 1815 | - 'espresso_registrations_resend_registration' |
|
| 1816 | - ) |
|
| 1817 | - ) { |
|
| 1818 | - $this->_process_resend_registration(); |
|
| 1819 | - } |
|
| 1820 | - return $result; |
|
| 1821 | - } |
|
| 1822 | - |
|
| 1823 | - |
|
| 1824 | - /** |
|
| 1825 | - * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
| 1826 | - * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
| 1827 | - * |
|
| 1828 | - * @param array $REG_IDs |
|
| 1829 | - * @param string $status |
|
| 1830 | - * @param bool $notify Used to indicate whether notification was requested or not. This determines the context |
|
| 1831 | - * slug sent with setting the registration status. |
|
| 1832 | - * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
| 1833 | - * @throws EE_Error |
|
| 1834 | - * @throws InvalidArgumentException |
|
| 1835 | - * @throws InvalidDataTypeException |
|
| 1836 | - * @throws InvalidInterfaceException |
|
| 1837 | - * @throws ReflectionException |
|
| 1838 | - * @throws RuntimeException |
|
| 1839 | - * @throws EntityNotFoundException |
|
| 1840 | - */ |
|
| 1841 | - protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false) |
|
| 1842 | - { |
|
| 1843 | - $success = false; |
|
| 1844 | - // typecast $REG_IDs |
|
| 1845 | - $REG_IDs = (array)$REG_IDs; |
|
| 1846 | - if ( ! empty($REG_IDs)) { |
|
| 1847 | - $success = true; |
|
| 1848 | - // set default status if none is passed |
|
| 1849 | - $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
| 1850 | - $status_context = $notify |
|
| 1851 | - ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY |
|
| 1852 | - : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN; |
|
| 1853 | - //loop through REG_ID's and change status |
|
| 1854 | - foreach ($REG_IDs as $REG_ID) { |
|
| 1855 | - $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1856 | - if ($registration instanceof EE_Registration) { |
|
| 1857 | - $registration->set_status( |
|
| 1858 | - $status, |
|
| 1859 | - false, |
|
| 1860 | - new Context( |
|
| 1861 | - $status_context, |
|
| 1862 | - esc_html__( |
|
| 1863 | - 'Manually triggered status change on a Registration Admin Page route.', |
|
| 1864 | - 'event_espresso' |
|
| 1865 | - ) |
|
| 1866 | - ) |
|
| 1867 | - ); |
|
| 1868 | - $result = $registration->save(); |
|
| 1869 | - // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
| 1870 | - $success = $result !== false ? $success : false; |
|
| 1871 | - } |
|
| 1872 | - } |
|
| 1873 | - } |
|
| 1874 | - |
|
| 1875 | - //return $success and processed registrations |
|
| 1876 | - return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
| 1877 | - } |
|
| 1878 | - |
|
| 1879 | - |
|
| 1880 | - /** |
|
| 1881 | - * Common logic for setting up success message and redirecting to appropriate route |
|
| 1882 | - * |
|
| 1883 | - * @param string $STS_ID status id for the registration changed to |
|
| 1884 | - * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
| 1885 | - * @return void |
|
| 1886 | - */ |
|
| 1887 | - protected function _reg_status_change_return($STS_ID, $notify = false) |
|
| 1888 | - { |
|
| 1889 | - $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
| 1890 | - : array('success' => false); |
|
| 1891 | - $success = isset($result['success']) && $result['success']; |
|
| 1892 | - //setup success message |
|
| 1893 | - if ($success) { |
|
| 1894 | - if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
| 1895 | - $msg = sprintf(esc_html__('Registration status has been set to %s', 'event_espresso'), |
|
| 1896 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1897 | - } else { |
|
| 1898 | - $msg = sprintf(esc_html__('Registrations have been set to %s.', 'event_espresso'), |
|
| 1899 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1900 | - } |
|
| 1901 | - EE_Error::add_success($msg); |
|
| 1902 | - } else { |
|
| 1903 | - EE_Error::add_error( |
|
| 1904 | - esc_html__( |
|
| 1905 | - 'Something went wrong, and the status was not changed', |
|
| 1906 | - 'event_espresso' |
|
| 1907 | - ), __FILE__, __LINE__, __FUNCTION__ |
|
| 1908 | - ); |
|
| 1909 | - } |
|
| 1910 | - if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
| 1911 | - $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
| 1912 | - } else { |
|
| 1913 | - $route = array('action' => 'default'); |
|
| 1914 | - } |
|
| 1915 | - //unset nonces |
|
| 1916 | - foreach ($this->_req_data as $ref => $value) { |
|
| 1917 | - if (strpos($ref, 'nonce') !== false) { |
|
| 1918 | - unset($this->_req_data[$ref]); |
|
| 1919 | - continue; |
|
| 1920 | - } |
|
| 1921 | - $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
| 1922 | - $this->_req_data[$ref] = $value; |
|
| 1923 | - } |
|
| 1924 | - //merge request vars so that the reloaded list table contains any existing filter query params |
|
| 1925 | - $route = array_merge($this->_req_data, $route); |
|
| 1926 | - $this->_redirect_after_action($success, '', '', $route, true); |
|
| 1927 | - } |
|
| 1928 | - |
|
| 1929 | - |
|
| 1930 | - /** |
|
| 1931 | - * incoming reg status change from reg details page. |
|
| 1932 | - * |
|
| 1933 | - * @return void |
|
| 1934 | - */ |
|
| 1935 | - protected function _change_reg_status() |
|
| 1936 | - { |
|
| 1937 | - $this->_req_data['return'] = 'view_registration'; |
|
| 1938 | - //set notify based on whether the send notifications toggle is set or not |
|
| 1939 | - $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
| 1940 | - //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
| 1941 | - $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
| 1942 | - ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
| 1943 | - switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
| 1944 | - case EEM_Registration::status_id_approved : |
|
| 1945 | - case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
| 1946 | - $this->approve_registration($notify); |
|
| 1947 | - break; |
|
| 1948 | - case EEM_Registration::status_id_pending_payment : |
|
| 1949 | - case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
| 1950 | - $this->pending_registration($notify); |
|
| 1951 | - break; |
|
| 1952 | - case EEM_Registration::status_id_not_approved : |
|
| 1953 | - case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
| 1954 | - $this->not_approve_registration($notify); |
|
| 1955 | - break; |
|
| 1956 | - case EEM_Registration::status_id_declined : |
|
| 1957 | - case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
| 1958 | - $this->decline_registration($notify); |
|
| 1959 | - break; |
|
| 1960 | - case EEM_Registration::status_id_cancelled : |
|
| 1961 | - case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
| 1962 | - $this->cancel_registration($notify); |
|
| 1963 | - break; |
|
| 1964 | - case EEM_Registration::status_id_wait_list : |
|
| 1965 | - case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
| 1966 | - $this->wait_list_registration($notify); |
|
| 1967 | - break; |
|
| 1968 | - case EEM_Registration::status_id_incomplete : |
|
| 1969 | - default : |
|
| 1970 | - $result['success'] = false; |
|
| 1971 | - unset($this->_req_data['return']); |
|
| 1972 | - $this->_reg_status_change_return('', false); |
|
| 1973 | - break; |
|
| 1974 | - } |
|
| 1975 | - } |
|
| 1976 | - |
|
| 1977 | - |
|
| 1978 | - /** |
|
| 1979 | - * Callback for bulk action routes. |
|
| 1980 | - * Note: although we could just register the singular route callbacks for each bulk action route as well, this |
|
| 1981 | - * method was chosen so there is one central place all the registration status bulk actions are going through. |
|
| 1982 | - * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to |
|
| 1983 | - * when an action is happening on just a single registration). |
|
| 1984 | - * @param $action |
|
| 1985 | - * @param bool $notify |
|
| 1986 | - */ |
|
| 1987 | - protected function bulk_action_on_registrations($action, $notify = false) { |
|
| 1988 | - do_action( |
|
| 1989 | - 'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution', |
|
| 1990 | - $this, |
|
| 1991 | - $action, |
|
| 1992 | - $notify |
|
| 1993 | - ); |
|
| 1994 | - $method = $action . '_registration'; |
|
| 1995 | - if (method_exists($this, $method)) { |
|
| 1996 | - $this->$method($notify); |
|
| 1997 | - } |
|
| 1998 | - } |
|
| 1999 | - |
|
| 2000 | - |
|
| 2001 | - /** |
|
| 2002 | - * approve_registration |
|
| 2003 | - * |
|
| 2004 | - * @access protected |
|
| 2005 | - * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 2006 | - * @return void |
|
| 2007 | - */ |
|
| 2008 | - protected function approve_registration($notify = false) |
|
| 2009 | - { |
|
| 2010 | - $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
| 2011 | - } |
|
| 2012 | - |
|
| 2013 | - |
|
| 2014 | - /** |
|
| 2015 | - * decline_registration |
|
| 2016 | - * |
|
| 2017 | - * @access protected |
|
| 2018 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2019 | - * @return void |
|
| 2020 | - */ |
|
| 2021 | - protected function decline_registration($notify = false) |
|
| 2022 | - { |
|
| 2023 | - $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
| 2024 | - } |
|
| 2025 | - |
|
| 2026 | - |
|
| 2027 | - /** |
|
| 2028 | - * cancel_registration |
|
| 2029 | - * |
|
| 2030 | - * @access protected |
|
| 2031 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2032 | - * @return void |
|
| 2033 | - */ |
|
| 2034 | - protected function cancel_registration($notify = false) |
|
| 2035 | - { |
|
| 2036 | - $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
| 2037 | - } |
|
| 2038 | - |
|
| 2039 | - |
|
| 2040 | - /** |
|
| 2041 | - * not_approve_registration |
|
| 2042 | - * |
|
| 2043 | - * @access protected |
|
| 2044 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2045 | - * @return void |
|
| 2046 | - */ |
|
| 2047 | - protected function not_approve_registration($notify = false) |
|
| 2048 | - { |
|
| 2049 | - $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
| 2050 | - } |
|
| 2051 | - |
|
| 2052 | - |
|
| 2053 | - /** |
|
| 2054 | - * decline_registration |
|
| 2055 | - * |
|
| 2056 | - * @access protected |
|
| 2057 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2058 | - * @return void |
|
| 2059 | - */ |
|
| 2060 | - protected function pending_registration($notify = false) |
|
| 2061 | - { |
|
| 2062 | - $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
| 2063 | - } |
|
| 2064 | - |
|
| 2065 | - |
|
| 2066 | - /** |
|
| 2067 | - * waitlist_registration |
|
| 2068 | - * |
|
| 2069 | - * @access protected |
|
| 2070 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2071 | - * @return void |
|
| 2072 | - */ |
|
| 2073 | - protected function wait_list_registration($notify = false) |
|
| 2074 | - { |
|
| 2075 | - $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
| 2076 | - } |
|
| 2077 | - |
|
| 2078 | - |
|
| 2079 | - /** |
|
| 2080 | - * generates HTML for the Registration main meta box |
|
| 2081 | - * |
|
| 2082 | - * @access public |
|
| 2083 | - * @return void |
|
| 2084 | - * @throws DomainException |
|
| 2085 | - * @throws EE_Error |
|
| 2086 | - * @throws EntityNotFoundException |
|
| 2087 | - */ |
|
| 2088 | - public function _reg_details_meta_box() |
|
| 2089 | - { |
|
| 2090 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 2091 | - EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 2092 | - EE_Registry::instance()->load_helper('Line_Item'); |
|
| 2093 | - $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 2094 | - : EE_Transaction::new_instance(); |
|
| 2095 | - $this->_session = $transaction->session_data(); |
|
| 2096 | - $filters = new EE_Line_Item_Filter_Collection(); |
|
| 2097 | - //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 2098 | - $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
| 2099 | - $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, |
|
| 2100 | - $transaction->total_line_item()); |
|
| 2101 | - $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 2102 | - $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
| 2103 | - 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
| 2104 | - $this->_template_args['line_item_table'] = $line_item_display->display_line_item( |
|
| 2105 | - $filtered_line_item_tree, |
|
| 2106 | - array('EE_Registration' => $this->_registration) |
|
| 2107 | - ); |
|
| 2108 | - $attendee = $this->_registration->attendee(); |
|
| 2109 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 2110 | - 'ee_read_transaction', |
|
| 2111 | - 'espresso_transactions_view_transaction' |
|
| 2112 | - )) { |
|
| 2113 | - $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link( |
|
| 2114 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 2115 | - array( |
|
| 2116 | - 'action' => 'view_transaction', |
|
| 2117 | - 'TXN_ID' => $transaction->ID(), |
|
| 2118 | - ), |
|
| 2119 | - TXN_ADMIN_URL |
|
| 2120 | - ), |
|
| 2121 | - esc_html__(' View Transaction', 'event_espresso'), |
|
| 2122 | - 'button secondary-button right', |
|
| 2123 | - 'dashicons dashicons-cart' |
|
| 2124 | - ); |
|
| 2125 | - } else { |
|
| 2126 | - $this->_template_args['view_transaction_button'] = ''; |
|
| 2127 | - } |
|
| 2128 | - if ($attendee instanceof EE_Attendee |
|
| 2129 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 2130 | - 'ee_send_message', |
|
| 2131 | - 'espresso_registrations_resend_registration' |
|
| 2132 | - ) |
|
| 2133 | - ) { |
|
| 2134 | - $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link( |
|
| 2135 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 2136 | - array( |
|
| 2137 | - 'action' => 'resend_registration', |
|
| 2138 | - '_REG_ID' => $this->_registration->ID(), |
|
| 2139 | - 'redirect_to' => 'view_registration', |
|
| 2140 | - ), |
|
| 2141 | - REG_ADMIN_URL |
|
| 2142 | - ), |
|
| 2143 | - esc_html__(' Resend Registration', 'event_espresso'), |
|
| 2144 | - 'button secondary-button right', |
|
| 2145 | - 'dashicons dashicons-email-alt' |
|
| 2146 | - ); |
|
| 2147 | - } else { |
|
| 2148 | - $this->_template_args['resend_registration_button'] = ''; |
|
| 2149 | - } |
|
| 2150 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2151 | - $payment = $transaction->get_first_related('Payment'); |
|
| 2152 | - $payment = ! $payment instanceof EE_Payment |
|
| 2153 | - ? EE_Payment::new_instance() |
|
| 2154 | - : $payment; |
|
| 2155 | - $payment_method = $payment->get_first_related('Payment_Method'); |
|
| 2156 | - $payment_method = ! $payment_method instanceof EE_Payment_Method |
|
| 2157 | - ? EE_Payment_Method::new_instance() |
|
| 2158 | - : $payment_method; |
|
| 2159 | - $reg_details = array( |
|
| 2160 | - 'payment_method' => $payment_method->name(), |
|
| 2161 | - 'response_msg' => $payment->gateway_response(), |
|
| 2162 | - 'registration_id' => $this->_registration->get('REG_code'), |
|
| 2163 | - 'registration_session' => $this->_registration->session_ID(), |
|
| 2164 | - 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
| 2165 | - 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
| 2166 | - ); |
|
| 2167 | - if (isset($reg_details['registration_id'])) { |
|
| 2168 | - $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
| 2169 | - $this->_template_args['reg_details']['registration_id']['label'] = esc_html__( |
|
| 2170 | - 'Registration ID', |
|
| 2171 | - 'event_espresso' |
|
| 2172 | - ); |
|
| 2173 | - $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
| 2174 | - } |
|
| 2175 | - if (isset($reg_details['payment_method'])) { |
|
| 2176 | - $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
| 2177 | - $this->_template_args['reg_details']['payment_method']['label'] = esc_html__( |
|
| 2178 | - 'Most Recent Payment Method', |
|
| 2179 | - 'event_espresso' |
|
| 2180 | - ); |
|
| 2181 | - $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
| 2182 | - $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
| 2183 | - $this->_template_args['reg_details']['response_msg']['label'] = esc_html__( |
|
| 2184 | - 'Payment method response', |
|
| 2185 | - 'event_espresso' |
|
| 2186 | - ); |
|
| 2187 | - $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 2188 | - } |
|
| 2189 | - $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
| 2190 | - $this->_template_args['reg_details']['registration_session']['label'] = esc_html__( |
|
| 2191 | - 'Registration Session', |
|
| 2192 | - 'event_espresso' |
|
| 2193 | - ); |
|
| 2194 | - $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
| 2195 | - $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
| 2196 | - $this->_template_args['reg_details']['ip_address']['label'] = esc_html__( |
|
| 2197 | - 'Registration placed from IP', |
|
| 2198 | - 'event_espresso' |
|
| 2199 | - ); |
|
| 2200 | - $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
| 2201 | - $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
| 2202 | - $this->_template_args['reg_details']['user_agent']['label'] = esc_html__('Registrant User Agent', |
|
| 2203 | - 'event_espresso'); |
|
| 2204 | - $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
| 2205 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2206 | - array( |
|
| 2207 | - 'action' => 'default', |
|
| 2208 | - 'event_id' => $this->_registration->event_ID(), |
|
| 2209 | - ), |
|
| 2210 | - REG_ADMIN_URL |
|
| 2211 | - ); |
|
| 2212 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2213 | - $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
| 2214 | - $template_path = |
|
| 2215 | - REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 2216 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2217 | - } |
|
| 2218 | - |
|
| 2219 | - |
|
| 2220 | - /** |
|
| 2221 | - * generates HTML for the Registration Questions meta box. |
|
| 2222 | - * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
| 2223 | - * otherwise uses new forms system |
|
| 2224 | - * |
|
| 2225 | - * @access public |
|
| 2226 | - * @return void |
|
| 2227 | - * @throws DomainException |
|
| 2228 | - * @throws EE_Error |
|
| 2229 | - */ |
|
| 2230 | - public function _reg_questions_meta_box() |
|
| 2231 | - { |
|
| 2232 | - //allow someone to override this method entirely |
|
| 2233 | - if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
| 2234 | - $this->_registration)) { |
|
| 2235 | - $form = $this->_get_reg_custom_questions_form( |
|
| 2236 | - $this->_registration->ID() |
|
| 2237 | - ); |
|
| 2238 | - $this->_template_args['att_questions'] = count($form->subforms()) > 0 |
|
| 2239 | - ? $form->get_html_and_js() |
|
| 2240 | - : ''; |
|
| 2241 | - $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
| 2242 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2243 | - $template_path = |
|
| 2244 | - REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 2245 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2246 | - } |
|
| 2247 | - } |
|
| 2248 | - |
|
| 2249 | - |
|
| 2250 | - /** |
|
| 2251 | - * form_before_question_group |
|
| 2252 | - * |
|
| 2253 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2254 | - * @access public |
|
| 2255 | - * @param string $output |
|
| 2256 | - * @return string |
|
| 2257 | - */ |
|
| 2258 | - public function form_before_question_group($output) |
|
| 2259 | - { |
|
| 2260 | - EE_Error::doing_it_wrong( |
|
| 2261 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2262 | - esc_html__( |
|
| 2263 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2264 | - 'event_espresso' |
|
| 2265 | - ), |
|
| 2266 | - '4.8.32.rc.000' |
|
| 2267 | - ); |
|
| 2268 | - return ' |
|
| 1251 | + if (! empty($registration_status)) { |
|
| 1252 | + $where['STS_ID'] = $registration_status; |
|
| 1253 | + } else { |
|
| 1254 | + //make sure we exclude incomplete registrations, but only if not trashed. |
|
| 1255 | + if ($view === 'trash') { |
|
| 1256 | + $where['REG_deleted'] = true; |
|
| 1257 | + } elseif ($view === 'incomplete') { |
|
| 1258 | + $where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 1259 | + } else { |
|
| 1260 | + $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 1261 | + } |
|
| 1262 | + } |
|
| 1263 | + return $where; |
|
| 1264 | + } |
|
| 1265 | + |
|
| 1266 | + |
|
| 1267 | + /** |
|
| 1268 | + * Adds any provided date restraints to the where conditions for the registrations query. |
|
| 1269 | + * |
|
| 1270 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1271 | + * @return array |
|
| 1272 | + * @throws EE_Error |
|
| 1273 | + */ |
|
| 1274 | + protected function _add_date_to_where_conditions(array $request) |
|
| 1275 | + { |
|
| 1276 | + $where = array(); |
|
| 1277 | + $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1278 | + $month_range = ! empty($request['month_range']) |
|
| 1279 | + ? sanitize_text_field($request['month_range']) |
|
| 1280 | + : ''; |
|
| 1281 | + $retrieve_for_today = $view === 'today'; |
|
| 1282 | + $retrieve_for_this_month = $view === 'month'; |
|
| 1283 | + |
|
| 1284 | + if ($retrieve_for_today) { |
|
| 1285 | + $now = date('Y-m-d', current_time('timestamp')); |
|
| 1286 | + $where['REG_date'] = array( |
|
| 1287 | + 'BETWEEN', |
|
| 1288 | + array( |
|
| 1289 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1290 | + 'REG_date', |
|
| 1291 | + $now . ' 00:00:00', |
|
| 1292 | + 'Y-m-d H:i:s' |
|
| 1293 | + ), |
|
| 1294 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1295 | + 'REG_date', |
|
| 1296 | + $now . ' 23:59:59', |
|
| 1297 | + 'Y-m-d H:i:s' |
|
| 1298 | + ), |
|
| 1299 | + ), |
|
| 1300 | + ); |
|
| 1301 | + } elseif ($retrieve_for_this_month) { |
|
| 1302 | + $current_year_and_month = date('Y-m', current_time('timestamp')); |
|
| 1303 | + $days_this_month = date('t', current_time('timestamp')); |
|
| 1304 | + $where['REG_date'] = array( |
|
| 1305 | + 'BETWEEN', |
|
| 1306 | + array( |
|
| 1307 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1308 | + 'REG_date', |
|
| 1309 | + $current_year_and_month . '-01 00:00:00', |
|
| 1310 | + 'Y-m-d H:i:s' |
|
| 1311 | + ), |
|
| 1312 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1313 | + 'REG_date', |
|
| 1314 | + $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1315 | + 'Y-m-d H:i:s' |
|
| 1316 | + ), |
|
| 1317 | + ), |
|
| 1318 | + ); |
|
| 1319 | + } elseif ($month_range) { |
|
| 1320 | + $pieces = explode(' ', $month_range, 3); |
|
| 1321 | + $month_requested = ! empty($pieces[0]) |
|
| 1322 | + ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) |
|
| 1323 | + : ''; |
|
| 1324 | + $year_requested = ! empty($pieces[1]) |
|
| 1325 | + ? $pieces[1] |
|
| 1326 | + : ''; |
|
| 1327 | + //if there is not a month or year then we can't go further |
|
| 1328 | + if ($month_requested && $year_requested) { |
|
| 1329 | + $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1330 | + $where['REG_date'] = array( |
|
| 1331 | + 'BETWEEN', |
|
| 1332 | + array( |
|
| 1333 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1334 | + 'REG_date', |
|
| 1335 | + $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1336 | + 'Y-m-d H:i:s' |
|
| 1337 | + ), |
|
| 1338 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1339 | + 'REG_date', |
|
| 1340 | + $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1341 | + 'Y-m-d H:i:s' |
|
| 1342 | + ), |
|
| 1343 | + ), |
|
| 1344 | + ); |
|
| 1345 | + } |
|
| 1346 | + } |
|
| 1347 | + return $where; |
|
| 1348 | + } |
|
| 1349 | + |
|
| 1350 | + |
|
| 1351 | + /** |
|
| 1352 | + * Adds any provided search restraints to the where conditions for the registrations query |
|
| 1353 | + * |
|
| 1354 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1355 | + * @return array |
|
| 1356 | + */ |
|
| 1357 | + protected function _add_search_to_where_conditions(array $request) |
|
| 1358 | + { |
|
| 1359 | + $where = array(); |
|
| 1360 | + if (! empty($request['s'])) { |
|
| 1361 | + $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1362 | + $where['OR*search_conditions'] = array( |
|
| 1363 | + 'Event.EVT_name' => array('LIKE', $search_string), |
|
| 1364 | + 'Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1365 | + 'Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1366 | + 'Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1367 | + 'Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1368 | + 'Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1369 | + 'Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1370 | + 'Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1371 | + 'Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1372 | + 'Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1373 | + 'Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1374 | + 'REG_final_price' => array('LIKE', $search_string), |
|
| 1375 | + 'REG_code' => array('LIKE', $search_string), |
|
| 1376 | + 'REG_count' => array('LIKE', $search_string), |
|
| 1377 | + 'REG_group_size' => array('LIKE', $search_string), |
|
| 1378 | + 'Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1379 | + 'Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1380 | + 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1381 | + ); |
|
| 1382 | + } |
|
| 1383 | + return $where; |
|
| 1384 | + } |
|
| 1385 | + |
|
| 1386 | + |
|
| 1387 | + /** |
|
| 1388 | + * Sets up the where conditions for the registrations query. |
|
| 1389 | + * |
|
| 1390 | + * @param array $request |
|
| 1391 | + * @return array |
|
| 1392 | + * @throws EE_Error |
|
| 1393 | + */ |
|
| 1394 | + protected function _get_where_conditions_for_registrations_query($request) |
|
| 1395 | + { |
|
| 1396 | + return apply_filters( |
|
| 1397 | + 'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query', |
|
| 1398 | + array_merge( |
|
| 1399 | + $this->_add_event_id_to_where_conditions($request), |
|
| 1400 | + $this->_add_category_id_to_where_conditions($request), |
|
| 1401 | + $this->_add_datetime_id_to_where_conditions($request), |
|
| 1402 | + $this->_add_registration_status_to_where_conditions($request), |
|
| 1403 | + $this->_add_date_to_where_conditions($request), |
|
| 1404 | + $this->_add_search_to_where_conditions($request) |
|
| 1405 | + ), |
|
| 1406 | + $request |
|
| 1407 | + ); |
|
| 1408 | + } |
|
| 1409 | + |
|
| 1410 | + |
|
| 1411 | + /** |
|
| 1412 | + * Sets up the orderby for the registrations query. |
|
| 1413 | + * |
|
| 1414 | + * @return array |
|
| 1415 | + */ |
|
| 1416 | + protected function _get_orderby_for_registrations_query() |
|
| 1417 | + { |
|
| 1418 | + $orderby_field = ! empty($this->_req_data['orderby']) |
|
| 1419 | + ? sanitize_text_field($this->_req_data['orderby']) |
|
| 1420 | + : ''; |
|
| 1421 | + switch ($orderby_field) { |
|
| 1422 | + case '_REG_ID': |
|
| 1423 | + $orderby_field = 'REG_ID'; |
|
| 1424 | + break; |
|
| 1425 | + case '_Reg_status': |
|
| 1426 | + $orderby_field = 'STS_ID'; |
|
| 1427 | + break; |
|
| 1428 | + case 'ATT_fname': |
|
| 1429 | + $orderby_field = array('Attendee.ATT_fname', 'Attendee.ATT_lname'); |
|
| 1430 | + break; |
|
| 1431 | + case 'ATT_lname': |
|
| 1432 | + $orderby_field = array('Attendee.ATT_lname', 'Attendee.ATT_fname'); |
|
| 1433 | + break; |
|
| 1434 | + case 'event_name': |
|
| 1435 | + $orderby_field = 'Event.EVT_name'; |
|
| 1436 | + break; |
|
| 1437 | + case 'DTT_EVT_start': |
|
| 1438 | + $orderby_field = 'Event.Datetime.DTT_EVT_start'; |
|
| 1439 | + break; |
|
| 1440 | + default: //'REG_date' |
|
| 1441 | + $orderby_field = 'REG_date'; |
|
| 1442 | + } |
|
| 1443 | + |
|
| 1444 | + //order |
|
| 1445 | + $order = ! empty($this->_req_data['order']) |
|
| 1446 | + ? sanitize_text_field($this->_req_data['order']) |
|
| 1447 | + : 'DESC'; |
|
| 1448 | + |
|
| 1449 | + //mutate orderby_field |
|
| 1450 | + $orderby_field = array_combine( |
|
| 1451 | + (array) $orderby_field, |
|
| 1452 | + array_fill(0, count($orderby_field), $order) |
|
| 1453 | + ); |
|
| 1454 | + //because there are many registrations with the same date, define |
|
| 1455 | + //a secondary way to order them, otherwise MySQL seems to be a bit random |
|
| 1456 | + if (empty($order['REG_ID'])) { |
|
| 1457 | + $orderby_field['REG_ID'] = $order; |
|
| 1458 | + } |
|
| 1459 | + return array('order_by' => $orderby_field); |
|
| 1460 | + } |
|
| 1461 | + |
|
| 1462 | + |
|
| 1463 | + /** |
|
| 1464 | + * Sets up the limit for the registrations query. |
|
| 1465 | + * |
|
| 1466 | + * @param $per_page |
|
| 1467 | + * @return array |
|
| 1468 | + */ |
|
| 1469 | + protected function _get_limit($per_page) |
|
| 1470 | + { |
|
| 1471 | + $current_page = ! empty($this->_req_data['paged']) |
|
| 1472 | + ? absint($this->_req_data['paged']) |
|
| 1473 | + : 1; |
|
| 1474 | + $per_page = ! empty($this->_req_data['perpage']) |
|
| 1475 | + ? $this->_req_data['perpage'] |
|
| 1476 | + : $per_page; |
|
| 1477 | + |
|
| 1478 | + //-1 means return all results so get out if that's set. |
|
| 1479 | + if ((int)$per_page === -1) { |
|
| 1480 | + return array(); |
|
| 1481 | + } |
|
| 1482 | + $per_page = absint($per_page); |
|
| 1483 | + $offset = ($current_page - 1) * $per_page; |
|
| 1484 | + return array('limit' => array($offset, $per_page)); |
|
| 1485 | + } |
|
| 1486 | + |
|
| 1487 | + |
|
| 1488 | + public function get_registration_status_array() |
|
| 1489 | + { |
|
| 1490 | + return self::$_reg_status; |
|
| 1491 | + } |
|
| 1492 | + |
|
| 1493 | + |
|
| 1494 | + |
|
| 1495 | + |
|
| 1496 | + /*************************************** REGISTRATION DETAILS ***************************************/ |
|
| 1497 | + /** |
|
| 1498 | + * generates HTML for the View Registration Details Admin page |
|
| 1499 | + * |
|
| 1500 | + * @access protected |
|
| 1501 | + * @return void |
|
| 1502 | + * @throws DomainException |
|
| 1503 | + * @throws EE_Error |
|
| 1504 | + * @throws EntityNotFoundException |
|
| 1505 | + */ |
|
| 1506 | + protected function _registration_details() |
|
| 1507 | + { |
|
| 1508 | + $this->_template_args = array(); |
|
| 1509 | + $this->_set_registration_object(); |
|
| 1510 | + if (is_object($this->_registration)) { |
|
| 1511 | + $transaction = $this->_registration->transaction() |
|
| 1512 | + ? $this->_registration->transaction() |
|
| 1513 | + : EE_Transaction::new_instance(); |
|
| 1514 | + $this->_session = $transaction->session_data(); |
|
| 1515 | + $event_id = $this->_registration->event_ID(); |
|
| 1516 | + $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
| 1517 | + $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso'); |
|
| 1518 | + $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
| 1519 | + $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
| 1520 | + $this->_template_args['grand_total'] = $transaction->total(); |
|
| 1521 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1522 | + // link back to overview |
|
| 1523 | + $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
| 1524 | + $this->_template_args['registration'] = $this->_registration; |
|
| 1525 | + $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1526 | + array( |
|
| 1527 | + 'action' => 'default', |
|
| 1528 | + 'event_id' => $event_id, |
|
| 1529 | + ), |
|
| 1530 | + REG_ADMIN_URL |
|
| 1531 | + ); |
|
| 1532 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1533 | + array( |
|
| 1534 | + 'action' => 'default', |
|
| 1535 | + 'EVT_ID' => $event_id, |
|
| 1536 | + 'page' => 'espresso_transactions', |
|
| 1537 | + ), |
|
| 1538 | + admin_url('admin.php') |
|
| 1539 | + ); |
|
| 1540 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1541 | + array( |
|
| 1542 | + 'page' => 'espresso_events', |
|
| 1543 | + 'action' => 'edit', |
|
| 1544 | + 'post' => $event_id, |
|
| 1545 | + ), |
|
| 1546 | + admin_url('admin.php') |
|
| 1547 | + ); |
|
| 1548 | + //next and previous links |
|
| 1549 | + $next_reg = $this->_registration->next( |
|
| 1550 | + null, |
|
| 1551 | + array(), |
|
| 1552 | + 'REG_ID' |
|
| 1553 | + ); |
|
| 1554 | + $this->_template_args['next_registration'] = $next_reg |
|
| 1555 | + ? $this->_next_link( |
|
| 1556 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 1557 | + array( |
|
| 1558 | + 'action' => 'view_registration', |
|
| 1559 | + '_REG_ID' => $next_reg['REG_ID'], |
|
| 1560 | + ), |
|
| 1561 | + REG_ADMIN_URL |
|
| 1562 | + ), |
|
| 1563 | + 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
| 1564 | + ) |
|
| 1565 | + : ''; |
|
| 1566 | + $previous_reg = $this->_registration->previous( |
|
| 1567 | + null, |
|
| 1568 | + array(), |
|
| 1569 | + 'REG_ID' |
|
| 1570 | + ); |
|
| 1571 | + $this->_template_args['previous_registration'] = $previous_reg |
|
| 1572 | + ? $this->_previous_link( |
|
| 1573 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 1574 | + array( |
|
| 1575 | + 'action' => 'view_registration', |
|
| 1576 | + '_REG_ID' => $previous_reg['REG_ID'], |
|
| 1577 | + ), |
|
| 1578 | + REG_ADMIN_URL |
|
| 1579 | + ), |
|
| 1580 | + 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
| 1581 | + ) |
|
| 1582 | + : ''; |
|
| 1583 | + // grab header |
|
| 1584 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1585 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1586 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template( |
|
| 1587 | + $template_path, |
|
| 1588 | + $this->_template_args, |
|
| 1589 | + true |
|
| 1590 | + ); |
|
| 1591 | + } else { |
|
| 1592 | + $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
| 1593 | + } |
|
| 1594 | + // the details template wrapper |
|
| 1595 | + $this->display_admin_page_with_sidebar(); |
|
| 1596 | + } |
|
| 1597 | + |
|
| 1598 | + |
|
| 1599 | + protected function _registration_details_metaboxes() |
|
| 1600 | + { |
|
| 1601 | + do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
| 1602 | + $this->_set_registration_object(); |
|
| 1603 | + $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
| 1604 | + add_meta_box('edit-reg-status-mbox', esc_html__('Registration Status', 'event_espresso'), |
|
| 1605 | + array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1606 | + add_meta_box('edit-reg-details-mbox', esc_html__('Registration Details', 'event_espresso'), |
|
| 1607 | + array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1608 | + if ($attendee instanceof EE_Attendee |
|
| 1609 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 1610 | + 'ee_edit_registration', |
|
| 1611 | + 'edit-reg-questions-mbox', |
|
| 1612 | + $this->_registration->ID() |
|
| 1613 | + ) |
|
| 1614 | + ) { |
|
| 1615 | + add_meta_box( |
|
| 1616 | + 'edit-reg-questions-mbox', |
|
| 1617 | + esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 1618 | + array($this, '_reg_questions_meta_box'), |
|
| 1619 | + $this->wp_page_slug, |
|
| 1620 | + 'normal', |
|
| 1621 | + 'high' |
|
| 1622 | + ); |
|
| 1623 | + } |
|
| 1624 | + add_meta_box( |
|
| 1625 | + 'edit-reg-registrant-mbox', |
|
| 1626 | + esc_html__('Contact Details', 'event_espresso'), |
|
| 1627 | + array($this, '_reg_registrant_side_meta_box'), |
|
| 1628 | + $this->wp_page_slug, |
|
| 1629 | + 'side', |
|
| 1630 | + 'high' |
|
| 1631 | + ); |
|
| 1632 | + if ($this->_registration->group_size() > 1) { |
|
| 1633 | + add_meta_box( |
|
| 1634 | + 'edit-reg-attendees-mbox', |
|
| 1635 | + esc_html__('Other Registrations in this Transaction', 'event_espresso'), |
|
| 1636 | + array($this, '_reg_attendees_meta_box'), |
|
| 1637 | + $this->wp_page_slug, |
|
| 1638 | + 'normal', |
|
| 1639 | + 'high' |
|
| 1640 | + ); |
|
| 1641 | + } |
|
| 1642 | + } |
|
| 1643 | + |
|
| 1644 | + |
|
| 1645 | + /** |
|
| 1646 | + * set_reg_status_buttons_metabox |
|
| 1647 | + * |
|
| 1648 | + * @access protected |
|
| 1649 | + * @return string |
|
| 1650 | + * @throws \EE_Error |
|
| 1651 | + */ |
|
| 1652 | + public function set_reg_status_buttons_metabox() |
|
| 1653 | + { |
|
| 1654 | + $this->_set_registration_object(); |
|
| 1655 | + $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
| 1656 | + echo $change_reg_status_form->form_open( |
|
| 1657 | + self::add_query_args_and_nonce( |
|
| 1658 | + array( |
|
| 1659 | + 'action' => 'change_reg_status', |
|
| 1660 | + ), |
|
| 1661 | + REG_ADMIN_URL |
|
| 1662 | + ) |
|
| 1663 | + ); |
|
| 1664 | + echo $change_reg_status_form->get_html(); |
|
| 1665 | + echo $change_reg_status_form->form_close(); |
|
| 1666 | + } |
|
| 1667 | + |
|
| 1668 | + |
|
| 1669 | + |
|
| 1670 | + /** |
|
| 1671 | + * @return EE_Form_Section_Proper |
|
| 1672 | + * @throws EE_Error |
|
| 1673 | + */ |
|
| 1674 | + protected function _generate_reg_status_change_form() |
|
| 1675 | + { |
|
| 1676 | + return new EE_Form_Section_Proper(array( |
|
| 1677 | + 'name' => 'reg_status_change_form', |
|
| 1678 | + 'html_id' => 'reg-status-change-form', |
|
| 1679 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1680 | + 'subsections' => array( |
|
| 1681 | + 'return' => new EE_Hidden_Input(array( |
|
| 1682 | + 'name' => 'return', |
|
| 1683 | + 'default' => 'view_registration', |
|
| 1684 | + )), |
|
| 1685 | + 'REG_ID' => new EE_Hidden_Input(array( |
|
| 1686 | + 'name' => 'REG_ID', |
|
| 1687 | + 'default' => $this->_registration->ID(), |
|
| 1688 | + )), |
|
| 1689 | + 'current_status' => new EE_Form_Section_HTML( |
|
| 1690 | + EEH_HTML::tr( |
|
| 1691 | + EEH_HTML::th( |
|
| 1692 | + EEH_HTML::label( |
|
| 1693 | + EEH_HTML::strong(esc_html__('Current Registration Status', 'event_espresso') |
|
| 1694 | + ) |
|
| 1695 | + ) |
|
| 1696 | + ) |
|
| 1697 | + . EEH_HTML::td( |
|
| 1698 | + EEH_HTML::strong( |
|
| 1699 | + $this->_registration->pretty_status(), |
|
| 1700 | + '', |
|
| 1701 | + 'status-' . $this->_registration->status_ID(), |
|
| 1702 | + 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
| 1703 | + ) |
|
| 1704 | + ) |
|
| 1705 | + ) |
|
| 1706 | + ), |
|
| 1707 | + 'reg_status' => new EE_Select_Input( |
|
| 1708 | + $this->_get_reg_statuses(), |
|
| 1709 | + array( |
|
| 1710 | + 'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'), |
|
| 1711 | + 'default' => $this->_registration->status_ID(), |
|
| 1712 | + ) |
|
| 1713 | + ), |
|
| 1714 | + 'send_notifications' => new EE_Yes_No_Input( |
|
| 1715 | + array( |
|
| 1716 | + 'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'), |
|
| 1717 | + 'default' => false, |
|
| 1718 | + 'html_help_text' => esc_html__( |
|
| 1719 | + 'If set to "Yes", then the related messages will be sent to the registrant.', |
|
| 1720 | + 'event_espresso' |
|
| 1721 | + ), |
|
| 1722 | + ) |
|
| 1723 | + ), |
|
| 1724 | + 'submit' => new EE_Submit_Input( |
|
| 1725 | + array( |
|
| 1726 | + 'html_class' => 'button-primary', |
|
| 1727 | + 'html_label_text' => ' ', |
|
| 1728 | + 'default' => esc_html__('Update Registration Status', 'event_espresso'), |
|
| 1729 | + ) |
|
| 1730 | + ), |
|
| 1731 | + ), |
|
| 1732 | + )); |
|
| 1733 | + } |
|
| 1734 | + |
|
| 1735 | + |
|
| 1736 | + /** |
|
| 1737 | + * Returns an array of all the buttons for the various statuses and switch status actions |
|
| 1738 | + * |
|
| 1739 | + * @return array |
|
| 1740 | + * @throws EE_Error |
|
| 1741 | + * @throws EntityNotFoundException |
|
| 1742 | + */ |
|
| 1743 | + protected function _get_reg_statuses() |
|
| 1744 | + { |
|
| 1745 | + $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
| 1746 | + unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
| 1747 | + // get current reg status |
|
| 1748 | + $current_status = $this->_registration->status_ID(); |
|
| 1749 | + // is registration for free event? This will determine whether to display the pending payment option |
|
| 1750 | + if ( |
|
| 1751 | + $current_status !== EEM_Registration::status_id_pending_payment |
|
| 1752 | + && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00) |
|
| 1753 | + ) { |
|
| 1754 | + unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
| 1755 | + } |
|
| 1756 | + return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
| 1757 | + } |
|
| 1758 | + |
|
| 1759 | + |
|
| 1760 | + /** |
|
| 1761 | + * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
| 1762 | + * |
|
| 1763 | + * @param bool $status REG status given for changing registrations to. |
|
| 1764 | + * @param bool $notify Whether to send messages notifications or not. |
|
| 1765 | + * @return array (array with reg_id(s) updated and whether update was successful. |
|
| 1766 | + * @throws EE_Error |
|
| 1767 | + * @throws InvalidArgumentException |
|
| 1768 | + * @throws InvalidDataTypeException |
|
| 1769 | + * @throws InvalidInterfaceException |
|
| 1770 | + * @throws ReflectionException |
|
| 1771 | + * @throws RuntimeException |
|
| 1772 | + * @throws EntityNotFoundException |
|
| 1773 | + */ |
|
| 1774 | + protected function _set_registration_status_from_request($status = false, $notify = false) |
|
| 1775 | + { |
|
| 1776 | + if (isset($this->_req_data['reg_status_change_form'])) { |
|
| 1777 | + $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 1778 | + ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] |
|
| 1779 | + : array(); |
|
| 1780 | + } else { |
|
| 1781 | + $REG_IDs = isset($this->_req_data['_REG_ID']) |
|
| 1782 | + ? (array)$this->_req_data['_REG_ID'] |
|
| 1783 | + : array(); |
|
| 1784 | + } |
|
| 1785 | + // sanitize $REG_IDs |
|
| 1786 | + $REG_IDs = array_map('absint', $REG_IDs); |
|
| 1787 | + // and remove empty entries |
|
| 1788 | + $REG_IDs = array_filter($REG_IDs); |
|
| 1789 | + |
|
| 1790 | + $result = $this->_set_registration_status($REG_IDs, $status, $notify); |
|
| 1791 | + |
|
| 1792 | + /** |
|
| 1793 | + * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications. |
|
| 1794 | + * Currently this value is used downstream by the _process_resend_registration method. |
|
| 1795 | + * |
|
| 1796 | + * @param int|array $registration_ids The registration ids that have had their status changed successfully. |
|
| 1797 | + * @param bool $status The status registrations were changed to. |
|
| 1798 | + * @param bool $success If the status was changed successfully for all registrations. |
|
| 1799 | + * @param Registrations_Admin_Page $admin_page_object |
|
| 1800 | + */ |
|
| 1801 | + $this->_req_data['_REG_ID'] = apply_filters( |
|
| 1802 | + 'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs', |
|
| 1803 | + $result['REG_ID'], |
|
| 1804 | + $status, |
|
| 1805 | + $result['success'], |
|
| 1806 | + $this |
|
| 1807 | + ); |
|
| 1808 | + |
|
| 1809 | + //notify? |
|
| 1810 | + if ($notify |
|
| 1811 | + && $result['success'] |
|
| 1812 | + && ! empty($this->_req_data['_REG_ID']) |
|
| 1813 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 1814 | + 'ee_send_message', |
|
| 1815 | + 'espresso_registrations_resend_registration' |
|
| 1816 | + ) |
|
| 1817 | + ) { |
|
| 1818 | + $this->_process_resend_registration(); |
|
| 1819 | + } |
|
| 1820 | + return $result; |
|
| 1821 | + } |
|
| 1822 | + |
|
| 1823 | + |
|
| 1824 | + /** |
|
| 1825 | + * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
| 1826 | + * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
| 1827 | + * |
|
| 1828 | + * @param array $REG_IDs |
|
| 1829 | + * @param string $status |
|
| 1830 | + * @param bool $notify Used to indicate whether notification was requested or not. This determines the context |
|
| 1831 | + * slug sent with setting the registration status. |
|
| 1832 | + * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
| 1833 | + * @throws EE_Error |
|
| 1834 | + * @throws InvalidArgumentException |
|
| 1835 | + * @throws InvalidDataTypeException |
|
| 1836 | + * @throws InvalidInterfaceException |
|
| 1837 | + * @throws ReflectionException |
|
| 1838 | + * @throws RuntimeException |
|
| 1839 | + * @throws EntityNotFoundException |
|
| 1840 | + */ |
|
| 1841 | + protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false) |
|
| 1842 | + { |
|
| 1843 | + $success = false; |
|
| 1844 | + // typecast $REG_IDs |
|
| 1845 | + $REG_IDs = (array)$REG_IDs; |
|
| 1846 | + if ( ! empty($REG_IDs)) { |
|
| 1847 | + $success = true; |
|
| 1848 | + // set default status if none is passed |
|
| 1849 | + $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
| 1850 | + $status_context = $notify |
|
| 1851 | + ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY |
|
| 1852 | + : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN; |
|
| 1853 | + //loop through REG_ID's and change status |
|
| 1854 | + foreach ($REG_IDs as $REG_ID) { |
|
| 1855 | + $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1856 | + if ($registration instanceof EE_Registration) { |
|
| 1857 | + $registration->set_status( |
|
| 1858 | + $status, |
|
| 1859 | + false, |
|
| 1860 | + new Context( |
|
| 1861 | + $status_context, |
|
| 1862 | + esc_html__( |
|
| 1863 | + 'Manually triggered status change on a Registration Admin Page route.', |
|
| 1864 | + 'event_espresso' |
|
| 1865 | + ) |
|
| 1866 | + ) |
|
| 1867 | + ); |
|
| 1868 | + $result = $registration->save(); |
|
| 1869 | + // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
| 1870 | + $success = $result !== false ? $success : false; |
|
| 1871 | + } |
|
| 1872 | + } |
|
| 1873 | + } |
|
| 1874 | + |
|
| 1875 | + //return $success and processed registrations |
|
| 1876 | + return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
| 1877 | + } |
|
| 1878 | + |
|
| 1879 | + |
|
| 1880 | + /** |
|
| 1881 | + * Common logic for setting up success message and redirecting to appropriate route |
|
| 1882 | + * |
|
| 1883 | + * @param string $STS_ID status id for the registration changed to |
|
| 1884 | + * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
| 1885 | + * @return void |
|
| 1886 | + */ |
|
| 1887 | + protected function _reg_status_change_return($STS_ID, $notify = false) |
|
| 1888 | + { |
|
| 1889 | + $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
| 1890 | + : array('success' => false); |
|
| 1891 | + $success = isset($result['success']) && $result['success']; |
|
| 1892 | + //setup success message |
|
| 1893 | + if ($success) { |
|
| 1894 | + if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
| 1895 | + $msg = sprintf(esc_html__('Registration status has been set to %s', 'event_espresso'), |
|
| 1896 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1897 | + } else { |
|
| 1898 | + $msg = sprintf(esc_html__('Registrations have been set to %s.', 'event_espresso'), |
|
| 1899 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1900 | + } |
|
| 1901 | + EE_Error::add_success($msg); |
|
| 1902 | + } else { |
|
| 1903 | + EE_Error::add_error( |
|
| 1904 | + esc_html__( |
|
| 1905 | + 'Something went wrong, and the status was not changed', |
|
| 1906 | + 'event_espresso' |
|
| 1907 | + ), __FILE__, __LINE__, __FUNCTION__ |
|
| 1908 | + ); |
|
| 1909 | + } |
|
| 1910 | + if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
| 1911 | + $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
| 1912 | + } else { |
|
| 1913 | + $route = array('action' => 'default'); |
|
| 1914 | + } |
|
| 1915 | + //unset nonces |
|
| 1916 | + foreach ($this->_req_data as $ref => $value) { |
|
| 1917 | + if (strpos($ref, 'nonce') !== false) { |
|
| 1918 | + unset($this->_req_data[$ref]); |
|
| 1919 | + continue; |
|
| 1920 | + } |
|
| 1921 | + $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
| 1922 | + $this->_req_data[$ref] = $value; |
|
| 1923 | + } |
|
| 1924 | + //merge request vars so that the reloaded list table contains any existing filter query params |
|
| 1925 | + $route = array_merge($this->_req_data, $route); |
|
| 1926 | + $this->_redirect_after_action($success, '', '', $route, true); |
|
| 1927 | + } |
|
| 1928 | + |
|
| 1929 | + |
|
| 1930 | + /** |
|
| 1931 | + * incoming reg status change from reg details page. |
|
| 1932 | + * |
|
| 1933 | + * @return void |
|
| 1934 | + */ |
|
| 1935 | + protected function _change_reg_status() |
|
| 1936 | + { |
|
| 1937 | + $this->_req_data['return'] = 'view_registration'; |
|
| 1938 | + //set notify based on whether the send notifications toggle is set or not |
|
| 1939 | + $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
| 1940 | + //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
| 1941 | + $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
| 1942 | + ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
| 1943 | + switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
| 1944 | + case EEM_Registration::status_id_approved : |
|
| 1945 | + case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
| 1946 | + $this->approve_registration($notify); |
|
| 1947 | + break; |
|
| 1948 | + case EEM_Registration::status_id_pending_payment : |
|
| 1949 | + case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
| 1950 | + $this->pending_registration($notify); |
|
| 1951 | + break; |
|
| 1952 | + case EEM_Registration::status_id_not_approved : |
|
| 1953 | + case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
| 1954 | + $this->not_approve_registration($notify); |
|
| 1955 | + break; |
|
| 1956 | + case EEM_Registration::status_id_declined : |
|
| 1957 | + case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
| 1958 | + $this->decline_registration($notify); |
|
| 1959 | + break; |
|
| 1960 | + case EEM_Registration::status_id_cancelled : |
|
| 1961 | + case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
| 1962 | + $this->cancel_registration($notify); |
|
| 1963 | + break; |
|
| 1964 | + case EEM_Registration::status_id_wait_list : |
|
| 1965 | + case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
| 1966 | + $this->wait_list_registration($notify); |
|
| 1967 | + break; |
|
| 1968 | + case EEM_Registration::status_id_incomplete : |
|
| 1969 | + default : |
|
| 1970 | + $result['success'] = false; |
|
| 1971 | + unset($this->_req_data['return']); |
|
| 1972 | + $this->_reg_status_change_return('', false); |
|
| 1973 | + break; |
|
| 1974 | + } |
|
| 1975 | + } |
|
| 1976 | + |
|
| 1977 | + |
|
| 1978 | + /** |
|
| 1979 | + * Callback for bulk action routes. |
|
| 1980 | + * Note: although we could just register the singular route callbacks for each bulk action route as well, this |
|
| 1981 | + * method was chosen so there is one central place all the registration status bulk actions are going through. |
|
| 1982 | + * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to |
|
| 1983 | + * when an action is happening on just a single registration). |
|
| 1984 | + * @param $action |
|
| 1985 | + * @param bool $notify |
|
| 1986 | + */ |
|
| 1987 | + protected function bulk_action_on_registrations($action, $notify = false) { |
|
| 1988 | + do_action( |
|
| 1989 | + 'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution', |
|
| 1990 | + $this, |
|
| 1991 | + $action, |
|
| 1992 | + $notify |
|
| 1993 | + ); |
|
| 1994 | + $method = $action . '_registration'; |
|
| 1995 | + if (method_exists($this, $method)) { |
|
| 1996 | + $this->$method($notify); |
|
| 1997 | + } |
|
| 1998 | + } |
|
| 1999 | + |
|
| 2000 | + |
|
| 2001 | + /** |
|
| 2002 | + * approve_registration |
|
| 2003 | + * |
|
| 2004 | + * @access protected |
|
| 2005 | + * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 2006 | + * @return void |
|
| 2007 | + */ |
|
| 2008 | + protected function approve_registration($notify = false) |
|
| 2009 | + { |
|
| 2010 | + $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
| 2011 | + } |
|
| 2012 | + |
|
| 2013 | + |
|
| 2014 | + /** |
|
| 2015 | + * decline_registration |
|
| 2016 | + * |
|
| 2017 | + * @access protected |
|
| 2018 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2019 | + * @return void |
|
| 2020 | + */ |
|
| 2021 | + protected function decline_registration($notify = false) |
|
| 2022 | + { |
|
| 2023 | + $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
| 2024 | + } |
|
| 2025 | + |
|
| 2026 | + |
|
| 2027 | + /** |
|
| 2028 | + * cancel_registration |
|
| 2029 | + * |
|
| 2030 | + * @access protected |
|
| 2031 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2032 | + * @return void |
|
| 2033 | + */ |
|
| 2034 | + protected function cancel_registration($notify = false) |
|
| 2035 | + { |
|
| 2036 | + $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
| 2037 | + } |
|
| 2038 | + |
|
| 2039 | + |
|
| 2040 | + /** |
|
| 2041 | + * not_approve_registration |
|
| 2042 | + * |
|
| 2043 | + * @access protected |
|
| 2044 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2045 | + * @return void |
|
| 2046 | + */ |
|
| 2047 | + protected function not_approve_registration($notify = false) |
|
| 2048 | + { |
|
| 2049 | + $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
| 2050 | + } |
|
| 2051 | + |
|
| 2052 | + |
|
| 2053 | + /** |
|
| 2054 | + * decline_registration |
|
| 2055 | + * |
|
| 2056 | + * @access protected |
|
| 2057 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2058 | + * @return void |
|
| 2059 | + */ |
|
| 2060 | + protected function pending_registration($notify = false) |
|
| 2061 | + { |
|
| 2062 | + $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
| 2063 | + } |
|
| 2064 | + |
|
| 2065 | + |
|
| 2066 | + /** |
|
| 2067 | + * waitlist_registration |
|
| 2068 | + * |
|
| 2069 | + * @access protected |
|
| 2070 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2071 | + * @return void |
|
| 2072 | + */ |
|
| 2073 | + protected function wait_list_registration($notify = false) |
|
| 2074 | + { |
|
| 2075 | + $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
| 2076 | + } |
|
| 2077 | + |
|
| 2078 | + |
|
| 2079 | + /** |
|
| 2080 | + * generates HTML for the Registration main meta box |
|
| 2081 | + * |
|
| 2082 | + * @access public |
|
| 2083 | + * @return void |
|
| 2084 | + * @throws DomainException |
|
| 2085 | + * @throws EE_Error |
|
| 2086 | + * @throws EntityNotFoundException |
|
| 2087 | + */ |
|
| 2088 | + public function _reg_details_meta_box() |
|
| 2089 | + { |
|
| 2090 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 2091 | + EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 2092 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
| 2093 | + $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 2094 | + : EE_Transaction::new_instance(); |
|
| 2095 | + $this->_session = $transaction->session_data(); |
|
| 2096 | + $filters = new EE_Line_Item_Filter_Collection(); |
|
| 2097 | + //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 2098 | + $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
| 2099 | + $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, |
|
| 2100 | + $transaction->total_line_item()); |
|
| 2101 | + $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 2102 | + $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
| 2103 | + 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
| 2104 | + $this->_template_args['line_item_table'] = $line_item_display->display_line_item( |
|
| 2105 | + $filtered_line_item_tree, |
|
| 2106 | + array('EE_Registration' => $this->_registration) |
|
| 2107 | + ); |
|
| 2108 | + $attendee = $this->_registration->attendee(); |
|
| 2109 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 2110 | + 'ee_read_transaction', |
|
| 2111 | + 'espresso_transactions_view_transaction' |
|
| 2112 | + )) { |
|
| 2113 | + $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link( |
|
| 2114 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 2115 | + array( |
|
| 2116 | + 'action' => 'view_transaction', |
|
| 2117 | + 'TXN_ID' => $transaction->ID(), |
|
| 2118 | + ), |
|
| 2119 | + TXN_ADMIN_URL |
|
| 2120 | + ), |
|
| 2121 | + esc_html__(' View Transaction', 'event_espresso'), |
|
| 2122 | + 'button secondary-button right', |
|
| 2123 | + 'dashicons dashicons-cart' |
|
| 2124 | + ); |
|
| 2125 | + } else { |
|
| 2126 | + $this->_template_args['view_transaction_button'] = ''; |
|
| 2127 | + } |
|
| 2128 | + if ($attendee instanceof EE_Attendee |
|
| 2129 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 2130 | + 'ee_send_message', |
|
| 2131 | + 'espresso_registrations_resend_registration' |
|
| 2132 | + ) |
|
| 2133 | + ) { |
|
| 2134 | + $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link( |
|
| 2135 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 2136 | + array( |
|
| 2137 | + 'action' => 'resend_registration', |
|
| 2138 | + '_REG_ID' => $this->_registration->ID(), |
|
| 2139 | + 'redirect_to' => 'view_registration', |
|
| 2140 | + ), |
|
| 2141 | + REG_ADMIN_URL |
|
| 2142 | + ), |
|
| 2143 | + esc_html__(' Resend Registration', 'event_espresso'), |
|
| 2144 | + 'button secondary-button right', |
|
| 2145 | + 'dashicons dashicons-email-alt' |
|
| 2146 | + ); |
|
| 2147 | + } else { |
|
| 2148 | + $this->_template_args['resend_registration_button'] = ''; |
|
| 2149 | + } |
|
| 2150 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2151 | + $payment = $transaction->get_first_related('Payment'); |
|
| 2152 | + $payment = ! $payment instanceof EE_Payment |
|
| 2153 | + ? EE_Payment::new_instance() |
|
| 2154 | + : $payment; |
|
| 2155 | + $payment_method = $payment->get_first_related('Payment_Method'); |
|
| 2156 | + $payment_method = ! $payment_method instanceof EE_Payment_Method |
|
| 2157 | + ? EE_Payment_Method::new_instance() |
|
| 2158 | + : $payment_method; |
|
| 2159 | + $reg_details = array( |
|
| 2160 | + 'payment_method' => $payment_method->name(), |
|
| 2161 | + 'response_msg' => $payment->gateway_response(), |
|
| 2162 | + 'registration_id' => $this->_registration->get('REG_code'), |
|
| 2163 | + 'registration_session' => $this->_registration->session_ID(), |
|
| 2164 | + 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
| 2165 | + 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
| 2166 | + ); |
|
| 2167 | + if (isset($reg_details['registration_id'])) { |
|
| 2168 | + $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
| 2169 | + $this->_template_args['reg_details']['registration_id']['label'] = esc_html__( |
|
| 2170 | + 'Registration ID', |
|
| 2171 | + 'event_espresso' |
|
| 2172 | + ); |
|
| 2173 | + $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
| 2174 | + } |
|
| 2175 | + if (isset($reg_details['payment_method'])) { |
|
| 2176 | + $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
| 2177 | + $this->_template_args['reg_details']['payment_method']['label'] = esc_html__( |
|
| 2178 | + 'Most Recent Payment Method', |
|
| 2179 | + 'event_espresso' |
|
| 2180 | + ); |
|
| 2181 | + $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
| 2182 | + $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
| 2183 | + $this->_template_args['reg_details']['response_msg']['label'] = esc_html__( |
|
| 2184 | + 'Payment method response', |
|
| 2185 | + 'event_espresso' |
|
| 2186 | + ); |
|
| 2187 | + $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 2188 | + } |
|
| 2189 | + $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
| 2190 | + $this->_template_args['reg_details']['registration_session']['label'] = esc_html__( |
|
| 2191 | + 'Registration Session', |
|
| 2192 | + 'event_espresso' |
|
| 2193 | + ); |
|
| 2194 | + $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
| 2195 | + $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
| 2196 | + $this->_template_args['reg_details']['ip_address']['label'] = esc_html__( |
|
| 2197 | + 'Registration placed from IP', |
|
| 2198 | + 'event_espresso' |
|
| 2199 | + ); |
|
| 2200 | + $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
| 2201 | + $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
| 2202 | + $this->_template_args['reg_details']['user_agent']['label'] = esc_html__('Registrant User Agent', |
|
| 2203 | + 'event_espresso'); |
|
| 2204 | + $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
| 2205 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2206 | + array( |
|
| 2207 | + 'action' => 'default', |
|
| 2208 | + 'event_id' => $this->_registration->event_ID(), |
|
| 2209 | + ), |
|
| 2210 | + REG_ADMIN_URL |
|
| 2211 | + ); |
|
| 2212 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2213 | + $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
| 2214 | + $template_path = |
|
| 2215 | + REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 2216 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2217 | + } |
|
| 2218 | + |
|
| 2219 | + |
|
| 2220 | + /** |
|
| 2221 | + * generates HTML for the Registration Questions meta box. |
|
| 2222 | + * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
| 2223 | + * otherwise uses new forms system |
|
| 2224 | + * |
|
| 2225 | + * @access public |
|
| 2226 | + * @return void |
|
| 2227 | + * @throws DomainException |
|
| 2228 | + * @throws EE_Error |
|
| 2229 | + */ |
|
| 2230 | + public function _reg_questions_meta_box() |
|
| 2231 | + { |
|
| 2232 | + //allow someone to override this method entirely |
|
| 2233 | + if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
| 2234 | + $this->_registration)) { |
|
| 2235 | + $form = $this->_get_reg_custom_questions_form( |
|
| 2236 | + $this->_registration->ID() |
|
| 2237 | + ); |
|
| 2238 | + $this->_template_args['att_questions'] = count($form->subforms()) > 0 |
|
| 2239 | + ? $form->get_html_and_js() |
|
| 2240 | + : ''; |
|
| 2241 | + $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
| 2242 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2243 | + $template_path = |
|
| 2244 | + REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 2245 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2246 | + } |
|
| 2247 | + } |
|
| 2248 | + |
|
| 2249 | + |
|
| 2250 | + /** |
|
| 2251 | + * form_before_question_group |
|
| 2252 | + * |
|
| 2253 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2254 | + * @access public |
|
| 2255 | + * @param string $output |
|
| 2256 | + * @return string |
|
| 2257 | + */ |
|
| 2258 | + public function form_before_question_group($output) |
|
| 2259 | + { |
|
| 2260 | + EE_Error::doing_it_wrong( |
|
| 2261 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2262 | + esc_html__( |
|
| 2263 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2264 | + 'event_espresso' |
|
| 2265 | + ), |
|
| 2266 | + '4.8.32.rc.000' |
|
| 2267 | + ); |
|
| 2268 | + return ' |
|
| 2269 | 2269 | <table class="form-table ee-width-100"> |
| 2270 | 2270 | <tbody> |
| 2271 | 2271 | '; |
| 2272 | - } |
|
| 2273 | - |
|
| 2274 | - |
|
| 2275 | - /** |
|
| 2276 | - * form_after_question_group |
|
| 2277 | - * |
|
| 2278 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2279 | - * @access public |
|
| 2280 | - * @param string $output |
|
| 2281 | - * @return string |
|
| 2282 | - */ |
|
| 2283 | - public function form_after_question_group($output) |
|
| 2284 | - { |
|
| 2285 | - EE_Error::doing_it_wrong( |
|
| 2286 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2287 | - esc_html__( |
|
| 2288 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2289 | - 'event_espresso' |
|
| 2290 | - ), |
|
| 2291 | - '4.8.32.rc.000' |
|
| 2292 | - ); |
|
| 2293 | - return ' |
|
| 2272 | + } |
|
| 2273 | + |
|
| 2274 | + |
|
| 2275 | + /** |
|
| 2276 | + * form_after_question_group |
|
| 2277 | + * |
|
| 2278 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2279 | + * @access public |
|
| 2280 | + * @param string $output |
|
| 2281 | + * @return string |
|
| 2282 | + */ |
|
| 2283 | + public function form_after_question_group($output) |
|
| 2284 | + { |
|
| 2285 | + EE_Error::doing_it_wrong( |
|
| 2286 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2287 | + esc_html__( |
|
| 2288 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2289 | + 'event_espresso' |
|
| 2290 | + ), |
|
| 2291 | + '4.8.32.rc.000' |
|
| 2292 | + ); |
|
| 2293 | + return ' |
|
| 2294 | 2294 | <tr class="hide-if-no-js"> |
| 2295 | 2295 | <th> </th> |
| 2296 | 2296 | <td class="reg-admin-edit-attendee-question-td"> |
| 2297 | 2297 | <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' |
| 2298 | - . esc_attr__('click to edit question', 'event_espresso') |
|
| 2299 | - . '"> |
|
| 2298 | + . esc_attr__('click to edit question', 'event_espresso') |
|
| 2299 | + . '"> |
|
| 2300 | 2300 | <span class="reg-admin-edit-question-group-spn lt-grey-txt">' |
| 2301 | - . esc_html__('edit the above question group', 'event_espresso') |
|
| 2302 | - . '</span> |
|
| 2301 | + . esc_html__('edit the above question group', 'event_espresso') |
|
| 2302 | + . '</span> |
|
| 2303 | 2303 | <div class="dashicons dashicons-edit"></div> |
| 2304 | 2304 | </a> |
| 2305 | 2305 | </td> |
@@ -2307,558 +2307,558 @@ discard block |
||
| 2307 | 2307 | </tbody> |
| 2308 | 2308 | </table> |
| 2309 | 2309 | '; |
| 2310 | - } |
|
| 2311 | - |
|
| 2312 | - |
|
| 2313 | - /** |
|
| 2314 | - * form_form_field_label_wrap |
|
| 2315 | - * |
|
| 2316 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2317 | - * @access public |
|
| 2318 | - * @param string $label |
|
| 2319 | - * @return string |
|
| 2320 | - */ |
|
| 2321 | - public function form_form_field_label_wrap($label) |
|
| 2322 | - { |
|
| 2323 | - EE_Error::doing_it_wrong( |
|
| 2324 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2325 | - esc_html__( |
|
| 2326 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2327 | - 'event_espresso' |
|
| 2328 | - ), |
|
| 2329 | - '4.8.32.rc.000' |
|
| 2330 | - ); |
|
| 2331 | - return ' |
|
| 2310 | + } |
|
| 2311 | + |
|
| 2312 | + |
|
| 2313 | + /** |
|
| 2314 | + * form_form_field_label_wrap |
|
| 2315 | + * |
|
| 2316 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2317 | + * @access public |
|
| 2318 | + * @param string $label |
|
| 2319 | + * @return string |
|
| 2320 | + */ |
|
| 2321 | + public function form_form_field_label_wrap($label) |
|
| 2322 | + { |
|
| 2323 | + EE_Error::doing_it_wrong( |
|
| 2324 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2325 | + esc_html__( |
|
| 2326 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2327 | + 'event_espresso' |
|
| 2328 | + ), |
|
| 2329 | + '4.8.32.rc.000' |
|
| 2330 | + ); |
|
| 2331 | + return ' |
|
| 2332 | 2332 | <tr> |
| 2333 | 2333 | <th> |
| 2334 | 2334 | ' . $label . ' |
| 2335 | 2335 | </th>'; |
| 2336 | - } |
|
| 2337 | - |
|
| 2338 | - |
|
| 2339 | - /** |
|
| 2340 | - * form_form_field_input__wrap |
|
| 2341 | - * |
|
| 2342 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2343 | - * @access public |
|
| 2344 | - * @param string $input |
|
| 2345 | - * @return string |
|
| 2346 | - */ |
|
| 2347 | - public function form_form_field_input__wrap($input) |
|
| 2348 | - { |
|
| 2349 | - EE_Error::doing_it_wrong( |
|
| 2350 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2351 | - esc_html__( |
|
| 2352 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2353 | - 'event_espresso' |
|
| 2354 | - ), |
|
| 2355 | - '4.8.32.rc.000' |
|
| 2356 | - ); |
|
| 2357 | - return ' |
|
| 2336 | + } |
|
| 2337 | + |
|
| 2338 | + |
|
| 2339 | + /** |
|
| 2340 | + * form_form_field_input__wrap |
|
| 2341 | + * |
|
| 2342 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2343 | + * @access public |
|
| 2344 | + * @param string $input |
|
| 2345 | + * @return string |
|
| 2346 | + */ |
|
| 2347 | + public function form_form_field_input__wrap($input) |
|
| 2348 | + { |
|
| 2349 | + EE_Error::doing_it_wrong( |
|
| 2350 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2351 | + esc_html__( |
|
| 2352 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2353 | + 'event_espresso' |
|
| 2354 | + ), |
|
| 2355 | + '4.8.32.rc.000' |
|
| 2356 | + ); |
|
| 2357 | + return ' |
|
| 2358 | 2358 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
| 2359 | 2359 | ' . $input . ' |
| 2360 | 2360 | </td> |
| 2361 | 2361 | </tr>'; |
| 2362 | - } |
|
| 2363 | - |
|
| 2364 | - |
|
| 2365 | - /** |
|
| 2366 | - * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
| 2367 | - * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
| 2368 | - * to display the page |
|
| 2369 | - * |
|
| 2370 | - * @access protected |
|
| 2371 | - * @return void |
|
| 2372 | - * @throws EE_Error |
|
| 2373 | - */ |
|
| 2374 | - protected function _update_attendee_registration_form() |
|
| 2375 | - { |
|
| 2376 | - do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
| 2377 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 2378 | - $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 2379 | - $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
| 2380 | - if ($success) { |
|
| 2381 | - $what = esc_html__('Registration Form', 'event_espresso'); |
|
| 2382 | - $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
| 2383 | - : array('action' => 'default'); |
|
| 2384 | - $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route); |
|
| 2385 | - } |
|
| 2386 | - } |
|
| 2387 | - } |
|
| 2388 | - |
|
| 2389 | - |
|
| 2390 | - /** |
|
| 2391 | - * Gets the form for saving registrations custom questions (if done |
|
| 2392 | - * previously retrieves the cached form object, which may have validation errors in it) |
|
| 2393 | - * |
|
| 2394 | - * @param int $REG_ID |
|
| 2395 | - * @return EE_Registration_Custom_Questions_Form |
|
| 2396 | - * @throws EE_Error |
|
| 2397 | - */ |
|
| 2398 | - protected function _get_reg_custom_questions_form($REG_ID) |
|
| 2399 | - { |
|
| 2400 | - if ( ! $this->_reg_custom_questions_form) { |
|
| 2401 | - require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 2402 | - $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( |
|
| 2403 | - EEM_Registration::instance()->get_one_by_ID($REG_ID) |
|
| 2404 | - ); |
|
| 2405 | - $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
| 2406 | - } |
|
| 2407 | - return $this->_reg_custom_questions_form; |
|
| 2408 | - } |
|
| 2409 | - |
|
| 2410 | - |
|
| 2411 | - /** |
|
| 2412 | - * Saves |
|
| 2413 | - * |
|
| 2414 | - * @access private |
|
| 2415 | - * @param bool $REG_ID |
|
| 2416 | - * @return bool |
|
| 2417 | - * @throws EE_Error |
|
| 2418 | - */ |
|
| 2419 | - private function _save_reg_custom_questions_form($REG_ID = false) |
|
| 2420 | - { |
|
| 2421 | - if ( ! $REG_ID) { |
|
| 2422 | - EE_Error::add_error( |
|
| 2423 | - esc_html__( |
|
| 2424 | - 'An error occurred. No registration ID was received.', 'event_espresso'), |
|
| 2425 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2426 | - ); |
|
| 2427 | - } |
|
| 2428 | - $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
| 2429 | - $form->receive_form_submission($this->_req_data); |
|
| 2430 | - $success = false; |
|
| 2431 | - if ($form->is_valid()) { |
|
| 2432 | - foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
| 2433 | - foreach ($question_group_form->inputs() as $question_id => $input) { |
|
| 2434 | - $where_conditions = array( |
|
| 2435 | - 'QST_ID' => $question_id, |
|
| 2436 | - 'REG_ID' => $REG_ID, |
|
| 2437 | - ); |
|
| 2438 | - $possibly_new_values = array( |
|
| 2439 | - 'ANS_value' => $input->normalized_value(), |
|
| 2440 | - ); |
|
| 2441 | - $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
| 2442 | - if ($answer instanceof EE_Answer) { |
|
| 2443 | - $success = $answer->save($possibly_new_values); |
|
| 2444 | - } else { |
|
| 2445 | - //insert it then |
|
| 2446 | - $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
| 2447 | - $answer = EE_Answer::new_instance($cols_n_vals); |
|
| 2448 | - $success = $answer->save(); |
|
| 2449 | - } |
|
| 2450 | - } |
|
| 2451 | - } |
|
| 2452 | - } else { |
|
| 2453 | - EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
| 2454 | - } |
|
| 2455 | - return $success; |
|
| 2456 | - } |
|
| 2457 | - |
|
| 2458 | - |
|
| 2459 | - /** |
|
| 2460 | - * generates HTML for the Registration main meta box |
|
| 2461 | - * |
|
| 2462 | - * @access public |
|
| 2463 | - * @return void |
|
| 2464 | - * @throws DomainException |
|
| 2465 | - * @throws EE_Error |
|
| 2466 | - */ |
|
| 2467 | - public function _reg_attendees_meta_box() |
|
| 2468 | - { |
|
| 2469 | - $REG = EEM_Registration::instance(); |
|
| 2470 | - //get all other registrations on this transaction, and cache |
|
| 2471 | - //the attendees for them so we don't have to run another query using force_join |
|
| 2472 | - $registrations = $REG->get_all(array( |
|
| 2473 | - array( |
|
| 2474 | - 'TXN_ID' => $this->_registration->transaction_ID(), |
|
| 2475 | - 'REG_ID' => array('!=', $this->_registration->ID()), |
|
| 2476 | - ), |
|
| 2477 | - 'force_join' => array('Attendee'), |
|
| 2478 | - )); |
|
| 2479 | - $this->_template_args['attendees'] = array(); |
|
| 2480 | - $this->_template_args['attendee_notice'] = ''; |
|
| 2481 | - if (empty($registrations) |
|
| 2482 | - || (is_array($registrations) |
|
| 2483 | - && ! EEH_Array::get_one_item_from_array($registrations)) |
|
| 2484 | - ) { |
|
| 2485 | - EE_Error::add_error( |
|
| 2486 | - esc_html__( |
|
| 2487 | - 'There are no records attached to this registration. Something may have gone wrong with the registration', |
|
| 2488 | - 'event_espresso' |
|
| 2489 | - ), __FILE__, __FUNCTION__, __LINE__ |
|
| 2490 | - ); |
|
| 2491 | - $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
| 2492 | - } else { |
|
| 2493 | - $att_nmbr = 1; |
|
| 2494 | - foreach ($registrations as $registration) { |
|
| 2495 | - /* @var $registration EE_Registration */ |
|
| 2496 | - $attendee = $registration->attendee() |
|
| 2497 | - ? $registration->attendee() |
|
| 2498 | - : EEM_Attendee::instance() |
|
| 2499 | - ->create_default_object(); |
|
| 2500 | - $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
| 2501 | - $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); |
|
| 2502 | - $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); |
|
| 2503 | - $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); |
|
| 2504 | - $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); |
|
| 2505 | - $this->_template_args['attendees'][$att_nmbr]['address'] = implode( |
|
| 2506 | - ', ', |
|
| 2507 | - $attendee->full_address_as_array() |
|
| 2508 | - ); |
|
| 2509 | - $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce( |
|
| 2510 | - array( |
|
| 2511 | - 'action' => 'edit_attendee', |
|
| 2512 | - 'post' => $attendee->ID(), |
|
| 2513 | - ), |
|
| 2514 | - REG_ADMIN_URL |
|
| 2515 | - ); |
|
| 2516 | - $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2517 | - $att_nmbr++; |
|
| 2518 | - } |
|
| 2519 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2520 | - } |
|
| 2521 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2522 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2523 | - } |
|
| 2524 | - |
|
| 2525 | - |
|
| 2526 | - /** |
|
| 2527 | - * generates HTML for the Edit Registration side meta box |
|
| 2528 | - * |
|
| 2529 | - * @access public |
|
| 2530 | - * @return void |
|
| 2531 | - * @throws DomainException |
|
| 2532 | - * @throws EE_Error |
|
| 2533 | - */ |
|
| 2534 | - public function _reg_registrant_side_meta_box() |
|
| 2535 | - { |
|
| 2536 | - /*@var $attendee EE_Attendee */ |
|
| 2537 | - $att_check = $this->_registration->attendee(); |
|
| 2538 | - $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
| 2539 | - //now let's determine if this is not the primary registration. If it isn't then we set the |
|
| 2540 | - //primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the |
|
| 2541 | - //primary registration object (that way we know if we need to show create button or not) |
|
| 2542 | - if ( ! $this->_registration->is_primary_registrant()) { |
|
| 2543 | - $primary_registration = $this->_registration->get_primary_registration(); |
|
| 2544 | - $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
| 2545 | - : null; |
|
| 2546 | - if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
| 2547 | - //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own |
|
| 2548 | - //custom attendee object so let's not worry about the primary reg. |
|
| 2549 | - $primary_registration = null; |
|
| 2550 | - } |
|
| 2551 | - } else { |
|
| 2552 | - $primary_registration = null; |
|
| 2553 | - } |
|
| 2554 | - $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
| 2555 | - $this->_template_args['fname'] = $attendee->fname(); |
|
| 2556 | - $this->_template_args['lname'] = $attendee->lname(); |
|
| 2557 | - $this->_template_args['email'] = $attendee->email(); |
|
| 2558 | - $this->_template_args['phone'] = $attendee->phone(); |
|
| 2559 | - $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
| 2560 | - //edit link |
|
| 2561 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2562 | - 'action' => 'edit_attendee', |
|
| 2563 | - 'post' => $attendee->ID(), |
|
| 2564 | - ), REG_ADMIN_URL); |
|
| 2565 | - $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso'); |
|
| 2566 | - //create link |
|
| 2567 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2568 | - ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2569 | - 'action' => 'duplicate_attendee', |
|
| 2570 | - '_REG_ID' => $this->_registration->ID(), |
|
| 2571 | - ), REG_ADMIN_URL) : ''; |
|
| 2572 | - $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso'); |
|
| 2573 | - $this->_template_args['att_check'] = $att_check; |
|
| 2574 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2575 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2576 | - } |
|
| 2577 | - |
|
| 2578 | - |
|
| 2579 | - /** |
|
| 2580 | - * trash or restore registrations |
|
| 2581 | - * |
|
| 2582 | - * @param boolean $trash whether to archive or restore |
|
| 2583 | - * @return void |
|
| 2584 | - * @throws EE_Error |
|
| 2585 | - * @throws RuntimeException |
|
| 2586 | - * @access protected |
|
| 2587 | - */ |
|
| 2588 | - protected function _trash_or_restore_registrations($trash = true) |
|
| 2589 | - { |
|
| 2590 | - //if empty _REG_ID then get out because there's nothing to do |
|
| 2591 | - if (empty($this->_req_data['_REG_ID'])) { |
|
| 2592 | - EE_Error::add_error( |
|
| 2593 | - sprintf( |
|
| 2594 | - esc_html__( |
|
| 2595 | - 'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.', |
|
| 2596 | - 'event_espresso' |
|
| 2597 | - ), |
|
| 2598 | - $trash ? 'trash' : 'restore' |
|
| 2599 | - ), |
|
| 2600 | - __FILE__, __LINE__, __FUNCTION__ |
|
| 2601 | - ); |
|
| 2602 | - $this->_redirect_after_action(false, '', '', array(), true); |
|
| 2603 | - } |
|
| 2604 | - $success = 0; |
|
| 2605 | - $overwrite_msgs = false; |
|
| 2606 | - //Checkboxes |
|
| 2607 | - if ( ! is_array($this->_req_data['_REG_ID'])) { |
|
| 2608 | - $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']); |
|
| 2609 | - } |
|
| 2610 | - $reg_count = count($this->_req_data['_REG_ID']); |
|
| 2611 | - // cycle thru checkboxes |
|
| 2612 | - foreach ($this->_req_data['_REG_ID'] as $REG_ID) { |
|
| 2613 | - /** @var EE_Registration $REG */ |
|
| 2614 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 2615 | - $payments = $REG->registration_payments(); |
|
| 2616 | - if (! empty($payments)) { |
|
| 2617 | - $name = $REG->attendee() instanceof EE_Attendee |
|
| 2618 | - ? $REG->attendee()->full_name() |
|
| 2619 | - : esc_html__('Unknown Attendee', 'event_espresso'); |
|
| 2620 | - $overwrite_msgs = true; |
|
| 2621 | - EE_Error::add_error( |
|
| 2622 | - sprintf( |
|
| 2623 | - esc_html__( |
|
| 2624 | - 'The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', |
|
| 2625 | - 'event_espresso' |
|
| 2626 | - ), |
|
| 2627 | - $name |
|
| 2628 | - ), |
|
| 2629 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2630 | - ); |
|
| 2631 | - //can't trash this registration because it has payments. |
|
| 2632 | - continue; |
|
| 2633 | - } |
|
| 2634 | - $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2635 | - if ($updated) { |
|
| 2636 | - $success++; |
|
| 2637 | - } |
|
| 2638 | - } |
|
| 2639 | - $this->_redirect_after_action( |
|
| 2640 | - $success === $reg_count, // were ALL registrations affected? |
|
| 2641 | - $success > 1 |
|
| 2642 | - ? esc_html__('Registrations', 'event_espresso') |
|
| 2643 | - : esc_html__('Registration', 'event_espresso'), |
|
| 2644 | - $trash |
|
| 2645 | - ? esc_html__('moved to the trash', 'event_espresso') |
|
| 2646 | - : esc_html__('restored', 'event_espresso'), |
|
| 2647 | - array('action' => 'default'), |
|
| 2648 | - $overwrite_msgs |
|
| 2649 | - ); |
|
| 2650 | - } |
|
| 2651 | - |
|
| 2652 | - |
|
| 2653 | - /** |
|
| 2654 | - * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
| 2655 | - * registration but also. |
|
| 2656 | - * 1. Removing relations to EE_Attendee |
|
| 2657 | - * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
| 2658 | - * ALSO trashed. |
|
| 2659 | - * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
| 2660 | - * 4. Removing relationships between all tickets and the related registrations |
|
| 2661 | - * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
| 2662 | - * 6. Deleting permanently any related Checkins. |
|
| 2663 | - * |
|
| 2664 | - * @return void |
|
| 2665 | - * @throws EE_Error |
|
| 2666 | - */ |
|
| 2667 | - protected function _delete_registrations() |
|
| 2668 | - { |
|
| 2669 | - $REG_MDL = EEM_Registration::instance(); |
|
| 2670 | - $success = 1; |
|
| 2671 | - //Checkboxes |
|
| 2672 | - if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2673 | - // if array has more than one element than success message should be plural |
|
| 2674 | - $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2675 | - // cycle thru checkboxes |
|
| 2676 | - while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2677 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2678 | - if ( ! $REG instanceof EE_Registration) { |
|
| 2679 | - continue; |
|
| 2680 | - } |
|
| 2681 | - $deleted = $this->_delete_registration($REG); |
|
| 2682 | - if ( ! $deleted) { |
|
| 2683 | - $success = 0; |
|
| 2684 | - } |
|
| 2685 | - } |
|
| 2686 | - } else { |
|
| 2687 | - // grab single id and delete |
|
| 2688 | - $REG_ID = $this->_req_data['_REG_ID']; |
|
| 2689 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2690 | - $deleted = $this->_delete_registration($REG); |
|
| 2691 | - if ( ! $deleted) { |
|
| 2692 | - $success = 0; |
|
| 2693 | - } |
|
| 2694 | - } |
|
| 2695 | - $what = $success > 1 |
|
| 2696 | - ? esc_html__('Registrations', 'event_espresso') |
|
| 2697 | - : esc_html__('Registration', 'event_espresso'); |
|
| 2698 | - $action_desc = esc_html__('permanently deleted.', 'event_espresso'); |
|
| 2699 | - $this->_redirect_after_action( |
|
| 2700 | - $success, |
|
| 2701 | - $what, |
|
| 2702 | - $action_desc, |
|
| 2703 | - array('action' => 'default'), |
|
| 2704 | - true |
|
| 2705 | - ); |
|
| 2706 | - } |
|
| 2707 | - |
|
| 2708 | - |
|
| 2709 | - /** |
|
| 2710 | - * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
| 2711 | - * models get affected. |
|
| 2712 | - * |
|
| 2713 | - * @param EE_Registration $REG registration to be deleted permenantly |
|
| 2714 | - * @return bool true = successful deletion, false = fail. |
|
| 2715 | - * @throws EE_Error |
|
| 2716 | - */ |
|
| 2717 | - protected function _delete_registration(EE_Registration $REG) |
|
| 2718 | - { |
|
| 2719 | - //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related |
|
| 2720 | - //registrations on the transaction that are NOT trashed. |
|
| 2721 | - $TXN = $REG->get_first_related('Transaction'); |
|
| 2722 | - $REGS = $TXN->get_many_related('Registration'); |
|
| 2723 | - $all_trashed = true; |
|
| 2724 | - foreach ($REGS as $registration) { |
|
| 2725 | - if ( ! $registration->get('REG_deleted')) { |
|
| 2726 | - $all_trashed = false; |
|
| 2727 | - } |
|
| 2728 | - } |
|
| 2729 | - if ( ! $all_trashed) { |
|
| 2730 | - EE_Error::add_error( |
|
| 2731 | - esc_html__( |
|
| 2732 | - 'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', |
|
| 2733 | - 'event_espresso' |
|
| 2734 | - ), |
|
| 2735 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2736 | - ); |
|
| 2737 | - return false; |
|
| 2738 | - } |
|
| 2739 | - //k made it here so that means we can delete all the related transactions and their answers (but let's do them |
|
| 2740 | - //separately from THIS one). |
|
| 2741 | - foreach ($REGS as $registration) { |
|
| 2742 | - //delete related answers |
|
| 2743 | - $registration->delete_related_permanently('Answer'); |
|
| 2744 | - //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
| 2745 | - $attendee = $registration->get_first_related('Attendee'); |
|
| 2746 | - if ($attendee instanceof EE_Attendee) { |
|
| 2747 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2748 | - } |
|
| 2749 | - //now remove relationships to tickets on this registration. |
|
| 2750 | - $registration->_remove_relations('Ticket'); |
|
| 2751 | - //now delete permanently the checkins related to this registration. |
|
| 2752 | - $registration->delete_related_permanently('Checkin'); |
|
| 2753 | - if ($registration->ID() === $REG->ID()) { |
|
| 2754 | - continue; |
|
| 2755 | - } //we don't want to delete permanently the existing registration just yet. |
|
| 2756 | - //remove relation to transaction for these registrations if NOT the existing registrations |
|
| 2757 | - $registration->_remove_relations('Transaction'); |
|
| 2758 | - //delete permanently any related messages. |
|
| 2759 | - $registration->delete_related_permanently('Message'); |
|
| 2760 | - //now delete this registration permanently |
|
| 2761 | - $registration->delete_permanently(); |
|
| 2762 | - } |
|
| 2763 | - //now all related registrations on the transaction are handled. So let's just handle this registration itself |
|
| 2764 | - // (the transaction and line items should be all that's left). |
|
| 2765 | - // delete the line items related to the transaction for this registration. |
|
| 2766 | - $TXN->delete_related_permanently('Line_Item'); |
|
| 2767 | - //we need to remove all the relationships on the transaction |
|
| 2768 | - $TXN->delete_related_permanently('Payment'); |
|
| 2769 | - $TXN->delete_related_permanently('Extra_Meta'); |
|
| 2770 | - $TXN->delete_related_permanently('Message'); |
|
| 2771 | - //now we can delete this REG permanently (and the transaction of course) |
|
| 2772 | - $REG->delete_related_permanently('Transaction'); |
|
| 2773 | - return $REG->delete_permanently(); |
|
| 2774 | - } |
|
| 2775 | - |
|
| 2776 | - |
|
| 2777 | - /** |
|
| 2778 | - * generates HTML for the Register New Attendee Admin page |
|
| 2779 | - * |
|
| 2780 | - * @access private |
|
| 2781 | - * @throws DomainException |
|
| 2782 | - * @throws EE_Error |
|
| 2783 | - */ |
|
| 2784 | - public function new_registration() |
|
| 2785 | - { |
|
| 2786 | - if ( ! $this->_set_reg_event()) { |
|
| 2787 | - throw new EE_Error( |
|
| 2788 | - esc_html__( |
|
| 2789 | - 'Unable to continue with registering because there is no Event ID in the request', |
|
| 2790 | - 'event_espresso' |
|
| 2791 | - ) |
|
| 2792 | - ); |
|
| 2793 | - } |
|
| 2794 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2795 | - // gotta start with a clean slate if we're not coming here via ajax |
|
| 2796 | - if ( ! defined('DOING_AJAX') |
|
| 2797 | - && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
| 2798 | - ) { |
|
| 2799 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2800 | - } |
|
| 2801 | - $this->_template_args['event_name'] = ''; |
|
| 2802 | - // event name |
|
| 2803 | - if ($this->_reg_event) { |
|
| 2804 | - $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
| 2805 | - $edit_event_url = self::add_query_args_and_nonce(array( |
|
| 2806 | - 'action' => 'edit', |
|
| 2807 | - 'post' => $this->_reg_event->ID(), |
|
| 2808 | - ), EVENTS_ADMIN_URL); |
|
| 2809 | - $edit_event_lnk = '<a href="' |
|
| 2810 | - . $edit_event_url |
|
| 2811 | - . '" title="' |
|
| 2812 | - . esc_attr__('Edit ', 'event_espresso') |
|
| 2813 | - . $this->_reg_event->name() |
|
| 2814 | - . '">' |
|
| 2815 | - . esc_html__('Edit Event', 'event_espresso') |
|
| 2816 | - . '</a>'; |
|
| 2817 | - $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
| 2818 | - . $edit_event_lnk |
|
| 2819 | - . '</span>'; |
|
| 2820 | - } |
|
| 2821 | - $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
| 2822 | - if (defined('DOING_AJAX')) { |
|
| 2823 | - $this->_return_json(); |
|
| 2824 | - } |
|
| 2825 | - // grab header |
|
| 2826 | - $template_path = |
|
| 2827 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2828 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
| 2829 | - $this->_template_args, true); |
|
| 2830 | - //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 2831 | - // the details template wrapper |
|
| 2832 | - $this->display_admin_page_with_sidebar(); |
|
| 2833 | - } |
|
| 2834 | - |
|
| 2835 | - |
|
| 2836 | - /** |
|
| 2837 | - * This returns the content for a registration step |
|
| 2838 | - * |
|
| 2839 | - * @access protected |
|
| 2840 | - * @return string html |
|
| 2841 | - * @throws DomainException |
|
| 2842 | - * @throws EE_Error |
|
| 2843 | - */ |
|
| 2844 | - protected function _get_registration_step_content() |
|
| 2845 | - { |
|
| 2846 | - if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
| 2847 | - $warning_msg = sprintf( |
|
| 2848 | - esc_html__( |
|
| 2849 | - '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
|
| 2850 | - 'event_espresso' |
|
| 2851 | - ), |
|
| 2852 | - '<br />', |
|
| 2853 | - '<h3 class="important-notice">', |
|
| 2854 | - '</h3>', |
|
| 2855 | - '<div class="float-right">', |
|
| 2856 | - '<span id="redirect_timer" class="important-notice">30</span>', |
|
| 2857 | - '</div>', |
|
| 2858 | - '<b>', |
|
| 2859 | - '</b>' |
|
| 2860 | - ); |
|
| 2861 | - return ' |
|
| 2362 | + } |
|
| 2363 | + |
|
| 2364 | + |
|
| 2365 | + /** |
|
| 2366 | + * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
| 2367 | + * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
| 2368 | + * to display the page |
|
| 2369 | + * |
|
| 2370 | + * @access protected |
|
| 2371 | + * @return void |
|
| 2372 | + * @throws EE_Error |
|
| 2373 | + */ |
|
| 2374 | + protected function _update_attendee_registration_form() |
|
| 2375 | + { |
|
| 2376 | + do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
| 2377 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 2378 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 2379 | + $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
| 2380 | + if ($success) { |
|
| 2381 | + $what = esc_html__('Registration Form', 'event_espresso'); |
|
| 2382 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
| 2383 | + : array('action' => 'default'); |
|
| 2384 | + $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route); |
|
| 2385 | + } |
|
| 2386 | + } |
|
| 2387 | + } |
|
| 2388 | + |
|
| 2389 | + |
|
| 2390 | + /** |
|
| 2391 | + * Gets the form for saving registrations custom questions (if done |
|
| 2392 | + * previously retrieves the cached form object, which may have validation errors in it) |
|
| 2393 | + * |
|
| 2394 | + * @param int $REG_ID |
|
| 2395 | + * @return EE_Registration_Custom_Questions_Form |
|
| 2396 | + * @throws EE_Error |
|
| 2397 | + */ |
|
| 2398 | + protected function _get_reg_custom_questions_form($REG_ID) |
|
| 2399 | + { |
|
| 2400 | + if ( ! $this->_reg_custom_questions_form) { |
|
| 2401 | + require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 2402 | + $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( |
|
| 2403 | + EEM_Registration::instance()->get_one_by_ID($REG_ID) |
|
| 2404 | + ); |
|
| 2405 | + $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
| 2406 | + } |
|
| 2407 | + return $this->_reg_custom_questions_form; |
|
| 2408 | + } |
|
| 2409 | + |
|
| 2410 | + |
|
| 2411 | + /** |
|
| 2412 | + * Saves |
|
| 2413 | + * |
|
| 2414 | + * @access private |
|
| 2415 | + * @param bool $REG_ID |
|
| 2416 | + * @return bool |
|
| 2417 | + * @throws EE_Error |
|
| 2418 | + */ |
|
| 2419 | + private function _save_reg_custom_questions_form($REG_ID = false) |
|
| 2420 | + { |
|
| 2421 | + if ( ! $REG_ID) { |
|
| 2422 | + EE_Error::add_error( |
|
| 2423 | + esc_html__( |
|
| 2424 | + 'An error occurred. No registration ID was received.', 'event_espresso'), |
|
| 2425 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2426 | + ); |
|
| 2427 | + } |
|
| 2428 | + $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
| 2429 | + $form->receive_form_submission($this->_req_data); |
|
| 2430 | + $success = false; |
|
| 2431 | + if ($form->is_valid()) { |
|
| 2432 | + foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
| 2433 | + foreach ($question_group_form->inputs() as $question_id => $input) { |
|
| 2434 | + $where_conditions = array( |
|
| 2435 | + 'QST_ID' => $question_id, |
|
| 2436 | + 'REG_ID' => $REG_ID, |
|
| 2437 | + ); |
|
| 2438 | + $possibly_new_values = array( |
|
| 2439 | + 'ANS_value' => $input->normalized_value(), |
|
| 2440 | + ); |
|
| 2441 | + $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
| 2442 | + if ($answer instanceof EE_Answer) { |
|
| 2443 | + $success = $answer->save($possibly_new_values); |
|
| 2444 | + } else { |
|
| 2445 | + //insert it then |
|
| 2446 | + $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
| 2447 | + $answer = EE_Answer::new_instance($cols_n_vals); |
|
| 2448 | + $success = $answer->save(); |
|
| 2449 | + } |
|
| 2450 | + } |
|
| 2451 | + } |
|
| 2452 | + } else { |
|
| 2453 | + EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
| 2454 | + } |
|
| 2455 | + return $success; |
|
| 2456 | + } |
|
| 2457 | + |
|
| 2458 | + |
|
| 2459 | + /** |
|
| 2460 | + * generates HTML for the Registration main meta box |
|
| 2461 | + * |
|
| 2462 | + * @access public |
|
| 2463 | + * @return void |
|
| 2464 | + * @throws DomainException |
|
| 2465 | + * @throws EE_Error |
|
| 2466 | + */ |
|
| 2467 | + public function _reg_attendees_meta_box() |
|
| 2468 | + { |
|
| 2469 | + $REG = EEM_Registration::instance(); |
|
| 2470 | + //get all other registrations on this transaction, and cache |
|
| 2471 | + //the attendees for them so we don't have to run another query using force_join |
|
| 2472 | + $registrations = $REG->get_all(array( |
|
| 2473 | + array( |
|
| 2474 | + 'TXN_ID' => $this->_registration->transaction_ID(), |
|
| 2475 | + 'REG_ID' => array('!=', $this->_registration->ID()), |
|
| 2476 | + ), |
|
| 2477 | + 'force_join' => array('Attendee'), |
|
| 2478 | + )); |
|
| 2479 | + $this->_template_args['attendees'] = array(); |
|
| 2480 | + $this->_template_args['attendee_notice'] = ''; |
|
| 2481 | + if (empty($registrations) |
|
| 2482 | + || (is_array($registrations) |
|
| 2483 | + && ! EEH_Array::get_one_item_from_array($registrations)) |
|
| 2484 | + ) { |
|
| 2485 | + EE_Error::add_error( |
|
| 2486 | + esc_html__( |
|
| 2487 | + 'There are no records attached to this registration. Something may have gone wrong with the registration', |
|
| 2488 | + 'event_espresso' |
|
| 2489 | + ), __FILE__, __FUNCTION__, __LINE__ |
|
| 2490 | + ); |
|
| 2491 | + $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
| 2492 | + } else { |
|
| 2493 | + $att_nmbr = 1; |
|
| 2494 | + foreach ($registrations as $registration) { |
|
| 2495 | + /* @var $registration EE_Registration */ |
|
| 2496 | + $attendee = $registration->attendee() |
|
| 2497 | + ? $registration->attendee() |
|
| 2498 | + : EEM_Attendee::instance() |
|
| 2499 | + ->create_default_object(); |
|
| 2500 | + $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
| 2501 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); |
|
| 2502 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); |
|
| 2503 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); |
|
| 2504 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); |
|
| 2505 | + $this->_template_args['attendees'][$att_nmbr]['address'] = implode( |
|
| 2506 | + ', ', |
|
| 2507 | + $attendee->full_address_as_array() |
|
| 2508 | + ); |
|
| 2509 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce( |
|
| 2510 | + array( |
|
| 2511 | + 'action' => 'edit_attendee', |
|
| 2512 | + 'post' => $attendee->ID(), |
|
| 2513 | + ), |
|
| 2514 | + REG_ADMIN_URL |
|
| 2515 | + ); |
|
| 2516 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2517 | + $att_nmbr++; |
|
| 2518 | + } |
|
| 2519 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2520 | + } |
|
| 2521 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2522 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2523 | + } |
|
| 2524 | + |
|
| 2525 | + |
|
| 2526 | + /** |
|
| 2527 | + * generates HTML for the Edit Registration side meta box |
|
| 2528 | + * |
|
| 2529 | + * @access public |
|
| 2530 | + * @return void |
|
| 2531 | + * @throws DomainException |
|
| 2532 | + * @throws EE_Error |
|
| 2533 | + */ |
|
| 2534 | + public function _reg_registrant_side_meta_box() |
|
| 2535 | + { |
|
| 2536 | + /*@var $attendee EE_Attendee */ |
|
| 2537 | + $att_check = $this->_registration->attendee(); |
|
| 2538 | + $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
| 2539 | + //now let's determine if this is not the primary registration. If it isn't then we set the |
|
| 2540 | + //primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the |
|
| 2541 | + //primary registration object (that way we know if we need to show create button or not) |
|
| 2542 | + if ( ! $this->_registration->is_primary_registrant()) { |
|
| 2543 | + $primary_registration = $this->_registration->get_primary_registration(); |
|
| 2544 | + $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
| 2545 | + : null; |
|
| 2546 | + if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
| 2547 | + //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own |
|
| 2548 | + //custom attendee object so let's not worry about the primary reg. |
|
| 2549 | + $primary_registration = null; |
|
| 2550 | + } |
|
| 2551 | + } else { |
|
| 2552 | + $primary_registration = null; |
|
| 2553 | + } |
|
| 2554 | + $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
| 2555 | + $this->_template_args['fname'] = $attendee->fname(); |
|
| 2556 | + $this->_template_args['lname'] = $attendee->lname(); |
|
| 2557 | + $this->_template_args['email'] = $attendee->email(); |
|
| 2558 | + $this->_template_args['phone'] = $attendee->phone(); |
|
| 2559 | + $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
| 2560 | + //edit link |
|
| 2561 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2562 | + 'action' => 'edit_attendee', |
|
| 2563 | + 'post' => $attendee->ID(), |
|
| 2564 | + ), REG_ADMIN_URL); |
|
| 2565 | + $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso'); |
|
| 2566 | + //create link |
|
| 2567 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2568 | + ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2569 | + 'action' => 'duplicate_attendee', |
|
| 2570 | + '_REG_ID' => $this->_registration->ID(), |
|
| 2571 | + ), REG_ADMIN_URL) : ''; |
|
| 2572 | + $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso'); |
|
| 2573 | + $this->_template_args['att_check'] = $att_check; |
|
| 2574 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2575 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2576 | + } |
|
| 2577 | + |
|
| 2578 | + |
|
| 2579 | + /** |
|
| 2580 | + * trash or restore registrations |
|
| 2581 | + * |
|
| 2582 | + * @param boolean $trash whether to archive or restore |
|
| 2583 | + * @return void |
|
| 2584 | + * @throws EE_Error |
|
| 2585 | + * @throws RuntimeException |
|
| 2586 | + * @access protected |
|
| 2587 | + */ |
|
| 2588 | + protected function _trash_or_restore_registrations($trash = true) |
|
| 2589 | + { |
|
| 2590 | + //if empty _REG_ID then get out because there's nothing to do |
|
| 2591 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 2592 | + EE_Error::add_error( |
|
| 2593 | + sprintf( |
|
| 2594 | + esc_html__( |
|
| 2595 | + 'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.', |
|
| 2596 | + 'event_espresso' |
|
| 2597 | + ), |
|
| 2598 | + $trash ? 'trash' : 'restore' |
|
| 2599 | + ), |
|
| 2600 | + __FILE__, __LINE__, __FUNCTION__ |
|
| 2601 | + ); |
|
| 2602 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
| 2603 | + } |
|
| 2604 | + $success = 0; |
|
| 2605 | + $overwrite_msgs = false; |
|
| 2606 | + //Checkboxes |
|
| 2607 | + if ( ! is_array($this->_req_data['_REG_ID'])) { |
|
| 2608 | + $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']); |
|
| 2609 | + } |
|
| 2610 | + $reg_count = count($this->_req_data['_REG_ID']); |
|
| 2611 | + // cycle thru checkboxes |
|
| 2612 | + foreach ($this->_req_data['_REG_ID'] as $REG_ID) { |
|
| 2613 | + /** @var EE_Registration $REG */ |
|
| 2614 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 2615 | + $payments = $REG->registration_payments(); |
|
| 2616 | + if (! empty($payments)) { |
|
| 2617 | + $name = $REG->attendee() instanceof EE_Attendee |
|
| 2618 | + ? $REG->attendee()->full_name() |
|
| 2619 | + : esc_html__('Unknown Attendee', 'event_espresso'); |
|
| 2620 | + $overwrite_msgs = true; |
|
| 2621 | + EE_Error::add_error( |
|
| 2622 | + sprintf( |
|
| 2623 | + esc_html__( |
|
| 2624 | + 'The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', |
|
| 2625 | + 'event_espresso' |
|
| 2626 | + ), |
|
| 2627 | + $name |
|
| 2628 | + ), |
|
| 2629 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2630 | + ); |
|
| 2631 | + //can't trash this registration because it has payments. |
|
| 2632 | + continue; |
|
| 2633 | + } |
|
| 2634 | + $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2635 | + if ($updated) { |
|
| 2636 | + $success++; |
|
| 2637 | + } |
|
| 2638 | + } |
|
| 2639 | + $this->_redirect_after_action( |
|
| 2640 | + $success === $reg_count, // were ALL registrations affected? |
|
| 2641 | + $success > 1 |
|
| 2642 | + ? esc_html__('Registrations', 'event_espresso') |
|
| 2643 | + : esc_html__('Registration', 'event_espresso'), |
|
| 2644 | + $trash |
|
| 2645 | + ? esc_html__('moved to the trash', 'event_espresso') |
|
| 2646 | + : esc_html__('restored', 'event_espresso'), |
|
| 2647 | + array('action' => 'default'), |
|
| 2648 | + $overwrite_msgs |
|
| 2649 | + ); |
|
| 2650 | + } |
|
| 2651 | + |
|
| 2652 | + |
|
| 2653 | + /** |
|
| 2654 | + * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
| 2655 | + * registration but also. |
|
| 2656 | + * 1. Removing relations to EE_Attendee |
|
| 2657 | + * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
| 2658 | + * ALSO trashed. |
|
| 2659 | + * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
| 2660 | + * 4. Removing relationships between all tickets and the related registrations |
|
| 2661 | + * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
| 2662 | + * 6. Deleting permanently any related Checkins. |
|
| 2663 | + * |
|
| 2664 | + * @return void |
|
| 2665 | + * @throws EE_Error |
|
| 2666 | + */ |
|
| 2667 | + protected function _delete_registrations() |
|
| 2668 | + { |
|
| 2669 | + $REG_MDL = EEM_Registration::instance(); |
|
| 2670 | + $success = 1; |
|
| 2671 | + //Checkboxes |
|
| 2672 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2673 | + // if array has more than one element than success message should be plural |
|
| 2674 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2675 | + // cycle thru checkboxes |
|
| 2676 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2677 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2678 | + if ( ! $REG instanceof EE_Registration) { |
|
| 2679 | + continue; |
|
| 2680 | + } |
|
| 2681 | + $deleted = $this->_delete_registration($REG); |
|
| 2682 | + if ( ! $deleted) { |
|
| 2683 | + $success = 0; |
|
| 2684 | + } |
|
| 2685 | + } |
|
| 2686 | + } else { |
|
| 2687 | + // grab single id and delete |
|
| 2688 | + $REG_ID = $this->_req_data['_REG_ID']; |
|
| 2689 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2690 | + $deleted = $this->_delete_registration($REG); |
|
| 2691 | + if ( ! $deleted) { |
|
| 2692 | + $success = 0; |
|
| 2693 | + } |
|
| 2694 | + } |
|
| 2695 | + $what = $success > 1 |
|
| 2696 | + ? esc_html__('Registrations', 'event_espresso') |
|
| 2697 | + : esc_html__('Registration', 'event_espresso'); |
|
| 2698 | + $action_desc = esc_html__('permanently deleted.', 'event_espresso'); |
|
| 2699 | + $this->_redirect_after_action( |
|
| 2700 | + $success, |
|
| 2701 | + $what, |
|
| 2702 | + $action_desc, |
|
| 2703 | + array('action' => 'default'), |
|
| 2704 | + true |
|
| 2705 | + ); |
|
| 2706 | + } |
|
| 2707 | + |
|
| 2708 | + |
|
| 2709 | + /** |
|
| 2710 | + * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
| 2711 | + * models get affected. |
|
| 2712 | + * |
|
| 2713 | + * @param EE_Registration $REG registration to be deleted permenantly |
|
| 2714 | + * @return bool true = successful deletion, false = fail. |
|
| 2715 | + * @throws EE_Error |
|
| 2716 | + */ |
|
| 2717 | + protected function _delete_registration(EE_Registration $REG) |
|
| 2718 | + { |
|
| 2719 | + //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related |
|
| 2720 | + //registrations on the transaction that are NOT trashed. |
|
| 2721 | + $TXN = $REG->get_first_related('Transaction'); |
|
| 2722 | + $REGS = $TXN->get_many_related('Registration'); |
|
| 2723 | + $all_trashed = true; |
|
| 2724 | + foreach ($REGS as $registration) { |
|
| 2725 | + if ( ! $registration->get('REG_deleted')) { |
|
| 2726 | + $all_trashed = false; |
|
| 2727 | + } |
|
| 2728 | + } |
|
| 2729 | + if ( ! $all_trashed) { |
|
| 2730 | + EE_Error::add_error( |
|
| 2731 | + esc_html__( |
|
| 2732 | + 'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', |
|
| 2733 | + 'event_espresso' |
|
| 2734 | + ), |
|
| 2735 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2736 | + ); |
|
| 2737 | + return false; |
|
| 2738 | + } |
|
| 2739 | + //k made it here so that means we can delete all the related transactions and their answers (but let's do them |
|
| 2740 | + //separately from THIS one). |
|
| 2741 | + foreach ($REGS as $registration) { |
|
| 2742 | + //delete related answers |
|
| 2743 | + $registration->delete_related_permanently('Answer'); |
|
| 2744 | + //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
| 2745 | + $attendee = $registration->get_first_related('Attendee'); |
|
| 2746 | + if ($attendee instanceof EE_Attendee) { |
|
| 2747 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2748 | + } |
|
| 2749 | + //now remove relationships to tickets on this registration. |
|
| 2750 | + $registration->_remove_relations('Ticket'); |
|
| 2751 | + //now delete permanently the checkins related to this registration. |
|
| 2752 | + $registration->delete_related_permanently('Checkin'); |
|
| 2753 | + if ($registration->ID() === $REG->ID()) { |
|
| 2754 | + continue; |
|
| 2755 | + } //we don't want to delete permanently the existing registration just yet. |
|
| 2756 | + //remove relation to transaction for these registrations if NOT the existing registrations |
|
| 2757 | + $registration->_remove_relations('Transaction'); |
|
| 2758 | + //delete permanently any related messages. |
|
| 2759 | + $registration->delete_related_permanently('Message'); |
|
| 2760 | + //now delete this registration permanently |
|
| 2761 | + $registration->delete_permanently(); |
|
| 2762 | + } |
|
| 2763 | + //now all related registrations on the transaction are handled. So let's just handle this registration itself |
|
| 2764 | + // (the transaction and line items should be all that's left). |
|
| 2765 | + // delete the line items related to the transaction for this registration. |
|
| 2766 | + $TXN->delete_related_permanently('Line_Item'); |
|
| 2767 | + //we need to remove all the relationships on the transaction |
|
| 2768 | + $TXN->delete_related_permanently('Payment'); |
|
| 2769 | + $TXN->delete_related_permanently('Extra_Meta'); |
|
| 2770 | + $TXN->delete_related_permanently('Message'); |
|
| 2771 | + //now we can delete this REG permanently (and the transaction of course) |
|
| 2772 | + $REG->delete_related_permanently('Transaction'); |
|
| 2773 | + return $REG->delete_permanently(); |
|
| 2774 | + } |
|
| 2775 | + |
|
| 2776 | + |
|
| 2777 | + /** |
|
| 2778 | + * generates HTML for the Register New Attendee Admin page |
|
| 2779 | + * |
|
| 2780 | + * @access private |
|
| 2781 | + * @throws DomainException |
|
| 2782 | + * @throws EE_Error |
|
| 2783 | + */ |
|
| 2784 | + public function new_registration() |
|
| 2785 | + { |
|
| 2786 | + if ( ! $this->_set_reg_event()) { |
|
| 2787 | + throw new EE_Error( |
|
| 2788 | + esc_html__( |
|
| 2789 | + 'Unable to continue with registering because there is no Event ID in the request', |
|
| 2790 | + 'event_espresso' |
|
| 2791 | + ) |
|
| 2792 | + ); |
|
| 2793 | + } |
|
| 2794 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2795 | + // gotta start with a clean slate if we're not coming here via ajax |
|
| 2796 | + if ( ! defined('DOING_AJAX') |
|
| 2797 | + && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
| 2798 | + ) { |
|
| 2799 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2800 | + } |
|
| 2801 | + $this->_template_args['event_name'] = ''; |
|
| 2802 | + // event name |
|
| 2803 | + if ($this->_reg_event) { |
|
| 2804 | + $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
| 2805 | + $edit_event_url = self::add_query_args_and_nonce(array( |
|
| 2806 | + 'action' => 'edit', |
|
| 2807 | + 'post' => $this->_reg_event->ID(), |
|
| 2808 | + ), EVENTS_ADMIN_URL); |
|
| 2809 | + $edit_event_lnk = '<a href="' |
|
| 2810 | + . $edit_event_url |
|
| 2811 | + . '" title="' |
|
| 2812 | + . esc_attr__('Edit ', 'event_espresso') |
|
| 2813 | + . $this->_reg_event->name() |
|
| 2814 | + . '">' |
|
| 2815 | + . esc_html__('Edit Event', 'event_espresso') |
|
| 2816 | + . '</a>'; |
|
| 2817 | + $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
| 2818 | + . $edit_event_lnk |
|
| 2819 | + . '</span>'; |
|
| 2820 | + } |
|
| 2821 | + $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
| 2822 | + if (defined('DOING_AJAX')) { |
|
| 2823 | + $this->_return_json(); |
|
| 2824 | + } |
|
| 2825 | + // grab header |
|
| 2826 | + $template_path = |
|
| 2827 | + REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2828 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
| 2829 | + $this->_template_args, true); |
|
| 2830 | + //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 2831 | + // the details template wrapper |
|
| 2832 | + $this->display_admin_page_with_sidebar(); |
|
| 2833 | + } |
|
| 2834 | + |
|
| 2835 | + |
|
| 2836 | + /** |
|
| 2837 | + * This returns the content for a registration step |
|
| 2838 | + * |
|
| 2839 | + * @access protected |
|
| 2840 | + * @return string html |
|
| 2841 | + * @throws DomainException |
|
| 2842 | + * @throws EE_Error |
|
| 2843 | + */ |
|
| 2844 | + protected function _get_registration_step_content() |
|
| 2845 | + { |
|
| 2846 | + if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
| 2847 | + $warning_msg = sprintf( |
|
| 2848 | + esc_html__( |
|
| 2849 | + '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
|
| 2850 | + 'event_espresso' |
|
| 2851 | + ), |
|
| 2852 | + '<br />', |
|
| 2853 | + '<h3 class="important-notice">', |
|
| 2854 | + '</h3>', |
|
| 2855 | + '<div class="float-right">', |
|
| 2856 | + '<span id="redirect_timer" class="important-notice">30</span>', |
|
| 2857 | + '</div>', |
|
| 2858 | + '<b>', |
|
| 2859 | + '</b>' |
|
| 2860 | + ); |
|
| 2861 | + return ' |
|
| 2862 | 2862 | <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
| 2863 | 2863 | <script > |
| 2864 | 2864 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
@@ -2871,792 +2871,792 @@ discard block |
||
| 2871 | 2871 | } |
| 2872 | 2872 | }, 800 ); |
| 2873 | 2873 | </script >'; |
| 2874 | - } |
|
| 2875 | - $template_args = array( |
|
| 2876 | - 'title' => '', |
|
| 2877 | - 'content' => '', |
|
| 2878 | - 'step_button_text' => '', |
|
| 2879 | - 'show_notification_toggle' => false, |
|
| 2880 | - ); |
|
| 2881 | - //to indicate we're processing a new registration |
|
| 2882 | - $hidden_fields = array( |
|
| 2883 | - 'processing_registration' => array( |
|
| 2884 | - 'type' => 'hidden', |
|
| 2885 | - 'value' => 0, |
|
| 2886 | - ), |
|
| 2887 | - 'event_id' => array( |
|
| 2888 | - 'type' => 'hidden', |
|
| 2889 | - 'value' => $this->_reg_event->ID(), |
|
| 2890 | - ), |
|
| 2891 | - ); |
|
| 2892 | - //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
| 2893 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2894 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2895 | - switch ($step) { |
|
| 2896 | - case 'ticket' : |
|
| 2897 | - $hidden_fields['processing_registration']['value'] = 1; |
|
| 2898 | - $template_args['title'] = esc_html__( |
|
| 2899 | - 'Step One: Select the Ticket for this registration', |
|
| 2900 | - 'event_espresso' |
|
| 2901 | - ); |
|
| 2902 | - $template_args['content'] = |
|
| 2903 | - EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
| 2904 | - $template_args['step_button_text'] = esc_html__( |
|
| 2905 | - 'Add Tickets and Continue to Registrant Details', |
|
| 2906 | - 'event_espresso' |
|
| 2907 | - ); |
|
| 2908 | - $template_args['show_notification_toggle'] = false; |
|
| 2909 | - break; |
|
| 2910 | - case 'questions' : |
|
| 2911 | - $hidden_fields['processing_registration']['value'] = 2; |
|
| 2912 | - $template_args['title'] = esc_html__( |
|
| 2913 | - 'Step Two: Add Registrant Details for this Registration', |
|
| 2914 | - 'event_espresso' |
|
| 2915 | - ); |
|
| 2916 | - //in theory we should be able to run EED_SPCO at this point because the cart should have been setup |
|
| 2917 | - // properly by the first process_reg_step run. |
|
| 2918 | - $template_args['content'] = |
|
| 2919 | - EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
| 2920 | - $template_args['step_button_text'] = esc_html__( |
|
| 2921 | - 'Save Registration and Continue to Details', |
|
| 2922 | - 'event_espresso' |
|
| 2923 | - ); |
|
| 2924 | - $template_args['show_notification_toggle'] = true; |
|
| 2925 | - break; |
|
| 2926 | - } |
|
| 2927 | - //we come back to the process_registration_step route. |
|
| 2928 | - $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); |
|
| 2929 | - return EEH_Template::display_template( |
|
| 2930 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2931 | - $template_args, |
|
| 2932 | - true |
|
| 2933 | - ); |
|
| 2934 | - } |
|
| 2935 | - |
|
| 2936 | - |
|
| 2937 | - /** |
|
| 2938 | - * set_reg_event |
|
| 2939 | - * |
|
| 2940 | - * @access private |
|
| 2941 | - * @return bool |
|
| 2942 | - * @throws EE_Error |
|
| 2943 | - */ |
|
| 2944 | - private function _set_reg_event() |
|
| 2945 | - { |
|
| 2946 | - if (is_object($this->_reg_event)) { |
|
| 2947 | - return true; |
|
| 2948 | - } |
|
| 2949 | - $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2950 | - if ( ! $EVT_ID) { |
|
| 2951 | - return false; |
|
| 2952 | - } |
|
| 2953 | - $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2954 | - return true; |
|
| 2955 | - } |
|
| 2956 | - |
|
| 2957 | - |
|
| 2958 | - /** |
|
| 2959 | - * process_reg_step |
|
| 2960 | - * |
|
| 2961 | - * @access public |
|
| 2962 | - * @return string |
|
| 2963 | - * @throws DomainException |
|
| 2964 | - * @throws EE_Error |
|
| 2965 | - * @throws RuntimeException |
|
| 2966 | - */ |
|
| 2967 | - public function process_reg_step() |
|
| 2968 | - { |
|
| 2969 | - EE_System::do_not_cache(); |
|
| 2970 | - $this->_set_reg_event(); |
|
| 2971 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2972 | - EE_Registry::instance()->REQ->set('uts', time()); |
|
| 2973 | - //what step are we on? |
|
| 2974 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2975 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2976 | - //if doing ajax then we need to verify the nonce |
|
| 2977 | - if (defined('DOING_AJAX')) { |
|
| 2978 | - $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 2979 | - ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 2980 | - $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 2981 | - } |
|
| 2982 | - switch ($step) { |
|
| 2983 | - case 'ticket' : |
|
| 2984 | - //process ticket selection |
|
| 2985 | - $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
| 2986 | - if ($success) { |
|
| 2987 | - EE_Error::add_success( |
|
| 2988 | - esc_html__( |
|
| 2989 | - 'Tickets Selected. Now complete the registration.', |
|
| 2990 | - 'event_espresso' |
|
| 2991 | - ) |
|
| 2992 | - ); |
|
| 2993 | - } else { |
|
| 2994 | - $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
| 2995 | - } |
|
| 2996 | - if (defined('DOING_AJAX')) { |
|
| 2997 | - $this->new_registration(); //display next step |
|
| 2998 | - } else { |
|
| 2999 | - $query_args = array( |
|
| 3000 | - 'action' => 'new_registration', |
|
| 3001 | - 'processing_registration' => 1, |
|
| 3002 | - 'event_id' => $this->_reg_event->ID(), |
|
| 3003 | - 'uts' => time(), |
|
| 3004 | - ); |
|
| 3005 | - $this->_redirect_after_action( |
|
| 3006 | - false, |
|
| 3007 | - '', |
|
| 3008 | - '', |
|
| 3009 | - $query_args, |
|
| 3010 | - true |
|
| 3011 | - ); |
|
| 3012 | - } |
|
| 3013 | - break; |
|
| 3014 | - case 'questions' : |
|
| 3015 | - if (! isset( |
|
| 3016 | - $this->_req_data['txn_reg_status_change'], |
|
| 3017 | - $this->_req_data['txn_reg_status_change']['send_notifications']) |
|
| 3018 | - ) { |
|
| 3019 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
| 3020 | - } |
|
| 3021 | - //process registration |
|
| 3022 | - $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
| 3023 | - if ($cart instanceof EE_Cart) { |
|
| 3024 | - $grand_total = $cart->get_cart_grand_total(); |
|
| 3025 | - if ($grand_total instanceof EE_Line_Item) { |
|
| 3026 | - $grand_total->save_this_and_descendants_to_txn(); |
|
| 3027 | - } |
|
| 3028 | - } |
|
| 3029 | - if ( ! $transaction instanceof EE_Transaction) { |
|
| 3030 | - $query_args = array( |
|
| 3031 | - 'action' => 'new_registration', |
|
| 3032 | - 'processing_registration' => 2, |
|
| 3033 | - 'event_id' => $this->_reg_event->ID(), |
|
| 3034 | - 'uts' => time(), |
|
| 3035 | - ); |
|
| 3036 | - if (defined('DOING_AJAX')) { |
|
| 3037 | - //display registration form again because there are errors (maybe validation?) |
|
| 3038 | - $this->new_registration(); |
|
| 3039 | - return; |
|
| 3040 | - } else { |
|
| 3041 | - $this->_redirect_after_action( |
|
| 3042 | - false, |
|
| 3043 | - '', |
|
| 3044 | - '', |
|
| 3045 | - $query_args, |
|
| 3046 | - true |
|
| 3047 | - ); |
|
| 3048 | - return; |
|
| 3049 | - } |
|
| 3050 | - } |
|
| 3051 | - // maybe update status, and make sure to save transaction if not done already |
|
| 3052 | - if ( ! $transaction->update_status_based_on_total_paid()) { |
|
| 3053 | - $transaction->save(); |
|
| 3054 | - } |
|
| 3055 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 3056 | - $this->_req_data = array(); |
|
| 3057 | - $query_args = array( |
|
| 3058 | - 'action' => 'redirect_to_txn', |
|
| 3059 | - 'TXN_ID' => $transaction->ID(), |
|
| 3060 | - 'EVT_ID' => $this->_reg_event->ID(), |
|
| 3061 | - 'event_name' => urlencode($this->_reg_event->name()), |
|
| 3062 | - 'redirect_from' => 'new_registration', |
|
| 3063 | - ); |
|
| 3064 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3065 | - break; |
|
| 3066 | - } |
|
| 3067 | - //what are you looking here for? Should be nothing to do at this point. |
|
| 3068 | - } |
|
| 3069 | - |
|
| 3070 | - |
|
| 3071 | - /** |
|
| 3072 | - * redirect_to_txn |
|
| 3073 | - * |
|
| 3074 | - * @access public |
|
| 3075 | - * @return void |
|
| 3076 | - * @throws EE_Error |
|
| 3077 | - */ |
|
| 3078 | - public function redirect_to_txn() |
|
| 3079 | - { |
|
| 3080 | - EE_System::do_not_cache(); |
|
| 3081 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 3082 | - $query_args = array( |
|
| 3083 | - 'action' => 'view_transaction', |
|
| 3084 | - 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
| 3085 | - 'page' => 'espresso_transactions', |
|
| 3086 | - ); |
|
| 3087 | - if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
| 3088 | - $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 3089 | - $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
| 3090 | - $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
| 3091 | - } |
|
| 3092 | - EE_Error::add_success( |
|
| 3093 | - esc_html__( |
|
| 3094 | - 'Registration Created. Please review the transaction and add any payments as necessary', |
|
| 3095 | - 'event_espresso' |
|
| 3096 | - ) |
|
| 3097 | - ); |
|
| 3098 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3099 | - } |
|
| 3100 | - |
|
| 3101 | - |
|
| 3102 | - /** |
|
| 3103 | - * generates HTML for the Attendee Contact List |
|
| 3104 | - * |
|
| 3105 | - * @access protected |
|
| 3106 | - * @return void |
|
| 3107 | - */ |
|
| 3108 | - protected function _attendee_contact_list_table() |
|
| 3109 | - { |
|
| 3110 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3111 | - $this->_search_btn_label = esc_html__('Contacts', 'event_espresso'); |
|
| 3112 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 3113 | - } |
|
| 3114 | - |
|
| 3115 | - |
|
| 3116 | - /** |
|
| 3117 | - * get_attendees |
|
| 3118 | - * |
|
| 3119 | - * @param $per_page |
|
| 3120 | - * @param bool $count whether to return count or data. |
|
| 3121 | - * @param bool $trash |
|
| 3122 | - * @return array |
|
| 3123 | - * @throws EE_Error |
|
| 3124 | - * @access public |
|
| 3125 | - */ |
|
| 3126 | - public function get_attendees($per_page, $count = false, $trash = false) |
|
| 3127 | - { |
|
| 3128 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3129 | - require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 3130 | - $ATT_MDL = EEM_Attendee::instance(); |
|
| 3131 | - $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 3132 | - switch ($this->_req_data['orderby']) { |
|
| 3133 | - case 'ATT_ID': |
|
| 3134 | - $orderby = 'ATT_ID'; |
|
| 3135 | - break; |
|
| 3136 | - case 'ATT_fname': |
|
| 3137 | - $orderby = 'ATT_fname'; |
|
| 3138 | - break; |
|
| 3139 | - case 'ATT_email': |
|
| 3140 | - $orderby = 'ATT_email'; |
|
| 3141 | - break; |
|
| 3142 | - case 'ATT_city': |
|
| 3143 | - $orderby = 'ATT_city'; |
|
| 3144 | - break; |
|
| 3145 | - case 'STA_ID': |
|
| 3146 | - $orderby = 'STA_ID'; |
|
| 3147 | - break; |
|
| 3148 | - case 'CNT_ID': |
|
| 3149 | - $orderby = 'CNT_ID'; |
|
| 3150 | - break; |
|
| 3151 | - default: |
|
| 3152 | - $orderby = 'ATT_lname'; |
|
| 3153 | - } |
|
| 3154 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) |
|
| 3155 | - ? $this->_req_data['order'] |
|
| 3156 | - : 'ASC'; |
|
| 3157 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 3158 | - ? $this->_req_data['paged'] |
|
| 3159 | - : 1; |
|
| 3160 | - $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
| 3161 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 3162 | - ? $this->_req_data['perpage'] |
|
| 3163 | - : $per_page; |
|
| 3164 | - $_where = array(); |
|
| 3165 | - if ( ! empty($this->_req_data['s'])) { |
|
| 3166 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 3167 | - $_where['OR'] = array( |
|
| 3168 | - 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
| 3169 | - 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
| 3170 | - 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 3171 | - 'ATT_fname' => array('LIKE', $sstr), |
|
| 3172 | - 'ATT_lname' => array('LIKE', $sstr), |
|
| 3173 | - 'ATT_short_bio' => array('LIKE', $sstr), |
|
| 3174 | - 'ATT_email' => array('LIKE', $sstr), |
|
| 3175 | - 'ATT_address' => array('LIKE', $sstr), |
|
| 3176 | - 'ATT_address2' => array('LIKE', $sstr), |
|
| 3177 | - 'ATT_city' => array('LIKE', $sstr), |
|
| 3178 | - 'Country.CNT_name' => array('LIKE', $sstr), |
|
| 3179 | - 'State.STA_name' => array('LIKE', $sstr), |
|
| 3180 | - 'ATT_phone' => array('LIKE', $sstr), |
|
| 3181 | - 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
| 3182 | - 'Registration.REG_code' => array('LIKE', $sstr), |
|
| 3183 | - 'Registration.REG_count' => array('LIKE', $sstr), |
|
| 3184 | - 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
| 3185 | - ); |
|
| 3186 | - } |
|
| 3187 | - $offset = ($current_page - 1) * $per_page; |
|
| 3188 | - $limit = $count ? null : array($offset, $per_page); |
|
| 3189 | - if ($trash) { |
|
| 3190 | - $_where['status'] = array('!=', 'publish'); |
|
| 3191 | - $all_attendees = $count |
|
| 3192 | - ? $ATT_MDL->count(array( |
|
| 3193 | - $_where, |
|
| 3194 | - 'order_by' => array($orderby => $sort), |
|
| 3195 | - 'limit' => $limit, |
|
| 3196 | - ), 'ATT_ID', true) |
|
| 3197 | - : $ATT_MDL->get_all(array( |
|
| 3198 | - $_where, |
|
| 3199 | - 'order_by' => array($orderby => $sort), |
|
| 3200 | - 'limit' => $limit, |
|
| 3201 | - )); |
|
| 3202 | - } else { |
|
| 3203 | - $_where['status'] = array('IN', array('publish')); |
|
| 3204 | - $all_attendees = $count |
|
| 3205 | - ? $ATT_MDL->count(array( |
|
| 3206 | - $_where, |
|
| 3207 | - 'order_by' => array($orderby => $sort), |
|
| 3208 | - 'limit' => $limit, |
|
| 3209 | - ), 'ATT_ID', true) |
|
| 3210 | - : $ATT_MDL->get_all(array( |
|
| 3211 | - $_where, |
|
| 3212 | - 'order_by' => array($orderby => $sort), |
|
| 3213 | - 'limit' => $limit, |
|
| 3214 | - )); |
|
| 3215 | - } |
|
| 3216 | - return $all_attendees; |
|
| 3217 | - } |
|
| 3218 | - |
|
| 3219 | - |
|
| 3220 | - /** |
|
| 3221 | - * This is just taking care of resending the registration confirmation |
|
| 3222 | - * |
|
| 3223 | - * @access protected |
|
| 3224 | - * @return void |
|
| 3225 | - */ |
|
| 3226 | - protected function _resend_registration() |
|
| 3227 | - { |
|
| 3228 | - $this->_process_resend_registration(); |
|
| 3229 | - $query_args = isset($this->_req_data['redirect_to']) |
|
| 3230 | - ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
| 3231 | - : array('action' => 'default'); |
|
| 3232 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3233 | - } |
|
| 3234 | - |
|
| 3235 | - /** |
|
| 3236 | - * Creates a registration report, but accepts the name of a method to use for preparing the query parameters |
|
| 3237 | - * to use when selecting registrations |
|
| 3238 | - * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing |
|
| 3239 | - * the query parameters from the request |
|
| 3240 | - * @return void ends the request with a redirect or download |
|
| 3241 | - */ |
|
| 3242 | - public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 3243 | - { |
|
| 3244 | - if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3245 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
| 3246 | - array( |
|
| 3247 | - 'page' => 'espresso_batch', |
|
| 3248 | - 'batch' => 'file', |
|
| 3249 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3250 | - 'filters' => urlencode( |
|
| 3251 | - serialize( |
|
| 3252 | - call_user_func( |
|
| 3253 | - array( $this, $method_name_for_getting_query_params ), |
|
| 3254 | - EEH_Array::is_set( |
|
| 3255 | - $this->_req_data, |
|
| 3256 | - 'filters', |
|
| 3257 | - array() |
|
| 3258 | - ) |
|
| 3259 | - ) |
|
| 3260 | - ) |
|
| 3261 | - ), |
|
| 3262 | - 'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false), |
|
| 3263 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
| 3264 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3265 | - ))); |
|
| 3266 | - } else { |
|
| 3267 | - $new_request_args = array( |
|
| 3268 | - 'export' => 'report', |
|
| 3269 | - 'action' => 'registrations_report_for_event', |
|
| 3270 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3271 | - ); |
|
| 3272 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 3273 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3274 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3275 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3276 | - $EE_Export->export(); |
|
| 3277 | - } |
|
| 3278 | - } |
|
| 3279 | - } |
|
| 3280 | - |
|
| 3281 | - |
|
| 3282 | - |
|
| 3283 | - /** |
|
| 3284 | - * Creates a registration report using only query parameters in the request |
|
| 3285 | - * @return void |
|
| 3286 | - */ |
|
| 3287 | - public function _registrations_report() |
|
| 3288 | - { |
|
| 3289 | - $this->_registrations_report_base('_get_registration_query_parameters'); |
|
| 3290 | - } |
|
| 3291 | - |
|
| 3292 | - |
|
| 3293 | - public function _contact_list_export() |
|
| 3294 | - { |
|
| 3295 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3296 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3297 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3298 | - $EE_Export->export_attendees(); |
|
| 3299 | - } |
|
| 3300 | - } |
|
| 3301 | - |
|
| 3302 | - |
|
| 3303 | - public function _contact_list_report() |
|
| 3304 | - { |
|
| 3305 | - if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3306 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 3307 | - 'page' => 'espresso_batch', |
|
| 3308 | - 'batch' => 'file', |
|
| 3309 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
| 3310 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3311 | - ))); |
|
| 3312 | - } else { |
|
| 3313 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3314 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3315 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3316 | - $EE_Export->report_attendees(); |
|
| 3317 | - } |
|
| 3318 | - } |
|
| 3319 | - } |
|
| 3320 | - |
|
| 3321 | - |
|
| 3322 | - |
|
| 3323 | - |
|
| 3324 | - |
|
| 3325 | - /*************************************** ATTENDEE DETAILS ***************************************/ |
|
| 3326 | - /** |
|
| 3327 | - * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
| 3328 | - * |
|
| 3329 | - * @return void |
|
| 3330 | - * @throws EE_Error |
|
| 3331 | - */ |
|
| 3332 | - protected function _duplicate_attendee() |
|
| 3333 | - { |
|
| 3334 | - $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
| 3335 | - //verify we have necessary info |
|
| 3336 | - if (empty($this->_req_data['_REG_ID'])) { |
|
| 3337 | - EE_Error::add_error( |
|
| 3338 | - esc_html__( |
|
| 3339 | - 'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
| 3340 | - 'event_espresso' |
|
| 3341 | - ), __FILE__, __LINE__, __FUNCTION__ |
|
| 3342 | - ); |
|
| 3343 | - $query_args = array('action' => $action); |
|
| 3344 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3345 | - } |
|
| 3346 | - //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
| 3347 | - $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
| 3348 | - $attendee = $registration->attendee(); |
|
| 3349 | - //remove relation of existing attendee on registration |
|
| 3350 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 3351 | - //new attendee |
|
| 3352 | - $new_attendee = clone $attendee; |
|
| 3353 | - $new_attendee->set('ATT_ID', 0); |
|
| 3354 | - $new_attendee->save(); |
|
| 3355 | - //add new attendee to reg |
|
| 3356 | - $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
| 3357 | - EE_Error::add_success( |
|
| 3358 | - esc_html__( |
|
| 3359 | - 'New Contact record created. Now make any edits you wish to make for this contact.', |
|
| 3360 | - 'event_espresso' |
|
| 3361 | - ) |
|
| 3362 | - ); |
|
| 3363 | - //redirect to edit page for attendee |
|
| 3364 | - $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
| 3365 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3366 | - } |
|
| 3367 | - |
|
| 3368 | - |
|
| 3369 | - //related to cpt routes |
|
| 3370 | - protected function _insert_update_cpt_item($post_id, $post) |
|
| 3371 | - { |
|
| 3372 | - $success = true; |
|
| 3373 | - $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
| 3374 | - //for attendee updates |
|
| 3375 | - if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
| 3376 | - //note we should only be UPDATING attendees at this point. |
|
| 3377 | - $updated_fields = array( |
|
| 3378 | - 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
| 3379 | - 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
| 3380 | - 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 3381 | - 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
| 3382 | - 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
| 3383 | - 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
| 3384 | - 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
| 3385 | - 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
| 3386 | - 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
| 3387 | - 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
| 3388 | - 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
| 3389 | - ); |
|
| 3390 | - foreach ($updated_fields as $field => $value) { |
|
| 3391 | - $attendee->set($field, $value); |
|
| 3392 | - } |
|
| 3393 | - $success = $attendee->save(); |
|
| 3394 | - $attendee_update_callbacks = apply_filters( |
|
| 3395 | - 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
| 3396 | - array() |
|
| 3397 | - ); |
|
| 3398 | - foreach ($attendee_update_callbacks as $a_callback) { |
|
| 3399 | - if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
| 3400 | - throw new EE_Error( |
|
| 3401 | - sprintf( |
|
| 3402 | - esc_html__( |
|
| 3403 | - 'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', |
|
| 3404 | - 'event_espresso' |
|
| 3405 | - ), |
|
| 3406 | - $a_callback |
|
| 3407 | - ) |
|
| 3408 | - ); |
|
| 3409 | - } |
|
| 3410 | - } |
|
| 3411 | - } |
|
| 3412 | - if ($success === false) { |
|
| 3413 | - EE_Error::add_error( |
|
| 3414 | - esc_html__( |
|
| 3415 | - 'Something went wrong with updating the meta table data for the registration.', |
|
| 3416 | - 'event_espresso' |
|
| 3417 | - ), |
|
| 3418 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 3419 | - ); |
|
| 3420 | - } |
|
| 3421 | - } |
|
| 3422 | - |
|
| 3423 | - |
|
| 3424 | - public function trash_cpt_item($post_id) |
|
| 3425 | - { |
|
| 3426 | - } |
|
| 3427 | - |
|
| 3428 | - |
|
| 3429 | - public function delete_cpt_item($post_id) |
|
| 3430 | - { |
|
| 3431 | - } |
|
| 3432 | - |
|
| 3433 | - |
|
| 3434 | - public function restore_cpt_item($post_id) |
|
| 3435 | - { |
|
| 3436 | - } |
|
| 3437 | - |
|
| 3438 | - |
|
| 3439 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
| 3440 | - { |
|
| 3441 | - } |
|
| 3442 | - |
|
| 3443 | - |
|
| 3444 | - public function attendee_editor_metaboxes() |
|
| 3445 | - { |
|
| 3446 | - $this->verify_cpt_object(); |
|
| 3447 | - remove_meta_box( |
|
| 3448 | - 'postexcerpt', |
|
| 3449 | - esc_html__('Excerpt', 'event_espresso'), |
|
| 3450 | - 'post_excerpt_meta_box', |
|
| 3451 | - $this->_cpt_routes[$this->_req_action], |
|
| 3452 | - 'normal', |
|
| 3453 | - 'core' |
|
| 3454 | - ); |
|
| 3455 | - remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 3456 | - if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
| 3457 | - add_meta_box( |
|
| 3458 | - 'postexcerpt', |
|
| 3459 | - esc_html__('Short Biography', 'event_espresso'), |
|
| 3460 | - 'post_excerpt_meta_box', |
|
| 3461 | - $this->_cpt_routes[$this->_req_action], |
|
| 3462 | - 'normal' |
|
| 3463 | - ); |
|
| 3464 | - } |
|
| 3465 | - if (post_type_supports('espresso_attendees', 'comments')) { |
|
| 3466 | - add_meta_box( |
|
| 3467 | - 'commentsdiv', |
|
| 3468 | - esc_html__('Notes on the Contact', 'event_espresso'), |
|
| 3469 | - 'post_comment_meta_box', |
|
| 3470 | - $this->_cpt_routes[$this->_req_action], |
|
| 3471 | - 'normal', |
|
| 3472 | - 'core' |
|
| 3473 | - ); |
|
| 3474 | - } |
|
| 3475 | - add_meta_box( |
|
| 3476 | - 'attendee_contact_info', |
|
| 3477 | - esc_html__('Contact Info', 'event_espresso'), |
|
| 3478 | - array($this, 'attendee_contact_info'), |
|
| 3479 | - $this->_cpt_routes[$this->_req_action], |
|
| 3480 | - 'side', |
|
| 3481 | - 'core' |
|
| 3482 | - ); |
|
| 3483 | - add_meta_box( |
|
| 3484 | - 'attendee_details_address', |
|
| 3485 | - esc_html__('Address Details', 'event_espresso'), |
|
| 3486 | - array($this, 'attendee_address_details'), |
|
| 3487 | - $this->_cpt_routes[$this->_req_action], |
|
| 3488 | - 'normal', |
|
| 3489 | - 'core' |
|
| 3490 | - ); |
|
| 3491 | - add_meta_box( |
|
| 3492 | - 'attendee_registrations', |
|
| 3493 | - esc_html__('Registrations for this Contact', 'event_espresso'), |
|
| 3494 | - array($this, 'attendee_registrations_meta_box'), |
|
| 3495 | - $this->_cpt_routes[$this->_req_action], |
|
| 3496 | - 'normal', |
|
| 3497 | - 'high' |
|
| 3498 | - ); |
|
| 3499 | - } |
|
| 3500 | - |
|
| 3501 | - |
|
| 3502 | - /** |
|
| 3503 | - * Metabox for attendee contact info |
|
| 3504 | - * |
|
| 3505 | - * @param WP_Post $post wp post object |
|
| 3506 | - * @return string attendee contact info ( and form ) |
|
| 3507 | - * @throws DomainException |
|
| 3508 | - */ |
|
| 3509 | - public function attendee_contact_info($post) |
|
| 3510 | - { |
|
| 3511 | - //get attendee object ( should already have it ) |
|
| 3512 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3513 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 3514 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 3515 | - } |
|
| 3516 | - |
|
| 3517 | - |
|
| 3518 | - /** |
|
| 3519 | - * Metabox for attendee details |
|
| 3520 | - * |
|
| 3521 | - * @param WP_Post $post wp post object |
|
| 3522 | - * @return string attendee address details (and form) |
|
| 3523 | - * @throws DomainException |
|
| 3524 | - */ |
|
| 3525 | - public function attendee_address_details($post) |
|
| 3526 | - { |
|
| 3527 | - //get attendee object (should already have it) |
|
| 3528 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3529 | - $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3530 | - new EE_Question_Form_Input( |
|
| 3531 | - EE_Question::new_instance( |
|
| 3532 | - array( |
|
| 3533 | - 'QST_ID' => 0, |
|
| 3534 | - 'QST_display_text' => esc_html__('State/Province', 'event_espresso'), |
|
| 3535 | - 'QST_system' => 'admin-state', |
|
| 3536 | - ) |
|
| 3537 | - ), |
|
| 3538 | - EE_Answer::new_instance( |
|
| 3539 | - array( |
|
| 3540 | - 'ANS_ID' => 0, |
|
| 3541 | - 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
| 3542 | - ) |
|
| 3543 | - ), |
|
| 3544 | - array( |
|
| 3545 | - 'input_id' => 'STA_ID', |
|
| 3546 | - 'input_name' => 'STA_ID', |
|
| 3547 | - 'input_prefix' => '', |
|
| 3548 | - 'append_qstn_id' => false, |
|
| 3549 | - ) |
|
| 3550 | - ) |
|
| 3551 | - ); |
|
| 3552 | - $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3553 | - new EE_Question_Form_Input( |
|
| 3554 | - EE_Question::new_instance( |
|
| 3555 | - array( |
|
| 3556 | - 'QST_ID' => 0, |
|
| 3557 | - 'QST_display_text' => esc_html__('Country', 'event_espresso'), |
|
| 3558 | - 'QST_system' => 'admin-country', |
|
| 3559 | - ) |
|
| 3560 | - ), |
|
| 3561 | - EE_Answer::new_instance( |
|
| 3562 | - array( |
|
| 3563 | - 'ANS_ID' => 0, |
|
| 3564 | - 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
| 3565 | - ) |
|
| 3566 | - ), |
|
| 3567 | - array( |
|
| 3568 | - 'input_id' => 'CNT_ISO', |
|
| 3569 | - 'input_name' => 'CNT_ISO', |
|
| 3570 | - 'input_prefix' => '', |
|
| 3571 | - 'append_qstn_id' => false, |
|
| 3572 | - ) |
|
| 3573 | - ) |
|
| 3574 | - ); |
|
| 3575 | - $template = |
|
| 3576 | - REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 3577 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 3578 | - } |
|
| 3579 | - |
|
| 3580 | - |
|
| 3581 | - /** |
|
| 3582 | - * _attendee_details |
|
| 3583 | - * |
|
| 3584 | - * @access protected |
|
| 3585 | - * @param $post |
|
| 3586 | - * @return void |
|
| 3587 | - * @throws DomainException |
|
| 3588 | - * @throws EE_Error |
|
| 3589 | - */ |
|
| 3590 | - public function attendee_registrations_meta_box($post) |
|
| 3591 | - { |
|
| 3592 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3593 | - $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
| 3594 | - $template = |
|
| 3595 | - REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 3596 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 3597 | - } |
|
| 3598 | - |
|
| 3599 | - |
|
| 3600 | - /** |
|
| 3601 | - * add in the form fields for the attendee edit |
|
| 3602 | - * |
|
| 3603 | - * @param WP_Post $post wp post object |
|
| 3604 | - * @return string html for new form. |
|
| 3605 | - * @throws DomainException |
|
| 3606 | - */ |
|
| 3607 | - public function after_title_form_fields($post) |
|
| 3608 | - { |
|
| 3609 | - if ($post->post_type == 'espresso_attendees') { |
|
| 3610 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 3611 | - $template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3612 | - EEH_Template::display_template($template, $template_args); |
|
| 3613 | - } |
|
| 3614 | - } |
|
| 3615 | - |
|
| 3616 | - |
|
| 3617 | - /** |
|
| 3618 | - * _trash_or_restore_attendee |
|
| 3619 | - * |
|
| 3620 | - * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 3621 | - * @return void |
|
| 3622 | - * @throws EE_Error |
|
| 3623 | - * @access protected |
|
| 3624 | - */ |
|
| 3625 | - protected function _trash_or_restore_attendees($trash = true) |
|
| 3626 | - { |
|
| 3627 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3628 | - $ATT_MDL = EEM_Attendee::instance(); |
|
| 3629 | - $success = 1; |
|
| 3630 | - //Checkboxes |
|
| 3631 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 3632 | - // if array has more than one element than success message should be plural |
|
| 3633 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 3634 | - // cycle thru checkboxes |
|
| 3635 | - while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 3636 | - $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
| 3637 | - : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
| 3638 | - if ( ! $updated) { |
|
| 3639 | - $success = 0; |
|
| 3640 | - } |
|
| 3641 | - } |
|
| 3642 | - } else { |
|
| 3643 | - // grab single id and delete |
|
| 3644 | - $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
| 3645 | - //get attendee |
|
| 3646 | - $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
| 3647 | - $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
| 3648 | - $updated = $att->save(); |
|
| 3649 | - if ( ! $updated) { |
|
| 3650 | - $success = 0; |
|
| 3651 | - } |
|
| 3652 | - } |
|
| 3653 | - $what = $success > 1 |
|
| 3654 | - ? esc_html__('Contacts', 'event_espresso') |
|
| 3655 | - : esc_html__('Contact', 'event_espresso'); |
|
| 3656 | - $action_desc = $trash |
|
| 3657 | - ? esc_html__('moved to the trash', 'event_espresso') |
|
| 3658 | - : esc_html__('restored', 'event_espresso'); |
|
| 3659 | - $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
| 3660 | - } |
|
| 2874 | + } |
|
| 2875 | + $template_args = array( |
|
| 2876 | + 'title' => '', |
|
| 2877 | + 'content' => '', |
|
| 2878 | + 'step_button_text' => '', |
|
| 2879 | + 'show_notification_toggle' => false, |
|
| 2880 | + ); |
|
| 2881 | + //to indicate we're processing a new registration |
|
| 2882 | + $hidden_fields = array( |
|
| 2883 | + 'processing_registration' => array( |
|
| 2884 | + 'type' => 'hidden', |
|
| 2885 | + 'value' => 0, |
|
| 2886 | + ), |
|
| 2887 | + 'event_id' => array( |
|
| 2888 | + 'type' => 'hidden', |
|
| 2889 | + 'value' => $this->_reg_event->ID(), |
|
| 2890 | + ), |
|
| 2891 | + ); |
|
| 2892 | + //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
| 2893 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2894 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2895 | + switch ($step) { |
|
| 2896 | + case 'ticket' : |
|
| 2897 | + $hidden_fields['processing_registration']['value'] = 1; |
|
| 2898 | + $template_args['title'] = esc_html__( |
|
| 2899 | + 'Step One: Select the Ticket for this registration', |
|
| 2900 | + 'event_espresso' |
|
| 2901 | + ); |
|
| 2902 | + $template_args['content'] = |
|
| 2903 | + EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
| 2904 | + $template_args['step_button_text'] = esc_html__( |
|
| 2905 | + 'Add Tickets and Continue to Registrant Details', |
|
| 2906 | + 'event_espresso' |
|
| 2907 | + ); |
|
| 2908 | + $template_args['show_notification_toggle'] = false; |
|
| 2909 | + break; |
|
| 2910 | + case 'questions' : |
|
| 2911 | + $hidden_fields['processing_registration']['value'] = 2; |
|
| 2912 | + $template_args['title'] = esc_html__( |
|
| 2913 | + 'Step Two: Add Registrant Details for this Registration', |
|
| 2914 | + 'event_espresso' |
|
| 2915 | + ); |
|
| 2916 | + //in theory we should be able to run EED_SPCO at this point because the cart should have been setup |
|
| 2917 | + // properly by the first process_reg_step run. |
|
| 2918 | + $template_args['content'] = |
|
| 2919 | + EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
| 2920 | + $template_args['step_button_text'] = esc_html__( |
|
| 2921 | + 'Save Registration and Continue to Details', |
|
| 2922 | + 'event_espresso' |
|
| 2923 | + ); |
|
| 2924 | + $template_args['show_notification_toggle'] = true; |
|
| 2925 | + break; |
|
| 2926 | + } |
|
| 2927 | + //we come back to the process_registration_step route. |
|
| 2928 | + $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); |
|
| 2929 | + return EEH_Template::display_template( |
|
| 2930 | + REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2931 | + $template_args, |
|
| 2932 | + true |
|
| 2933 | + ); |
|
| 2934 | + } |
|
| 2935 | + |
|
| 2936 | + |
|
| 2937 | + /** |
|
| 2938 | + * set_reg_event |
|
| 2939 | + * |
|
| 2940 | + * @access private |
|
| 2941 | + * @return bool |
|
| 2942 | + * @throws EE_Error |
|
| 2943 | + */ |
|
| 2944 | + private function _set_reg_event() |
|
| 2945 | + { |
|
| 2946 | + if (is_object($this->_reg_event)) { |
|
| 2947 | + return true; |
|
| 2948 | + } |
|
| 2949 | + $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2950 | + if ( ! $EVT_ID) { |
|
| 2951 | + return false; |
|
| 2952 | + } |
|
| 2953 | + $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2954 | + return true; |
|
| 2955 | + } |
|
| 2956 | + |
|
| 2957 | + |
|
| 2958 | + /** |
|
| 2959 | + * process_reg_step |
|
| 2960 | + * |
|
| 2961 | + * @access public |
|
| 2962 | + * @return string |
|
| 2963 | + * @throws DomainException |
|
| 2964 | + * @throws EE_Error |
|
| 2965 | + * @throws RuntimeException |
|
| 2966 | + */ |
|
| 2967 | + public function process_reg_step() |
|
| 2968 | + { |
|
| 2969 | + EE_System::do_not_cache(); |
|
| 2970 | + $this->_set_reg_event(); |
|
| 2971 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2972 | + EE_Registry::instance()->REQ->set('uts', time()); |
|
| 2973 | + //what step are we on? |
|
| 2974 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2975 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2976 | + //if doing ajax then we need to verify the nonce |
|
| 2977 | + if (defined('DOING_AJAX')) { |
|
| 2978 | + $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 2979 | + ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 2980 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 2981 | + } |
|
| 2982 | + switch ($step) { |
|
| 2983 | + case 'ticket' : |
|
| 2984 | + //process ticket selection |
|
| 2985 | + $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
| 2986 | + if ($success) { |
|
| 2987 | + EE_Error::add_success( |
|
| 2988 | + esc_html__( |
|
| 2989 | + 'Tickets Selected. Now complete the registration.', |
|
| 2990 | + 'event_espresso' |
|
| 2991 | + ) |
|
| 2992 | + ); |
|
| 2993 | + } else { |
|
| 2994 | + $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
| 2995 | + } |
|
| 2996 | + if (defined('DOING_AJAX')) { |
|
| 2997 | + $this->new_registration(); //display next step |
|
| 2998 | + } else { |
|
| 2999 | + $query_args = array( |
|
| 3000 | + 'action' => 'new_registration', |
|
| 3001 | + 'processing_registration' => 1, |
|
| 3002 | + 'event_id' => $this->_reg_event->ID(), |
|
| 3003 | + 'uts' => time(), |
|
| 3004 | + ); |
|
| 3005 | + $this->_redirect_after_action( |
|
| 3006 | + false, |
|
| 3007 | + '', |
|
| 3008 | + '', |
|
| 3009 | + $query_args, |
|
| 3010 | + true |
|
| 3011 | + ); |
|
| 3012 | + } |
|
| 3013 | + break; |
|
| 3014 | + case 'questions' : |
|
| 3015 | + if (! isset( |
|
| 3016 | + $this->_req_data['txn_reg_status_change'], |
|
| 3017 | + $this->_req_data['txn_reg_status_change']['send_notifications']) |
|
| 3018 | + ) { |
|
| 3019 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
| 3020 | + } |
|
| 3021 | + //process registration |
|
| 3022 | + $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
| 3023 | + if ($cart instanceof EE_Cart) { |
|
| 3024 | + $grand_total = $cart->get_cart_grand_total(); |
|
| 3025 | + if ($grand_total instanceof EE_Line_Item) { |
|
| 3026 | + $grand_total->save_this_and_descendants_to_txn(); |
|
| 3027 | + } |
|
| 3028 | + } |
|
| 3029 | + if ( ! $transaction instanceof EE_Transaction) { |
|
| 3030 | + $query_args = array( |
|
| 3031 | + 'action' => 'new_registration', |
|
| 3032 | + 'processing_registration' => 2, |
|
| 3033 | + 'event_id' => $this->_reg_event->ID(), |
|
| 3034 | + 'uts' => time(), |
|
| 3035 | + ); |
|
| 3036 | + if (defined('DOING_AJAX')) { |
|
| 3037 | + //display registration form again because there are errors (maybe validation?) |
|
| 3038 | + $this->new_registration(); |
|
| 3039 | + return; |
|
| 3040 | + } else { |
|
| 3041 | + $this->_redirect_after_action( |
|
| 3042 | + false, |
|
| 3043 | + '', |
|
| 3044 | + '', |
|
| 3045 | + $query_args, |
|
| 3046 | + true |
|
| 3047 | + ); |
|
| 3048 | + return; |
|
| 3049 | + } |
|
| 3050 | + } |
|
| 3051 | + // maybe update status, and make sure to save transaction if not done already |
|
| 3052 | + if ( ! $transaction->update_status_based_on_total_paid()) { |
|
| 3053 | + $transaction->save(); |
|
| 3054 | + } |
|
| 3055 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 3056 | + $this->_req_data = array(); |
|
| 3057 | + $query_args = array( |
|
| 3058 | + 'action' => 'redirect_to_txn', |
|
| 3059 | + 'TXN_ID' => $transaction->ID(), |
|
| 3060 | + 'EVT_ID' => $this->_reg_event->ID(), |
|
| 3061 | + 'event_name' => urlencode($this->_reg_event->name()), |
|
| 3062 | + 'redirect_from' => 'new_registration', |
|
| 3063 | + ); |
|
| 3064 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3065 | + break; |
|
| 3066 | + } |
|
| 3067 | + //what are you looking here for? Should be nothing to do at this point. |
|
| 3068 | + } |
|
| 3069 | + |
|
| 3070 | + |
|
| 3071 | + /** |
|
| 3072 | + * redirect_to_txn |
|
| 3073 | + * |
|
| 3074 | + * @access public |
|
| 3075 | + * @return void |
|
| 3076 | + * @throws EE_Error |
|
| 3077 | + */ |
|
| 3078 | + public function redirect_to_txn() |
|
| 3079 | + { |
|
| 3080 | + EE_System::do_not_cache(); |
|
| 3081 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 3082 | + $query_args = array( |
|
| 3083 | + 'action' => 'view_transaction', |
|
| 3084 | + 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
| 3085 | + 'page' => 'espresso_transactions', |
|
| 3086 | + ); |
|
| 3087 | + if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
| 3088 | + $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 3089 | + $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
| 3090 | + $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
| 3091 | + } |
|
| 3092 | + EE_Error::add_success( |
|
| 3093 | + esc_html__( |
|
| 3094 | + 'Registration Created. Please review the transaction and add any payments as necessary', |
|
| 3095 | + 'event_espresso' |
|
| 3096 | + ) |
|
| 3097 | + ); |
|
| 3098 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3099 | + } |
|
| 3100 | + |
|
| 3101 | + |
|
| 3102 | + /** |
|
| 3103 | + * generates HTML for the Attendee Contact List |
|
| 3104 | + * |
|
| 3105 | + * @access protected |
|
| 3106 | + * @return void |
|
| 3107 | + */ |
|
| 3108 | + protected function _attendee_contact_list_table() |
|
| 3109 | + { |
|
| 3110 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3111 | + $this->_search_btn_label = esc_html__('Contacts', 'event_espresso'); |
|
| 3112 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 3113 | + } |
|
| 3114 | + |
|
| 3115 | + |
|
| 3116 | + /** |
|
| 3117 | + * get_attendees |
|
| 3118 | + * |
|
| 3119 | + * @param $per_page |
|
| 3120 | + * @param bool $count whether to return count or data. |
|
| 3121 | + * @param bool $trash |
|
| 3122 | + * @return array |
|
| 3123 | + * @throws EE_Error |
|
| 3124 | + * @access public |
|
| 3125 | + */ |
|
| 3126 | + public function get_attendees($per_page, $count = false, $trash = false) |
|
| 3127 | + { |
|
| 3128 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3129 | + require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 3130 | + $ATT_MDL = EEM_Attendee::instance(); |
|
| 3131 | + $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 3132 | + switch ($this->_req_data['orderby']) { |
|
| 3133 | + case 'ATT_ID': |
|
| 3134 | + $orderby = 'ATT_ID'; |
|
| 3135 | + break; |
|
| 3136 | + case 'ATT_fname': |
|
| 3137 | + $orderby = 'ATT_fname'; |
|
| 3138 | + break; |
|
| 3139 | + case 'ATT_email': |
|
| 3140 | + $orderby = 'ATT_email'; |
|
| 3141 | + break; |
|
| 3142 | + case 'ATT_city': |
|
| 3143 | + $orderby = 'ATT_city'; |
|
| 3144 | + break; |
|
| 3145 | + case 'STA_ID': |
|
| 3146 | + $orderby = 'STA_ID'; |
|
| 3147 | + break; |
|
| 3148 | + case 'CNT_ID': |
|
| 3149 | + $orderby = 'CNT_ID'; |
|
| 3150 | + break; |
|
| 3151 | + default: |
|
| 3152 | + $orderby = 'ATT_lname'; |
|
| 3153 | + } |
|
| 3154 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) |
|
| 3155 | + ? $this->_req_data['order'] |
|
| 3156 | + : 'ASC'; |
|
| 3157 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 3158 | + ? $this->_req_data['paged'] |
|
| 3159 | + : 1; |
|
| 3160 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
| 3161 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 3162 | + ? $this->_req_data['perpage'] |
|
| 3163 | + : $per_page; |
|
| 3164 | + $_where = array(); |
|
| 3165 | + if ( ! empty($this->_req_data['s'])) { |
|
| 3166 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 3167 | + $_where['OR'] = array( |
|
| 3168 | + 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
| 3169 | + 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
| 3170 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 3171 | + 'ATT_fname' => array('LIKE', $sstr), |
|
| 3172 | + 'ATT_lname' => array('LIKE', $sstr), |
|
| 3173 | + 'ATT_short_bio' => array('LIKE', $sstr), |
|
| 3174 | + 'ATT_email' => array('LIKE', $sstr), |
|
| 3175 | + 'ATT_address' => array('LIKE', $sstr), |
|
| 3176 | + 'ATT_address2' => array('LIKE', $sstr), |
|
| 3177 | + 'ATT_city' => array('LIKE', $sstr), |
|
| 3178 | + 'Country.CNT_name' => array('LIKE', $sstr), |
|
| 3179 | + 'State.STA_name' => array('LIKE', $sstr), |
|
| 3180 | + 'ATT_phone' => array('LIKE', $sstr), |
|
| 3181 | + 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
| 3182 | + 'Registration.REG_code' => array('LIKE', $sstr), |
|
| 3183 | + 'Registration.REG_count' => array('LIKE', $sstr), |
|
| 3184 | + 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
| 3185 | + ); |
|
| 3186 | + } |
|
| 3187 | + $offset = ($current_page - 1) * $per_page; |
|
| 3188 | + $limit = $count ? null : array($offset, $per_page); |
|
| 3189 | + if ($trash) { |
|
| 3190 | + $_where['status'] = array('!=', 'publish'); |
|
| 3191 | + $all_attendees = $count |
|
| 3192 | + ? $ATT_MDL->count(array( |
|
| 3193 | + $_where, |
|
| 3194 | + 'order_by' => array($orderby => $sort), |
|
| 3195 | + 'limit' => $limit, |
|
| 3196 | + ), 'ATT_ID', true) |
|
| 3197 | + : $ATT_MDL->get_all(array( |
|
| 3198 | + $_where, |
|
| 3199 | + 'order_by' => array($orderby => $sort), |
|
| 3200 | + 'limit' => $limit, |
|
| 3201 | + )); |
|
| 3202 | + } else { |
|
| 3203 | + $_where['status'] = array('IN', array('publish')); |
|
| 3204 | + $all_attendees = $count |
|
| 3205 | + ? $ATT_MDL->count(array( |
|
| 3206 | + $_where, |
|
| 3207 | + 'order_by' => array($orderby => $sort), |
|
| 3208 | + 'limit' => $limit, |
|
| 3209 | + ), 'ATT_ID', true) |
|
| 3210 | + : $ATT_MDL->get_all(array( |
|
| 3211 | + $_where, |
|
| 3212 | + 'order_by' => array($orderby => $sort), |
|
| 3213 | + 'limit' => $limit, |
|
| 3214 | + )); |
|
| 3215 | + } |
|
| 3216 | + return $all_attendees; |
|
| 3217 | + } |
|
| 3218 | + |
|
| 3219 | + |
|
| 3220 | + /** |
|
| 3221 | + * This is just taking care of resending the registration confirmation |
|
| 3222 | + * |
|
| 3223 | + * @access protected |
|
| 3224 | + * @return void |
|
| 3225 | + */ |
|
| 3226 | + protected function _resend_registration() |
|
| 3227 | + { |
|
| 3228 | + $this->_process_resend_registration(); |
|
| 3229 | + $query_args = isset($this->_req_data['redirect_to']) |
|
| 3230 | + ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
| 3231 | + : array('action' => 'default'); |
|
| 3232 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3233 | + } |
|
| 3234 | + |
|
| 3235 | + /** |
|
| 3236 | + * Creates a registration report, but accepts the name of a method to use for preparing the query parameters |
|
| 3237 | + * to use when selecting registrations |
|
| 3238 | + * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing |
|
| 3239 | + * the query parameters from the request |
|
| 3240 | + * @return void ends the request with a redirect or download |
|
| 3241 | + */ |
|
| 3242 | + public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 3243 | + { |
|
| 3244 | + if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3245 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
| 3246 | + array( |
|
| 3247 | + 'page' => 'espresso_batch', |
|
| 3248 | + 'batch' => 'file', |
|
| 3249 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3250 | + 'filters' => urlencode( |
|
| 3251 | + serialize( |
|
| 3252 | + call_user_func( |
|
| 3253 | + array( $this, $method_name_for_getting_query_params ), |
|
| 3254 | + EEH_Array::is_set( |
|
| 3255 | + $this->_req_data, |
|
| 3256 | + 'filters', |
|
| 3257 | + array() |
|
| 3258 | + ) |
|
| 3259 | + ) |
|
| 3260 | + ) |
|
| 3261 | + ), |
|
| 3262 | + 'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false), |
|
| 3263 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
| 3264 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3265 | + ))); |
|
| 3266 | + } else { |
|
| 3267 | + $new_request_args = array( |
|
| 3268 | + 'export' => 'report', |
|
| 3269 | + 'action' => 'registrations_report_for_event', |
|
| 3270 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3271 | + ); |
|
| 3272 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 3273 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3274 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3275 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3276 | + $EE_Export->export(); |
|
| 3277 | + } |
|
| 3278 | + } |
|
| 3279 | + } |
|
| 3280 | + |
|
| 3281 | + |
|
| 3282 | + |
|
| 3283 | + /** |
|
| 3284 | + * Creates a registration report using only query parameters in the request |
|
| 3285 | + * @return void |
|
| 3286 | + */ |
|
| 3287 | + public function _registrations_report() |
|
| 3288 | + { |
|
| 3289 | + $this->_registrations_report_base('_get_registration_query_parameters'); |
|
| 3290 | + } |
|
| 3291 | + |
|
| 3292 | + |
|
| 3293 | + public function _contact_list_export() |
|
| 3294 | + { |
|
| 3295 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3296 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3297 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3298 | + $EE_Export->export_attendees(); |
|
| 3299 | + } |
|
| 3300 | + } |
|
| 3301 | + |
|
| 3302 | + |
|
| 3303 | + public function _contact_list_report() |
|
| 3304 | + { |
|
| 3305 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3306 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 3307 | + 'page' => 'espresso_batch', |
|
| 3308 | + 'batch' => 'file', |
|
| 3309 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
| 3310 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3311 | + ))); |
|
| 3312 | + } else { |
|
| 3313 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3314 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3315 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3316 | + $EE_Export->report_attendees(); |
|
| 3317 | + } |
|
| 3318 | + } |
|
| 3319 | + } |
|
| 3320 | + |
|
| 3321 | + |
|
| 3322 | + |
|
| 3323 | + |
|
| 3324 | + |
|
| 3325 | + /*************************************** ATTENDEE DETAILS ***************************************/ |
|
| 3326 | + /** |
|
| 3327 | + * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
| 3328 | + * |
|
| 3329 | + * @return void |
|
| 3330 | + * @throws EE_Error |
|
| 3331 | + */ |
|
| 3332 | + protected function _duplicate_attendee() |
|
| 3333 | + { |
|
| 3334 | + $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
| 3335 | + //verify we have necessary info |
|
| 3336 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 3337 | + EE_Error::add_error( |
|
| 3338 | + esc_html__( |
|
| 3339 | + 'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
| 3340 | + 'event_espresso' |
|
| 3341 | + ), __FILE__, __LINE__, __FUNCTION__ |
|
| 3342 | + ); |
|
| 3343 | + $query_args = array('action' => $action); |
|
| 3344 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3345 | + } |
|
| 3346 | + //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
| 3347 | + $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
| 3348 | + $attendee = $registration->attendee(); |
|
| 3349 | + //remove relation of existing attendee on registration |
|
| 3350 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 3351 | + //new attendee |
|
| 3352 | + $new_attendee = clone $attendee; |
|
| 3353 | + $new_attendee->set('ATT_ID', 0); |
|
| 3354 | + $new_attendee->save(); |
|
| 3355 | + //add new attendee to reg |
|
| 3356 | + $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
| 3357 | + EE_Error::add_success( |
|
| 3358 | + esc_html__( |
|
| 3359 | + 'New Contact record created. Now make any edits you wish to make for this contact.', |
|
| 3360 | + 'event_espresso' |
|
| 3361 | + ) |
|
| 3362 | + ); |
|
| 3363 | + //redirect to edit page for attendee |
|
| 3364 | + $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
| 3365 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3366 | + } |
|
| 3367 | + |
|
| 3368 | + |
|
| 3369 | + //related to cpt routes |
|
| 3370 | + protected function _insert_update_cpt_item($post_id, $post) |
|
| 3371 | + { |
|
| 3372 | + $success = true; |
|
| 3373 | + $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
| 3374 | + //for attendee updates |
|
| 3375 | + if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
| 3376 | + //note we should only be UPDATING attendees at this point. |
|
| 3377 | + $updated_fields = array( |
|
| 3378 | + 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
| 3379 | + 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
| 3380 | + 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 3381 | + 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
| 3382 | + 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
| 3383 | + 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
| 3384 | + 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
| 3385 | + 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
| 3386 | + 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
| 3387 | + 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
| 3388 | + 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
| 3389 | + ); |
|
| 3390 | + foreach ($updated_fields as $field => $value) { |
|
| 3391 | + $attendee->set($field, $value); |
|
| 3392 | + } |
|
| 3393 | + $success = $attendee->save(); |
|
| 3394 | + $attendee_update_callbacks = apply_filters( |
|
| 3395 | + 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
| 3396 | + array() |
|
| 3397 | + ); |
|
| 3398 | + foreach ($attendee_update_callbacks as $a_callback) { |
|
| 3399 | + if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
| 3400 | + throw new EE_Error( |
|
| 3401 | + sprintf( |
|
| 3402 | + esc_html__( |
|
| 3403 | + 'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', |
|
| 3404 | + 'event_espresso' |
|
| 3405 | + ), |
|
| 3406 | + $a_callback |
|
| 3407 | + ) |
|
| 3408 | + ); |
|
| 3409 | + } |
|
| 3410 | + } |
|
| 3411 | + } |
|
| 3412 | + if ($success === false) { |
|
| 3413 | + EE_Error::add_error( |
|
| 3414 | + esc_html__( |
|
| 3415 | + 'Something went wrong with updating the meta table data for the registration.', |
|
| 3416 | + 'event_espresso' |
|
| 3417 | + ), |
|
| 3418 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 3419 | + ); |
|
| 3420 | + } |
|
| 3421 | + } |
|
| 3422 | + |
|
| 3423 | + |
|
| 3424 | + public function trash_cpt_item($post_id) |
|
| 3425 | + { |
|
| 3426 | + } |
|
| 3427 | + |
|
| 3428 | + |
|
| 3429 | + public function delete_cpt_item($post_id) |
|
| 3430 | + { |
|
| 3431 | + } |
|
| 3432 | + |
|
| 3433 | + |
|
| 3434 | + public function restore_cpt_item($post_id) |
|
| 3435 | + { |
|
| 3436 | + } |
|
| 3437 | + |
|
| 3438 | + |
|
| 3439 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
| 3440 | + { |
|
| 3441 | + } |
|
| 3442 | + |
|
| 3443 | + |
|
| 3444 | + public function attendee_editor_metaboxes() |
|
| 3445 | + { |
|
| 3446 | + $this->verify_cpt_object(); |
|
| 3447 | + remove_meta_box( |
|
| 3448 | + 'postexcerpt', |
|
| 3449 | + esc_html__('Excerpt', 'event_espresso'), |
|
| 3450 | + 'post_excerpt_meta_box', |
|
| 3451 | + $this->_cpt_routes[$this->_req_action], |
|
| 3452 | + 'normal', |
|
| 3453 | + 'core' |
|
| 3454 | + ); |
|
| 3455 | + remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 3456 | + if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
| 3457 | + add_meta_box( |
|
| 3458 | + 'postexcerpt', |
|
| 3459 | + esc_html__('Short Biography', 'event_espresso'), |
|
| 3460 | + 'post_excerpt_meta_box', |
|
| 3461 | + $this->_cpt_routes[$this->_req_action], |
|
| 3462 | + 'normal' |
|
| 3463 | + ); |
|
| 3464 | + } |
|
| 3465 | + if (post_type_supports('espresso_attendees', 'comments')) { |
|
| 3466 | + add_meta_box( |
|
| 3467 | + 'commentsdiv', |
|
| 3468 | + esc_html__('Notes on the Contact', 'event_espresso'), |
|
| 3469 | + 'post_comment_meta_box', |
|
| 3470 | + $this->_cpt_routes[$this->_req_action], |
|
| 3471 | + 'normal', |
|
| 3472 | + 'core' |
|
| 3473 | + ); |
|
| 3474 | + } |
|
| 3475 | + add_meta_box( |
|
| 3476 | + 'attendee_contact_info', |
|
| 3477 | + esc_html__('Contact Info', 'event_espresso'), |
|
| 3478 | + array($this, 'attendee_contact_info'), |
|
| 3479 | + $this->_cpt_routes[$this->_req_action], |
|
| 3480 | + 'side', |
|
| 3481 | + 'core' |
|
| 3482 | + ); |
|
| 3483 | + add_meta_box( |
|
| 3484 | + 'attendee_details_address', |
|
| 3485 | + esc_html__('Address Details', 'event_espresso'), |
|
| 3486 | + array($this, 'attendee_address_details'), |
|
| 3487 | + $this->_cpt_routes[$this->_req_action], |
|
| 3488 | + 'normal', |
|
| 3489 | + 'core' |
|
| 3490 | + ); |
|
| 3491 | + add_meta_box( |
|
| 3492 | + 'attendee_registrations', |
|
| 3493 | + esc_html__('Registrations for this Contact', 'event_espresso'), |
|
| 3494 | + array($this, 'attendee_registrations_meta_box'), |
|
| 3495 | + $this->_cpt_routes[$this->_req_action], |
|
| 3496 | + 'normal', |
|
| 3497 | + 'high' |
|
| 3498 | + ); |
|
| 3499 | + } |
|
| 3500 | + |
|
| 3501 | + |
|
| 3502 | + /** |
|
| 3503 | + * Metabox for attendee contact info |
|
| 3504 | + * |
|
| 3505 | + * @param WP_Post $post wp post object |
|
| 3506 | + * @return string attendee contact info ( and form ) |
|
| 3507 | + * @throws DomainException |
|
| 3508 | + */ |
|
| 3509 | + public function attendee_contact_info($post) |
|
| 3510 | + { |
|
| 3511 | + //get attendee object ( should already have it ) |
|
| 3512 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3513 | + $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 3514 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 3515 | + } |
|
| 3516 | + |
|
| 3517 | + |
|
| 3518 | + /** |
|
| 3519 | + * Metabox for attendee details |
|
| 3520 | + * |
|
| 3521 | + * @param WP_Post $post wp post object |
|
| 3522 | + * @return string attendee address details (and form) |
|
| 3523 | + * @throws DomainException |
|
| 3524 | + */ |
|
| 3525 | + public function attendee_address_details($post) |
|
| 3526 | + { |
|
| 3527 | + //get attendee object (should already have it) |
|
| 3528 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3529 | + $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3530 | + new EE_Question_Form_Input( |
|
| 3531 | + EE_Question::new_instance( |
|
| 3532 | + array( |
|
| 3533 | + 'QST_ID' => 0, |
|
| 3534 | + 'QST_display_text' => esc_html__('State/Province', 'event_espresso'), |
|
| 3535 | + 'QST_system' => 'admin-state', |
|
| 3536 | + ) |
|
| 3537 | + ), |
|
| 3538 | + EE_Answer::new_instance( |
|
| 3539 | + array( |
|
| 3540 | + 'ANS_ID' => 0, |
|
| 3541 | + 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
| 3542 | + ) |
|
| 3543 | + ), |
|
| 3544 | + array( |
|
| 3545 | + 'input_id' => 'STA_ID', |
|
| 3546 | + 'input_name' => 'STA_ID', |
|
| 3547 | + 'input_prefix' => '', |
|
| 3548 | + 'append_qstn_id' => false, |
|
| 3549 | + ) |
|
| 3550 | + ) |
|
| 3551 | + ); |
|
| 3552 | + $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3553 | + new EE_Question_Form_Input( |
|
| 3554 | + EE_Question::new_instance( |
|
| 3555 | + array( |
|
| 3556 | + 'QST_ID' => 0, |
|
| 3557 | + 'QST_display_text' => esc_html__('Country', 'event_espresso'), |
|
| 3558 | + 'QST_system' => 'admin-country', |
|
| 3559 | + ) |
|
| 3560 | + ), |
|
| 3561 | + EE_Answer::new_instance( |
|
| 3562 | + array( |
|
| 3563 | + 'ANS_ID' => 0, |
|
| 3564 | + 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
| 3565 | + ) |
|
| 3566 | + ), |
|
| 3567 | + array( |
|
| 3568 | + 'input_id' => 'CNT_ISO', |
|
| 3569 | + 'input_name' => 'CNT_ISO', |
|
| 3570 | + 'input_prefix' => '', |
|
| 3571 | + 'append_qstn_id' => false, |
|
| 3572 | + ) |
|
| 3573 | + ) |
|
| 3574 | + ); |
|
| 3575 | + $template = |
|
| 3576 | + REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 3577 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 3578 | + } |
|
| 3579 | + |
|
| 3580 | + |
|
| 3581 | + /** |
|
| 3582 | + * _attendee_details |
|
| 3583 | + * |
|
| 3584 | + * @access protected |
|
| 3585 | + * @param $post |
|
| 3586 | + * @return void |
|
| 3587 | + * @throws DomainException |
|
| 3588 | + * @throws EE_Error |
|
| 3589 | + */ |
|
| 3590 | + public function attendee_registrations_meta_box($post) |
|
| 3591 | + { |
|
| 3592 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3593 | + $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
| 3594 | + $template = |
|
| 3595 | + REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 3596 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 3597 | + } |
|
| 3598 | + |
|
| 3599 | + |
|
| 3600 | + /** |
|
| 3601 | + * add in the form fields for the attendee edit |
|
| 3602 | + * |
|
| 3603 | + * @param WP_Post $post wp post object |
|
| 3604 | + * @return string html for new form. |
|
| 3605 | + * @throws DomainException |
|
| 3606 | + */ |
|
| 3607 | + public function after_title_form_fields($post) |
|
| 3608 | + { |
|
| 3609 | + if ($post->post_type == 'espresso_attendees') { |
|
| 3610 | + $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 3611 | + $template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3612 | + EEH_Template::display_template($template, $template_args); |
|
| 3613 | + } |
|
| 3614 | + } |
|
| 3615 | + |
|
| 3616 | + |
|
| 3617 | + /** |
|
| 3618 | + * _trash_or_restore_attendee |
|
| 3619 | + * |
|
| 3620 | + * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 3621 | + * @return void |
|
| 3622 | + * @throws EE_Error |
|
| 3623 | + * @access protected |
|
| 3624 | + */ |
|
| 3625 | + protected function _trash_or_restore_attendees($trash = true) |
|
| 3626 | + { |
|
| 3627 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3628 | + $ATT_MDL = EEM_Attendee::instance(); |
|
| 3629 | + $success = 1; |
|
| 3630 | + //Checkboxes |
|
| 3631 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 3632 | + // if array has more than one element than success message should be plural |
|
| 3633 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 3634 | + // cycle thru checkboxes |
|
| 3635 | + while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 3636 | + $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
| 3637 | + : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
| 3638 | + if ( ! $updated) { |
|
| 3639 | + $success = 0; |
|
| 3640 | + } |
|
| 3641 | + } |
|
| 3642 | + } else { |
|
| 3643 | + // grab single id and delete |
|
| 3644 | + $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
| 3645 | + //get attendee |
|
| 3646 | + $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
| 3647 | + $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
| 3648 | + $updated = $att->save(); |
|
| 3649 | + if ( ! $updated) { |
|
| 3650 | + $success = 0; |
|
| 3651 | + } |
|
| 3652 | + } |
|
| 3653 | + $what = $success > 1 |
|
| 3654 | + ? esc_html__('Contacts', 'event_espresso') |
|
| 3655 | + : esc_html__('Contact', 'event_espresso'); |
|
| 3656 | + $action_desc = $trash |
|
| 3657 | + ? esc_html__('moved to the trash', 'event_espresso') |
|
| 3658 | + : esc_html__('restored', 'event_espresso'); |
|
| 3659 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
| 3660 | + } |
|
| 3661 | 3661 | |
| 3662 | 3662 | } |
@@ -157,9 +157,9 @@ |
||
| 157 | 157 | $aee = array_merge( $this->_default_addressee_data, $aee ); |
| 158 | 158 | |
| 159 | 159 | //make sure txn is set |
| 160 | - if (empty($aee['txn']) && $aee['reg_obj'] instanceof EE_Registration) { |
|
| 161 | - $aee['txn'] = $aee['reg_obj']->transaction(); |
|
| 162 | - } |
|
| 160 | + if (empty($aee['txn']) && $aee['reg_obj'] instanceof EE_Registration) { |
|
| 161 | + $aee['txn'] = $aee['reg_obj']->transaction(); |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | 164 | $addressee[] = new EE_Messages_Addressee( $aee ); |
| 165 | 165 | } |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public function __construct() { |
| 24 | 24 | $this->name = 'newsletter'; |
| 25 | - $this->description = __( 'Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', 'event_espresso' ); |
|
| 25 | + $this->description = __('Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', 'event_espresso'); |
|
| 26 | 26 | $this->label = array( |
| 27 | - 'singular' => __( 'batch', 'event_espresso' ), |
|
| 28 | - 'plural' => __( 'batches', 'event_espresso' ) |
|
| 27 | + 'singular' => __('batch', 'event_espresso'), |
|
| 28 | + 'plural' => __('batches', 'event_espresso') |
|
| 29 | 29 | ); |
| 30 | 30 | $this->_master_templates = array( |
| 31 | 31 | 'email' => 'registration', |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | |
| 52 | - protected function _get_data_for_context( $context, EE_Registration $registration, $id ) { |
|
| 52 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) { |
|
| 53 | 53 | //newsletter message type data handler is 'Registrations' and it expects an array of EE_Registration objects. |
| 54 | - return array( $registration ); |
|
| 54 | + return array($registration); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
@@ -64,15 +64,15 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | protected function _set_contexts() { |
| 66 | 66 | $this->_context_label = array( |
| 67 | - 'label' => __( 'recipient', 'event_espresso' ), |
|
| 68 | - 'plural' => __( 'recipients', 'event_espresso' ), |
|
| 69 | - 'description' => __( 'Recipient\'s are who will receive the message.', 'event_espresso' ) |
|
| 67 | + 'label' => __('recipient', 'event_espresso'), |
|
| 68 | + 'plural' => __('recipients', 'event_espresso'), |
|
| 69 | + 'description' => __('Recipient\'s are who will receive the message.', 'event_espresso') |
|
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | 72 | $this->_contexts = array( |
| 73 | 73 | 'attendee' => array( |
| 74 | - 'label' => __( 'Registrant', 'event_espresso' ), |
|
| 75 | - 'description' => __( 'This template goes to selected registrants.', 'event_espresso' ) |
|
| 74 | + 'label' => __('Registrant', 'event_espresso'), |
|
| 75 | + 'description' => __('This template goes to selected registrants.', 'event_espresso') |
|
| 76 | 76 | ) |
| 77 | 77 | ); |
| 78 | 78 | } |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | 'newsletter', |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - foreach ( $this->_valid_shortcodes as $context => $shortcodes ) { |
|
| 102 | - foreach ( $shortcodes as $key => $shortcode ) { |
|
| 103 | - if ( ! in_array( $shortcode, $included_shortcodes ) ) { |
|
| 104 | - unset( $this->_valid_shortcodes[ $context ][ $key ] ); |
|
| 101 | + foreach ($this->_valid_shortcodes as $context => $shortcodes) { |
|
| 102 | + foreach ($shortcodes as $key => $shortcode) { |
|
| 103 | + if ( ! in_array($shortcode, $included_shortcodes)) { |
|
| 104 | + unset($this->_valid_shortcodes[$context][$key]); |
|
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | - $this->_valid_shortcodes[ $context ][] = 'newsletter'; |
|
| 107 | + $this->_valid_shortcodes[$context][] = 'newsletter'; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | } |
@@ -118,50 +118,50 @@ discard block |
||
| 118 | 118 | $addressee = array(); |
| 119 | 119 | |
| 120 | 120 | //looping through registrations |
| 121 | - foreach ( $this->_data->registrations as $reg_id => $details ) { |
|
| 121 | + foreach ($this->_data->registrations as $reg_id => $details) { |
|
| 122 | 122 | //set $attendee array to blank on each loop |
| 123 | 123 | $aee = array(); |
| 124 | 124 | |
| 125 | 125 | //need to get the attendee from this registration. |
| 126 | - $attendee = isset( $details['att_obj'] ) && $details['att_obj'] instanceof EE_Attendee |
|
| 126 | + $attendee = isset($details['att_obj']) && $details['att_obj'] instanceof EE_Attendee |
|
| 127 | 127 | ? $details['att_obj'] |
| 128 | 128 | : null; |
| 129 | 129 | |
| 130 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
| 130 | + if ( ! $attendee instanceof EE_Attendee) { |
|
| 131 | 131 | continue; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | //set $aee from attendee object |
| 135 | 135 | $aee['att_obj'] = $attendee; |
| 136 | - $aee['reg_objs'] = isset( $this->_data->attendees[ $attendee->ID() ]['reg_objs'] ) |
|
| 137 | - ? $this->_data->attendees[ $attendee->ID() ]['reg_objs'] |
|
| 136 | + $aee['reg_objs'] = isset($this->_data->attendees[$attendee->ID()]['reg_objs']) |
|
| 137 | + ? $this->_data->attendees[$attendee->ID()]['reg_objs'] |
|
| 138 | 138 | : array(); |
| 139 | 139 | $aee['attendee_email'] = $attendee->email(); |
| 140 | - $aee['tkt_objs'] = isset( $this->_data->attendees[ $attendee->ID() ]['tkt_objs'] ) |
|
| 141 | - ? $this->_data->attendees[ $attendee->ID() ]['tkt_objs'] |
|
| 140 | + $aee['tkt_objs'] = isset($this->_data->attendees[$attendee->ID()]['tkt_objs']) |
|
| 141 | + ? $this->_data->attendees[$attendee->ID()]['tkt_objs'] |
|
| 142 | 142 | : array(); |
| 143 | 143 | |
| 144 | - if ( isset( $this->_data->attendees[ $attendee->ID() ]['evt_objs'] ) ) { |
|
| 145 | - $aee['evt_objs'] = $this->_data->attendees[ $attendee->ID() ]['evt_objs']; |
|
| 146 | - $aee['events'] = $this->_data->attendees[ $attendee->ID() ]['evt_objs']; |
|
| 144 | + if (isset($this->_data->attendees[$attendee->ID()]['evt_objs'])) { |
|
| 145 | + $aee['evt_objs'] = $this->_data->attendees[$attendee->ID()]['evt_objs']; |
|
| 146 | + $aee['events'] = $this->_data->attendees[$attendee->ID()]['evt_objs']; |
|
| 147 | 147 | } else { |
| 148 | 148 | $aee['evt_objs'] = $aee['events'] = array(); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $aee['reg_obj'] = isset( $details['reg_obj'] ) |
|
| 151 | + $aee['reg_obj'] = isset($details['reg_obj']) |
|
| 152 | 152 | ? $details['reg_obj'] |
| 153 | 153 | : null; |
| 154 | 154 | $aee['attendees'] = $this->_data->attendees; |
| 155 | 155 | |
| 156 | 156 | //merge in the primary attendee data |
| 157 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
| 157 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
| 158 | 158 | |
| 159 | 159 | //make sure txn is set |
| 160 | 160 | if (empty($aee['txn']) && $aee['reg_obj'] instanceof EE_Registration) { |
| 161 | 161 | $aee['txn'] = $aee['reg_obj']->transaction(); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $addressee[] = new EE_Messages_Addressee( $aee ); |
|
| 164 | + $addressee[] = new EE_Messages_Addressee($aee); |
|
| 165 | 165 | } |
| 166 | 166 | return $addressee; |
| 167 | 167 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | use EventEspresso\core\exceptions\InvalidEntityException; |
| 6 | 6 | |
| 7 | 7 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 8 | - exit('No direct script access allowed'); |
|
| 8 | + exit('No direct script access allowed'); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | |
@@ -20,1865 +20,1865 @@ discard block |
||
| 20 | 20 | class EED_Single_Page_Checkout extends EED_Module |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * $_initialized - has the SPCO controller already been initialized ? |
|
| 25 | - * |
|
| 26 | - * @access private |
|
| 27 | - * @var bool $_initialized |
|
| 28 | - */ |
|
| 29 | - private static $_initialized = false; |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
| 34 | - * |
|
| 35 | - * @access private |
|
| 36 | - * @var bool $_valid_checkout |
|
| 37 | - */ |
|
| 38 | - private static $_checkout_verified = true; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * $_reg_steps_array - holds initial array of reg steps |
|
| 42 | - * |
|
| 43 | - * @access private |
|
| 44 | - * @var array $_reg_steps_array |
|
| 45 | - */ |
|
| 46 | - private static $_reg_steps_array = array(); |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
| 50 | - * |
|
| 51 | - * @access public |
|
| 52 | - * @var EE_Checkout $checkout |
|
| 53 | - */ |
|
| 54 | - public $checkout; |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @return EED_Module|EED_Single_Page_Checkout |
|
| 60 | - */ |
|
| 61 | - public static function instance() |
|
| 62 | - { |
|
| 63 | - add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
| 64 | - return parent::get_instance(__CLASS__); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @return EE_CART |
|
| 71 | - */ |
|
| 72 | - public function cart() |
|
| 73 | - { |
|
| 74 | - return $this->checkout->cart; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @return EE_Transaction |
|
| 81 | - */ |
|
| 82 | - public function transaction() |
|
| 83 | - { |
|
| 84 | - return $this->checkout->transaction; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 91 | - * |
|
| 92 | - * @access public |
|
| 93 | - * @return void |
|
| 94 | - * @throws EE_Error |
|
| 95 | - */ |
|
| 96 | - public static function set_hooks() |
|
| 97 | - { |
|
| 98 | - EED_Single_Page_Checkout::set_definitions(); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 105 | - * |
|
| 106 | - * @access public |
|
| 107 | - * @return void |
|
| 108 | - * @throws EE_Error |
|
| 109 | - */ |
|
| 110 | - public static function set_hooks_admin() |
|
| 111 | - { |
|
| 112 | - EED_Single_Page_Checkout::set_definitions(); |
|
| 113 | - if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 114 | - return; |
|
| 115 | - } |
|
| 116 | - // going to start an output buffer in case anything gets accidentally output |
|
| 117 | - // that might disrupt our JSON response |
|
| 118 | - ob_start(); |
|
| 119 | - EED_Single_Page_Checkout::load_request_handler(); |
|
| 120 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
| 121 | - // set ajax hooks |
|
| 122 | - add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 123 | - add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 124 | - add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 125 | - add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 126 | - add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 127 | - add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * process ajax request |
|
| 134 | - * |
|
| 135 | - * @param string $ajax_action |
|
| 136 | - * @throws EE_Error |
|
| 137 | - */ |
|
| 138 | - public static function process_ajax_request($ajax_action) |
|
| 139 | - { |
|
| 140 | - EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
| 141 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * ajax display registration step |
|
| 148 | - * |
|
| 149 | - * @throws EE_Error |
|
| 150 | - */ |
|
| 151 | - public static function display_reg_step() |
|
| 152 | - { |
|
| 153 | - EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * ajax process registration step |
|
| 160 | - * |
|
| 161 | - * @throws EE_Error |
|
| 162 | - */ |
|
| 163 | - public static function process_reg_step() |
|
| 164 | - { |
|
| 165 | - EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * ajax process registration step |
|
| 172 | - * |
|
| 173 | - * @throws EE_Error |
|
| 174 | - */ |
|
| 175 | - public static function update_reg_step() |
|
| 176 | - { |
|
| 177 | - EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * update_checkout |
|
| 184 | - * |
|
| 185 | - * @access public |
|
| 186 | - * @return void |
|
| 187 | - * @throws EE_Error |
|
| 188 | - */ |
|
| 189 | - public static function update_checkout() |
|
| 190 | - { |
|
| 191 | - EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * load_request_handler |
|
| 198 | - * |
|
| 199 | - * @access public |
|
| 200 | - * @return void |
|
| 201 | - */ |
|
| 202 | - public static function load_request_handler() |
|
| 203 | - { |
|
| 204 | - // load core Request_Handler class |
|
| 205 | - if (EE_Registry::instance()->REQ !== null) { |
|
| 206 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * set_definitions |
|
| 214 | - * |
|
| 215 | - * @access public |
|
| 216 | - * @return void |
|
| 217 | - * @throws EE_Error |
|
| 218 | - */ |
|
| 219 | - public static function set_definitions() |
|
| 220 | - { |
|
| 221 | - if(defined('SPCO_BASE_PATH')) { |
|
| 222 | - return; |
|
| 223 | - } |
|
| 224 | - define( |
|
| 225 | - 'SPCO_BASE_PATH', |
|
| 226 | - rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS |
|
| 227 | - ); |
|
| 228 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
| 229 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
| 230 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
| 231 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
| 232 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
| 233 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
| 234 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
| 235 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
| 236 | - __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', |
|
| 237 | - 'event_espresso'), |
|
| 238 | - '<h4 class="important-notice">', |
|
| 239 | - '</h4>', |
|
| 240 | - '<br />', |
|
| 241 | - '<p>', |
|
| 242 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 243 | - '">', |
|
| 244 | - '</a>', |
|
| 245 | - '</p>' |
|
| 246 | - ); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * load_reg_steps |
|
| 253 | - * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
| 254 | - * |
|
| 255 | - * @access private |
|
| 256 | - * @throws EE_Error |
|
| 257 | - */ |
|
| 258 | - public static function load_reg_steps() |
|
| 259 | - { |
|
| 260 | - static $reg_steps_loaded = false; |
|
| 261 | - if ($reg_steps_loaded) { |
|
| 262 | - return; |
|
| 263 | - } |
|
| 264 | - // filter list of reg_steps |
|
| 265 | - $reg_steps_to_load = (array)apply_filters( |
|
| 266 | - 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
| 267 | - EED_Single_Page_Checkout::get_reg_steps() |
|
| 268 | - ); |
|
| 269 | - // sort by key (order) |
|
| 270 | - ksort($reg_steps_to_load); |
|
| 271 | - // loop through folders |
|
| 272 | - foreach ($reg_steps_to_load as $order => $reg_step) { |
|
| 273 | - // we need a |
|
| 274 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 275 | - // copy over to the reg_steps_array |
|
| 276 | - EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
| 277 | - // register custom key route for each reg step |
|
| 278 | - // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
| 279 | - EE_Config::register_route( |
|
| 280 | - $reg_step['slug'], |
|
| 281 | - 'EED_Single_Page_Checkout', |
|
| 282 | - 'run', |
|
| 283 | - 'step' |
|
| 284 | - ); |
|
| 285 | - // add AJAX or other hooks |
|
| 286 | - if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
| 287 | - // setup autoloaders if necessary |
|
| 288 | - if ( ! class_exists($reg_step['class_name'])) { |
|
| 289 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
| 290 | - $reg_step['file_path'], |
|
| 291 | - true |
|
| 292 | - ); |
|
| 293 | - } |
|
| 294 | - if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
| 295 | - call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - $reg_steps_loaded = true; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * get_reg_steps |
|
| 307 | - * |
|
| 308 | - * @access public |
|
| 309 | - * @return array |
|
| 310 | - */ |
|
| 311 | - public static function get_reg_steps() |
|
| 312 | - { |
|
| 313 | - $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
| 314 | - if (empty($reg_steps)) { |
|
| 315 | - $reg_steps = array( |
|
| 316 | - 10 => array( |
|
| 317 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
| 318 | - 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
| 319 | - 'slug' => 'attendee_information', |
|
| 320 | - 'has_hooks' => false, |
|
| 321 | - ), |
|
| 322 | - 20 => array( |
|
| 323 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
| 324 | - 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
|
| 325 | - 'slug' => 'registration_confirmation', |
|
| 326 | - 'has_hooks' => false, |
|
| 327 | - ), |
|
| 328 | - 30 => array( |
|
| 329 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
| 330 | - 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
| 331 | - 'slug' => 'payment_options', |
|
| 332 | - 'has_hooks' => true, |
|
| 333 | - ), |
|
| 334 | - 999 => array( |
|
| 335 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
| 336 | - 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
| 337 | - 'slug' => 'finalize_registration', |
|
| 338 | - 'has_hooks' => false, |
|
| 339 | - ), |
|
| 340 | - ); |
|
| 341 | - } |
|
| 342 | - return $reg_steps; |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - |
|
| 346 | - |
|
| 347 | - /** |
|
| 348 | - * registration_checkout_for_admin |
|
| 349 | - * |
|
| 350 | - * @access public |
|
| 351 | - * @return string |
|
| 352 | - * @throws EE_Error |
|
| 353 | - */ |
|
| 354 | - public static function registration_checkout_for_admin() |
|
| 355 | - { |
|
| 356 | - EED_Single_Page_Checkout::load_request_handler(); |
|
| 357 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 358 | - EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
| 359 | - EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
| 360 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 361 | - EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
| 362 | - return EE_Registry::instance()->REQ->get_output(); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * process_registration_from_admin |
|
| 369 | - * |
|
| 370 | - * @access public |
|
| 371 | - * @return \EE_Transaction |
|
| 372 | - * @throws EE_Error |
|
| 373 | - */ |
|
| 374 | - public static function process_registration_from_admin() |
|
| 375 | - { |
|
| 376 | - EED_Single_Page_Checkout::load_request_handler(); |
|
| 377 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 378 | - EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
| 379 | - EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
| 380 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 381 | - if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
| 382 | - $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
| 383 | - if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
| 384 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
| 385 | - if ($final_reg_step->process_reg_step()) { |
|
| 386 | - $final_reg_step->set_completed(); |
|
| 387 | - EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
| 388 | - return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - return null; |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - |
|
| 396 | - |
|
| 397 | - /** |
|
| 398 | - * run |
|
| 399 | - * |
|
| 400 | - * @access public |
|
| 401 | - * @param WP_Query $WP_Query |
|
| 402 | - * @return void |
|
| 403 | - * @throws EE_Error |
|
| 404 | - */ |
|
| 405 | - public function run($WP_Query) |
|
| 406 | - { |
|
| 407 | - if ( |
|
| 408 | - $WP_Query instanceof WP_Query |
|
| 409 | - && $WP_Query->is_main_query() |
|
| 410 | - && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
| 411 | - && $this->_is_reg_checkout() |
|
| 412 | - ) { |
|
| 413 | - $this->_initialize(); |
|
| 414 | - } |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - |
|
| 418 | - |
|
| 419 | - /** |
|
| 420 | - * determines whether current url matches reg page url |
|
| 421 | - * |
|
| 422 | - * @return bool |
|
| 423 | - */ |
|
| 424 | - protected function _is_reg_checkout() |
|
| 425 | - { |
|
| 426 | - // get current permalink for reg page without any extra query args |
|
| 427 | - $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
| 428 | - // get request URI for current request, but without the scheme or host |
|
| 429 | - $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
| 430 | - $current_request_uri = html_entity_decode($current_request_uri); |
|
| 431 | - // get array of query args from the current request URI |
|
| 432 | - $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
| 433 | - // grab page id if it is set |
|
| 434 | - $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
| 435 | - // and remove the page id from the query args (we will re-add it later) |
|
| 436 | - unset($query_args['page_id']); |
|
| 437 | - // now strip all query args from current request URI |
|
| 438 | - $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
| 439 | - // and re-add the page id if it was set |
|
| 440 | - if ($page_id) { |
|
| 441 | - $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
| 442 | - } |
|
| 443 | - // remove slashes and ? |
|
| 444 | - $current_request_uri = trim($current_request_uri, '?/'); |
|
| 445 | - // is current request URI part of the known full reg page URL ? |
|
| 446 | - return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - |
|
| 450 | - |
|
| 451 | - /** |
|
| 452 | - * @param WP_Query $wp_query |
|
| 453 | - * @return void |
|
| 454 | - * @throws EE_Error |
|
| 455 | - */ |
|
| 456 | - public static function init($wp_query) |
|
| 457 | - { |
|
| 458 | - EED_Single_Page_Checkout::instance()->run($wp_query); |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - |
|
| 462 | - |
|
| 463 | - /** |
|
| 464 | - * _initialize - initial module setup |
|
| 465 | - * |
|
| 466 | - * @access private |
|
| 467 | - * @throws EE_Error |
|
| 468 | - * @return void |
|
| 469 | - */ |
|
| 470 | - private function _initialize() |
|
| 471 | - { |
|
| 472 | - // ensure SPCO doesn't run twice |
|
| 473 | - if (EED_Single_Page_Checkout::$_initialized) { |
|
| 474 | - return; |
|
| 475 | - } |
|
| 476 | - try { |
|
| 477 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
| 478 | - $this->_verify_session(); |
|
| 479 | - // setup the EE_Checkout object |
|
| 480 | - $this->checkout = $this->_initialize_checkout(); |
|
| 481 | - // filter checkout |
|
| 482 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
| 483 | - // get the $_GET |
|
| 484 | - $this->_get_request_vars(); |
|
| 485 | - if ($this->_block_bots()) { |
|
| 486 | - return; |
|
| 487 | - } |
|
| 488 | - // filter continue_reg |
|
| 489 | - $this->checkout->continue_reg = apply_filters( |
|
| 490 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
| 491 | - true, |
|
| 492 | - $this->checkout |
|
| 493 | - ); |
|
| 494 | - // load the reg steps array |
|
| 495 | - if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
| 496 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 497 | - return; |
|
| 498 | - } |
|
| 499 | - // set the current step |
|
| 500 | - $this->checkout->set_current_step($this->checkout->step); |
|
| 501 | - // and the next step |
|
| 502 | - $this->checkout->set_next_step(); |
|
| 503 | - // verify that everything has been setup correctly |
|
| 504 | - if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
| 505 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 506 | - return; |
|
| 507 | - } |
|
| 508 | - // lock the transaction |
|
| 509 | - $this->checkout->transaction->lock(); |
|
| 510 | - // make sure all of our cached objects are added to their respective model entity mappers |
|
| 511 | - $this->checkout->refresh_all_entities(); |
|
| 512 | - // set amount owing |
|
| 513 | - $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
| 514 | - // initialize each reg step, which gives them the chance to potentially alter the process |
|
| 515 | - $this->_initialize_reg_steps(); |
|
| 516 | - // DEBUG LOG |
|
| 517 | - //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
| 518 | - // get reg form |
|
| 519 | - if( ! $this->_check_form_submission()) { |
|
| 520 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 521 | - return; |
|
| 522 | - } |
|
| 523 | - // checkout the action!!! |
|
| 524 | - $this->_process_form_action(); |
|
| 525 | - // add some style and make it dance |
|
| 526 | - $this->add_styles_and_scripts(); |
|
| 527 | - // kk... SPCO has successfully run |
|
| 528 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 529 | - // set no cache headers and constants |
|
| 530 | - EE_System::do_not_cache(); |
|
| 531 | - // add anchor |
|
| 532 | - add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
| 533 | - // remove transaction lock |
|
| 534 | - add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
| 535 | - } catch (Exception $e) { |
|
| 536 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 537 | - } |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - |
|
| 541 | - |
|
| 542 | - /** |
|
| 543 | - * _verify_session |
|
| 544 | - * checks that the session is valid and not expired |
|
| 545 | - * |
|
| 546 | - * @access private |
|
| 547 | - * @throws EE_Error |
|
| 548 | - */ |
|
| 549 | - private function _verify_session() |
|
| 550 | - { |
|
| 551 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 552 | - throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
| 553 | - } |
|
| 554 | - $clear_session_requested = filter_var( |
|
| 555 | - EE_Registry::instance()->REQ->get('clear_session', false), |
|
| 556 | - FILTER_VALIDATE_BOOLEAN |
|
| 557 | - ); |
|
| 558 | - // is session still valid ? |
|
| 559 | - if ($clear_session_requested |
|
| 560 | - || ( EE_Registry::instance()->SSN->expired() |
|
| 561 | - && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '' |
|
| 562 | - ) |
|
| 563 | - ) { |
|
| 564 | - $this->checkout = new EE_Checkout(); |
|
| 565 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 566 | - // EE_Registry::instance()->SSN->reset_cart(); |
|
| 567 | - // EE_Registry::instance()->SSN->reset_checkout(); |
|
| 568 | - // EE_Registry::instance()->SSN->reset_transaction(); |
|
| 569 | - if (! $clear_session_requested) { |
|
| 570 | - EE_Error::add_attention( |
|
| 571 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
| 572 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 573 | - ); |
|
| 574 | - } |
|
| 575 | - // EE_Registry::instance()->SSN->reset_expired(); |
|
| 576 | - } |
|
| 577 | - } |
|
| 578 | - |
|
| 579 | - |
|
| 580 | - |
|
| 581 | - /** |
|
| 582 | - * _initialize_checkout |
|
| 583 | - * loads and instantiates EE_Checkout |
|
| 584 | - * |
|
| 585 | - * @access private |
|
| 586 | - * @throws EE_Error |
|
| 587 | - * @return EE_Checkout |
|
| 588 | - */ |
|
| 589 | - private function _initialize_checkout() |
|
| 590 | - { |
|
| 591 | - // look in session for existing checkout |
|
| 592 | - /** @type EE_Checkout $checkout */ |
|
| 593 | - $checkout = EE_Registry::instance()->SSN->checkout(); |
|
| 594 | - // verify |
|
| 595 | - if ( ! $checkout instanceof EE_Checkout) { |
|
| 596 | - // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
| 597 | - $checkout = EE_Registry::instance()->load_file( |
|
| 598 | - SPCO_INC_PATH, |
|
| 599 | - 'EE_Checkout', |
|
| 600 | - 'class', array(), |
|
| 601 | - false |
|
| 602 | - ); |
|
| 603 | - } else { |
|
| 604 | - if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
| 605 | - $this->unlock_transaction(); |
|
| 606 | - wp_safe_redirect($checkout->redirect_url); |
|
| 607 | - exit(); |
|
| 608 | - } |
|
| 609 | - } |
|
| 610 | - $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
| 611 | - // verify again |
|
| 612 | - if ( ! $checkout instanceof EE_Checkout) { |
|
| 613 | - throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
| 614 | - } |
|
| 615 | - // reset anything that needs a clean slate for each request |
|
| 616 | - $checkout->reset_for_current_request(); |
|
| 617 | - return $checkout; |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - |
|
| 621 | - |
|
| 622 | - /** |
|
| 623 | - * _get_request_vars |
|
| 624 | - * |
|
| 625 | - * @access private |
|
| 626 | - * @return void |
|
| 627 | - * @throws EE_Error |
|
| 628 | - */ |
|
| 629 | - private function _get_request_vars() |
|
| 630 | - { |
|
| 631 | - // load classes |
|
| 632 | - EED_Single_Page_Checkout::load_request_handler(); |
|
| 633 | - //make sure this request is marked as belonging to EE |
|
| 634 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 635 | - // which step is being requested ? |
|
| 636 | - $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
| 637 | - // which step is being edited ? |
|
| 638 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
| 639 | - // and what we're doing on the current step |
|
| 640 | - $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
| 641 | - // timestamp |
|
| 642 | - $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
| 643 | - // returning to edit ? |
|
| 644 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
| 645 | - // add reg url link to registration query params |
|
| 646 | - if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
| 647 | - $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
| 648 | - } |
|
| 649 | - // or some other kind of revisit ? |
|
| 650 | - $this->checkout->revisit = filter_var( |
|
| 651 | - EE_Registry::instance()->REQ->get('revisit', false), |
|
| 652 | - FILTER_VALIDATE_BOOLEAN |
|
| 653 | - ); |
|
| 654 | - // and whether or not to generate a reg form for this request |
|
| 655 | - $this->checkout->generate_reg_form = filter_var( |
|
| 656 | - EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
| 657 | - FILTER_VALIDATE_BOOLEAN |
|
| 658 | - ); |
|
| 659 | - // and whether or not to process a reg form submission for this request |
|
| 660 | - $this->checkout->process_form_submission = filter_var( |
|
| 661 | - EE_Registry::instance()->REQ->get( |
|
| 662 | - 'process_form_submission', |
|
| 663 | - $this->checkout->action === 'process_reg_step' |
|
| 664 | - ), |
|
| 665 | - FILTER_VALIDATE_BOOLEAN |
|
| 666 | - ); |
|
| 667 | - $this->checkout->process_form_submission = filter_var( |
|
| 668 | - $this->checkout->action !== 'display_spco_reg_step' |
|
| 669 | - ? $this->checkout->process_form_submission |
|
| 670 | - : false, |
|
| 671 | - FILTER_VALIDATE_BOOLEAN |
|
| 672 | - ); |
|
| 673 | - // $this->_display_request_vars(); |
|
| 674 | - } |
|
| 675 | - |
|
| 676 | - |
|
| 677 | - |
|
| 678 | - /** |
|
| 679 | - * _display_request_vars |
|
| 680 | - * |
|
| 681 | - * @access protected |
|
| 682 | - * @return void |
|
| 683 | - */ |
|
| 684 | - protected function _display_request_vars() |
|
| 685 | - { |
|
| 686 | - if ( ! WP_DEBUG) { |
|
| 687 | - return; |
|
| 688 | - } |
|
| 689 | - EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
| 690 | - EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
| 691 | - EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
| 692 | - EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
| 693 | - EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
| 694 | - EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
| 695 | - EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
| 696 | - EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
| 697 | - } |
|
| 698 | - |
|
| 699 | - |
|
| 700 | - |
|
| 701 | - /** |
|
| 702 | - * _block_bots |
|
| 703 | - * checks that the incoming request has either of the following set: |
|
| 704 | - * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
| 705 | - * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
| 706 | - * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
| 707 | - * then where you coming from man? |
|
| 708 | - * |
|
| 709 | - * @return boolean |
|
| 710 | - */ |
|
| 711 | - private function _block_bots() |
|
| 712 | - { |
|
| 713 | - $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
| 714 | - if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
| 715 | - return true; |
|
| 716 | - } |
|
| 717 | - return false; |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - |
|
| 721 | - |
|
| 722 | - /** |
|
| 723 | - * _get_first_step |
|
| 724 | - * gets slug for first step in $_reg_steps_array |
|
| 725 | - * |
|
| 726 | - * @access private |
|
| 727 | - * @throws EE_Error |
|
| 728 | - * @return string |
|
| 729 | - */ |
|
| 730 | - private function _get_first_step() |
|
| 731 | - { |
|
| 732 | - $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
| 733 | - return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
| 734 | - } |
|
| 735 | - |
|
| 736 | - |
|
| 737 | - |
|
| 738 | - /** |
|
| 739 | - * _load_and_instantiate_reg_steps |
|
| 740 | - * instantiates each reg step based on the loaded reg_steps array |
|
| 741 | - * |
|
| 742 | - * @access private |
|
| 743 | - * @throws EE_Error |
|
| 744 | - * @return bool |
|
| 745 | - */ |
|
| 746 | - private function _load_and_instantiate_reg_steps() |
|
| 747 | - { |
|
| 748 | - do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
| 749 | - // have reg_steps already been instantiated ? |
|
| 750 | - if ( |
|
| 751 | - empty($this->checkout->reg_steps) |
|
| 752 | - || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
| 753 | - ) { |
|
| 754 | - // if not, then loop through raw reg steps array |
|
| 755 | - foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
| 756 | - if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
| 757 | - return false; |
|
| 758 | - } |
|
| 759 | - } |
|
| 760 | - EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true; |
|
| 761 | - EE_Registry::instance()->CFG->registration->reg_confirmation_last = true; |
|
| 762 | - // skip the registration_confirmation page ? |
|
| 763 | - if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
| 764 | - // just remove it from the reg steps array |
|
| 765 | - $this->checkout->remove_reg_step('registration_confirmation', false); |
|
| 766 | - } else if ( |
|
| 767 | - isset($this->checkout->reg_steps['registration_confirmation']) |
|
| 768 | - && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
| 769 | - ) { |
|
| 770 | - // set the order to something big like 100 |
|
| 771 | - $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
| 772 | - } |
|
| 773 | - // filter the array for good luck |
|
| 774 | - $this->checkout->reg_steps = apply_filters( |
|
| 775 | - 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
| 776 | - $this->checkout->reg_steps |
|
| 777 | - ); |
|
| 778 | - // finally re-sort based on the reg step class order properties |
|
| 779 | - $this->checkout->sort_reg_steps(); |
|
| 780 | - } else { |
|
| 781 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 782 | - // set all current step stati to FALSE |
|
| 783 | - $reg_step->set_is_current_step(false); |
|
| 784 | - } |
|
| 785 | - } |
|
| 786 | - if (empty($this->checkout->reg_steps)) { |
|
| 787 | - EE_Error::add_error( |
|
| 788 | - __('No Reg Steps were loaded..', 'event_espresso'), |
|
| 789 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 790 | - ); |
|
| 791 | - return false; |
|
| 792 | - } |
|
| 793 | - // make reg step details available to JS |
|
| 794 | - $this->checkout->set_reg_step_JSON_info(); |
|
| 795 | - return true; |
|
| 796 | - } |
|
| 797 | - |
|
| 798 | - |
|
| 799 | - |
|
| 800 | - /** |
|
| 801 | - * _load_and_instantiate_reg_step |
|
| 802 | - * |
|
| 803 | - * @access private |
|
| 804 | - * @param array $reg_step |
|
| 805 | - * @param int $order |
|
| 806 | - * @return bool |
|
| 807 | - */ |
|
| 808 | - private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
| 809 | - { |
|
| 810 | - // we need a file_path, class_name, and slug to add a reg step |
|
| 811 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 812 | - // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
| 813 | - if ( |
|
| 814 | - $this->checkout->reg_url_link |
|
| 815 | - && $this->checkout->step !== $reg_step['slug'] |
|
| 816 | - && $reg_step['slug'] !== 'finalize_registration' |
|
| 817 | - // normally at this point we would NOT load the reg step, but this filter can change that |
|
| 818 | - && apply_filters( |
|
| 819 | - 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
| 820 | - true, |
|
| 821 | - $reg_step, |
|
| 822 | - $this->checkout |
|
| 823 | - ) |
|
| 824 | - ) { |
|
| 825 | - return true; |
|
| 826 | - } |
|
| 827 | - // instantiate step class using file path and class name |
|
| 828 | - $reg_step_obj = EE_Registry::instance()->load_file( |
|
| 829 | - $reg_step['file_path'], |
|
| 830 | - $reg_step['class_name'], |
|
| 831 | - 'class', |
|
| 832 | - $this->checkout, |
|
| 833 | - false |
|
| 834 | - ); |
|
| 835 | - // did we gets the goods ? |
|
| 836 | - if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
| 837 | - // set reg step order based on config |
|
| 838 | - $reg_step_obj->set_order($order); |
|
| 839 | - // add instantiated reg step object to the master reg steps array |
|
| 840 | - $this->checkout->add_reg_step($reg_step_obj); |
|
| 841 | - } else { |
|
| 842 | - EE_Error::add_error( |
|
| 843 | - __('The current step could not be set.', 'event_espresso'), |
|
| 844 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 845 | - ); |
|
| 846 | - return false; |
|
| 847 | - } |
|
| 848 | - } else { |
|
| 849 | - if (WP_DEBUG) { |
|
| 850 | - EE_Error::add_error( |
|
| 851 | - sprintf( |
|
| 852 | - __( |
|
| 853 | - 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
| 854 | - 'event_espresso' |
|
| 855 | - ), |
|
| 856 | - isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
| 857 | - isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
| 858 | - isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
| 859 | - '<ul>', |
|
| 860 | - '<li>', |
|
| 861 | - '</li>', |
|
| 862 | - '</ul>' |
|
| 863 | - ), |
|
| 864 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 865 | - ); |
|
| 866 | - } |
|
| 867 | - return false; |
|
| 868 | - } |
|
| 869 | - return true; |
|
| 870 | - } |
|
| 871 | - |
|
| 872 | - |
|
| 873 | - /** |
|
| 874 | - * _verify_transaction_and_get_registrations |
|
| 875 | - * |
|
| 876 | - * @access private |
|
| 877 | - * @return bool |
|
| 878 | - * @throws InvalidDataTypeException |
|
| 879 | - * @throws InvalidEntityException |
|
| 880 | - * @throws EE_Error |
|
| 881 | - */ |
|
| 882 | - private function _verify_transaction_and_get_registrations() |
|
| 883 | - { |
|
| 884 | - // was there already a valid transaction in the checkout from the session ? |
|
| 885 | - if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 886 | - // get transaction from db or session |
|
| 887 | - $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
| 888 | - ? $this->_get_transaction_and_cart_for_previous_visit() |
|
| 889 | - : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
| 890 | - if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 891 | - EE_Error::add_error( |
|
| 892 | - __('Your Registration and Transaction information could not be retrieved from the db.', |
|
| 893 | - 'event_espresso'), |
|
| 894 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 895 | - ); |
|
| 896 | - $this->checkout->transaction = EE_Transaction::new_instance(); |
|
| 897 | - // add some style and make it dance |
|
| 898 | - $this->add_styles_and_scripts(); |
|
| 899 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 900 | - return false; |
|
| 901 | - } |
|
| 902 | - // and the registrations for the transaction |
|
| 903 | - $this->_get_registrations($this->checkout->transaction); |
|
| 904 | - } |
|
| 905 | - return true; |
|
| 906 | - } |
|
| 907 | - |
|
| 908 | - |
|
| 909 | - |
|
| 910 | - /** |
|
| 911 | - * _get_transaction_and_cart_for_previous_visit |
|
| 912 | - * |
|
| 913 | - * @access private |
|
| 914 | - * @return mixed EE_Transaction|NULL |
|
| 915 | - */ |
|
| 916 | - private function _get_transaction_and_cart_for_previous_visit() |
|
| 917 | - { |
|
| 918 | - /** @var $TXN_model EEM_Transaction */ |
|
| 919 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
| 920 | - // because the reg_url_link is present in the request, |
|
| 921 | - // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
| 922 | - $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
| 923 | - // verify transaction |
|
| 924 | - if ($transaction instanceof EE_Transaction) { |
|
| 925 | - // and get the cart that was used for that transaction |
|
| 926 | - $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
| 927 | - return $transaction; |
|
| 928 | - } |
|
| 929 | - EE_Error::add_error( |
|
| 930 | - __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
| 931 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 932 | - ); |
|
| 933 | - return null; |
|
| 934 | - |
|
| 935 | - } |
|
| 936 | - |
|
| 937 | - |
|
| 938 | - |
|
| 939 | - /** |
|
| 940 | - * _get_cart_for_transaction |
|
| 941 | - * |
|
| 942 | - * @access private |
|
| 943 | - * @param EE_Transaction $transaction |
|
| 944 | - * @return EE_Cart |
|
| 945 | - */ |
|
| 946 | - private function _get_cart_for_transaction($transaction) |
|
| 947 | - { |
|
| 948 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
| 949 | - } |
|
| 950 | - |
|
| 951 | - |
|
| 952 | - |
|
| 953 | - /** |
|
| 954 | - * get_cart_for_transaction |
|
| 955 | - * |
|
| 956 | - * @access public |
|
| 957 | - * @param EE_Transaction $transaction |
|
| 958 | - * @return EE_Cart |
|
| 959 | - */ |
|
| 960 | - public function get_cart_for_transaction(EE_Transaction $transaction) |
|
| 961 | - { |
|
| 962 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
| 963 | - } |
|
| 964 | - |
|
| 965 | - |
|
| 966 | - |
|
| 967 | - /** |
|
| 968 | - * _get_transaction_and_cart_for_current_session |
|
| 969 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 970 | - * |
|
| 971 | - * @access private |
|
| 972 | - * @return EE_Transaction |
|
| 973 | - * @throws EE_Error |
|
| 974 | - */ |
|
| 975 | - private function _get_cart_for_current_session_and_setup_new_transaction() |
|
| 976 | - { |
|
| 977 | - // if there's no transaction, then this is the FIRST visit to SPCO |
|
| 978 | - // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
| 979 | - $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
| 980 | - // and then create a new transaction |
|
| 981 | - $transaction = $this->_initialize_transaction(); |
|
| 982 | - // verify transaction |
|
| 983 | - if ($transaction instanceof EE_Transaction) { |
|
| 984 | - // save it so that we have an ID for other objects to use |
|
| 985 | - $transaction->save(); |
|
| 986 | - // and save TXN data to the cart |
|
| 987 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 988 | - } else { |
|
| 989 | - EE_Error::add_error( |
|
| 990 | - __('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
| 991 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 992 | - ); |
|
| 993 | - } |
|
| 994 | - return $transaction; |
|
| 995 | - } |
|
| 996 | - |
|
| 997 | - |
|
| 998 | - |
|
| 999 | - /** |
|
| 1000 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 1001 | - * |
|
| 1002 | - * @access private |
|
| 1003 | - * @return mixed EE_Transaction|NULL |
|
| 1004 | - */ |
|
| 1005 | - private function _initialize_transaction() |
|
| 1006 | - { |
|
| 1007 | - try { |
|
| 1008 | - // ensure cart totals have been calculated |
|
| 1009 | - $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
| 1010 | - // grab the cart grand total |
|
| 1011 | - $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
| 1012 | - // create new TXN |
|
| 1013 | - $transaction = EE_Transaction::new_instance( |
|
| 1014 | - array( |
|
| 1015 | - 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
| 1016 | - 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
| 1017 | - 'TXN_paid' => 0, |
|
| 1018 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
| 1019 | - ) |
|
| 1020 | - ); |
|
| 1021 | - // save it so that we have an ID for other objects to use |
|
| 1022 | - $transaction->save(); |
|
| 1023 | - // set cron job for following up on TXNs after their session has expired |
|
| 1024 | - EE_Cron_Tasks::schedule_expired_transaction_check( |
|
| 1025 | - EE_Registry::instance()->SSN->expiration() + 1, |
|
| 1026 | - $transaction->ID() |
|
| 1027 | - ); |
|
| 1028 | - return $transaction; |
|
| 1029 | - } catch (Exception $e) { |
|
| 1030 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1031 | - } |
|
| 1032 | - return null; |
|
| 1033 | - } |
|
| 1034 | - |
|
| 1035 | - |
|
| 1036 | - /** |
|
| 1037 | - * _get_registrations |
|
| 1038 | - * |
|
| 1039 | - * @access private |
|
| 1040 | - * @param EE_Transaction $transaction |
|
| 1041 | - * @return void |
|
| 1042 | - * @throws InvalidDataTypeException |
|
| 1043 | - * @throws InvalidEntityException |
|
| 1044 | - * @throws EE_Error |
|
| 1045 | - */ |
|
| 1046 | - private function _get_registrations(EE_Transaction $transaction) |
|
| 1047 | - { |
|
| 1048 | - // first step: grab the registrants { : o |
|
| 1049 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
| 1050 | - $this->checkout->total_ticket_count = count($registrations); |
|
| 1051 | - // verify registrations have been set |
|
| 1052 | - if (empty($registrations)) { |
|
| 1053 | - // if no cached registrations, then check the db |
|
| 1054 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
| 1055 | - // still nothing ? well as long as this isn't a revisit |
|
| 1056 | - if (empty($registrations) && ! $this->checkout->revisit) { |
|
| 1057 | - // generate new registrations from scratch |
|
| 1058 | - $registrations = $this->_initialize_registrations($transaction); |
|
| 1059 | - } |
|
| 1060 | - } |
|
| 1061 | - // sort by their original registration order |
|
| 1062 | - usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
| 1063 | - // then loop thru the array |
|
| 1064 | - foreach ($registrations as $registration) { |
|
| 1065 | - // verify each registration |
|
| 1066 | - if ($registration instanceof EE_Registration) { |
|
| 1067 | - // we display all attendee info for the primary registrant |
|
| 1068 | - if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
| 1069 | - && $registration->is_primary_registrant() |
|
| 1070 | - ) { |
|
| 1071 | - $this->checkout->primary_revisit = true; |
|
| 1072 | - break; |
|
| 1073 | - } |
|
| 1074 | - if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
| 1075 | - // but hide info if it doesn't belong to you |
|
| 1076 | - $transaction->clear_cache('Registration', $registration->ID()); |
|
| 1077 | - $this->checkout->total_ticket_count--; |
|
| 1078 | - } |
|
| 1079 | - $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
| 1080 | - } |
|
| 1081 | - } |
|
| 1082 | - } |
|
| 1083 | - |
|
| 1084 | - |
|
| 1085 | - /** |
|
| 1086 | - * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
| 1087 | - * |
|
| 1088 | - * @access private |
|
| 1089 | - * @param EE_Transaction $transaction |
|
| 1090 | - * @return array |
|
| 1091 | - * @throws InvalidDataTypeException |
|
| 1092 | - * @throws InvalidEntityException |
|
| 1093 | - * @throws EE_Error |
|
| 1094 | - */ |
|
| 1095 | - private function _initialize_registrations(EE_Transaction $transaction) |
|
| 1096 | - { |
|
| 1097 | - $att_nmbr = 0; |
|
| 1098 | - $registrations = array(); |
|
| 1099 | - if ($transaction instanceof EE_Transaction) { |
|
| 1100 | - /** @type EE_Registration_Processor $registration_processor */ |
|
| 1101 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 1102 | - $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
| 1103 | - // now let's add the cart items to the $transaction |
|
| 1104 | - foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
| 1105 | - //do the following for each ticket of this type they selected |
|
| 1106 | - for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
| 1107 | - $att_nmbr++; |
|
| 1108 | - /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
| 1109 | - $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
| 1110 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 1111 | - array( |
|
| 1112 | - $transaction, |
|
| 1113 | - $line_item, |
|
| 1114 | - $att_nmbr, |
|
| 1115 | - $this->checkout->total_ticket_count, |
|
| 1116 | - ) |
|
| 1117 | - ); |
|
| 1118 | - // override capabilities for frontend registrations |
|
| 1119 | - if ( ! is_admin()) { |
|
| 1120 | - $CreateRegistrationCommand->setCapCheck( |
|
| 1121 | - new PublicCapabilities('', 'create_new_registration') |
|
| 1122 | - ); |
|
| 1123 | - } |
|
| 1124 | - $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
| 1125 | - if ( ! $registration instanceof EE_Registration) { |
|
| 1126 | - throw new InvalidEntityException($registration, 'EE_Registration'); |
|
| 1127 | - } |
|
| 1128 | - $registrations[ $registration->ID() ] = $registration; |
|
| 1129 | - } |
|
| 1130 | - } |
|
| 1131 | - $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
| 1132 | - } |
|
| 1133 | - return $registrations; |
|
| 1134 | - } |
|
| 1135 | - |
|
| 1136 | - |
|
| 1137 | - |
|
| 1138 | - /** |
|
| 1139 | - * sorts registrations by REG_count |
|
| 1140 | - * |
|
| 1141 | - * @access public |
|
| 1142 | - * @param EE_Registration $reg_A |
|
| 1143 | - * @param EE_Registration $reg_B |
|
| 1144 | - * @return int |
|
| 1145 | - */ |
|
| 1146 | - public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
| 1147 | - { |
|
| 1148 | - // this shouldn't ever happen within the same TXN, but oh well |
|
| 1149 | - if ($reg_A->count() === $reg_B->count()) { |
|
| 1150 | - return 0; |
|
| 1151 | - } |
|
| 1152 | - return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
| 1153 | - } |
|
| 1154 | - |
|
| 1155 | - |
|
| 1156 | - |
|
| 1157 | - /** |
|
| 1158 | - * _final_verifications |
|
| 1159 | - * just makes sure that everything is set up correctly before proceeding |
|
| 1160 | - * |
|
| 1161 | - * @access private |
|
| 1162 | - * @return bool |
|
| 1163 | - * @throws EE_Error |
|
| 1164 | - */ |
|
| 1165 | - private function _final_verifications() |
|
| 1166 | - { |
|
| 1167 | - // filter checkout |
|
| 1168 | - $this->checkout = apply_filters( |
|
| 1169 | - 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
| 1170 | - $this->checkout |
|
| 1171 | - ); |
|
| 1172 | - //verify that current step is still set correctly |
|
| 1173 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
| 1174 | - EE_Error::add_error( |
|
| 1175 | - __('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1176 | - __FILE__, |
|
| 1177 | - __FUNCTION__, |
|
| 1178 | - __LINE__ |
|
| 1179 | - ); |
|
| 1180 | - return false; |
|
| 1181 | - } |
|
| 1182 | - // if returning to SPCO, then verify that primary registrant is set |
|
| 1183 | - if ( ! empty($this->checkout->reg_url_link)) { |
|
| 1184 | - $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
| 1185 | - if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1186 | - EE_Error::add_error( |
|
| 1187 | - __('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1188 | - __FILE__, |
|
| 1189 | - __FUNCTION__, |
|
| 1190 | - __LINE__ |
|
| 1191 | - ); |
|
| 1192 | - return false; |
|
| 1193 | - } |
|
| 1194 | - $valid_registrant = null; |
|
| 1195 | - foreach ( |
|
| 1196 | - $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration |
|
| 1197 | - ) { |
|
| 1198 | - if ( |
|
| 1199 | - $registration instanceof EE_Registration |
|
| 1200 | - && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
| 1201 | - ) { |
|
| 1202 | - $valid_registrant = $registration; |
|
| 1203 | - } |
|
| 1204 | - } |
|
| 1205 | - if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1206 | - // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
| 1207 | - if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
| 1208 | - // clear the session, mark the checkout as unverified, and try again |
|
| 1209 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 1210 | - EED_Single_Page_Checkout::$_initialized = false; |
|
| 1211 | - EED_Single_Page_Checkout::$_checkout_verified = false; |
|
| 1212 | - $this->_initialize(); |
|
| 1213 | - EE_Error::reset_notices(); |
|
| 1214 | - return false; |
|
| 1215 | - } |
|
| 1216 | - EE_Error::add_error( |
|
| 1217 | - __( |
|
| 1218 | - 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
| 1219 | - 'event_espresso' |
|
| 1220 | - ), |
|
| 1221 | - __FILE__, |
|
| 1222 | - __FUNCTION__, |
|
| 1223 | - __LINE__ |
|
| 1224 | - ); |
|
| 1225 | - return false; |
|
| 1226 | - } |
|
| 1227 | - } |
|
| 1228 | - // now that things have been kinda sufficiently verified, |
|
| 1229 | - // let's add the checkout to the session so that it's available to other systems |
|
| 1230 | - EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
| 1231 | - return true; |
|
| 1232 | - } |
|
| 1233 | - |
|
| 1234 | - |
|
| 1235 | - |
|
| 1236 | - /** |
|
| 1237 | - * _initialize_reg_steps |
|
| 1238 | - * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
| 1239 | - * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
| 1240 | - * |
|
| 1241 | - * @access private |
|
| 1242 | - * @param bool $reinitializing |
|
| 1243 | - * @throws EE_Error |
|
| 1244 | - */ |
|
| 1245 | - private function _initialize_reg_steps($reinitializing = false) |
|
| 1246 | - { |
|
| 1247 | - $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
| 1248 | - // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
| 1249 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 1250 | - if ( ! $reg_step->initialize_reg_step()) { |
|
| 1251 | - // if not initialized then maybe this step is being removed... |
|
| 1252 | - if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
| 1253 | - // if it was the current step, then we need to start over here |
|
| 1254 | - $this->_initialize_reg_steps(true); |
|
| 1255 | - return; |
|
| 1256 | - } |
|
| 1257 | - continue; |
|
| 1258 | - } |
|
| 1259 | - // add css and JS for current step |
|
| 1260 | - $reg_step->enqueue_styles_and_scripts(); |
|
| 1261 | - // i18n |
|
| 1262 | - $reg_step->translate_js_strings(); |
|
| 1263 | - if ($reg_step->is_current_step()) { |
|
| 1264 | - // the text that appears on the reg step form submit button |
|
| 1265 | - $reg_step->set_submit_button_text(); |
|
| 1266 | - } |
|
| 1267 | - } |
|
| 1268 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
| 1269 | - do_action( |
|
| 1270 | - "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
| 1271 | - $this->checkout->current_step |
|
| 1272 | - ); |
|
| 1273 | - } |
|
| 1274 | - |
|
| 1275 | - |
|
| 1276 | - |
|
| 1277 | - /** |
|
| 1278 | - * _check_form_submission |
|
| 1279 | - * |
|
| 1280 | - * @access private |
|
| 1281 | - * @return boolean |
|
| 1282 | - */ |
|
| 1283 | - private function _check_form_submission() |
|
| 1284 | - { |
|
| 1285 | - //does this request require the reg form to be generated ? |
|
| 1286 | - if ($this->checkout->generate_reg_form) { |
|
| 1287 | - // ever heard that song by Blue Rodeo ? |
|
| 1288 | - try { |
|
| 1289 | - $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
| 1290 | - // if not displaying a form, then check for form submission |
|
| 1291 | - if ( |
|
| 1292 | - $this->checkout->process_form_submission |
|
| 1293 | - && $this->checkout->current_step->reg_form->was_submitted() |
|
| 1294 | - ) { |
|
| 1295 | - // clear out any old data in case this step is being run again |
|
| 1296 | - $this->checkout->current_step->set_valid_data(array()); |
|
| 1297 | - // capture submitted form data |
|
| 1298 | - $this->checkout->current_step->reg_form->receive_form_submission( |
|
| 1299 | - apply_filters( |
|
| 1300 | - 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
| 1301 | - EE_Registry::instance()->REQ->params(), |
|
| 1302 | - $this->checkout |
|
| 1303 | - ) |
|
| 1304 | - ); |
|
| 1305 | - // validate submitted form data |
|
| 1306 | - if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
| 1307 | - // thou shall not pass !!! |
|
| 1308 | - $this->checkout->continue_reg = false; |
|
| 1309 | - // any form validation errors? |
|
| 1310 | - if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
| 1311 | - $submission_error_messages = array(); |
|
| 1312 | - // bad, bad, bad registrant |
|
| 1313 | - foreach ( |
|
| 1314 | - $this->checkout->current_step->reg_form->get_validation_errors_accumulated() |
|
| 1315 | - as $validation_error |
|
| 1316 | - ) { |
|
| 1317 | - if ($validation_error instanceof EE_Validation_Error) { |
|
| 1318 | - $submission_error_messages[] = sprintf( |
|
| 1319 | - __('%s : %s', 'event_espresso'), |
|
| 1320 | - $validation_error->get_form_section()->html_label_text(), |
|
| 1321 | - $validation_error->getMessage() |
|
| 1322 | - ); |
|
| 1323 | - } |
|
| 1324 | - } |
|
| 1325 | - EE_Error::add_error( |
|
| 1326 | - implode('<br />', $submission_error_messages), |
|
| 1327 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1328 | - ); |
|
| 1329 | - } |
|
| 1330 | - // well not really... what will happen is |
|
| 1331 | - // we'll just get redirected back to redo the current step |
|
| 1332 | - $this->go_to_next_step(); |
|
| 1333 | - return false; |
|
| 1334 | - } |
|
| 1335 | - } |
|
| 1336 | - } catch (EE_Error $e) { |
|
| 1337 | - $e->get_error(); |
|
| 1338 | - } |
|
| 1339 | - } |
|
| 1340 | - return true; |
|
| 1341 | - } |
|
| 1342 | - |
|
| 1343 | - |
|
| 1344 | - |
|
| 1345 | - /** |
|
| 1346 | - * _process_action |
|
| 1347 | - * |
|
| 1348 | - * @access private |
|
| 1349 | - * @return void |
|
| 1350 | - * @throws EE_Error |
|
| 1351 | - */ |
|
| 1352 | - private function _process_form_action() |
|
| 1353 | - { |
|
| 1354 | - // what cha wanna do? |
|
| 1355 | - switch ($this->checkout->action) { |
|
| 1356 | - // AJAX next step reg form |
|
| 1357 | - case 'display_spco_reg_step' : |
|
| 1358 | - $this->checkout->redirect = false; |
|
| 1359 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 1360 | - $this->checkout->json_response->set_reg_step_html( |
|
| 1361 | - $this->checkout->current_step->display_reg_form() |
|
| 1362 | - ); |
|
| 1363 | - } |
|
| 1364 | - break; |
|
| 1365 | - default : |
|
| 1366 | - // meh... do one of those other steps first |
|
| 1367 | - if ( |
|
| 1368 | - ! empty($this->checkout->action) |
|
| 1369 | - && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
| 1370 | - ) { |
|
| 1371 | - // dynamically creates hook point like: |
|
| 1372 | - // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
| 1373 | - do_action( |
|
| 1374 | - "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
| 1375 | - $this->checkout->current_step |
|
| 1376 | - ); |
|
| 1377 | - // call action on current step |
|
| 1378 | - if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
| 1379 | - // good registrant, you get to proceed |
|
| 1380 | - if ( |
|
| 1381 | - $this->checkout->current_step->success_message() !== '' |
|
| 1382 | - && apply_filters( |
|
| 1383 | - 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
| 1384 | - false |
|
| 1385 | - ) |
|
| 1386 | - ) { |
|
| 1387 | - EE_Error::add_success( |
|
| 1388 | - $this->checkout->current_step->success_message() |
|
| 1389 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
| 1390 | - ); |
|
| 1391 | - } |
|
| 1392 | - // pack it up, pack it in... |
|
| 1393 | - $this->_setup_redirect(); |
|
| 1394 | - } |
|
| 1395 | - // dynamically creates hook point like: |
|
| 1396 | - // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
| 1397 | - do_action( |
|
| 1398 | - "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
| 1399 | - $this->checkout->current_step |
|
| 1400 | - ); |
|
| 1401 | - } else { |
|
| 1402 | - EE_Error::add_error( |
|
| 1403 | - sprintf( |
|
| 1404 | - __( |
|
| 1405 | - 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
| 1406 | - 'event_espresso' |
|
| 1407 | - ), |
|
| 1408 | - $this->checkout->action, |
|
| 1409 | - $this->checkout->current_step->name() |
|
| 1410 | - ), |
|
| 1411 | - __FILE__, |
|
| 1412 | - __FUNCTION__, |
|
| 1413 | - __LINE__ |
|
| 1414 | - ); |
|
| 1415 | - } |
|
| 1416 | - // end default |
|
| 1417 | - } |
|
| 1418 | - // store our progress so far |
|
| 1419 | - $this->checkout->stash_transaction_and_checkout(); |
|
| 1420 | - // advance to the next step! If you pass GO, collect $200 |
|
| 1421 | - $this->go_to_next_step(); |
|
| 1422 | - } |
|
| 1423 | - |
|
| 1424 | - |
|
| 1425 | - |
|
| 1426 | - /** |
|
| 1427 | - * add_styles_and_scripts |
|
| 1428 | - * |
|
| 1429 | - * @access public |
|
| 1430 | - * @return void |
|
| 1431 | - */ |
|
| 1432 | - public function add_styles_and_scripts() |
|
| 1433 | - { |
|
| 1434 | - // i18n |
|
| 1435 | - $this->translate_js_strings(); |
|
| 1436 | - if ($this->checkout->admin_request) { |
|
| 1437 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1438 | - } else { |
|
| 1439 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1440 | - } |
|
| 1441 | - } |
|
| 1442 | - |
|
| 1443 | - |
|
| 1444 | - |
|
| 1445 | - /** |
|
| 1446 | - * translate_js_strings |
|
| 1447 | - * |
|
| 1448 | - * @access public |
|
| 1449 | - * @return void |
|
| 1450 | - */ |
|
| 1451 | - public function translate_js_strings() |
|
| 1452 | - { |
|
| 1453 | - EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
| 1454 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
| 1455 | - EE_Registry::$i18n_js_strings['server_error'] = __( |
|
| 1456 | - 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
| 1457 | - 'event_espresso' |
|
| 1458 | - ); |
|
| 1459 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( |
|
| 1460 | - 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
| 1461 | - 'event_espresso' |
|
| 1462 | - ); |
|
| 1463 | - EE_Registry::$i18n_js_strings['validation_error'] = __( |
|
| 1464 | - 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
| 1465 | - 'event_espresso' |
|
| 1466 | - ); |
|
| 1467 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( |
|
| 1468 | - 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
| 1469 | - 'event_espresso' |
|
| 1470 | - ); |
|
| 1471 | - EE_Registry::$i18n_js_strings['reg_step_error'] = __( |
|
| 1472 | - 'This registration step could not be completed. Please refresh the page and try again.', |
|
| 1473 | - 'event_espresso' |
|
| 1474 | - ); |
|
| 1475 | - EE_Registry::$i18n_js_strings['invalid_coupon'] = __( |
|
| 1476 | - 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
| 1477 | - 'event_espresso' |
|
| 1478 | - ); |
|
| 1479 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
| 1480 | - __( |
|
| 1481 | - 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
| 1482 | - 'event_espresso' |
|
| 1483 | - ), |
|
| 1484 | - '<br/>', |
|
| 1485 | - '<br/>' |
|
| 1486 | - ); |
|
| 1487 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
| 1488 | - EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
| 1489 | - EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
| 1490 | - EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
| 1491 | - EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
| 1492 | - EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
| 1493 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
| 1494 | - EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
| 1495 | - EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
| 1496 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
| 1497 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
| 1498 | - EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
| 1499 | - EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
| 1500 | - EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
| 1501 | - EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
| 1502 | - EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
| 1503 | - EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
| 1504 | - EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
| 1505 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
| 1506 | - __( |
|
| 1507 | - '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', |
|
| 1508 | - 'event_espresso' |
|
| 1509 | - ), |
|
| 1510 | - '<h4 class="important-notice">', |
|
| 1511 | - '</h4>', |
|
| 1512 | - '<br />', |
|
| 1513 | - '<p>', |
|
| 1514 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 1515 | - '">', |
|
| 1516 | - '</a>', |
|
| 1517 | - '</p>' |
|
| 1518 | - ); |
|
| 1519 | - EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
| 1520 | - 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
| 1521 | - true |
|
| 1522 | - ); |
|
| 1523 | - EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
| 1524 | - apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
| 1525 | - ); |
|
| 1526 | - EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
| 1527 | - 'M d, Y H:i:s', |
|
| 1528 | - EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
| 1529 | - ); |
|
| 1530 | - } |
|
| 1531 | - |
|
| 1532 | - |
|
| 1533 | - |
|
| 1534 | - /** |
|
| 1535 | - * enqueue_styles_and_scripts |
|
| 1536 | - * |
|
| 1537 | - * @access public |
|
| 1538 | - * @return void |
|
| 1539 | - * @throws EE_Error |
|
| 1540 | - */ |
|
| 1541 | - public function enqueue_styles_and_scripts() |
|
| 1542 | - { |
|
| 1543 | - // load css |
|
| 1544 | - wp_register_style( |
|
| 1545 | - 'single_page_checkout', |
|
| 1546 | - SPCO_CSS_URL . 'single_page_checkout.css', |
|
| 1547 | - array('espresso_default'), |
|
| 1548 | - EVENT_ESPRESSO_VERSION |
|
| 1549 | - ); |
|
| 1550 | - wp_enqueue_style('single_page_checkout'); |
|
| 1551 | - // load JS |
|
| 1552 | - wp_register_script( |
|
| 1553 | - 'jquery_plugin', |
|
| 1554 | - EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', |
|
| 1555 | - array('jquery'), |
|
| 1556 | - '1.0.1', |
|
| 1557 | - true |
|
| 1558 | - ); |
|
| 1559 | - wp_register_script( |
|
| 1560 | - 'jquery_countdown', |
|
| 1561 | - EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', |
|
| 1562 | - array('jquery_plugin'), |
|
| 1563 | - '2.0.2', |
|
| 1564 | - true |
|
| 1565 | - ); |
|
| 1566 | - wp_register_script( |
|
| 1567 | - 'single_page_checkout', |
|
| 1568 | - SPCO_JS_URL . 'single_page_checkout.js', |
|
| 1569 | - array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), |
|
| 1570 | - EVENT_ESPRESSO_VERSION, |
|
| 1571 | - true |
|
| 1572 | - ); |
|
| 1573 | - if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
| 1574 | - $this->checkout->registration_form->enqueue_js(); |
|
| 1575 | - } |
|
| 1576 | - if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
| 1577 | - $this->checkout->current_step->reg_form->enqueue_js(); |
|
| 1578 | - } |
|
| 1579 | - wp_enqueue_script('single_page_checkout'); |
|
| 1580 | - /** |
|
| 1581 | - * global action hook for enqueueing styles and scripts with |
|
| 1582 | - * spco calls. |
|
| 1583 | - */ |
|
| 1584 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
| 1585 | - /** |
|
| 1586 | - * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
| 1587 | - * The hook will end up being something like: |
|
| 1588 | - * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
| 1589 | - */ |
|
| 1590 | - do_action( |
|
| 1591 | - 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
| 1592 | - $this |
|
| 1593 | - ); |
|
| 1594 | - } |
|
| 1595 | - |
|
| 1596 | - |
|
| 1597 | - |
|
| 1598 | - /** |
|
| 1599 | - * display the Registration Single Page Checkout Form |
|
| 1600 | - * |
|
| 1601 | - * @access private |
|
| 1602 | - * @return void |
|
| 1603 | - * @throws EE_Error |
|
| 1604 | - */ |
|
| 1605 | - private function _display_spco_reg_form() |
|
| 1606 | - { |
|
| 1607 | - // if registering via the admin, just display the reg form for the current step |
|
| 1608 | - if ($this->checkout->admin_request) { |
|
| 1609 | - EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
| 1610 | - } else { |
|
| 1611 | - // add powered by EE msg |
|
| 1612 | - add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
| 1613 | - $empty_cart = count( |
|
| 1614 | - $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) |
|
| 1615 | - ) < 1; |
|
| 1616 | - EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
| 1617 | - $cookies_not_set_msg = ''; |
|
| 1618 | - if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
| 1619 | - $cookies_not_set_msg = apply_filters( |
|
| 1620 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
| 1621 | - sprintf( |
|
| 1622 | - __( |
|
| 1623 | - '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
| 1624 | - 'event_espresso' |
|
| 1625 | - ), |
|
| 1626 | - '<div class="ee-attention">', |
|
| 1627 | - '</div>', |
|
| 1628 | - '<h6 class="important-notice">', |
|
| 1629 | - '</h6>', |
|
| 1630 | - '<p>', |
|
| 1631 | - '</p>', |
|
| 1632 | - '<br />', |
|
| 1633 | - '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">', |
|
| 1634 | - '</a>' |
|
| 1635 | - ) |
|
| 1636 | - ); |
|
| 1637 | - } |
|
| 1638 | - $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
| 1639 | - array( |
|
| 1640 | - 'name' => 'single-page-checkout', |
|
| 1641 | - 'html_id' => 'ee-single-page-checkout-dv', |
|
| 1642 | - 'layout_strategy' => |
|
| 1643 | - new EE_Template_Layout( |
|
| 1644 | - array( |
|
| 1645 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
| 1646 | - 'template_args' => array( |
|
| 1647 | - 'empty_cart' => $empty_cart, |
|
| 1648 | - 'revisit' => $this->checkout->revisit, |
|
| 1649 | - 'reg_steps' => $this->checkout->reg_steps, |
|
| 1650 | - 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
| 1651 | - ? $this->checkout->next_step->slug() |
|
| 1652 | - : '', |
|
| 1653 | - 'cancel_page_url' => $this->checkout->cancel_page_url, |
|
| 1654 | - 'empty_msg' => apply_filters( |
|
| 1655 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
| 1656 | - sprintf( |
|
| 1657 | - __( |
|
| 1658 | - 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
| 1659 | - 'event_espresso' |
|
| 1660 | - ), |
|
| 1661 | - '<a href="' |
|
| 1662 | - . get_post_type_archive_link('espresso_events') |
|
| 1663 | - . '" title="', |
|
| 1664 | - '">', |
|
| 1665 | - '</a>' |
|
| 1666 | - ) |
|
| 1667 | - ), |
|
| 1668 | - 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
| 1669 | - 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
| 1670 | - 'session_expiration' => gmdate( |
|
| 1671 | - 'M d, Y H:i:s', |
|
| 1672 | - EE_Registry::instance()->SSN->expiration() |
|
| 1673 | - + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
| 1674 | - ), |
|
| 1675 | - ), |
|
| 1676 | - ) |
|
| 1677 | - ), |
|
| 1678 | - ) |
|
| 1679 | - ); |
|
| 1680 | - // load template and add to output sent that gets filtered into the_content() |
|
| 1681 | - EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
| 1682 | - } |
|
| 1683 | - } |
|
| 1684 | - |
|
| 1685 | - |
|
| 1686 | - |
|
| 1687 | - /** |
|
| 1688 | - * add_extra_finalize_registration_inputs |
|
| 1689 | - * |
|
| 1690 | - * @access public |
|
| 1691 | - * @param $next_step |
|
| 1692 | - * @internal param string $label |
|
| 1693 | - * @return void |
|
| 1694 | - */ |
|
| 1695 | - public function add_extra_finalize_registration_inputs($next_step) |
|
| 1696 | - { |
|
| 1697 | - if ($next_step === 'finalize_registration') { |
|
| 1698 | - echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
| 1699 | - } |
|
| 1700 | - } |
|
| 1701 | - |
|
| 1702 | - |
|
| 1703 | - |
|
| 1704 | - /** |
|
| 1705 | - * display_registration_footer |
|
| 1706 | - * |
|
| 1707 | - * @access public |
|
| 1708 | - * @return string |
|
| 1709 | - */ |
|
| 1710 | - public static function display_registration_footer() |
|
| 1711 | - { |
|
| 1712 | - if ( |
|
| 1713 | - apply_filters( |
|
| 1714 | - 'FHEE__EE_Front__Controller__show_reg_footer', |
|
| 1715 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
| 1716 | - ) |
|
| 1717 | - ) { |
|
| 1718 | - add_filter( |
|
| 1719 | - 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
| 1720 | - function ($url) { |
|
| 1721 | - return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
| 1722 | - } |
|
| 1723 | - ); |
|
| 1724 | - echo apply_filters( |
|
| 1725 | - 'FHEE__EE_Front_Controller__display_registration_footer', |
|
| 1726 | - \EEH_Template::powered_by_event_espresso( |
|
| 1727 | - '', |
|
| 1728 | - 'espresso-registration-footer-dv', |
|
| 1729 | - array('utm_content' => 'registration_checkout') |
|
| 1730 | - ) |
|
| 1731 | - ); |
|
| 1732 | - } |
|
| 1733 | - return ''; |
|
| 1734 | - } |
|
| 1735 | - |
|
| 1736 | - |
|
| 1737 | - |
|
| 1738 | - /** |
|
| 1739 | - * unlock_transaction |
|
| 1740 | - * |
|
| 1741 | - * @access public |
|
| 1742 | - * @return void |
|
| 1743 | - * @throws EE_Error |
|
| 1744 | - */ |
|
| 1745 | - public function unlock_transaction() |
|
| 1746 | - { |
|
| 1747 | - if ($this->checkout->transaction instanceof EE_Transaction) { |
|
| 1748 | - $this->checkout->transaction->unlock(); |
|
| 1749 | - } |
|
| 1750 | - } |
|
| 1751 | - |
|
| 1752 | - |
|
| 1753 | - |
|
| 1754 | - /** |
|
| 1755 | - * _setup_redirect |
|
| 1756 | - * |
|
| 1757 | - * @access private |
|
| 1758 | - * @return void |
|
| 1759 | - */ |
|
| 1760 | - private function _setup_redirect() |
|
| 1761 | - { |
|
| 1762 | - if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 1763 | - $this->checkout->redirect = true; |
|
| 1764 | - if (empty($this->checkout->redirect_url)) { |
|
| 1765 | - $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
| 1766 | - } |
|
| 1767 | - $this->checkout->redirect_url = apply_filters( |
|
| 1768 | - 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
| 1769 | - $this->checkout->redirect_url, |
|
| 1770 | - $this->checkout |
|
| 1771 | - ); |
|
| 1772 | - } |
|
| 1773 | - } |
|
| 1774 | - |
|
| 1775 | - |
|
| 1776 | - |
|
| 1777 | - /** |
|
| 1778 | - * handle ajax message responses and redirects |
|
| 1779 | - * |
|
| 1780 | - * @access public |
|
| 1781 | - * @return void |
|
| 1782 | - * @throws EE_Error |
|
| 1783 | - */ |
|
| 1784 | - public function go_to_next_step() |
|
| 1785 | - { |
|
| 1786 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 1787 | - // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
| 1788 | - $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
| 1789 | - } |
|
| 1790 | - $this->unlock_transaction(); |
|
| 1791 | - // just return for these conditions |
|
| 1792 | - if ( |
|
| 1793 | - $this->checkout->admin_request |
|
| 1794 | - || $this->checkout->action === 'redirect_form' |
|
| 1795 | - || $this->checkout->action === 'update_checkout' |
|
| 1796 | - ) { |
|
| 1797 | - return; |
|
| 1798 | - } |
|
| 1799 | - // AJAX response |
|
| 1800 | - $this->_handle_json_response(); |
|
| 1801 | - // redirect to next step or the Thank You page |
|
| 1802 | - $this->_handle_html_redirects(); |
|
| 1803 | - // hmmm... must be something wrong, so let's just display the form again ! |
|
| 1804 | - $this->_display_spco_reg_form(); |
|
| 1805 | - } |
|
| 1806 | - |
|
| 1807 | - |
|
| 1808 | - |
|
| 1809 | - /** |
|
| 1810 | - * _handle_json_response |
|
| 1811 | - * |
|
| 1812 | - * @access protected |
|
| 1813 | - * @return void |
|
| 1814 | - */ |
|
| 1815 | - protected function _handle_json_response() |
|
| 1816 | - { |
|
| 1817 | - // if this is an ajax request |
|
| 1818 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 1819 | - // DEBUG LOG |
|
| 1820 | - //$this->checkout->log( |
|
| 1821 | - // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1822 | - // array( |
|
| 1823 | - // 'json_response_redirect_url' => $this->checkout->json_response->redirect_url(), |
|
| 1824 | - // 'redirect' => $this->checkout->redirect, |
|
| 1825 | - // 'continue_reg' => $this->checkout->continue_reg, |
|
| 1826 | - // ) |
|
| 1827 | - //); |
|
| 1828 | - $this->checkout->json_response->set_registration_time_limit( |
|
| 1829 | - $this->checkout->get_registration_time_limit() |
|
| 1830 | - ); |
|
| 1831 | - $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
| 1832 | - // just send the ajax ( |
|
| 1833 | - $json_response = apply_filters( |
|
| 1834 | - 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
| 1835 | - $this->checkout->json_response |
|
| 1836 | - ); |
|
| 1837 | - echo $json_response; |
|
| 1838 | - exit(); |
|
| 1839 | - } |
|
| 1840 | - } |
|
| 1841 | - |
|
| 1842 | - |
|
| 1843 | - |
|
| 1844 | - /** |
|
| 1845 | - * _handle_redirects |
|
| 1846 | - * |
|
| 1847 | - * @access protected |
|
| 1848 | - * @return void |
|
| 1849 | - */ |
|
| 1850 | - protected function _handle_html_redirects() |
|
| 1851 | - { |
|
| 1852 | - // going somewhere ? |
|
| 1853 | - if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
| 1854 | - // store notices in a transient |
|
| 1855 | - EE_Error::get_notices(false, true, true); |
|
| 1856 | - // DEBUG LOG |
|
| 1857 | - //$this->checkout->log( |
|
| 1858 | - // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1859 | - // array( |
|
| 1860 | - // 'headers_sent' => headers_sent(), |
|
| 1861 | - // 'redirect_url' => $this->checkout->redirect_url, |
|
| 1862 | - // 'headers_list' => headers_list(), |
|
| 1863 | - // ) |
|
| 1864 | - //); |
|
| 1865 | - wp_safe_redirect($this->checkout->redirect_url); |
|
| 1866 | - exit(); |
|
| 1867 | - } |
|
| 1868 | - } |
|
| 1869 | - |
|
| 1870 | - |
|
| 1871 | - |
|
| 1872 | - /** |
|
| 1873 | - * set_checkout_anchor |
|
| 1874 | - * |
|
| 1875 | - * @access public |
|
| 1876 | - * @return void |
|
| 1877 | - */ |
|
| 1878 | - public function set_checkout_anchor() |
|
| 1879 | - { |
|
| 1880 | - echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
| 1881 | - } |
|
| 23 | + /** |
|
| 24 | + * $_initialized - has the SPCO controller already been initialized ? |
|
| 25 | + * |
|
| 26 | + * @access private |
|
| 27 | + * @var bool $_initialized |
|
| 28 | + */ |
|
| 29 | + private static $_initialized = false; |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
| 34 | + * |
|
| 35 | + * @access private |
|
| 36 | + * @var bool $_valid_checkout |
|
| 37 | + */ |
|
| 38 | + private static $_checkout_verified = true; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * $_reg_steps_array - holds initial array of reg steps |
|
| 42 | + * |
|
| 43 | + * @access private |
|
| 44 | + * @var array $_reg_steps_array |
|
| 45 | + */ |
|
| 46 | + private static $_reg_steps_array = array(); |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
| 50 | + * |
|
| 51 | + * @access public |
|
| 52 | + * @var EE_Checkout $checkout |
|
| 53 | + */ |
|
| 54 | + public $checkout; |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @return EED_Module|EED_Single_Page_Checkout |
|
| 60 | + */ |
|
| 61 | + public static function instance() |
|
| 62 | + { |
|
| 63 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
| 64 | + return parent::get_instance(__CLASS__); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @return EE_CART |
|
| 71 | + */ |
|
| 72 | + public function cart() |
|
| 73 | + { |
|
| 74 | + return $this->checkout->cart; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @return EE_Transaction |
|
| 81 | + */ |
|
| 82 | + public function transaction() |
|
| 83 | + { |
|
| 84 | + return $this->checkout->transaction; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 91 | + * |
|
| 92 | + * @access public |
|
| 93 | + * @return void |
|
| 94 | + * @throws EE_Error |
|
| 95 | + */ |
|
| 96 | + public static function set_hooks() |
|
| 97 | + { |
|
| 98 | + EED_Single_Page_Checkout::set_definitions(); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 105 | + * |
|
| 106 | + * @access public |
|
| 107 | + * @return void |
|
| 108 | + * @throws EE_Error |
|
| 109 | + */ |
|
| 110 | + public static function set_hooks_admin() |
|
| 111 | + { |
|
| 112 | + EED_Single_Page_Checkout::set_definitions(); |
|
| 113 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 114 | + return; |
|
| 115 | + } |
|
| 116 | + // going to start an output buffer in case anything gets accidentally output |
|
| 117 | + // that might disrupt our JSON response |
|
| 118 | + ob_start(); |
|
| 119 | + EED_Single_Page_Checkout::load_request_handler(); |
|
| 120 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
| 121 | + // set ajax hooks |
|
| 122 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 123 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 124 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 125 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 126 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 127 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * process ajax request |
|
| 134 | + * |
|
| 135 | + * @param string $ajax_action |
|
| 136 | + * @throws EE_Error |
|
| 137 | + */ |
|
| 138 | + public static function process_ajax_request($ajax_action) |
|
| 139 | + { |
|
| 140 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
| 141 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * ajax display registration step |
|
| 148 | + * |
|
| 149 | + * @throws EE_Error |
|
| 150 | + */ |
|
| 151 | + public static function display_reg_step() |
|
| 152 | + { |
|
| 153 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * ajax process registration step |
|
| 160 | + * |
|
| 161 | + * @throws EE_Error |
|
| 162 | + */ |
|
| 163 | + public static function process_reg_step() |
|
| 164 | + { |
|
| 165 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * ajax process registration step |
|
| 172 | + * |
|
| 173 | + * @throws EE_Error |
|
| 174 | + */ |
|
| 175 | + public static function update_reg_step() |
|
| 176 | + { |
|
| 177 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * update_checkout |
|
| 184 | + * |
|
| 185 | + * @access public |
|
| 186 | + * @return void |
|
| 187 | + * @throws EE_Error |
|
| 188 | + */ |
|
| 189 | + public static function update_checkout() |
|
| 190 | + { |
|
| 191 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * load_request_handler |
|
| 198 | + * |
|
| 199 | + * @access public |
|
| 200 | + * @return void |
|
| 201 | + */ |
|
| 202 | + public static function load_request_handler() |
|
| 203 | + { |
|
| 204 | + // load core Request_Handler class |
|
| 205 | + if (EE_Registry::instance()->REQ !== null) { |
|
| 206 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * set_definitions |
|
| 214 | + * |
|
| 215 | + * @access public |
|
| 216 | + * @return void |
|
| 217 | + * @throws EE_Error |
|
| 218 | + */ |
|
| 219 | + public static function set_definitions() |
|
| 220 | + { |
|
| 221 | + if(defined('SPCO_BASE_PATH')) { |
|
| 222 | + return; |
|
| 223 | + } |
|
| 224 | + define( |
|
| 225 | + 'SPCO_BASE_PATH', |
|
| 226 | + rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS |
|
| 227 | + ); |
|
| 228 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
| 229 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
| 230 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
| 231 | + define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
| 232 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
| 233 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
| 234 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
| 235 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
| 236 | + __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', |
|
| 237 | + 'event_espresso'), |
|
| 238 | + '<h4 class="important-notice">', |
|
| 239 | + '</h4>', |
|
| 240 | + '<br />', |
|
| 241 | + '<p>', |
|
| 242 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 243 | + '">', |
|
| 244 | + '</a>', |
|
| 245 | + '</p>' |
|
| 246 | + ); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * load_reg_steps |
|
| 253 | + * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
| 254 | + * |
|
| 255 | + * @access private |
|
| 256 | + * @throws EE_Error |
|
| 257 | + */ |
|
| 258 | + public static function load_reg_steps() |
|
| 259 | + { |
|
| 260 | + static $reg_steps_loaded = false; |
|
| 261 | + if ($reg_steps_loaded) { |
|
| 262 | + return; |
|
| 263 | + } |
|
| 264 | + // filter list of reg_steps |
|
| 265 | + $reg_steps_to_load = (array)apply_filters( |
|
| 266 | + 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
| 267 | + EED_Single_Page_Checkout::get_reg_steps() |
|
| 268 | + ); |
|
| 269 | + // sort by key (order) |
|
| 270 | + ksort($reg_steps_to_load); |
|
| 271 | + // loop through folders |
|
| 272 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
| 273 | + // we need a |
|
| 274 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 275 | + // copy over to the reg_steps_array |
|
| 276 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
| 277 | + // register custom key route for each reg step |
|
| 278 | + // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
| 279 | + EE_Config::register_route( |
|
| 280 | + $reg_step['slug'], |
|
| 281 | + 'EED_Single_Page_Checkout', |
|
| 282 | + 'run', |
|
| 283 | + 'step' |
|
| 284 | + ); |
|
| 285 | + // add AJAX or other hooks |
|
| 286 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
| 287 | + // setup autoloaders if necessary |
|
| 288 | + if ( ! class_exists($reg_step['class_name'])) { |
|
| 289 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
| 290 | + $reg_step['file_path'], |
|
| 291 | + true |
|
| 292 | + ); |
|
| 293 | + } |
|
| 294 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
| 295 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + $reg_steps_loaded = true; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * get_reg_steps |
|
| 307 | + * |
|
| 308 | + * @access public |
|
| 309 | + * @return array |
|
| 310 | + */ |
|
| 311 | + public static function get_reg_steps() |
|
| 312 | + { |
|
| 313 | + $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
| 314 | + if (empty($reg_steps)) { |
|
| 315 | + $reg_steps = array( |
|
| 316 | + 10 => array( |
|
| 317 | + 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
| 318 | + 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
| 319 | + 'slug' => 'attendee_information', |
|
| 320 | + 'has_hooks' => false, |
|
| 321 | + ), |
|
| 322 | + 20 => array( |
|
| 323 | + 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
| 324 | + 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
|
| 325 | + 'slug' => 'registration_confirmation', |
|
| 326 | + 'has_hooks' => false, |
|
| 327 | + ), |
|
| 328 | + 30 => array( |
|
| 329 | + 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
| 330 | + 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
| 331 | + 'slug' => 'payment_options', |
|
| 332 | + 'has_hooks' => true, |
|
| 333 | + ), |
|
| 334 | + 999 => array( |
|
| 335 | + 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
| 336 | + 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
| 337 | + 'slug' => 'finalize_registration', |
|
| 338 | + 'has_hooks' => false, |
|
| 339 | + ), |
|
| 340 | + ); |
|
| 341 | + } |
|
| 342 | + return $reg_steps; |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + |
|
| 346 | + |
|
| 347 | + /** |
|
| 348 | + * registration_checkout_for_admin |
|
| 349 | + * |
|
| 350 | + * @access public |
|
| 351 | + * @return string |
|
| 352 | + * @throws EE_Error |
|
| 353 | + */ |
|
| 354 | + public static function registration_checkout_for_admin() |
|
| 355 | + { |
|
| 356 | + EED_Single_Page_Checkout::load_request_handler(); |
|
| 357 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 358 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
| 359 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
| 360 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 361 | + EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
| 362 | + return EE_Registry::instance()->REQ->get_output(); |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * process_registration_from_admin |
|
| 369 | + * |
|
| 370 | + * @access public |
|
| 371 | + * @return \EE_Transaction |
|
| 372 | + * @throws EE_Error |
|
| 373 | + */ |
|
| 374 | + public static function process_registration_from_admin() |
|
| 375 | + { |
|
| 376 | + EED_Single_Page_Checkout::load_request_handler(); |
|
| 377 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 378 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
| 379 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
| 380 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 381 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
| 382 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
| 383 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
| 384 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
| 385 | + if ($final_reg_step->process_reg_step()) { |
|
| 386 | + $final_reg_step->set_completed(); |
|
| 387 | + EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
| 388 | + return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + return null; |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + |
|
| 396 | + |
|
| 397 | + /** |
|
| 398 | + * run |
|
| 399 | + * |
|
| 400 | + * @access public |
|
| 401 | + * @param WP_Query $WP_Query |
|
| 402 | + * @return void |
|
| 403 | + * @throws EE_Error |
|
| 404 | + */ |
|
| 405 | + public function run($WP_Query) |
|
| 406 | + { |
|
| 407 | + if ( |
|
| 408 | + $WP_Query instanceof WP_Query |
|
| 409 | + && $WP_Query->is_main_query() |
|
| 410 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
| 411 | + && $this->_is_reg_checkout() |
|
| 412 | + ) { |
|
| 413 | + $this->_initialize(); |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + |
|
| 418 | + |
|
| 419 | + /** |
|
| 420 | + * determines whether current url matches reg page url |
|
| 421 | + * |
|
| 422 | + * @return bool |
|
| 423 | + */ |
|
| 424 | + protected function _is_reg_checkout() |
|
| 425 | + { |
|
| 426 | + // get current permalink for reg page without any extra query args |
|
| 427 | + $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
| 428 | + // get request URI for current request, but without the scheme or host |
|
| 429 | + $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
| 430 | + $current_request_uri = html_entity_decode($current_request_uri); |
|
| 431 | + // get array of query args from the current request URI |
|
| 432 | + $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
| 433 | + // grab page id if it is set |
|
| 434 | + $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
| 435 | + // and remove the page id from the query args (we will re-add it later) |
|
| 436 | + unset($query_args['page_id']); |
|
| 437 | + // now strip all query args from current request URI |
|
| 438 | + $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
| 439 | + // and re-add the page id if it was set |
|
| 440 | + if ($page_id) { |
|
| 441 | + $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
| 442 | + } |
|
| 443 | + // remove slashes and ? |
|
| 444 | + $current_request_uri = trim($current_request_uri, '?/'); |
|
| 445 | + // is current request URI part of the known full reg page URL ? |
|
| 446 | + return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + |
|
| 450 | + |
|
| 451 | + /** |
|
| 452 | + * @param WP_Query $wp_query |
|
| 453 | + * @return void |
|
| 454 | + * @throws EE_Error |
|
| 455 | + */ |
|
| 456 | + public static function init($wp_query) |
|
| 457 | + { |
|
| 458 | + EED_Single_Page_Checkout::instance()->run($wp_query); |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + |
|
| 462 | + |
|
| 463 | + /** |
|
| 464 | + * _initialize - initial module setup |
|
| 465 | + * |
|
| 466 | + * @access private |
|
| 467 | + * @throws EE_Error |
|
| 468 | + * @return void |
|
| 469 | + */ |
|
| 470 | + private function _initialize() |
|
| 471 | + { |
|
| 472 | + // ensure SPCO doesn't run twice |
|
| 473 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
| 474 | + return; |
|
| 475 | + } |
|
| 476 | + try { |
|
| 477 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
| 478 | + $this->_verify_session(); |
|
| 479 | + // setup the EE_Checkout object |
|
| 480 | + $this->checkout = $this->_initialize_checkout(); |
|
| 481 | + // filter checkout |
|
| 482 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
| 483 | + // get the $_GET |
|
| 484 | + $this->_get_request_vars(); |
|
| 485 | + if ($this->_block_bots()) { |
|
| 486 | + return; |
|
| 487 | + } |
|
| 488 | + // filter continue_reg |
|
| 489 | + $this->checkout->continue_reg = apply_filters( |
|
| 490 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
| 491 | + true, |
|
| 492 | + $this->checkout |
|
| 493 | + ); |
|
| 494 | + // load the reg steps array |
|
| 495 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
| 496 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 497 | + return; |
|
| 498 | + } |
|
| 499 | + // set the current step |
|
| 500 | + $this->checkout->set_current_step($this->checkout->step); |
|
| 501 | + // and the next step |
|
| 502 | + $this->checkout->set_next_step(); |
|
| 503 | + // verify that everything has been setup correctly |
|
| 504 | + if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
| 505 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 506 | + return; |
|
| 507 | + } |
|
| 508 | + // lock the transaction |
|
| 509 | + $this->checkout->transaction->lock(); |
|
| 510 | + // make sure all of our cached objects are added to their respective model entity mappers |
|
| 511 | + $this->checkout->refresh_all_entities(); |
|
| 512 | + // set amount owing |
|
| 513 | + $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
| 514 | + // initialize each reg step, which gives them the chance to potentially alter the process |
|
| 515 | + $this->_initialize_reg_steps(); |
|
| 516 | + // DEBUG LOG |
|
| 517 | + //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
| 518 | + // get reg form |
|
| 519 | + if( ! $this->_check_form_submission()) { |
|
| 520 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 521 | + return; |
|
| 522 | + } |
|
| 523 | + // checkout the action!!! |
|
| 524 | + $this->_process_form_action(); |
|
| 525 | + // add some style and make it dance |
|
| 526 | + $this->add_styles_and_scripts(); |
|
| 527 | + // kk... SPCO has successfully run |
|
| 528 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 529 | + // set no cache headers and constants |
|
| 530 | + EE_System::do_not_cache(); |
|
| 531 | + // add anchor |
|
| 532 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
| 533 | + // remove transaction lock |
|
| 534 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
| 535 | + } catch (Exception $e) { |
|
| 536 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 537 | + } |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + |
|
| 541 | + |
|
| 542 | + /** |
|
| 543 | + * _verify_session |
|
| 544 | + * checks that the session is valid and not expired |
|
| 545 | + * |
|
| 546 | + * @access private |
|
| 547 | + * @throws EE_Error |
|
| 548 | + */ |
|
| 549 | + private function _verify_session() |
|
| 550 | + { |
|
| 551 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 552 | + throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
| 553 | + } |
|
| 554 | + $clear_session_requested = filter_var( |
|
| 555 | + EE_Registry::instance()->REQ->get('clear_session', false), |
|
| 556 | + FILTER_VALIDATE_BOOLEAN |
|
| 557 | + ); |
|
| 558 | + // is session still valid ? |
|
| 559 | + if ($clear_session_requested |
|
| 560 | + || ( EE_Registry::instance()->SSN->expired() |
|
| 561 | + && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '' |
|
| 562 | + ) |
|
| 563 | + ) { |
|
| 564 | + $this->checkout = new EE_Checkout(); |
|
| 565 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 566 | + // EE_Registry::instance()->SSN->reset_cart(); |
|
| 567 | + // EE_Registry::instance()->SSN->reset_checkout(); |
|
| 568 | + // EE_Registry::instance()->SSN->reset_transaction(); |
|
| 569 | + if (! $clear_session_requested) { |
|
| 570 | + EE_Error::add_attention( |
|
| 571 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
| 572 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 573 | + ); |
|
| 574 | + } |
|
| 575 | + // EE_Registry::instance()->SSN->reset_expired(); |
|
| 576 | + } |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + |
|
| 580 | + |
|
| 581 | + /** |
|
| 582 | + * _initialize_checkout |
|
| 583 | + * loads and instantiates EE_Checkout |
|
| 584 | + * |
|
| 585 | + * @access private |
|
| 586 | + * @throws EE_Error |
|
| 587 | + * @return EE_Checkout |
|
| 588 | + */ |
|
| 589 | + private function _initialize_checkout() |
|
| 590 | + { |
|
| 591 | + // look in session for existing checkout |
|
| 592 | + /** @type EE_Checkout $checkout */ |
|
| 593 | + $checkout = EE_Registry::instance()->SSN->checkout(); |
|
| 594 | + // verify |
|
| 595 | + if ( ! $checkout instanceof EE_Checkout) { |
|
| 596 | + // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
| 597 | + $checkout = EE_Registry::instance()->load_file( |
|
| 598 | + SPCO_INC_PATH, |
|
| 599 | + 'EE_Checkout', |
|
| 600 | + 'class', array(), |
|
| 601 | + false |
|
| 602 | + ); |
|
| 603 | + } else { |
|
| 604 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
| 605 | + $this->unlock_transaction(); |
|
| 606 | + wp_safe_redirect($checkout->redirect_url); |
|
| 607 | + exit(); |
|
| 608 | + } |
|
| 609 | + } |
|
| 610 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
| 611 | + // verify again |
|
| 612 | + if ( ! $checkout instanceof EE_Checkout) { |
|
| 613 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
| 614 | + } |
|
| 615 | + // reset anything that needs a clean slate for each request |
|
| 616 | + $checkout->reset_for_current_request(); |
|
| 617 | + return $checkout; |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + |
|
| 621 | + |
|
| 622 | + /** |
|
| 623 | + * _get_request_vars |
|
| 624 | + * |
|
| 625 | + * @access private |
|
| 626 | + * @return void |
|
| 627 | + * @throws EE_Error |
|
| 628 | + */ |
|
| 629 | + private function _get_request_vars() |
|
| 630 | + { |
|
| 631 | + // load classes |
|
| 632 | + EED_Single_Page_Checkout::load_request_handler(); |
|
| 633 | + //make sure this request is marked as belonging to EE |
|
| 634 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 635 | + // which step is being requested ? |
|
| 636 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
| 637 | + // which step is being edited ? |
|
| 638 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
| 639 | + // and what we're doing on the current step |
|
| 640 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
| 641 | + // timestamp |
|
| 642 | + $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
| 643 | + // returning to edit ? |
|
| 644 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
| 645 | + // add reg url link to registration query params |
|
| 646 | + if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
| 647 | + $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
| 648 | + } |
|
| 649 | + // or some other kind of revisit ? |
|
| 650 | + $this->checkout->revisit = filter_var( |
|
| 651 | + EE_Registry::instance()->REQ->get('revisit', false), |
|
| 652 | + FILTER_VALIDATE_BOOLEAN |
|
| 653 | + ); |
|
| 654 | + // and whether or not to generate a reg form for this request |
|
| 655 | + $this->checkout->generate_reg_form = filter_var( |
|
| 656 | + EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
| 657 | + FILTER_VALIDATE_BOOLEAN |
|
| 658 | + ); |
|
| 659 | + // and whether or not to process a reg form submission for this request |
|
| 660 | + $this->checkout->process_form_submission = filter_var( |
|
| 661 | + EE_Registry::instance()->REQ->get( |
|
| 662 | + 'process_form_submission', |
|
| 663 | + $this->checkout->action === 'process_reg_step' |
|
| 664 | + ), |
|
| 665 | + FILTER_VALIDATE_BOOLEAN |
|
| 666 | + ); |
|
| 667 | + $this->checkout->process_form_submission = filter_var( |
|
| 668 | + $this->checkout->action !== 'display_spco_reg_step' |
|
| 669 | + ? $this->checkout->process_form_submission |
|
| 670 | + : false, |
|
| 671 | + FILTER_VALIDATE_BOOLEAN |
|
| 672 | + ); |
|
| 673 | + // $this->_display_request_vars(); |
|
| 674 | + } |
|
| 675 | + |
|
| 676 | + |
|
| 677 | + |
|
| 678 | + /** |
|
| 679 | + * _display_request_vars |
|
| 680 | + * |
|
| 681 | + * @access protected |
|
| 682 | + * @return void |
|
| 683 | + */ |
|
| 684 | + protected function _display_request_vars() |
|
| 685 | + { |
|
| 686 | + if ( ! WP_DEBUG) { |
|
| 687 | + return; |
|
| 688 | + } |
|
| 689 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
| 690 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
| 691 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
| 692 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
| 693 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
| 694 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
| 695 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
| 696 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + |
|
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * _block_bots |
|
| 703 | + * checks that the incoming request has either of the following set: |
|
| 704 | + * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
| 705 | + * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
| 706 | + * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
| 707 | + * then where you coming from man? |
|
| 708 | + * |
|
| 709 | + * @return boolean |
|
| 710 | + */ |
|
| 711 | + private function _block_bots() |
|
| 712 | + { |
|
| 713 | + $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
| 714 | + if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
| 715 | + return true; |
|
| 716 | + } |
|
| 717 | + return false; |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + |
|
| 721 | + |
|
| 722 | + /** |
|
| 723 | + * _get_first_step |
|
| 724 | + * gets slug for first step in $_reg_steps_array |
|
| 725 | + * |
|
| 726 | + * @access private |
|
| 727 | + * @throws EE_Error |
|
| 728 | + * @return string |
|
| 729 | + */ |
|
| 730 | + private function _get_first_step() |
|
| 731 | + { |
|
| 732 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
| 733 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
| 734 | + } |
|
| 735 | + |
|
| 736 | + |
|
| 737 | + |
|
| 738 | + /** |
|
| 739 | + * _load_and_instantiate_reg_steps |
|
| 740 | + * instantiates each reg step based on the loaded reg_steps array |
|
| 741 | + * |
|
| 742 | + * @access private |
|
| 743 | + * @throws EE_Error |
|
| 744 | + * @return bool |
|
| 745 | + */ |
|
| 746 | + private function _load_and_instantiate_reg_steps() |
|
| 747 | + { |
|
| 748 | + do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
| 749 | + // have reg_steps already been instantiated ? |
|
| 750 | + if ( |
|
| 751 | + empty($this->checkout->reg_steps) |
|
| 752 | + || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
| 753 | + ) { |
|
| 754 | + // if not, then loop through raw reg steps array |
|
| 755 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
| 756 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
| 757 | + return false; |
|
| 758 | + } |
|
| 759 | + } |
|
| 760 | + EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true; |
|
| 761 | + EE_Registry::instance()->CFG->registration->reg_confirmation_last = true; |
|
| 762 | + // skip the registration_confirmation page ? |
|
| 763 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
| 764 | + // just remove it from the reg steps array |
|
| 765 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
| 766 | + } else if ( |
|
| 767 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
| 768 | + && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
| 769 | + ) { |
|
| 770 | + // set the order to something big like 100 |
|
| 771 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
| 772 | + } |
|
| 773 | + // filter the array for good luck |
|
| 774 | + $this->checkout->reg_steps = apply_filters( |
|
| 775 | + 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
| 776 | + $this->checkout->reg_steps |
|
| 777 | + ); |
|
| 778 | + // finally re-sort based on the reg step class order properties |
|
| 779 | + $this->checkout->sort_reg_steps(); |
|
| 780 | + } else { |
|
| 781 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 782 | + // set all current step stati to FALSE |
|
| 783 | + $reg_step->set_is_current_step(false); |
|
| 784 | + } |
|
| 785 | + } |
|
| 786 | + if (empty($this->checkout->reg_steps)) { |
|
| 787 | + EE_Error::add_error( |
|
| 788 | + __('No Reg Steps were loaded..', 'event_espresso'), |
|
| 789 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 790 | + ); |
|
| 791 | + return false; |
|
| 792 | + } |
|
| 793 | + // make reg step details available to JS |
|
| 794 | + $this->checkout->set_reg_step_JSON_info(); |
|
| 795 | + return true; |
|
| 796 | + } |
|
| 797 | + |
|
| 798 | + |
|
| 799 | + |
|
| 800 | + /** |
|
| 801 | + * _load_and_instantiate_reg_step |
|
| 802 | + * |
|
| 803 | + * @access private |
|
| 804 | + * @param array $reg_step |
|
| 805 | + * @param int $order |
|
| 806 | + * @return bool |
|
| 807 | + */ |
|
| 808 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
| 809 | + { |
|
| 810 | + // we need a file_path, class_name, and slug to add a reg step |
|
| 811 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 812 | + // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
| 813 | + if ( |
|
| 814 | + $this->checkout->reg_url_link |
|
| 815 | + && $this->checkout->step !== $reg_step['slug'] |
|
| 816 | + && $reg_step['slug'] !== 'finalize_registration' |
|
| 817 | + // normally at this point we would NOT load the reg step, but this filter can change that |
|
| 818 | + && apply_filters( |
|
| 819 | + 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
| 820 | + true, |
|
| 821 | + $reg_step, |
|
| 822 | + $this->checkout |
|
| 823 | + ) |
|
| 824 | + ) { |
|
| 825 | + return true; |
|
| 826 | + } |
|
| 827 | + // instantiate step class using file path and class name |
|
| 828 | + $reg_step_obj = EE_Registry::instance()->load_file( |
|
| 829 | + $reg_step['file_path'], |
|
| 830 | + $reg_step['class_name'], |
|
| 831 | + 'class', |
|
| 832 | + $this->checkout, |
|
| 833 | + false |
|
| 834 | + ); |
|
| 835 | + // did we gets the goods ? |
|
| 836 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
| 837 | + // set reg step order based on config |
|
| 838 | + $reg_step_obj->set_order($order); |
|
| 839 | + // add instantiated reg step object to the master reg steps array |
|
| 840 | + $this->checkout->add_reg_step($reg_step_obj); |
|
| 841 | + } else { |
|
| 842 | + EE_Error::add_error( |
|
| 843 | + __('The current step could not be set.', 'event_espresso'), |
|
| 844 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 845 | + ); |
|
| 846 | + return false; |
|
| 847 | + } |
|
| 848 | + } else { |
|
| 849 | + if (WP_DEBUG) { |
|
| 850 | + EE_Error::add_error( |
|
| 851 | + sprintf( |
|
| 852 | + __( |
|
| 853 | + 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
| 854 | + 'event_espresso' |
|
| 855 | + ), |
|
| 856 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
| 857 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
| 858 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
| 859 | + '<ul>', |
|
| 860 | + '<li>', |
|
| 861 | + '</li>', |
|
| 862 | + '</ul>' |
|
| 863 | + ), |
|
| 864 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 865 | + ); |
|
| 866 | + } |
|
| 867 | + return false; |
|
| 868 | + } |
|
| 869 | + return true; |
|
| 870 | + } |
|
| 871 | + |
|
| 872 | + |
|
| 873 | + /** |
|
| 874 | + * _verify_transaction_and_get_registrations |
|
| 875 | + * |
|
| 876 | + * @access private |
|
| 877 | + * @return bool |
|
| 878 | + * @throws InvalidDataTypeException |
|
| 879 | + * @throws InvalidEntityException |
|
| 880 | + * @throws EE_Error |
|
| 881 | + */ |
|
| 882 | + private function _verify_transaction_and_get_registrations() |
|
| 883 | + { |
|
| 884 | + // was there already a valid transaction in the checkout from the session ? |
|
| 885 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 886 | + // get transaction from db or session |
|
| 887 | + $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
| 888 | + ? $this->_get_transaction_and_cart_for_previous_visit() |
|
| 889 | + : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
| 890 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 891 | + EE_Error::add_error( |
|
| 892 | + __('Your Registration and Transaction information could not be retrieved from the db.', |
|
| 893 | + 'event_espresso'), |
|
| 894 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 895 | + ); |
|
| 896 | + $this->checkout->transaction = EE_Transaction::new_instance(); |
|
| 897 | + // add some style and make it dance |
|
| 898 | + $this->add_styles_and_scripts(); |
|
| 899 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 900 | + return false; |
|
| 901 | + } |
|
| 902 | + // and the registrations for the transaction |
|
| 903 | + $this->_get_registrations($this->checkout->transaction); |
|
| 904 | + } |
|
| 905 | + return true; |
|
| 906 | + } |
|
| 907 | + |
|
| 908 | + |
|
| 909 | + |
|
| 910 | + /** |
|
| 911 | + * _get_transaction_and_cart_for_previous_visit |
|
| 912 | + * |
|
| 913 | + * @access private |
|
| 914 | + * @return mixed EE_Transaction|NULL |
|
| 915 | + */ |
|
| 916 | + private function _get_transaction_and_cart_for_previous_visit() |
|
| 917 | + { |
|
| 918 | + /** @var $TXN_model EEM_Transaction */ |
|
| 919 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
| 920 | + // because the reg_url_link is present in the request, |
|
| 921 | + // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
| 922 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
| 923 | + // verify transaction |
|
| 924 | + if ($transaction instanceof EE_Transaction) { |
|
| 925 | + // and get the cart that was used for that transaction |
|
| 926 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
| 927 | + return $transaction; |
|
| 928 | + } |
|
| 929 | + EE_Error::add_error( |
|
| 930 | + __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
| 931 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 932 | + ); |
|
| 933 | + return null; |
|
| 934 | + |
|
| 935 | + } |
|
| 936 | + |
|
| 937 | + |
|
| 938 | + |
|
| 939 | + /** |
|
| 940 | + * _get_cart_for_transaction |
|
| 941 | + * |
|
| 942 | + * @access private |
|
| 943 | + * @param EE_Transaction $transaction |
|
| 944 | + * @return EE_Cart |
|
| 945 | + */ |
|
| 946 | + private function _get_cart_for_transaction($transaction) |
|
| 947 | + { |
|
| 948 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
| 949 | + } |
|
| 950 | + |
|
| 951 | + |
|
| 952 | + |
|
| 953 | + /** |
|
| 954 | + * get_cart_for_transaction |
|
| 955 | + * |
|
| 956 | + * @access public |
|
| 957 | + * @param EE_Transaction $transaction |
|
| 958 | + * @return EE_Cart |
|
| 959 | + */ |
|
| 960 | + public function get_cart_for_transaction(EE_Transaction $transaction) |
|
| 961 | + { |
|
| 962 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
| 963 | + } |
|
| 964 | + |
|
| 965 | + |
|
| 966 | + |
|
| 967 | + /** |
|
| 968 | + * _get_transaction_and_cart_for_current_session |
|
| 969 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 970 | + * |
|
| 971 | + * @access private |
|
| 972 | + * @return EE_Transaction |
|
| 973 | + * @throws EE_Error |
|
| 974 | + */ |
|
| 975 | + private function _get_cart_for_current_session_and_setup_new_transaction() |
|
| 976 | + { |
|
| 977 | + // if there's no transaction, then this is the FIRST visit to SPCO |
|
| 978 | + // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
| 979 | + $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
| 980 | + // and then create a new transaction |
|
| 981 | + $transaction = $this->_initialize_transaction(); |
|
| 982 | + // verify transaction |
|
| 983 | + if ($transaction instanceof EE_Transaction) { |
|
| 984 | + // save it so that we have an ID for other objects to use |
|
| 985 | + $transaction->save(); |
|
| 986 | + // and save TXN data to the cart |
|
| 987 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 988 | + } else { |
|
| 989 | + EE_Error::add_error( |
|
| 990 | + __('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
| 991 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 992 | + ); |
|
| 993 | + } |
|
| 994 | + return $transaction; |
|
| 995 | + } |
|
| 996 | + |
|
| 997 | + |
|
| 998 | + |
|
| 999 | + /** |
|
| 1000 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 1001 | + * |
|
| 1002 | + * @access private |
|
| 1003 | + * @return mixed EE_Transaction|NULL |
|
| 1004 | + */ |
|
| 1005 | + private function _initialize_transaction() |
|
| 1006 | + { |
|
| 1007 | + try { |
|
| 1008 | + // ensure cart totals have been calculated |
|
| 1009 | + $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
| 1010 | + // grab the cart grand total |
|
| 1011 | + $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
| 1012 | + // create new TXN |
|
| 1013 | + $transaction = EE_Transaction::new_instance( |
|
| 1014 | + array( |
|
| 1015 | + 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
| 1016 | + 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
| 1017 | + 'TXN_paid' => 0, |
|
| 1018 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
| 1019 | + ) |
|
| 1020 | + ); |
|
| 1021 | + // save it so that we have an ID for other objects to use |
|
| 1022 | + $transaction->save(); |
|
| 1023 | + // set cron job for following up on TXNs after their session has expired |
|
| 1024 | + EE_Cron_Tasks::schedule_expired_transaction_check( |
|
| 1025 | + EE_Registry::instance()->SSN->expiration() + 1, |
|
| 1026 | + $transaction->ID() |
|
| 1027 | + ); |
|
| 1028 | + return $transaction; |
|
| 1029 | + } catch (Exception $e) { |
|
| 1030 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1031 | + } |
|
| 1032 | + return null; |
|
| 1033 | + } |
|
| 1034 | + |
|
| 1035 | + |
|
| 1036 | + /** |
|
| 1037 | + * _get_registrations |
|
| 1038 | + * |
|
| 1039 | + * @access private |
|
| 1040 | + * @param EE_Transaction $transaction |
|
| 1041 | + * @return void |
|
| 1042 | + * @throws InvalidDataTypeException |
|
| 1043 | + * @throws InvalidEntityException |
|
| 1044 | + * @throws EE_Error |
|
| 1045 | + */ |
|
| 1046 | + private function _get_registrations(EE_Transaction $transaction) |
|
| 1047 | + { |
|
| 1048 | + // first step: grab the registrants { : o |
|
| 1049 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
| 1050 | + $this->checkout->total_ticket_count = count($registrations); |
|
| 1051 | + // verify registrations have been set |
|
| 1052 | + if (empty($registrations)) { |
|
| 1053 | + // if no cached registrations, then check the db |
|
| 1054 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
| 1055 | + // still nothing ? well as long as this isn't a revisit |
|
| 1056 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
| 1057 | + // generate new registrations from scratch |
|
| 1058 | + $registrations = $this->_initialize_registrations($transaction); |
|
| 1059 | + } |
|
| 1060 | + } |
|
| 1061 | + // sort by their original registration order |
|
| 1062 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
| 1063 | + // then loop thru the array |
|
| 1064 | + foreach ($registrations as $registration) { |
|
| 1065 | + // verify each registration |
|
| 1066 | + if ($registration instanceof EE_Registration) { |
|
| 1067 | + // we display all attendee info for the primary registrant |
|
| 1068 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
| 1069 | + && $registration->is_primary_registrant() |
|
| 1070 | + ) { |
|
| 1071 | + $this->checkout->primary_revisit = true; |
|
| 1072 | + break; |
|
| 1073 | + } |
|
| 1074 | + if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
| 1075 | + // but hide info if it doesn't belong to you |
|
| 1076 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
| 1077 | + $this->checkout->total_ticket_count--; |
|
| 1078 | + } |
|
| 1079 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
| 1080 | + } |
|
| 1081 | + } |
|
| 1082 | + } |
|
| 1083 | + |
|
| 1084 | + |
|
| 1085 | + /** |
|
| 1086 | + * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
| 1087 | + * |
|
| 1088 | + * @access private |
|
| 1089 | + * @param EE_Transaction $transaction |
|
| 1090 | + * @return array |
|
| 1091 | + * @throws InvalidDataTypeException |
|
| 1092 | + * @throws InvalidEntityException |
|
| 1093 | + * @throws EE_Error |
|
| 1094 | + */ |
|
| 1095 | + private function _initialize_registrations(EE_Transaction $transaction) |
|
| 1096 | + { |
|
| 1097 | + $att_nmbr = 0; |
|
| 1098 | + $registrations = array(); |
|
| 1099 | + if ($transaction instanceof EE_Transaction) { |
|
| 1100 | + /** @type EE_Registration_Processor $registration_processor */ |
|
| 1101 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 1102 | + $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
| 1103 | + // now let's add the cart items to the $transaction |
|
| 1104 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
| 1105 | + //do the following for each ticket of this type they selected |
|
| 1106 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
| 1107 | + $att_nmbr++; |
|
| 1108 | + /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
| 1109 | + $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
| 1110 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 1111 | + array( |
|
| 1112 | + $transaction, |
|
| 1113 | + $line_item, |
|
| 1114 | + $att_nmbr, |
|
| 1115 | + $this->checkout->total_ticket_count, |
|
| 1116 | + ) |
|
| 1117 | + ); |
|
| 1118 | + // override capabilities for frontend registrations |
|
| 1119 | + if ( ! is_admin()) { |
|
| 1120 | + $CreateRegistrationCommand->setCapCheck( |
|
| 1121 | + new PublicCapabilities('', 'create_new_registration') |
|
| 1122 | + ); |
|
| 1123 | + } |
|
| 1124 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
| 1125 | + if ( ! $registration instanceof EE_Registration) { |
|
| 1126 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
| 1127 | + } |
|
| 1128 | + $registrations[ $registration->ID() ] = $registration; |
|
| 1129 | + } |
|
| 1130 | + } |
|
| 1131 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
| 1132 | + } |
|
| 1133 | + return $registrations; |
|
| 1134 | + } |
|
| 1135 | + |
|
| 1136 | + |
|
| 1137 | + |
|
| 1138 | + /** |
|
| 1139 | + * sorts registrations by REG_count |
|
| 1140 | + * |
|
| 1141 | + * @access public |
|
| 1142 | + * @param EE_Registration $reg_A |
|
| 1143 | + * @param EE_Registration $reg_B |
|
| 1144 | + * @return int |
|
| 1145 | + */ |
|
| 1146 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
| 1147 | + { |
|
| 1148 | + // this shouldn't ever happen within the same TXN, but oh well |
|
| 1149 | + if ($reg_A->count() === $reg_B->count()) { |
|
| 1150 | + return 0; |
|
| 1151 | + } |
|
| 1152 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
| 1153 | + } |
|
| 1154 | + |
|
| 1155 | + |
|
| 1156 | + |
|
| 1157 | + /** |
|
| 1158 | + * _final_verifications |
|
| 1159 | + * just makes sure that everything is set up correctly before proceeding |
|
| 1160 | + * |
|
| 1161 | + * @access private |
|
| 1162 | + * @return bool |
|
| 1163 | + * @throws EE_Error |
|
| 1164 | + */ |
|
| 1165 | + private function _final_verifications() |
|
| 1166 | + { |
|
| 1167 | + // filter checkout |
|
| 1168 | + $this->checkout = apply_filters( |
|
| 1169 | + 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
| 1170 | + $this->checkout |
|
| 1171 | + ); |
|
| 1172 | + //verify that current step is still set correctly |
|
| 1173 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
| 1174 | + EE_Error::add_error( |
|
| 1175 | + __('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1176 | + __FILE__, |
|
| 1177 | + __FUNCTION__, |
|
| 1178 | + __LINE__ |
|
| 1179 | + ); |
|
| 1180 | + return false; |
|
| 1181 | + } |
|
| 1182 | + // if returning to SPCO, then verify that primary registrant is set |
|
| 1183 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
| 1184 | + $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
| 1185 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1186 | + EE_Error::add_error( |
|
| 1187 | + __('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1188 | + __FILE__, |
|
| 1189 | + __FUNCTION__, |
|
| 1190 | + __LINE__ |
|
| 1191 | + ); |
|
| 1192 | + return false; |
|
| 1193 | + } |
|
| 1194 | + $valid_registrant = null; |
|
| 1195 | + foreach ( |
|
| 1196 | + $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration |
|
| 1197 | + ) { |
|
| 1198 | + if ( |
|
| 1199 | + $registration instanceof EE_Registration |
|
| 1200 | + && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
| 1201 | + ) { |
|
| 1202 | + $valid_registrant = $registration; |
|
| 1203 | + } |
|
| 1204 | + } |
|
| 1205 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1206 | + // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
| 1207 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
| 1208 | + // clear the session, mark the checkout as unverified, and try again |
|
| 1209 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 1210 | + EED_Single_Page_Checkout::$_initialized = false; |
|
| 1211 | + EED_Single_Page_Checkout::$_checkout_verified = false; |
|
| 1212 | + $this->_initialize(); |
|
| 1213 | + EE_Error::reset_notices(); |
|
| 1214 | + return false; |
|
| 1215 | + } |
|
| 1216 | + EE_Error::add_error( |
|
| 1217 | + __( |
|
| 1218 | + 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
| 1219 | + 'event_espresso' |
|
| 1220 | + ), |
|
| 1221 | + __FILE__, |
|
| 1222 | + __FUNCTION__, |
|
| 1223 | + __LINE__ |
|
| 1224 | + ); |
|
| 1225 | + return false; |
|
| 1226 | + } |
|
| 1227 | + } |
|
| 1228 | + // now that things have been kinda sufficiently verified, |
|
| 1229 | + // let's add the checkout to the session so that it's available to other systems |
|
| 1230 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
| 1231 | + return true; |
|
| 1232 | + } |
|
| 1233 | + |
|
| 1234 | + |
|
| 1235 | + |
|
| 1236 | + /** |
|
| 1237 | + * _initialize_reg_steps |
|
| 1238 | + * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
| 1239 | + * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
| 1240 | + * |
|
| 1241 | + * @access private |
|
| 1242 | + * @param bool $reinitializing |
|
| 1243 | + * @throws EE_Error |
|
| 1244 | + */ |
|
| 1245 | + private function _initialize_reg_steps($reinitializing = false) |
|
| 1246 | + { |
|
| 1247 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
| 1248 | + // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
| 1249 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 1250 | + if ( ! $reg_step->initialize_reg_step()) { |
|
| 1251 | + // if not initialized then maybe this step is being removed... |
|
| 1252 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
| 1253 | + // if it was the current step, then we need to start over here |
|
| 1254 | + $this->_initialize_reg_steps(true); |
|
| 1255 | + return; |
|
| 1256 | + } |
|
| 1257 | + continue; |
|
| 1258 | + } |
|
| 1259 | + // add css and JS for current step |
|
| 1260 | + $reg_step->enqueue_styles_and_scripts(); |
|
| 1261 | + // i18n |
|
| 1262 | + $reg_step->translate_js_strings(); |
|
| 1263 | + if ($reg_step->is_current_step()) { |
|
| 1264 | + // the text that appears on the reg step form submit button |
|
| 1265 | + $reg_step->set_submit_button_text(); |
|
| 1266 | + } |
|
| 1267 | + } |
|
| 1268 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
| 1269 | + do_action( |
|
| 1270 | + "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
| 1271 | + $this->checkout->current_step |
|
| 1272 | + ); |
|
| 1273 | + } |
|
| 1274 | + |
|
| 1275 | + |
|
| 1276 | + |
|
| 1277 | + /** |
|
| 1278 | + * _check_form_submission |
|
| 1279 | + * |
|
| 1280 | + * @access private |
|
| 1281 | + * @return boolean |
|
| 1282 | + */ |
|
| 1283 | + private function _check_form_submission() |
|
| 1284 | + { |
|
| 1285 | + //does this request require the reg form to be generated ? |
|
| 1286 | + if ($this->checkout->generate_reg_form) { |
|
| 1287 | + // ever heard that song by Blue Rodeo ? |
|
| 1288 | + try { |
|
| 1289 | + $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
| 1290 | + // if not displaying a form, then check for form submission |
|
| 1291 | + if ( |
|
| 1292 | + $this->checkout->process_form_submission |
|
| 1293 | + && $this->checkout->current_step->reg_form->was_submitted() |
|
| 1294 | + ) { |
|
| 1295 | + // clear out any old data in case this step is being run again |
|
| 1296 | + $this->checkout->current_step->set_valid_data(array()); |
|
| 1297 | + // capture submitted form data |
|
| 1298 | + $this->checkout->current_step->reg_form->receive_form_submission( |
|
| 1299 | + apply_filters( |
|
| 1300 | + 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
| 1301 | + EE_Registry::instance()->REQ->params(), |
|
| 1302 | + $this->checkout |
|
| 1303 | + ) |
|
| 1304 | + ); |
|
| 1305 | + // validate submitted form data |
|
| 1306 | + if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
| 1307 | + // thou shall not pass !!! |
|
| 1308 | + $this->checkout->continue_reg = false; |
|
| 1309 | + // any form validation errors? |
|
| 1310 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
| 1311 | + $submission_error_messages = array(); |
|
| 1312 | + // bad, bad, bad registrant |
|
| 1313 | + foreach ( |
|
| 1314 | + $this->checkout->current_step->reg_form->get_validation_errors_accumulated() |
|
| 1315 | + as $validation_error |
|
| 1316 | + ) { |
|
| 1317 | + if ($validation_error instanceof EE_Validation_Error) { |
|
| 1318 | + $submission_error_messages[] = sprintf( |
|
| 1319 | + __('%s : %s', 'event_espresso'), |
|
| 1320 | + $validation_error->get_form_section()->html_label_text(), |
|
| 1321 | + $validation_error->getMessage() |
|
| 1322 | + ); |
|
| 1323 | + } |
|
| 1324 | + } |
|
| 1325 | + EE_Error::add_error( |
|
| 1326 | + implode('<br />', $submission_error_messages), |
|
| 1327 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1328 | + ); |
|
| 1329 | + } |
|
| 1330 | + // well not really... what will happen is |
|
| 1331 | + // we'll just get redirected back to redo the current step |
|
| 1332 | + $this->go_to_next_step(); |
|
| 1333 | + return false; |
|
| 1334 | + } |
|
| 1335 | + } |
|
| 1336 | + } catch (EE_Error $e) { |
|
| 1337 | + $e->get_error(); |
|
| 1338 | + } |
|
| 1339 | + } |
|
| 1340 | + return true; |
|
| 1341 | + } |
|
| 1342 | + |
|
| 1343 | + |
|
| 1344 | + |
|
| 1345 | + /** |
|
| 1346 | + * _process_action |
|
| 1347 | + * |
|
| 1348 | + * @access private |
|
| 1349 | + * @return void |
|
| 1350 | + * @throws EE_Error |
|
| 1351 | + */ |
|
| 1352 | + private function _process_form_action() |
|
| 1353 | + { |
|
| 1354 | + // what cha wanna do? |
|
| 1355 | + switch ($this->checkout->action) { |
|
| 1356 | + // AJAX next step reg form |
|
| 1357 | + case 'display_spco_reg_step' : |
|
| 1358 | + $this->checkout->redirect = false; |
|
| 1359 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1360 | + $this->checkout->json_response->set_reg_step_html( |
|
| 1361 | + $this->checkout->current_step->display_reg_form() |
|
| 1362 | + ); |
|
| 1363 | + } |
|
| 1364 | + break; |
|
| 1365 | + default : |
|
| 1366 | + // meh... do one of those other steps first |
|
| 1367 | + if ( |
|
| 1368 | + ! empty($this->checkout->action) |
|
| 1369 | + && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
| 1370 | + ) { |
|
| 1371 | + // dynamically creates hook point like: |
|
| 1372 | + // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
| 1373 | + do_action( |
|
| 1374 | + "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
| 1375 | + $this->checkout->current_step |
|
| 1376 | + ); |
|
| 1377 | + // call action on current step |
|
| 1378 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
| 1379 | + // good registrant, you get to proceed |
|
| 1380 | + if ( |
|
| 1381 | + $this->checkout->current_step->success_message() !== '' |
|
| 1382 | + && apply_filters( |
|
| 1383 | + 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
| 1384 | + false |
|
| 1385 | + ) |
|
| 1386 | + ) { |
|
| 1387 | + EE_Error::add_success( |
|
| 1388 | + $this->checkout->current_step->success_message() |
|
| 1389 | + . '<br />' . $this->checkout->next_step->_instructions() |
|
| 1390 | + ); |
|
| 1391 | + } |
|
| 1392 | + // pack it up, pack it in... |
|
| 1393 | + $this->_setup_redirect(); |
|
| 1394 | + } |
|
| 1395 | + // dynamically creates hook point like: |
|
| 1396 | + // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
| 1397 | + do_action( |
|
| 1398 | + "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
| 1399 | + $this->checkout->current_step |
|
| 1400 | + ); |
|
| 1401 | + } else { |
|
| 1402 | + EE_Error::add_error( |
|
| 1403 | + sprintf( |
|
| 1404 | + __( |
|
| 1405 | + 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
| 1406 | + 'event_espresso' |
|
| 1407 | + ), |
|
| 1408 | + $this->checkout->action, |
|
| 1409 | + $this->checkout->current_step->name() |
|
| 1410 | + ), |
|
| 1411 | + __FILE__, |
|
| 1412 | + __FUNCTION__, |
|
| 1413 | + __LINE__ |
|
| 1414 | + ); |
|
| 1415 | + } |
|
| 1416 | + // end default |
|
| 1417 | + } |
|
| 1418 | + // store our progress so far |
|
| 1419 | + $this->checkout->stash_transaction_and_checkout(); |
|
| 1420 | + // advance to the next step! If you pass GO, collect $200 |
|
| 1421 | + $this->go_to_next_step(); |
|
| 1422 | + } |
|
| 1423 | + |
|
| 1424 | + |
|
| 1425 | + |
|
| 1426 | + /** |
|
| 1427 | + * add_styles_and_scripts |
|
| 1428 | + * |
|
| 1429 | + * @access public |
|
| 1430 | + * @return void |
|
| 1431 | + */ |
|
| 1432 | + public function add_styles_and_scripts() |
|
| 1433 | + { |
|
| 1434 | + // i18n |
|
| 1435 | + $this->translate_js_strings(); |
|
| 1436 | + if ($this->checkout->admin_request) { |
|
| 1437 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1438 | + } else { |
|
| 1439 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1440 | + } |
|
| 1441 | + } |
|
| 1442 | + |
|
| 1443 | + |
|
| 1444 | + |
|
| 1445 | + /** |
|
| 1446 | + * translate_js_strings |
|
| 1447 | + * |
|
| 1448 | + * @access public |
|
| 1449 | + * @return void |
|
| 1450 | + */ |
|
| 1451 | + public function translate_js_strings() |
|
| 1452 | + { |
|
| 1453 | + EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
| 1454 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
| 1455 | + EE_Registry::$i18n_js_strings['server_error'] = __( |
|
| 1456 | + 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
| 1457 | + 'event_espresso' |
|
| 1458 | + ); |
|
| 1459 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __( |
|
| 1460 | + 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
| 1461 | + 'event_espresso' |
|
| 1462 | + ); |
|
| 1463 | + EE_Registry::$i18n_js_strings['validation_error'] = __( |
|
| 1464 | + 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
| 1465 | + 'event_espresso' |
|
| 1466 | + ); |
|
| 1467 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( |
|
| 1468 | + 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
| 1469 | + 'event_espresso' |
|
| 1470 | + ); |
|
| 1471 | + EE_Registry::$i18n_js_strings['reg_step_error'] = __( |
|
| 1472 | + 'This registration step could not be completed. Please refresh the page and try again.', |
|
| 1473 | + 'event_espresso' |
|
| 1474 | + ); |
|
| 1475 | + EE_Registry::$i18n_js_strings['invalid_coupon'] = __( |
|
| 1476 | + 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
| 1477 | + 'event_espresso' |
|
| 1478 | + ); |
|
| 1479 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
| 1480 | + __( |
|
| 1481 | + 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
| 1482 | + 'event_espresso' |
|
| 1483 | + ), |
|
| 1484 | + '<br/>', |
|
| 1485 | + '<br/>' |
|
| 1486 | + ); |
|
| 1487 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
| 1488 | + EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
| 1489 | + EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
| 1490 | + EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
| 1491 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
| 1492 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
| 1493 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
| 1494 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
| 1495 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
| 1496 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
| 1497 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
| 1498 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
| 1499 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
| 1500 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
| 1501 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
| 1502 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
| 1503 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
| 1504 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
| 1505 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
| 1506 | + __( |
|
| 1507 | + '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', |
|
| 1508 | + 'event_espresso' |
|
| 1509 | + ), |
|
| 1510 | + '<h4 class="important-notice">', |
|
| 1511 | + '</h4>', |
|
| 1512 | + '<br />', |
|
| 1513 | + '<p>', |
|
| 1514 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 1515 | + '">', |
|
| 1516 | + '</a>', |
|
| 1517 | + '</p>' |
|
| 1518 | + ); |
|
| 1519 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
| 1520 | + 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
| 1521 | + true |
|
| 1522 | + ); |
|
| 1523 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
| 1524 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
| 1525 | + ); |
|
| 1526 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
| 1527 | + 'M d, Y H:i:s', |
|
| 1528 | + EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
| 1529 | + ); |
|
| 1530 | + } |
|
| 1531 | + |
|
| 1532 | + |
|
| 1533 | + |
|
| 1534 | + /** |
|
| 1535 | + * enqueue_styles_and_scripts |
|
| 1536 | + * |
|
| 1537 | + * @access public |
|
| 1538 | + * @return void |
|
| 1539 | + * @throws EE_Error |
|
| 1540 | + */ |
|
| 1541 | + public function enqueue_styles_and_scripts() |
|
| 1542 | + { |
|
| 1543 | + // load css |
|
| 1544 | + wp_register_style( |
|
| 1545 | + 'single_page_checkout', |
|
| 1546 | + SPCO_CSS_URL . 'single_page_checkout.css', |
|
| 1547 | + array('espresso_default'), |
|
| 1548 | + EVENT_ESPRESSO_VERSION |
|
| 1549 | + ); |
|
| 1550 | + wp_enqueue_style('single_page_checkout'); |
|
| 1551 | + // load JS |
|
| 1552 | + wp_register_script( |
|
| 1553 | + 'jquery_plugin', |
|
| 1554 | + EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', |
|
| 1555 | + array('jquery'), |
|
| 1556 | + '1.0.1', |
|
| 1557 | + true |
|
| 1558 | + ); |
|
| 1559 | + wp_register_script( |
|
| 1560 | + 'jquery_countdown', |
|
| 1561 | + EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', |
|
| 1562 | + array('jquery_plugin'), |
|
| 1563 | + '2.0.2', |
|
| 1564 | + true |
|
| 1565 | + ); |
|
| 1566 | + wp_register_script( |
|
| 1567 | + 'single_page_checkout', |
|
| 1568 | + SPCO_JS_URL . 'single_page_checkout.js', |
|
| 1569 | + array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), |
|
| 1570 | + EVENT_ESPRESSO_VERSION, |
|
| 1571 | + true |
|
| 1572 | + ); |
|
| 1573 | + if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
| 1574 | + $this->checkout->registration_form->enqueue_js(); |
|
| 1575 | + } |
|
| 1576 | + if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
| 1577 | + $this->checkout->current_step->reg_form->enqueue_js(); |
|
| 1578 | + } |
|
| 1579 | + wp_enqueue_script('single_page_checkout'); |
|
| 1580 | + /** |
|
| 1581 | + * global action hook for enqueueing styles and scripts with |
|
| 1582 | + * spco calls. |
|
| 1583 | + */ |
|
| 1584 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
| 1585 | + /** |
|
| 1586 | + * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
| 1587 | + * The hook will end up being something like: |
|
| 1588 | + * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
| 1589 | + */ |
|
| 1590 | + do_action( |
|
| 1591 | + 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
| 1592 | + $this |
|
| 1593 | + ); |
|
| 1594 | + } |
|
| 1595 | + |
|
| 1596 | + |
|
| 1597 | + |
|
| 1598 | + /** |
|
| 1599 | + * display the Registration Single Page Checkout Form |
|
| 1600 | + * |
|
| 1601 | + * @access private |
|
| 1602 | + * @return void |
|
| 1603 | + * @throws EE_Error |
|
| 1604 | + */ |
|
| 1605 | + private function _display_spco_reg_form() |
|
| 1606 | + { |
|
| 1607 | + // if registering via the admin, just display the reg form for the current step |
|
| 1608 | + if ($this->checkout->admin_request) { |
|
| 1609 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
| 1610 | + } else { |
|
| 1611 | + // add powered by EE msg |
|
| 1612 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
| 1613 | + $empty_cart = count( |
|
| 1614 | + $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) |
|
| 1615 | + ) < 1; |
|
| 1616 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
| 1617 | + $cookies_not_set_msg = ''; |
|
| 1618 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
| 1619 | + $cookies_not_set_msg = apply_filters( |
|
| 1620 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
| 1621 | + sprintf( |
|
| 1622 | + __( |
|
| 1623 | + '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
| 1624 | + 'event_espresso' |
|
| 1625 | + ), |
|
| 1626 | + '<div class="ee-attention">', |
|
| 1627 | + '</div>', |
|
| 1628 | + '<h6 class="important-notice">', |
|
| 1629 | + '</h6>', |
|
| 1630 | + '<p>', |
|
| 1631 | + '</p>', |
|
| 1632 | + '<br />', |
|
| 1633 | + '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">', |
|
| 1634 | + '</a>' |
|
| 1635 | + ) |
|
| 1636 | + ); |
|
| 1637 | + } |
|
| 1638 | + $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
| 1639 | + array( |
|
| 1640 | + 'name' => 'single-page-checkout', |
|
| 1641 | + 'html_id' => 'ee-single-page-checkout-dv', |
|
| 1642 | + 'layout_strategy' => |
|
| 1643 | + new EE_Template_Layout( |
|
| 1644 | + array( |
|
| 1645 | + 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
| 1646 | + 'template_args' => array( |
|
| 1647 | + 'empty_cart' => $empty_cart, |
|
| 1648 | + 'revisit' => $this->checkout->revisit, |
|
| 1649 | + 'reg_steps' => $this->checkout->reg_steps, |
|
| 1650 | + 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
| 1651 | + ? $this->checkout->next_step->slug() |
|
| 1652 | + : '', |
|
| 1653 | + 'cancel_page_url' => $this->checkout->cancel_page_url, |
|
| 1654 | + 'empty_msg' => apply_filters( |
|
| 1655 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
| 1656 | + sprintf( |
|
| 1657 | + __( |
|
| 1658 | + 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
| 1659 | + 'event_espresso' |
|
| 1660 | + ), |
|
| 1661 | + '<a href="' |
|
| 1662 | + . get_post_type_archive_link('espresso_events') |
|
| 1663 | + . '" title="', |
|
| 1664 | + '">', |
|
| 1665 | + '</a>' |
|
| 1666 | + ) |
|
| 1667 | + ), |
|
| 1668 | + 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
| 1669 | + 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
| 1670 | + 'session_expiration' => gmdate( |
|
| 1671 | + 'M d, Y H:i:s', |
|
| 1672 | + EE_Registry::instance()->SSN->expiration() |
|
| 1673 | + + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
| 1674 | + ), |
|
| 1675 | + ), |
|
| 1676 | + ) |
|
| 1677 | + ), |
|
| 1678 | + ) |
|
| 1679 | + ); |
|
| 1680 | + // load template and add to output sent that gets filtered into the_content() |
|
| 1681 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
| 1682 | + } |
|
| 1683 | + } |
|
| 1684 | + |
|
| 1685 | + |
|
| 1686 | + |
|
| 1687 | + /** |
|
| 1688 | + * add_extra_finalize_registration_inputs |
|
| 1689 | + * |
|
| 1690 | + * @access public |
|
| 1691 | + * @param $next_step |
|
| 1692 | + * @internal param string $label |
|
| 1693 | + * @return void |
|
| 1694 | + */ |
|
| 1695 | + public function add_extra_finalize_registration_inputs($next_step) |
|
| 1696 | + { |
|
| 1697 | + if ($next_step === 'finalize_registration') { |
|
| 1698 | + echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
| 1699 | + } |
|
| 1700 | + } |
|
| 1701 | + |
|
| 1702 | + |
|
| 1703 | + |
|
| 1704 | + /** |
|
| 1705 | + * display_registration_footer |
|
| 1706 | + * |
|
| 1707 | + * @access public |
|
| 1708 | + * @return string |
|
| 1709 | + */ |
|
| 1710 | + public static function display_registration_footer() |
|
| 1711 | + { |
|
| 1712 | + if ( |
|
| 1713 | + apply_filters( |
|
| 1714 | + 'FHEE__EE_Front__Controller__show_reg_footer', |
|
| 1715 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
| 1716 | + ) |
|
| 1717 | + ) { |
|
| 1718 | + add_filter( |
|
| 1719 | + 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
| 1720 | + function ($url) { |
|
| 1721 | + return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
| 1722 | + } |
|
| 1723 | + ); |
|
| 1724 | + echo apply_filters( |
|
| 1725 | + 'FHEE__EE_Front_Controller__display_registration_footer', |
|
| 1726 | + \EEH_Template::powered_by_event_espresso( |
|
| 1727 | + '', |
|
| 1728 | + 'espresso-registration-footer-dv', |
|
| 1729 | + array('utm_content' => 'registration_checkout') |
|
| 1730 | + ) |
|
| 1731 | + ); |
|
| 1732 | + } |
|
| 1733 | + return ''; |
|
| 1734 | + } |
|
| 1735 | + |
|
| 1736 | + |
|
| 1737 | + |
|
| 1738 | + /** |
|
| 1739 | + * unlock_transaction |
|
| 1740 | + * |
|
| 1741 | + * @access public |
|
| 1742 | + * @return void |
|
| 1743 | + * @throws EE_Error |
|
| 1744 | + */ |
|
| 1745 | + public function unlock_transaction() |
|
| 1746 | + { |
|
| 1747 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
| 1748 | + $this->checkout->transaction->unlock(); |
|
| 1749 | + } |
|
| 1750 | + } |
|
| 1751 | + |
|
| 1752 | + |
|
| 1753 | + |
|
| 1754 | + /** |
|
| 1755 | + * _setup_redirect |
|
| 1756 | + * |
|
| 1757 | + * @access private |
|
| 1758 | + * @return void |
|
| 1759 | + */ |
|
| 1760 | + private function _setup_redirect() |
|
| 1761 | + { |
|
| 1762 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 1763 | + $this->checkout->redirect = true; |
|
| 1764 | + if (empty($this->checkout->redirect_url)) { |
|
| 1765 | + $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
| 1766 | + } |
|
| 1767 | + $this->checkout->redirect_url = apply_filters( |
|
| 1768 | + 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
| 1769 | + $this->checkout->redirect_url, |
|
| 1770 | + $this->checkout |
|
| 1771 | + ); |
|
| 1772 | + } |
|
| 1773 | + } |
|
| 1774 | + |
|
| 1775 | + |
|
| 1776 | + |
|
| 1777 | + /** |
|
| 1778 | + * handle ajax message responses and redirects |
|
| 1779 | + * |
|
| 1780 | + * @access public |
|
| 1781 | + * @return void |
|
| 1782 | + * @throws EE_Error |
|
| 1783 | + */ |
|
| 1784 | + public function go_to_next_step() |
|
| 1785 | + { |
|
| 1786 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1787 | + // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
| 1788 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
| 1789 | + } |
|
| 1790 | + $this->unlock_transaction(); |
|
| 1791 | + // just return for these conditions |
|
| 1792 | + if ( |
|
| 1793 | + $this->checkout->admin_request |
|
| 1794 | + || $this->checkout->action === 'redirect_form' |
|
| 1795 | + || $this->checkout->action === 'update_checkout' |
|
| 1796 | + ) { |
|
| 1797 | + return; |
|
| 1798 | + } |
|
| 1799 | + // AJAX response |
|
| 1800 | + $this->_handle_json_response(); |
|
| 1801 | + // redirect to next step or the Thank You page |
|
| 1802 | + $this->_handle_html_redirects(); |
|
| 1803 | + // hmmm... must be something wrong, so let's just display the form again ! |
|
| 1804 | + $this->_display_spco_reg_form(); |
|
| 1805 | + } |
|
| 1806 | + |
|
| 1807 | + |
|
| 1808 | + |
|
| 1809 | + /** |
|
| 1810 | + * _handle_json_response |
|
| 1811 | + * |
|
| 1812 | + * @access protected |
|
| 1813 | + * @return void |
|
| 1814 | + */ |
|
| 1815 | + protected function _handle_json_response() |
|
| 1816 | + { |
|
| 1817 | + // if this is an ajax request |
|
| 1818 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1819 | + // DEBUG LOG |
|
| 1820 | + //$this->checkout->log( |
|
| 1821 | + // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1822 | + // array( |
|
| 1823 | + // 'json_response_redirect_url' => $this->checkout->json_response->redirect_url(), |
|
| 1824 | + // 'redirect' => $this->checkout->redirect, |
|
| 1825 | + // 'continue_reg' => $this->checkout->continue_reg, |
|
| 1826 | + // ) |
|
| 1827 | + //); |
|
| 1828 | + $this->checkout->json_response->set_registration_time_limit( |
|
| 1829 | + $this->checkout->get_registration_time_limit() |
|
| 1830 | + ); |
|
| 1831 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
| 1832 | + // just send the ajax ( |
|
| 1833 | + $json_response = apply_filters( |
|
| 1834 | + 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
| 1835 | + $this->checkout->json_response |
|
| 1836 | + ); |
|
| 1837 | + echo $json_response; |
|
| 1838 | + exit(); |
|
| 1839 | + } |
|
| 1840 | + } |
|
| 1841 | + |
|
| 1842 | + |
|
| 1843 | + |
|
| 1844 | + /** |
|
| 1845 | + * _handle_redirects |
|
| 1846 | + * |
|
| 1847 | + * @access protected |
|
| 1848 | + * @return void |
|
| 1849 | + */ |
|
| 1850 | + protected function _handle_html_redirects() |
|
| 1851 | + { |
|
| 1852 | + // going somewhere ? |
|
| 1853 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
| 1854 | + // store notices in a transient |
|
| 1855 | + EE_Error::get_notices(false, true, true); |
|
| 1856 | + // DEBUG LOG |
|
| 1857 | + //$this->checkout->log( |
|
| 1858 | + // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1859 | + // array( |
|
| 1860 | + // 'headers_sent' => headers_sent(), |
|
| 1861 | + // 'redirect_url' => $this->checkout->redirect_url, |
|
| 1862 | + // 'headers_list' => headers_list(), |
|
| 1863 | + // ) |
|
| 1864 | + //); |
|
| 1865 | + wp_safe_redirect($this->checkout->redirect_url); |
|
| 1866 | + exit(); |
|
| 1867 | + } |
|
| 1868 | + } |
|
| 1869 | + |
|
| 1870 | + |
|
| 1871 | + |
|
| 1872 | + /** |
|
| 1873 | + * set_checkout_anchor |
|
| 1874 | + * |
|
| 1875 | + * @access public |
|
| 1876 | + * @return void |
|
| 1877 | + */ |
|
| 1878 | + public function set_checkout_anchor() |
|
| 1879 | + { |
|
| 1880 | + echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
| 1881 | + } |
|
| 1882 | 1882 | |
| 1883 | 1883 | |
| 1884 | 1884 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 3 | - exit('NO direct script access allowed'); |
|
| 3 | + exit('NO direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -26,62 +26,62 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - protected $_event; |
|
| 29 | + protected $_event; |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | - public function __construct(EE_Admin_Page $admin_page) |
|
| 33 | - { |
|
| 34 | - parent::__construct($admin_page); |
|
| 35 | - } |
|
| 32 | + public function __construct(EE_Admin_Page $admin_page) |
|
| 33 | + { |
|
| 34 | + parent::__construct($admin_page); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - protected function _set_hooks_properties() |
|
| 39 | - { |
|
| 38 | + protected function _set_hooks_properties() |
|
| 39 | + { |
|
| 40 | 40 | |
| 41 | - $this->_name = 'registration_form'; |
|
| 42 | - $this->_metaboxes = array( |
|
| 43 | - 0 => array( |
|
| 44 | - 'page_route' => array('edit', 'create_new'), |
|
| 45 | - 'func' => 'primary_questions', |
|
| 46 | - 'label' => __('Questions for Primary Registrant', 'event_espresso'), |
|
| 47 | - 'priority' => 'default', |
|
| 48 | - 'context' => 'side', |
|
| 49 | - ), |
|
| 50 | - ); |
|
| 41 | + $this->_name = 'registration_form'; |
|
| 42 | + $this->_metaboxes = array( |
|
| 43 | + 0 => array( |
|
| 44 | + 'page_route' => array('edit', 'create_new'), |
|
| 45 | + 'func' => 'primary_questions', |
|
| 46 | + 'label' => __('Questions for Primary Registrant', 'event_espresso'), |
|
| 47 | + 'priority' => 'default', |
|
| 48 | + 'context' => 'side', |
|
| 49 | + ), |
|
| 50 | + ); |
|
| 51 | 51 | |
| 52 | - //hook into the handler for saving question groups |
|
| 53 | - add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 54 | - array($this, 'modify_callbacks'), 10); |
|
| 52 | + //hook into the handler for saving question groups |
|
| 53 | + add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 54 | + array($this, 'modify_callbacks'), 10); |
|
| 55 | 55 | |
| 56 | - //hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already restricted by page) |
|
| 57 | - add_action('AHEE_EE_Admin_Page_CPT__restore_revision', array($this, 'restore_revision'), 10, 2); |
|
| 58 | - } |
|
| 56 | + //hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already restricted by page) |
|
| 57 | + add_action('AHEE_EE_Admin_Page_CPT__restore_revision', array($this, 'restore_revision'), 10, 2); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | |
| 61 | - public function modify_callbacks($callbacks) |
|
| 62 | - { |
|
| 63 | - //now let's add the question group callback |
|
| 64 | - $callbacks[] = array($this, 'primary_question_group_update'); |
|
| 65 | - return $callbacks; |
|
| 66 | - } |
|
| 61 | + public function modify_callbacks($callbacks) |
|
| 62 | + { |
|
| 63 | + //now let's add the question group callback |
|
| 64 | + $callbacks[] = array($this, 'primary_question_group_update'); |
|
| 65 | + return $callbacks; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | - public function restore_revision($post_id, $revision_id) |
|
| 70 | - { |
|
| 71 | - $EVT_MDL = EE_Registry::instance()->load_model('Event'); |
|
| 72 | - $post_evt = $EVT_MDL->get_one_by_ID($post_id); |
|
| 73 | - //restore revision for primary questions |
|
| 74 | - $post_evt->restore_revision($revision_id, array('Question_Group'), |
|
| 75 | - array('Question_Group' => array('Event_Question_Group.EQG_primary' => 1))); |
|
| 76 | - return $post_evt; //for any caffeinated functionality extending. |
|
| 77 | - } |
|
| 69 | + public function restore_revision($post_id, $revision_id) |
|
| 70 | + { |
|
| 71 | + $EVT_MDL = EE_Registry::instance()->load_model('Event'); |
|
| 72 | + $post_evt = $EVT_MDL->get_one_by_ID($post_id); |
|
| 73 | + //restore revision for primary questions |
|
| 74 | + $post_evt->restore_revision($revision_id, array('Question_Group'), |
|
| 75 | + array('Question_Group' => array('Event_Question_Group.EQG_primary' => 1))); |
|
| 76 | + return $post_evt; //for any caffeinated functionality extending. |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | |
| 80 | - public function primary_questions($post_id, $post) |
|
| 81 | - { |
|
| 82 | - $this->_event = $this->_adminpage_obj->get_event_object(); |
|
| 83 | - $event_id = $this->_event->ID(); |
|
| 84 | - ?> |
|
| 80 | + public function primary_questions($post_id, $post) |
|
| 81 | + { |
|
| 82 | + $this->_event = $this->_adminpage_obj->get_event_object(); |
|
| 83 | + $event_id = $this->_event->ID(); |
|
| 84 | + ?> |
|
| 85 | 85 | <div class="inside"> |
| 86 | 86 | <p><strong> |
| 87 | 87 | <?php _e('Question Groups', 'event_espresso'); ?> |
@@ -91,86 +91,86 @@ discard block |
||
| 91 | 91 | <?php _e('group of questions', 'event_espresso'); ?> |
| 92 | 92 | </a> |
| 93 | 93 | <?php _e('to your event. The personal information group is required for all events.', |
| 94 | - 'event_espresso'); ?> |
|
| 94 | + 'event_espresso'); ?> |
|
| 95 | 95 | </p> |
| 96 | 96 | <?php |
| 97 | 97 | |
| 98 | - $qsg_where['QSG_deleted'] = false; |
|
| 99 | - $query_params = array($qsg_where, 'order_by' => array('QSG_order' => 'ASC')); |
|
| 100 | - $QSGs = EEM_Question_Group::instance()->get_all($query_params); |
|
| 101 | - $EQGs = ! empty($event_id) ? $this->_event->get_many_related('Question_Group', |
|
| 102 | - array(array('Event_Question_Group.EQG_primary' => 1))) : array(); |
|
| 103 | - $EQGids = array_keys($EQGs); |
|
| 104 | - |
|
| 105 | - //EEH_Debug_Tools::printr( $QSGs, '$QSGs <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
| 106 | - |
|
| 107 | - if (! empty($QSGs)) { |
|
| 108 | - $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
|
| 109 | - foreach ($QSGs as $QSG) { |
|
| 110 | - |
|
| 111 | - $checked = (in_array($QSG->ID(), |
|
| 112 | - $EQGids) || $QSG->get('QSG_system') == 1) ? ' checked="checked"' : ''; |
|
| 113 | - $visibility = $QSG->get('QSG_system') == 1 ? ' style="visibility:hidden"' : ''; |
|
| 114 | - $edit_query_args = $this->_adminpage_obj->is_caf() ? array( |
|
| 115 | - 'action' => 'edit_question_group', |
|
| 116 | - 'QSG_ID' => $QSG->ID(), |
|
| 117 | - ) : array('action' => 'question_groups'); |
|
| 118 | - $edit_link = $this->_adminpage_obj->add_query_args_and_nonce($edit_query_args, |
|
| 119 | - EE_FORMS_ADMIN_URL); |
|
| 120 | - |
|
| 121 | - $html .= ' |
|
| 98 | + $qsg_where['QSG_deleted'] = false; |
|
| 99 | + $query_params = array($qsg_where, 'order_by' => array('QSG_order' => 'ASC')); |
|
| 100 | + $QSGs = EEM_Question_Group::instance()->get_all($query_params); |
|
| 101 | + $EQGs = ! empty($event_id) ? $this->_event->get_many_related('Question_Group', |
|
| 102 | + array(array('Event_Question_Group.EQG_primary' => 1))) : array(); |
|
| 103 | + $EQGids = array_keys($EQGs); |
|
| 104 | + |
|
| 105 | + //EEH_Debug_Tools::printr( $QSGs, '$QSGs <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
| 106 | + |
|
| 107 | + if (! empty($QSGs)) { |
|
| 108 | + $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
|
| 109 | + foreach ($QSGs as $QSG) { |
|
| 110 | + |
|
| 111 | + $checked = (in_array($QSG->ID(), |
|
| 112 | + $EQGids) || $QSG->get('QSG_system') == 1) ? ' checked="checked"' : ''; |
|
| 113 | + $visibility = $QSG->get('QSG_system') == 1 ? ' style="visibility:hidden"' : ''; |
|
| 114 | + $edit_query_args = $this->_adminpage_obj->is_caf() ? array( |
|
| 115 | + 'action' => 'edit_question_group', |
|
| 116 | + 'QSG_ID' => $QSG->ID(), |
|
| 117 | + ) : array('action' => 'question_groups'); |
|
| 118 | + $edit_link = $this->_adminpage_obj->add_query_args_and_nonce($edit_query_args, |
|
| 119 | + EE_FORMS_ADMIN_URL); |
|
| 120 | + |
|
| 121 | + $html .= ' |
|
| 122 | 122 | <p id="event-question-group-' . $QSG->ID() . '"> |
| 123 | 123 | <input value="' . $QSG->ID() . '" type="checkbox"' . $visibility . ' name="question_groups[' . $QSG->ID() . ']"' . $checked . ' /> |
| 124 | 124 | <a href="' . $edit_link . '" title="' . sprintf(esc_attr__('Edit %s Group', 'event_espresso'), |
| 125 | - $QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
| 125 | + $QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
| 126 | 126 | </p>'; |
| 127 | - } |
|
| 128 | - $html .= count($QSGs) > 10 ? '</div>' : ''; |
|
| 129 | - |
|
| 130 | - echo $html; |
|
| 131 | - } else { |
|
| 132 | - echo __('There seems to be a problem with your questions. Please contact [email protected]', |
|
| 133 | - 'event_espresso'); |
|
| 134 | - } |
|
| 135 | - do_action('AHEE_event_editor_questions_notice'); |
|
| 136 | - ?> |
|
| 127 | + } |
|
| 128 | + $html .= count($QSGs) > 10 ? '</div>' : ''; |
|
| 129 | + |
|
| 130 | + echo $html; |
|
| 131 | + } else { |
|
| 132 | + echo __('There seems to be a problem with your questions. Please contact [email protected]', |
|
| 133 | + 'event_espresso'); |
|
| 134 | + } |
|
| 135 | + do_action('AHEE_event_editor_questions_notice'); |
|
| 136 | + ?> |
|
| 137 | 137 | </div> |
| 138 | 138 | <?php |
| 139 | - } |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | - public function primary_question_group_update($evtobj, $data) |
|
| 143 | - { |
|
| 144 | - $question_groups = ! empty($data['question_groups']) ? (array)$data['question_groups'] : array(); |
|
| 145 | - $added_qgs = array_keys($question_groups); |
|
| 146 | - $success = array(); |
|
| 142 | + public function primary_question_group_update($evtobj, $data) |
|
| 143 | + { |
|
| 144 | + $question_groups = ! empty($data['question_groups']) ? (array)$data['question_groups'] : array(); |
|
| 145 | + $added_qgs = array_keys($question_groups); |
|
| 146 | + $success = array(); |
|
| 147 | 147 | |
| 148 | - //let's get all current question groups associated with this event. |
|
| 149 | - $current_qgs = $evtobj->get_many_related('Question_Group', |
|
| 150 | - array(array('Event_Question_Group.EQG_primary' => 1))); |
|
| 151 | - $current_qgs = array_keys($current_qgs); //we just want the ids |
|
| 148 | + //let's get all current question groups associated with this event. |
|
| 149 | + $current_qgs = $evtobj->get_many_related('Question_Group', |
|
| 150 | + array(array('Event_Question_Group.EQG_primary' => 1))); |
|
| 151 | + $current_qgs = array_keys($current_qgs); //we just want the ids |
|
| 152 | 152 | |
| 153 | - //now let's get the groups selected in the editor and update (IF we have data) |
|
| 154 | - if (! empty($question_groups)) { |
|
| 155 | - foreach ($question_groups as $id => $val) { |
|
| 156 | - //add to event |
|
| 157 | - if ($val) { |
|
| 158 | - $qg = $evtobj->_add_relation_to($id, 'Question_Group', array('EQG_primary' => 1)); |
|
| 159 | - } |
|
| 160 | - $success[] = ! empty($qg) ? 1 : 0; |
|
| 161 | - } |
|
| 162 | - } |
|
| 153 | + //now let's get the groups selected in the editor and update (IF we have data) |
|
| 154 | + if (! empty($question_groups)) { |
|
| 155 | + foreach ($question_groups as $id => $val) { |
|
| 156 | + //add to event |
|
| 157 | + if ($val) { |
|
| 158 | + $qg = $evtobj->_add_relation_to($id, 'Question_Group', array('EQG_primary' => 1)); |
|
| 159 | + } |
|
| 160 | + $success[] = ! empty($qg) ? 1 : 0; |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - //wait a minute... are there question groups missing in the saved groups that ARE with the current event? |
|
| 165 | - $removed_qgs = array_diff($current_qgs, $added_qgs); |
|
| 164 | + //wait a minute... are there question groups missing in the saved groups that ARE with the current event? |
|
| 165 | + $removed_qgs = array_diff($current_qgs, $added_qgs); |
|
| 166 | 166 | |
| 167 | - foreach ($removed_qgs as $qgid) { |
|
| 168 | - $qg = $evtobj->_remove_relation_to($qgid, 'Question_Group', array('EQG_primary' => 1)); |
|
| 169 | - $success[] = ! empty($qg) ? 1 : 0; |
|
| 170 | - } |
|
| 167 | + foreach ($removed_qgs as $qgid) { |
|
| 168 | + $qg = $evtobj->_remove_relation_to($qgid, 'Question_Group', array('EQG_primary' => 1)); |
|
| 169 | + $success[] = ! empty($qg) ? 1 : 0; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | 172 | |
| 173 | - return in_array(0, $success) ? false : true; |
|
| 173 | + return in_array(0, $success) ? false : true; |
|
| 174 | 174 | |
| 175 | - } |
|
| 175 | + } |
|
| 176 | 176 | } //end espresso_events_Registration_Form_Hooks |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | 3 | exit('NO direct script access allowed'); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | //EEH_Debug_Tools::printr( $QSGs, '$QSGs <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 106 | 106 | |
| 107 | - if (! empty($QSGs)) { |
|
| 107 | + if ( ! empty($QSGs)) { |
|
| 108 | 108 | $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
| 109 | 109 | foreach ($QSGs as $QSG) { |
| 110 | 110 | |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | 'action' => 'edit_question_group', |
| 116 | 116 | 'QSG_ID' => $QSG->ID(), |
| 117 | 117 | ) : array('action' => 'question_groups'); |
| 118 | - $edit_link = $this->_adminpage_obj->add_query_args_and_nonce($edit_query_args, |
|
| 118 | + $edit_link = $this->_adminpage_obj->add_query_args_and_nonce($edit_query_args, |
|
| 119 | 119 | EE_FORMS_ADMIN_URL); |
| 120 | 120 | |
| 121 | 121 | $html .= ' |
| 122 | - <p id="event-question-group-' . $QSG->ID() . '"> |
|
| 123 | - <input value="' . $QSG->ID() . '" type="checkbox"' . $visibility . ' name="question_groups[' . $QSG->ID() . ']"' . $checked . ' /> |
|
| 124 | - <a href="' . $edit_link . '" title="' . sprintf(esc_attr__('Edit %s Group', 'event_espresso'), |
|
| 125 | - $QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
| 122 | + <p id="event-question-group-' . $QSG->ID().'"> |
|
| 123 | + <input value="' . $QSG->ID().'" type="checkbox"'.$visibility.' name="question_groups['.$QSG->ID().']"'.$checked.' /> |
|
| 124 | + <a href="' . $edit_link.'" title="'.sprintf(esc_attr__('Edit %s Group', 'event_espresso'), |
|
| 125 | + $QSG->get('QSG_name')).'" target="_blank">'.$QSG->get('QSG_name').'</a> |
|
| 126 | 126 | </p>'; |
| 127 | 127 | } |
| 128 | 128 | $html .= count($QSGs) > 10 ? '</div>' : ''; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | public function primary_question_group_update($evtobj, $data) |
| 143 | 143 | { |
| 144 | - $question_groups = ! empty($data['question_groups']) ? (array)$data['question_groups'] : array(); |
|
| 144 | + $question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : array(); |
|
| 145 | 145 | $added_qgs = array_keys($question_groups); |
| 146 | 146 | $success = array(); |
| 147 | 147 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $current_qgs = array_keys($current_qgs); //we just want the ids |
| 152 | 152 | |
| 153 | 153 | //now let's get the groups selected in the editor and update (IF we have data) |
| 154 | - if (! empty($question_groups)) { |
|
| 154 | + if ( ! empty($question_groups)) { |
|
| 155 | 155 | foreach ($question_groups as $id => $val) { |
| 156 | 156 | //add to event |
| 157 | 157 | if ($val) { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 3 | - exit('NO direct script access allowed'); |
|
| 3 | + exit('NO direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -26,69 +26,69 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - public function __construct(EE_Admin_Page $admin_page) |
|
| 30 | - { |
|
| 31 | - parent::__construct($admin_page); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * extending the properties set in espresso_events_Registration_From_Hooks |
|
| 37 | - * |
|
| 38 | - * @access protected |
|
| 39 | - * @return void |
|
| 40 | - */ |
|
| 41 | - protected function _extend_properties() |
|
| 42 | - { |
|
| 43 | - $this->_metaboxes = array_merge( |
|
| 44 | - $this->_metaboxes, |
|
| 45 | - array( |
|
| 46 | - 1 => array( |
|
| 47 | - 'page_route' => array('create_new', 'edit'), |
|
| 48 | - 'func' => 'additional_questions', |
|
| 49 | - 'label' => __('Questions for Additional Registrants', 'event_espresso'), |
|
| 50 | - 'priority' => 'default', |
|
| 51 | - 'context' => 'side', |
|
| 52 | - ), |
|
| 53 | - ) |
|
| 54 | - ); |
|
| 55 | - $this->_scripts_styles = array( |
|
| 56 | - 'registers' => array( |
|
| 57 | - 'extended-event-editor' => array( |
|
| 58 | - 'url' => EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/event-editor-question-groups.js', |
|
| 59 | - 'depends' => array('jquery'), |
|
| 60 | - ), |
|
| 61 | - ), |
|
| 62 | - 'enqueues' => array( |
|
| 63 | - 'extended-event-editor' => array('edit', 'create_new'), |
|
| 64 | - ), |
|
| 65 | - ); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - public function modify_callbacks($callbacks) |
|
| 70 | - { |
|
| 71 | - $callbacks = parent::modify_callbacks($callbacks); |
|
| 72 | - $callbacks[] = array($this, 'additional_question_group_update'); |
|
| 73 | - return $callbacks; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - public function restore_revision($post_id, $revision_id) |
|
| 78 | - { |
|
| 79 | - $post_evt = parent::restore_revision($post_id, $revision_id); |
|
| 80 | - |
|
| 81 | - //restore revision for additional questions |
|
| 82 | - $post_evt->restore_revision($revision_id, array('Question_Group'), |
|
| 83 | - array('Question_Group' => array('Event_Question_Group.EQG_primary' => 0))); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - public function additional_questions($post_id, $post) |
|
| 88 | - { |
|
| 89 | - $this->_event = $this->_adminpage_obj->get_event_object(); |
|
| 90 | - $event_id = $this->_event->ID(); |
|
| 91 | - ?> |
|
| 29 | + public function __construct(EE_Admin_Page $admin_page) |
|
| 30 | + { |
|
| 31 | + parent::__construct($admin_page); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * extending the properties set in espresso_events_Registration_From_Hooks |
|
| 37 | + * |
|
| 38 | + * @access protected |
|
| 39 | + * @return void |
|
| 40 | + */ |
|
| 41 | + protected function _extend_properties() |
|
| 42 | + { |
|
| 43 | + $this->_metaboxes = array_merge( |
|
| 44 | + $this->_metaboxes, |
|
| 45 | + array( |
|
| 46 | + 1 => array( |
|
| 47 | + 'page_route' => array('create_new', 'edit'), |
|
| 48 | + 'func' => 'additional_questions', |
|
| 49 | + 'label' => __('Questions for Additional Registrants', 'event_espresso'), |
|
| 50 | + 'priority' => 'default', |
|
| 51 | + 'context' => 'side', |
|
| 52 | + ), |
|
| 53 | + ) |
|
| 54 | + ); |
|
| 55 | + $this->_scripts_styles = array( |
|
| 56 | + 'registers' => array( |
|
| 57 | + 'extended-event-editor' => array( |
|
| 58 | + 'url' => EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/event-editor-question-groups.js', |
|
| 59 | + 'depends' => array('jquery'), |
|
| 60 | + ), |
|
| 61 | + ), |
|
| 62 | + 'enqueues' => array( |
|
| 63 | + 'extended-event-editor' => array('edit', 'create_new'), |
|
| 64 | + ), |
|
| 65 | + ); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + public function modify_callbacks($callbacks) |
|
| 70 | + { |
|
| 71 | + $callbacks = parent::modify_callbacks($callbacks); |
|
| 72 | + $callbacks[] = array($this, 'additional_question_group_update'); |
|
| 73 | + return $callbacks; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + public function restore_revision($post_id, $revision_id) |
|
| 78 | + { |
|
| 79 | + $post_evt = parent::restore_revision($post_id, $revision_id); |
|
| 80 | + |
|
| 81 | + //restore revision for additional questions |
|
| 82 | + $post_evt->restore_revision($revision_id, array('Question_Group'), |
|
| 83 | + array('Question_Group' => array('Event_Question_Group.EQG_primary' => 0))); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + public function additional_questions($post_id, $post) |
|
| 88 | + { |
|
| 89 | + $this->_event = $this->_adminpage_obj->get_event_object(); |
|
| 90 | + $event_id = $this->_event->ID(); |
|
| 91 | + ?> |
|
| 92 | 92 | <div class="inside"> |
| 93 | 93 | <p><strong> |
| 94 | 94 | <?php _e('Question Groups', 'event_espresso'); ?> |
@@ -101,83 +101,83 @@ discard block |
||
| 101 | 101 | </p> |
| 102 | 102 | <?php |
| 103 | 103 | |
| 104 | - $qsg_where['QSG_deleted'] = false; |
|
| 105 | - $query_params = array($qsg_where, 'order_by' => array('QSG_order' => 'ASC')); |
|
| 106 | - $QSGs = EEM_Question_Group::instance()->get_all($query_params); |
|
| 107 | - $EQGs = ! empty($event_id) ? $this->_event->get_many_related('Question_Group', |
|
| 108 | - array(array('Event_Question_Group.EQG_primary' => 0))) : array(); |
|
| 109 | - $EQGids = array_keys($EQGs); |
|
| 104 | + $qsg_where['QSG_deleted'] = false; |
|
| 105 | + $query_params = array($qsg_where, 'order_by' => array('QSG_order' => 'ASC')); |
|
| 106 | + $QSGs = EEM_Question_Group::instance()->get_all($query_params); |
|
| 107 | + $EQGs = ! empty($event_id) ? $this->_event->get_many_related('Question_Group', |
|
| 108 | + array(array('Event_Question_Group.EQG_primary' => 0))) : array(); |
|
| 109 | + $EQGids = array_keys($EQGs); |
|
| 110 | 110 | |
| 111 | - if (! empty($QSGs)) { |
|
| 112 | - $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
|
| 113 | - foreach ($QSGs as $QSG) { |
|
| 111 | + if (! empty($QSGs)) { |
|
| 112 | + $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
|
| 113 | + foreach ($QSGs as $QSG) { |
|
| 114 | 114 | |
| 115 | - $checked = in_array($QSG->ID(), $EQGids) ? ' checked="checked" ' : ''; |
|
| 116 | - $edit_link = $this->_adminpage_obj->add_query_args_and_nonce(array( |
|
| 117 | - 'action' => 'edit_question_group', |
|
| 118 | - 'QSG_ID' => $QSG->ID(), |
|
| 119 | - ), EE_FORMS_ADMIN_URL); |
|
| 115 | + $checked = in_array($QSG->ID(), $EQGids) ? ' checked="checked" ' : ''; |
|
| 116 | + $edit_link = $this->_adminpage_obj->add_query_args_and_nonce(array( |
|
| 117 | + 'action' => 'edit_question_group', |
|
| 118 | + 'QSG_ID' => $QSG->ID(), |
|
| 119 | + ), EE_FORMS_ADMIN_URL); |
|
| 120 | 120 | |
| 121 | - $html .= ' |
|
| 121 | + $html .= ' |
|
| 122 | 122 | <p id="event-question-group-' . $QSG->ID() . '"> |
| 123 | 123 | <input value="' . $QSG->ID() . '" type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' /> |
| 124 | 124 | <a href="' . $edit_link . '" title="' . sprintf(esc_attr__('Edit %s Group', 'event_espresso'), |
| 125 | - $QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
| 125 | + $QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
| 126 | 126 | </p>'; |
| 127 | - if ($QSG->ID() === 2) { |
|
| 128 | - $html .= ' |
|
| 127 | + if ($QSG->ID() === 2) { |
|
| 128 | + $html .= ' |
|
| 129 | 129 | <p id="question-group-requirements-notice-pg" class="important-notice small-text" style="display: none;"> |
| 130 | 130 | ' . esc_html__('The Personal Information question group is required whenever the Address Information question group is activated.', |
| 131 | - 'event_espresso') . ' |
|
| 131 | + 'event_espresso') . ' |
|
| 132 | 132 | </p>'; |
| 133 | - } |
|
| 134 | - } |
|
| 135 | - $html .= count($QSGs) > 10 ? '</div>' : ''; |
|
| 136 | - |
|
| 137 | - echo $html; |
|
| 138 | - |
|
| 139 | - } else { |
|
| 140 | - echo __('There seems to be a problem with your questions. Please contact [email protected]', |
|
| 141 | - 'event_espresso'); |
|
| 142 | - } |
|
| 143 | - do_action('AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content'); |
|
| 144 | - ?> |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + $html .= count($QSGs) > 10 ? '</div>' : ''; |
|
| 136 | + |
|
| 137 | + echo $html; |
|
| 138 | + |
|
| 139 | + } else { |
|
| 140 | + echo __('There seems to be a problem with your questions. Please contact [email protected]', |
|
| 141 | + 'event_espresso'); |
|
| 142 | + } |
|
| 143 | + do_action('AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content'); |
|
| 144 | + ?> |
|
| 145 | 145 | </div> |
| 146 | 146 | <?php |
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - public function additional_question_group_update($evtobj, $data) |
|
| 151 | - { |
|
| 152 | - $question_groups = ! empty($data['add_attendee_question_groups']) ? (array)$data['add_attendee_question_groups'] : array(); |
|
| 153 | - $added_qgs = array_keys($question_groups); |
|
| 154 | - $success = array(); |
|
| 155 | - |
|
| 156 | - //let's get all current question groups associated with this event. |
|
| 157 | - $current_qgs = $evtobj->get_many_related('Question_Group', |
|
| 158 | - array(array('Event_Question_Group.EQG_primary' => 0))); |
|
| 159 | - $current_qgs = array_keys($current_qgs); //we just want the ids |
|
| 160 | - |
|
| 161 | - //now let's get the groups selected in the editor and update (IF we have data) |
|
| 162 | - if (! empty($question_groups)) { |
|
| 163 | - foreach ($question_groups as $id => $val) { |
|
| 164 | - //add to event |
|
| 165 | - if ($val) { |
|
| 166 | - $qg = $evtobj->_add_relation_to($id, 'Question_Group', array('EQG_primary' => 0)); |
|
| 167 | - } |
|
| 168 | - $success[] = ! empty($qg) ? 1 : 0; |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - //wait a minute... are there question groups missing in the saved groups that ARE with the current event? |
|
| 173 | - $removed_qgs = array_diff($current_qgs, $added_qgs); |
|
| 174 | - |
|
| 175 | - foreach ($removed_qgs as $qgid) { |
|
| 176 | - $qg = $evtobj->_remove_relation_to($qgid, 'Question_Group', array('EQG_primary' => 0)); |
|
| 177 | - $success[] = ! empty($qg) ? 1 : 0; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - return in_array(0, $success) ? false : true; |
|
| 182 | - } |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + public function additional_question_group_update($evtobj, $data) |
|
| 151 | + { |
|
| 152 | + $question_groups = ! empty($data['add_attendee_question_groups']) ? (array)$data['add_attendee_question_groups'] : array(); |
|
| 153 | + $added_qgs = array_keys($question_groups); |
|
| 154 | + $success = array(); |
|
| 155 | + |
|
| 156 | + //let's get all current question groups associated with this event. |
|
| 157 | + $current_qgs = $evtobj->get_many_related('Question_Group', |
|
| 158 | + array(array('Event_Question_Group.EQG_primary' => 0))); |
|
| 159 | + $current_qgs = array_keys($current_qgs); //we just want the ids |
|
| 160 | + |
|
| 161 | + //now let's get the groups selected in the editor and update (IF we have data) |
|
| 162 | + if (! empty($question_groups)) { |
|
| 163 | + foreach ($question_groups as $id => $val) { |
|
| 164 | + //add to event |
|
| 165 | + if ($val) { |
|
| 166 | + $qg = $evtobj->_add_relation_to($id, 'Question_Group', array('EQG_primary' => 0)); |
|
| 167 | + } |
|
| 168 | + $success[] = ! empty($qg) ? 1 : 0; |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + //wait a minute... are there question groups missing in the saved groups that ARE with the current event? |
|
| 173 | + $removed_qgs = array_diff($current_qgs, $added_qgs); |
|
| 174 | + |
|
| 175 | + foreach ($removed_qgs as $qgid) { |
|
| 176 | + $qg = $evtobj->_remove_relation_to($qgid, 'Question_Group', array('EQG_primary' => 0)); |
|
| 177 | + $success[] = ! empty($qg) ? 1 : 0; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + return in_array(0, $success) ? false : true; |
|
| 182 | + } |
|
| 183 | 183 | } //end class espresso_events_Registration_Form_Hooks_Extend |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | 3 | exit('NO direct script access allowed'); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | protected function _extend_properties() |
| 42 | 42 | { |
| 43 | - $this->_metaboxes = array_merge( |
|
| 43 | + $this->_metaboxes = array_merge( |
|
| 44 | 44 | $this->_metaboxes, |
| 45 | 45 | array( |
| 46 | 46 | 1 => array( |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $this->_scripts_styles = array( |
| 56 | 56 | 'registers' => array( |
| 57 | 57 | 'extended-event-editor' => array( |
| 58 | - 'url' => EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/event-editor-question-groups.js', |
|
| 58 | + 'url' => EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/event-editor-question-groups.js', |
|
| 59 | 59 | 'depends' => array('jquery'), |
| 60 | 60 | ), |
| 61 | 61 | ), |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | array(array('Event_Question_Group.EQG_primary' => 0))) : array(); |
| 109 | 109 | $EQGids = array_keys($EQGs); |
| 110 | 110 | |
| 111 | - if (! empty($QSGs)) { |
|
| 111 | + if ( ! empty($QSGs)) { |
|
| 112 | 112 | $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
| 113 | 113 | foreach ($QSGs as $QSG) { |
| 114 | 114 | |
@@ -119,16 +119,16 @@ discard block |
||
| 119 | 119 | ), EE_FORMS_ADMIN_URL); |
| 120 | 120 | |
| 121 | 121 | $html .= ' |
| 122 | - <p id="event-question-group-' . $QSG->ID() . '"> |
|
| 123 | - <input value="' . $QSG->ID() . '" type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' /> |
|
| 124 | - <a href="' . $edit_link . '" title="' . sprintf(esc_attr__('Edit %s Group', 'event_espresso'), |
|
| 125 | - $QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
| 122 | + <p id="event-question-group-' . $QSG->ID().'"> |
|
| 123 | + <input value="' . $QSG->ID().'" type="checkbox" name="add_attendee_question_groups['.$QSG->ID().']"'.$checked.' /> |
|
| 124 | + <a href="' . $edit_link.'" title="'.sprintf(esc_attr__('Edit %s Group', 'event_espresso'), |
|
| 125 | + $QSG->get('QSG_name')).'" target="_blank">'.$QSG->get('QSG_name').'</a> |
|
| 126 | 126 | </p>'; |
| 127 | 127 | if ($QSG->ID() === 2) { |
| 128 | 128 | $html .= ' |
| 129 | 129 | <p id="question-group-requirements-notice-pg" class="important-notice small-text" style="display: none;"> |
| 130 | 130 | ' . esc_html__('The Personal Information question group is required whenever the Address Information question group is activated.', |
| 131 | - 'event_espresso') . ' |
|
| 131 | + 'event_espresso').' |
|
| 132 | 132 | </p>'; |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | public function additional_question_group_update($evtobj, $data) |
| 151 | 151 | { |
| 152 | - $question_groups = ! empty($data['add_attendee_question_groups']) ? (array)$data['add_attendee_question_groups'] : array(); |
|
| 152 | + $question_groups = ! empty($data['add_attendee_question_groups']) ? (array) $data['add_attendee_question_groups'] : array(); |
|
| 153 | 153 | $added_qgs = array_keys($question_groups); |
| 154 | 154 | $success = array(); |
| 155 | 155 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $current_qgs = array_keys($current_qgs); //we just want the ids |
| 160 | 160 | |
| 161 | 161 | //now let's get the groups selected in the editor and update (IF we have data) |
| 162 | - if (! empty($question_groups)) { |
|
| 162 | + if ( ! empty($question_groups)) { |
|
| 163 | 163 | foreach ($question_groups as $id => $val) { |
| 164 | 164 | //add to event |
| 165 | 165 | if ($val) { |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 4 | - exit('NO direct script access allowed'); |
|
| 4 | + exit('NO direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -27,511 +27,511 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * user id for logged in user when data collected |
|
| 32 | - * |
|
| 33 | - * @var string $user_id |
|
| 34 | - */ |
|
| 35 | - public $user_id; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * IP Address of browser used |
|
| 39 | - * |
|
| 40 | - * @var string $ip_address |
|
| 41 | - */ |
|
| 42 | - public $ip_address; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * browser |
|
| 46 | - * |
|
| 47 | - * @var string $user_agent |
|
| 48 | - */ |
|
| 49 | - public $user_agent; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Unix timestamp |
|
| 53 | - * |
|
| 54 | - * @var string $init_access |
|
| 55 | - */ |
|
| 56 | - public $init_access; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Unix timestamp |
|
| 60 | - * |
|
| 61 | - * @var string $last_access |
|
| 62 | - */ |
|
| 63 | - public $last_access; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * The registrations details from the cart |
|
| 67 | - * |
|
| 68 | - * @var array $reg_info |
|
| 69 | - */ |
|
| 70 | - public $reg_info; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Some data handlers can set what reg status all the registrations are filtered by. |
|
| 74 | - * The status should match a EEM_Registration status constant. |
|
| 75 | - * |
|
| 76 | - * @var string $filtered_reg_status |
|
| 77 | - */ |
|
| 78 | - public $filtered_reg_status; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * will hold an array of events assembled from $reg_info |
|
| 82 | - * |
|
| 83 | - * @var EE_Event[] $events |
|
| 84 | - */ |
|
| 85 | - public $events; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * holds an array of datetimes assembled from the incoming data. |
|
| 89 | - * |
|
| 90 | - * @var EE_Datetime[] $datetimes |
|
| 91 | - */ |
|
| 92 | - public $datetimes; |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * holds an array of tickets assembled from the incoming data. |
|
| 96 | - * |
|
| 97 | - * @var EE_Ticket[] $tickets |
|
| 98 | - */ |
|
| 99 | - public $tickets; |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * holds an array with a key of parent line item and values are an array of children of that line item. |
|
| 103 | - * |
|
| 104 | - * @since 4.5.0 |
|
| 105 | - * @var EE_Line_Item[] $line_items_with_children |
|
| 106 | - */ |
|
| 107 | - public $line_items_with_children; |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * will hold an array of attendees assembled from the $reg_info |
|
| 111 | - * |
|
| 112 | - * @var EE_Attendee[] $attendees |
|
| 113 | - */ |
|
| 114 | - public $attendees; |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * will hold an array of cached registration objects and info assembled from reg_info |
|
| 118 | - * |
|
| 119 | - * @var array $registrations |
|
| 120 | - */ |
|
| 121 | - public $registrations; |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * will hold an array of answers assembled from the $reg_info |
|
| 125 | - * |
|
| 126 | - * @var EE_Answer[] $answers |
|
| 127 | - */ |
|
| 128 | - public $answers; |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * will hold an array of questions assembled from the $reg_info (indexed by Answer ID); |
|
| 132 | - * |
|
| 133 | - * @var EE_Question[] $questions |
|
| 134 | - */ |
|
| 135 | - public $questions; |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * Will hold billing data assembled from $billing_info (if present) |
|
| 139 | - * |
|
| 140 | - * @var mixed (array|null) $billing |
|
| 141 | - */ |
|
| 142 | - public $billing; |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * The total amount of tax for the transaction |
|
| 146 | - * |
|
| 147 | - * @var float $taxes |
|
| 148 | - */ |
|
| 149 | - public $taxes; |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Holds the line items related to taxes |
|
| 153 | - * |
|
| 154 | - * @since 4.5.0 |
|
| 155 | - * @var EE_Line_Item[] $tax_line_items |
|
| 156 | - */ |
|
| 157 | - public $tax_line_items; |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Hold the line items which aren't taxes and don't relate |
|
| 161 | - * to tickets. So: promotions and miscellaneous charges |
|
| 162 | - * |
|
| 163 | - * @since 4.5 |
|
| 164 | - * @var EE_Line_Item[] $additional_line_items |
|
| 165 | - */ |
|
| 166 | - public $additional_line_items; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Holds the grand total EE_Line_Item |
|
| 170 | - * |
|
| 171 | - * @var EE_Line_Item $grand_total_line_item |
|
| 172 | - */ |
|
| 173 | - public $grand_total_line_item; |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * holds the grand total price object |
|
| 177 | - * |
|
| 178 | - * @var object $grand_total_price_object |
|
| 179 | - */ |
|
| 180 | - public $grand_total_price_object; |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * total number of tickets |
|
| 184 | - * |
|
| 185 | - * @var int $total_ticket_count |
|
| 186 | - */ |
|
| 187 | - public $total_ticket_count; |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Will hold the final transaction object (EE_Transaction) |
|
| 191 | - * |
|
| 192 | - * @var EE_Transaction $txn |
|
| 193 | - */ |
|
| 194 | - public $txn; |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Holds the payments related to a transaction |
|
| 198 | - * |
|
| 199 | - * @since 4.5.0 |
|
| 200 | - * @var EE_Payment[] $payments |
|
| 201 | - */ |
|
| 202 | - public $payments; |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Holds the first related payment related for a transaction |
|
| 206 | - * |
|
| 207 | - * @since 4.5.0 |
|
| 208 | - * @var EE_Payment $payment |
|
| 209 | - */ |
|
| 210 | - public $payment; |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * Will hold the label for the txn status |
|
| 214 | - * |
|
| 215 | - * @var string $txn_status |
|
| 216 | - */ |
|
| 217 | - public $txn_status; |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Will hold the final registration object (EE_Registration) |
|
| 221 | - * |
|
| 222 | - * @var EE_Registration[] $reg_objs |
|
| 223 | - */ |
|
| 224 | - public $reg_objs; |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Will hold an array of primary attendee data (if present) |
|
| 228 | - * |
|
| 229 | - * @var array $primary_attendee_data |
|
| 230 | - */ |
|
| 231 | - public $primary_attendee_data; |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * This is just an internal object used for passing around the incoming data. |
|
| 235 | - * |
|
| 236 | - * @var object $_data |
|
| 237 | - */ |
|
| 238 | - protected $_data; |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * This is just an internal object used for passing around the incoming data. |
|
| 242 | - * |
|
| 243 | - * @var object $incoming_data |
|
| 244 | - */ |
|
| 245 | - public $incoming_data; |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * hold objects that might be created |
|
| 249 | - * |
|
| 250 | - * @type EE_Registration $reg_obj |
|
| 251 | - */ |
|
| 252 | - public $reg_obj; |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * constructor |
|
| 257 | - * |
|
| 258 | - * @param mixed $data incoming data object|array. Suggested that child classes use type hinting for expected |
|
| 259 | - * data object. But here parent will be generic because we don't know what's coming in. |
|
| 260 | - */ |
|
| 261 | - public function __construct($data) |
|
| 262 | - { |
|
| 263 | - $this->_data = $data; |
|
| 264 | - $this->_setup_data(); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * Every child class has to setup the data object ! |
|
| 270 | - * |
|
| 271 | - * @return void |
|
| 272 | - */ |
|
| 273 | - abstract protected function _setup_data(); |
|
| 274 | - |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * Returns database safe representation of the data later used to when instantiating this object. |
|
| 278 | - * |
|
| 279 | - * @param mixed $data The incoming data to be prepped. |
|
| 280 | - * @return mixed The prepped data for db |
|
| 281 | - */ |
|
| 282 | - static public function convert_data_for_persistent_storage($data) |
|
| 283 | - { |
|
| 284 | - return $data; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
| 290 | - * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
| 291 | - * |
|
| 292 | - * @param $data |
|
| 293 | - * @return mixed |
|
| 294 | - */ |
|
| 295 | - static public function convert_data_from_persistent_storage($data) |
|
| 296 | - { |
|
| 297 | - return $data; |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - |
|
| 301 | - /** |
|
| 302 | - * only purpose is to return the data |
|
| 303 | - * |
|
| 304 | - * @access public |
|
| 305 | - * @return object the formatted data object! |
|
| 306 | - */ |
|
| 307 | - public function data() |
|
| 308 | - { |
|
| 309 | - return $this->_data; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * This helper method can be used by any incoming data handlers to setup the data correctly. All that is required |
|
| 315 | - * is that $this->reg_objs be set. |
|
| 316 | - * |
|
| 317 | - * @throws \EE_Error |
|
| 318 | - */ |
|
| 319 | - protected function _assemble_data() |
|
| 320 | - { |
|
| 321 | - //verify that reg_objs is set |
|
| 322 | - if ( |
|
| 323 | - ! is_array($this->reg_objs) |
|
| 324 | - && ! reset($this->reg_objs) instanceof EE_Registration |
|
| 325 | - ) { |
|
| 326 | - throw new EE_Error( |
|
| 327 | - __( |
|
| 328 | - 'In order to assemble the data correctly, the "reg_objs" property must be an array of EE_Registration objects', |
|
| 329 | - 'event_espresso' |
|
| 330 | - ) |
|
| 331 | - ); |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - //get all attendee and events associated with the registrations in this transaction |
|
| 335 | - $events = $event_setup = $evtcache = $tickets = $datetimes = array(); |
|
| 336 | - $answers = $questions = $attendees = $line_items = $registrations = array(); |
|
| 337 | - $total_ticket_count = 0; |
|
| 338 | - |
|
| 339 | - if (! empty($this->reg_objs)) { |
|
| 340 | - $event_attendee_count = array(); |
|
| 341 | - foreach ($this->reg_objs as $reg) { |
|
| 342 | - |
|
| 343 | - if ( |
|
| 344 | - $this->_skip_registration_for_processing($reg) |
|
| 345 | - ) { |
|
| 346 | - continue; |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - $evt_id = $reg->event_ID(); |
|
| 350 | - /** @type EE_Ticket $ticket */ |
|
| 351 | - $ticket = $reg->get_first_related('Ticket'); |
|
| 352 | - $relateddatetime = $ticket->datetimes(); |
|
| 353 | - $total_ticket_count++; |
|
| 354 | - $tickets[$ticket->ID()]['ticket'] = $ticket; |
|
| 355 | - $tickets[$ticket->ID()]['count'] = is_array($tickets[$ticket->ID()]) |
|
| 356 | - && isset($tickets[$ticket->ID()]['count']) |
|
| 357 | - ? $tickets[$ticket->ID()]['count'] + 1 |
|
| 358 | - : 1; |
|
| 359 | - $tickets[$ticket->ID()]['att_objs'][$reg->attendee_ID()] = $reg->attendee(); |
|
| 360 | - $tickets[$ticket->ID()]['dtt_objs'] = $relateddatetime; |
|
| 361 | - $tickets[$ticket->ID()]['reg_objs'][$reg->ID()] = $reg; |
|
| 362 | - $event = $reg->event(); |
|
| 363 | - $tickets[$ticket->ID()]['EE_Event'] = $event; |
|
| 364 | - $evtcache[$evt_id] = $event; |
|
| 365 | - $eventsetup[$evt_id]['reg_objs'][$reg->ID()] = $reg; |
|
| 366 | - $eventsetup[$evt_id]['tkt_objs'][$ticket->ID()] = $ticket; |
|
| 367 | - $eventsetup[$evt_id]['att_objs'][$reg->attendee_ID()] = $reg->attendee(); |
|
| 368 | - $event_attendee_count[$evt_id] = isset($event_attendee_count[$evt_id]) |
|
| 369 | - ? $event_attendee_count[$evt_id] + 1 |
|
| 370 | - : 0; |
|
| 371 | - $attendees[$reg->attendee_ID()]['line_ref'][] = $evt_id; |
|
| 372 | - $attendees[$reg->attendee_ID()]['att_obj'] = $reg->attendee(); |
|
| 373 | - $attendees[$reg->attendee_ID()]['reg_objs'][$reg->ID()] = $reg; |
|
| 374 | - //$attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID(); |
|
| 375 | - $attendees[$reg->attendee_ID()]['attendee_email'] = $reg->attendee() instanceof EE_Attendee |
|
| 376 | - ? $reg->attendee()->email() |
|
| 377 | - : ''; |
|
| 378 | - $attendees[$reg->attendee_ID()]['tkt_objs'][$ticket->ID()] = $ticket; |
|
| 379 | - $attendees[$reg->attendee_ID()]['evt_objs'][$evt_id] = $event; |
|
| 380 | - |
|
| 381 | - //registrations |
|
| 382 | - $registrations[$reg->ID()]['tkt_obj'] = $ticket; |
|
| 383 | - $registrations[$reg->ID()]['evt_obj'] = $event; |
|
| 384 | - $registrations[$reg->ID()]['reg_obj'] = $reg; |
|
| 385 | - $registrations[$reg->ID()]['att_obj'] = $reg->attendee(); |
|
| 386 | - |
|
| 387 | - //set up answer objects |
|
| 388 | - $rel_ans = $reg->get_many_related('Answer'); |
|
| 389 | - foreach ($rel_ans as $ansid => $answer) { |
|
| 390 | - if (! isset($questions[$ansid])) { |
|
| 391 | - $questions[$ansid] = $answer->get_first_related('Question'); |
|
| 392 | - } |
|
| 393 | - $answers[$ansid] = $answer; |
|
| 394 | - $registrations[$reg->ID()]['ans_objs'][$ansid] = $answer; |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - foreach ($relateddatetime as $dtt_id => $datetime) { |
|
| 398 | - $eventsetup[$evt_id]['dtt_objs'][$dtt_id] = $datetime; |
|
| 399 | - $registrations[$reg->ID()]['dtt_objs'][$dtt_id] = $datetime; |
|
| 400 | - |
|
| 401 | - if (isset($datetimes[$dtt_id])) { |
|
| 402 | - continue; //already have this info in the datetimes array. |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - $datetimes[$dtt_id]['tkt_objs'][] = $ticket; |
|
| 406 | - $datetimes[$dtt_id]['datetime'] = $datetime; |
|
| 407 | - $datetimes[$dtt_id]['evt_objs'][$evt_id] = $event; |
|
| 408 | - $datetimes[$dtt_id]['reg_objs'][$reg->ID()] = $reg; |
|
| 409 | - } |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - //let's loop through the unique event=>reg items and setup data on them |
|
| 413 | - |
|
| 414 | - if (! empty($eventsetup)) { |
|
| 415 | - foreach ($eventsetup as $evt_id => $items) { |
|
| 416 | - if ($this->txn instanceof EE_Transaction) { |
|
| 417 | - $ticket_line_items_for_event = EEM_Line_Item::instance()->get_all( |
|
| 418 | - array( |
|
| 419 | - array( |
|
| 420 | - 'Ticket.Datetime.EVT_ID' => $evt_id, |
|
| 421 | - 'TXN_ID' => $this->txn->ID(), |
|
| 422 | - ), |
|
| 423 | - 'default_where_conditions' => 'none', |
|
| 424 | - ) |
|
| 425 | - ); |
|
| 426 | - } else { |
|
| 427 | - $ticket_line_items_for_event = array(); |
|
| 428 | - } |
|
| 429 | - $events[$evt_id] = array( |
|
| 430 | - 'ID' => $evt_id, |
|
| 431 | - 'event' => $evtcache[$evt_id], |
|
| 432 | - 'name' => $evtcache[$evt_id] instanceof EE_Event ? $evtcache[$evt_id]->name() : '', |
|
| 433 | - 'total_attendees' => $event_attendee_count[$evt_id], |
|
| 434 | - 'reg_objs' => $items['reg_objs'], |
|
| 435 | - 'tkt_objs' => $items['tkt_objs'], |
|
| 436 | - 'att_objs' => $items['att_objs'], |
|
| 437 | - 'dtt_objs' => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(), |
|
| 438 | - 'line_items' => $ticket_line_items_for_event, |
|
| 439 | - ); |
|
| 440 | - |
|
| 441 | - //make sure the tickets have the line items setup for them. |
|
| 442 | - foreach ($ticket_line_items_for_event as $line_id => $line_item) { |
|
| 443 | - if ($line_item instanceof EE_Line_Item) { |
|
| 444 | - $tickets[$line_item->ticket()->ID()]['line_item'] = $line_item; |
|
| 445 | - $tickets[$line_item->ticket()->ID()]['sub_line_items'] = $line_item->children(); |
|
| 446 | - $line_items[$line_item->ID()]['children'] = $line_item->children(); |
|
| 447 | - $line_items[$line_item->ID()]['EE_Ticket'] = $line_item->ticket(); |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - $this->grand_total_line_item = $this->txn instanceof EE_Transaction |
|
| 454 | - ? $this->txn->total_line_item() |
|
| 455 | - : null; |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - //lets set the attendees and events properties |
|
| 459 | - $this->attendees = $attendees; |
|
| 460 | - $this->events = $events; |
|
| 461 | - $this->tickets = $tickets; |
|
| 462 | - $this->line_items_with_children = $line_items; |
|
| 463 | - $this->datetimes = $datetimes; |
|
| 464 | - $this->questions = $questions; |
|
| 465 | - $this->answers = $answers; |
|
| 466 | - $this->total_ticket_count = $total_ticket_count; |
|
| 467 | - $this->registrations = $registrations; |
|
| 468 | - |
|
| 469 | - if ($this->txn instanceof EE_Transaction) { |
|
| 470 | - $this->tax_line_items = $this->txn->tax_items(); |
|
| 471 | - $this->additional_line_items = $this->txn->non_ticket_line_items(); |
|
| 472 | - $this->payments = $this->txn->payments(); |
|
| 473 | - |
|
| 474 | - //setup primary registration if we have a single transaction object to work with |
|
| 475 | - |
|
| 476 | - //let's get just the primary_attendee_data! First we get the primary registration object. |
|
| 477 | - $primary_reg = $this->txn->primary_registration(); |
|
| 478 | - // verify |
|
| 479 | - if ($primary_reg instanceof EE_Registration) { |
|
| 480 | - |
|
| 481 | - // get attendee object |
|
| 482 | - if ($primary_reg->attendee() instanceof EE_Attendee) { |
|
| 483 | - |
|
| 484 | - //now we can setup the primary_attendee_data array |
|
| 485 | - $this->primary_attendee_data = array( |
|
| 486 | - 'registration_id' => $primary_reg->ID(), |
|
| 487 | - 'att_obj' => $primary_reg->attendee(), |
|
| 488 | - 'reg_obj' => $primary_reg, |
|
| 489 | - 'primary_att_obj' => $primary_reg->attendee(), |
|
| 490 | - 'primary_reg_obj' => $primary_reg, |
|
| 491 | - ); |
|
| 492 | - |
|
| 493 | - } else { |
|
| 494 | - EE_Error::add_error( |
|
| 495 | - __( |
|
| 496 | - 'Incoming data does not have a valid Attendee object for the primary registrant.', |
|
| 497 | - 'event_espresso' |
|
| 498 | - ), |
|
| 499 | - __FILE__, |
|
| 500 | - __FUNCTION__, |
|
| 501 | - __LINE__ |
|
| 502 | - ); |
|
| 503 | - } |
|
| 504 | - } else { |
|
| 505 | - EE_Error::add_error( |
|
| 506 | - __( |
|
| 507 | - 'Incoming data does not have a valid Registration object for the primary registrant.', |
|
| 508 | - 'event_espresso' |
|
| 509 | - ), |
|
| 510 | - __FILE__, |
|
| 511 | - __FUNCTION__, |
|
| 512 | - __LINE__ |
|
| 513 | - ); |
|
| 514 | - } |
|
| 515 | - } |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - /** |
|
| 519 | - * This simply considers whether the given registration should be processed or not based on comparison with the |
|
| 520 | - * filtered_reg_status property. |
|
| 521 | - * |
|
| 522 | - * @param EE_Registration $registration |
|
| 523 | - * @return bool returning true means we DO want to skip processing. returning false means we DON'T want to skip |
|
| 524 | - * processing |
|
| 525 | - */ |
|
| 526 | - protected function _skip_registration_for_processing(EE_Registration $registration) |
|
| 527 | - { |
|
| 528 | - if (empty($this->filtered_reg_status)) { |
|
| 529 | - return false; |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - //if we made it here then we just compare the filtered_reg_status with the registration status and return that |
|
| 533 | - return $this->filtered_reg_status !== $registration->status_ID(); |
|
| 534 | - } |
|
| 30 | + /** |
|
| 31 | + * user id for logged in user when data collected |
|
| 32 | + * |
|
| 33 | + * @var string $user_id |
|
| 34 | + */ |
|
| 35 | + public $user_id; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * IP Address of browser used |
|
| 39 | + * |
|
| 40 | + * @var string $ip_address |
|
| 41 | + */ |
|
| 42 | + public $ip_address; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * browser |
|
| 46 | + * |
|
| 47 | + * @var string $user_agent |
|
| 48 | + */ |
|
| 49 | + public $user_agent; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Unix timestamp |
|
| 53 | + * |
|
| 54 | + * @var string $init_access |
|
| 55 | + */ |
|
| 56 | + public $init_access; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Unix timestamp |
|
| 60 | + * |
|
| 61 | + * @var string $last_access |
|
| 62 | + */ |
|
| 63 | + public $last_access; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * The registrations details from the cart |
|
| 67 | + * |
|
| 68 | + * @var array $reg_info |
|
| 69 | + */ |
|
| 70 | + public $reg_info; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Some data handlers can set what reg status all the registrations are filtered by. |
|
| 74 | + * The status should match a EEM_Registration status constant. |
|
| 75 | + * |
|
| 76 | + * @var string $filtered_reg_status |
|
| 77 | + */ |
|
| 78 | + public $filtered_reg_status; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * will hold an array of events assembled from $reg_info |
|
| 82 | + * |
|
| 83 | + * @var EE_Event[] $events |
|
| 84 | + */ |
|
| 85 | + public $events; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * holds an array of datetimes assembled from the incoming data. |
|
| 89 | + * |
|
| 90 | + * @var EE_Datetime[] $datetimes |
|
| 91 | + */ |
|
| 92 | + public $datetimes; |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * holds an array of tickets assembled from the incoming data. |
|
| 96 | + * |
|
| 97 | + * @var EE_Ticket[] $tickets |
|
| 98 | + */ |
|
| 99 | + public $tickets; |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * holds an array with a key of parent line item and values are an array of children of that line item. |
|
| 103 | + * |
|
| 104 | + * @since 4.5.0 |
|
| 105 | + * @var EE_Line_Item[] $line_items_with_children |
|
| 106 | + */ |
|
| 107 | + public $line_items_with_children; |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * will hold an array of attendees assembled from the $reg_info |
|
| 111 | + * |
|
| 112 | + * @var EE_Attendee[] $attendees |
|
| 113 | + */ |
|
| 114 | + public $attendees; |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * will hold an array of cached registration objects and info assembled from reg_info |
|
| 118 | + * |
|
| 119 | + * @var array $registrations |
|
| 120 | + */ |
|
| 121 | + public $registrations; |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * will hold an array of answers assembled from the $reg_info |
|
| 125 | + * |
|
| 126 | + * @var EE_Answer[] $answers |
|
| 127 | + */ |
|
| 128 | + public $answers; |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * will hold an array of questions assembled from the $reg_info (indexed by Answer ID); |
|
| 132 | + * |
|
| 133 | + * @var EE_Question[] $questions |
|
| 134 | + */ |
|
| 135 | + public $questions; |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * Will hold billing data assembled from $billing_info (if present) |
|
| 139 | + * |
|
| 140 | + * @var mixed (array|null) $billing |
|
| 141 | + */ |
|
| 142 | + public $billing; |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * The total amount of tax for the transaction |
|
| 146 | + * |
|
| 147 | + * @var float $taxes |
|
| 148 | + */ |
|
| 149 | + public $taxes; |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Holds the line items related to taxes |
|
| 153 | + * |
|
| 154 | + * @since 4.5.0 |
|
| 155 | + * @var EE_Line_Item[] $tax_line_items |
|
| 156 | + */ |
|
| 157 | + public $tax_line_items; |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Hold the line items which aren't taxes and don't relate |
|
| 161 | + * to tickets. So: promotions and miscellaneous charges |
|
| 162 | + * |
|
| 163 | + * @since 4.5 |
|
| 164 | + * @var EE_Line_Item[] $additional_line_items |
|
| 165 | + */ |
|
| 166 | + public $additional_line_items; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Holds the grand total EE_Line_Item |
|
| 170 | + * |
|
| 171 | + * @var EE_Line_Item $grand_total_line_item |
|
| 172 | + */ |
|
| 173 | + public $grand_total_line_item; |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * holds the grand total price object |
|
| 177 | + * |
|
| 178 | + * @var object $grand_total_price_object |
|
| 179 | + */ |
|
| 180 | + public $grand_total_price_object; |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * total number of tickets |
|
| 184 | + * |
|
| 185 | + * @var int $total_ticket_count |
|
| 186 | + */ |
|
| 187 | + public $total_ticket_count; |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Will hold the final transaction object (EE_Transaction) |
|
| 191 | + * |
|
| 192 | + * @var EE_Transaction $txn |
|
| 193 | + */ |
|
| 194 | + public $txn; |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Holds the payments related to a transaction |
|
| 198 | + * |
|
| 199 | + * @since 4.5.0 |
|
| 200 | + * @var EE_Payment[] $payments |
|
| 201 | + */ |
|
| 202 | + public $payments; |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Holds the first related payment related for a transaction |
|
| 206 | + * |
|
| 207 | + * @since 4.5.0 |
|
| 208 | + * @var EE_Payment $payment |
|
| 209 | + */ |
|
| 210 | + public $payment; |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * Will hold the label for the txn status |
|
| 214 | + * |
|
| 215 | + * @var string $txn_status |
|
| 216 | + */ |
|
| 217 | + public $txn_status; |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Will hold the final registration object (EE_Registration) |
|
| 221 | + * |
|
| 222 | + * @var EE_Registration[] $reg_objs |
|
| 223 | + */ |
|
| 224 | + public $reg_objs; |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Will hold an array of primary attendee data (if present) |
|
| 228 | + * |
|
| 229 | + * @var array $primary_attendee_data |
|
| 230 | + */ |
|
| 231 | + public $primary_attendee_data; |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * This is just an internal object used for passing around the incoming data. |
|
| 235 | + * |
|
| 236 | + * @var object $_data |
|
| 237 | + */ |
|
| 238 | + protected $_data; |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * This is just an internal object used for passing around the incoming data. |
|
| 242 | + * |
|
| 243 | + * @var object $incoming_data |
|
| 244 | + */ |
|
| 245 | + public $incoming_data; |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * hold objects that might be created |
|
| 249 | + * |
|
| 250 | + * @type EE_Registration $reg_obj |
|
| 251 | + */ |
|
| 252 | + public $reg_obj; |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * constructor |
|
| 257 | + * |
|
| 258 | + * @param mixed $data incoming data object|array. Suggested that child classes use type hinting for expected |
|
| 259 | + * data object. But here parent will be generic because we don't know what's coming in. |
|
| 260 | + */ |
|
| 261 | + public function __construct($data) |
|
| 262 | + { |
|
| 263 | + $this->_data = $data; |
|
| 264 | + $this->_setup_data(); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * Every child class has to setup the data object ! |
|
| 270 | + * |
|
| 271 | + * @return void |
|
| 272 | + */ |
|
| 273 | + abstract protected function _setup_data(); |
|
| 274 | + |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * Returns database safe representation of the data later used to when instantiating this object. |
|
| 278 | + * |
|
| 279 | + * @param mixed $data The incoming data to be prepped. |
|
| 280 | + * @return mixed The prepped data for db |
|
| 281 | + */ |
|
| 282 | + static public function convert_data_for_persistent_storage($data) |
|
| 283 | + { |
|
| 284 | + return $data; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
| 290 | + * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
| 291 | + * |
|
| 292 | + * @param $data |
|
| 293 | + * @return mixed |
|
| 294 | + */ |
|
| 295 | + static public function convert_data_from_persistent_storage($data) |
|
| 296 | + { |
|
| 297 | + return $data; |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * only purpose is to return the data |
|
| 303 | + * |
|
| 304 | + * @access public |
|
| 305 | + * @return object the formatted data object! |
|
| 306 | + */ |
|
| 307 | + public function data() |
|
| 308 | + { |
|
| 309 | + return $this->_data; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * This helper method can be used by any incoming data handlers to setup the data correctly. All that is required |
|
| 315 | + * is that $this->reg_objs be set. |
|
| 316 | + * |
|
| 317 | + * @throws \EE_Error |
|
| 318 | + */ |
|
| 319 | + protected function _assemble_data() |
|
| 320 | + { |
|
| 321 | + //verify that reg_objs is set |
|
| 322 | + if ( |
|
| 323 | + ! is_array($this->reg_objs) |
|
| 324 | + && ! reset($this->reg_objs) instanceof EE_Registration |
|
| 325 | + ) { |
|
| 326 | + throw new EE_Error( |
|
| 327 | + __( |
|
| 328 | + 'In order to assemble the data correctly, the "reg_objs" property must be an array of EE_Registration objects', |
|
| 329 | + 'event_espresso' |
|
| 330 | + ) |
|
| 331 | + ); |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + //get all attendee and events associated with the registrations in this transaction |
|
| 335 | + $events = $event_setup = $evtcache = $tickets = $datetimes = array(); |
|
| 336 | + $answers = $questions = $attendees = $line_items = $registrations = array(); |
|
| 337 | + $total_ticket_count = 0; |
|
| 338 | + |
|
| 339 | + if (! empty($this->reg_objs)) { |
|
| 340 | + $event_attendee_count = array(); |
|
| 341 | + foreach ($this->reg_objs as $reg) { |
|
| 342 | + |
|
| 343 | + if ( |
|
| 344 | + $this->_skip_registration_for_processing($reg) |
|
| 345 | + ) { |
|
| 346 | + continue; |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + $evt_id = $reg->event_ID(); |
|
| 350 | + /** @type EE_Ticket $ticket */ |
|
| 351 | + $ticket = $reg->get_first_related('Ticket'); |
|
| 352 | + $relateddatetime = $ticket->datetimes(); |
|
| 353 | + $total_ticket_count++; |
|
| 354 | + $tickets[$ticket->ID()]['ticket'] = $ticket; |
|
| 355 | + $tickets[$ticket->ID()]['count'] = is_array($tickets[$ticket->ID()]) |
|
| 356 | + && isset($tickets[$ticket->ID()]['count']) |
|
| 357 | + ? $tickets[$ticket->ID()]['count'] + 1 |
|
| 358 | + : 1; |
|
| 359 | + $tickets[$ticket->ID()]['att_objs'][$reg->attendee_ID()] = $reg->attendee(); |
|
| 360 | + $tickets[$ticket->ID()]['dtt_objs'] = $relateddatetime; |
|
| 361 | + $tickets[$ticket->ID()]['reg_objs'][$reg->ID()] = $reg; |
|
| 362 | + $event = $reg->event(); |
|
| 363 | + $tickets[$ticket->ID()]['EE_Event'] = $event; |
|
| 364 | + $evtcache[$evt_id] = $event; |
|
| 365 | + $eventsetup[$evt_id]['reg_objs'][$reg->ID()] = $reg; |
|
| 366 | + $eventsetup[$evt_id]['tkt_objs'][$ticket->ID()] = $ticket; |
|
| 367 | + $eventsetup[$evt_id]['att_objs'][$reg->attendee_ID()] = $reg->attendee(); |
|
| 368 | + $event_attendee_count[$evt_id] = isset($event_attendee_count[$evt_id]) |
|
| 369 | + ? $event_attendee_count[$evt_id] + 1 |
|
| 370 | + : 0; |
|
| 371 | + $attendees[$reg->attendee_ID()]['line_ref'][] = $evt_id; |
|
| 372 | + $attendees[$reg->attendee_ID()]['att_obj'] = $reg->attendee(); |
|
| 373 | + $attendees[$reg->attendee_ID()]['reg_objs'][$reg->ID()] = $reg; |
|
| 374 | + //$attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID(); |
|
| 375 | + $attendees[$reg->attendee_ID()]['attendee_email'] = $reg->attendee() instanceof EE_Attendee |
|
| 376 | + ? $reg->attendee()->email() |
|
| 377 | + : ''; |
|
| 378 | + $attendees[$reg->attendee_ID()]['tkt_objs'][$ticket->ID()] = $ticket; |
|
| 379 | + $attendees[$reg->attendee_ID()]['evt_objs'][$evt_id] = $event; |
|
| 380 | + |
|
| 381 | + //registrations |
|
| 382 | + $registrations[$reg->ID()]['tkt_obj'] = $ticket; |
|
| 383 | + $registrations[$reg->ID()]['evt_obj'] = $event; |
|
| 384 | + $registrations[$reg->ID()]['reg_obj'] = $reg; |
|
| 385 | + $registrations[$reg->ID()]['att_obj'] = $reg->attendee(); |
|
| 386 | + |
|
| 387 | + //set up answer objects |
|
| 388 | + $rel_ans = $reg->get_many_related('Answer'); |
|
| 389 | + foreach ($rel_ans as $ansid => $answer) { |
|
| 390 | + if (! isset($questions[$ansid])) { |
|
| 391 | + $questions[$ansid] = $answer->get_first_related('Question'); |
|
| 392 | + } |
|
| 393 | + $answers[$ansid] = $answer; |
|
| 394 | + $registrations[$reg->ID()]['ans_objs'][$ansid] = $answer; |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + foreach ($relateddatetime as $dtt_id => $datetime) { |
|
| 398 | + $eventsetup[$evt_id]['dtt_objs'][$dtt_id] = $datetime; |
|
| 399 | + $registrations[$reg->ID()]['dtt_objs'][$dtt_id] = $datetime; |
|
| 400 | + |
|
| 401 | + if (isset($datetimes[$dtt_id])) { |
|
| 402 | + continue; //already have this info in the datetimes array. |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + $datetimes[$dtt_id]['tkt_objs'][] = $ticket; |
|
| 406 | + $datetimes[$dtt_id]['datetime'] = $datetime; |
|
| 407 | + $datetimes[$dtt_id]['evt_objs'][$evt_id] = $event; |
|
| 408 | + $datetimes[$dtt_id]['reg_objs'][$reg->ID()] = $reg; |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + //let's loop through the unique event=>reg items and setup data on them |
|
| 413 | + |
|
| 414 | + if (! empty($eventsetup)) { |
|
| 415 | + foreach ($eventsetup as $evt_id => $items) { |
|
| 416 | + if ($this->txn instanceof EE_Transaction) { |
|
| 417 | + $ticket_line_items_for_event = EEM_Line_Item::instance()->get_all( |
|
| 418 | + array( |
|
| 419 | + array( |
|
| 420 | + 'Ticket.Datetime.EVT_ID' => $evt_id, |
|
| 421 | + 'TXN_ID' => $this->txn->ID(), |
|
| 422 | + ), |
|
| 423 | + 'default_where_conditions' => 'none', |
|
| 424 | + ) |
|
| 425 | + ); |
|
| 426 | + } else { |
|
| 427 | + $ticket_line_items_for_event = array(); |
|
| 428 | + } |
|
| 429 | + $events[$evt_id] = array( |
|
| 430 | + 'ID' => $evt_id, |
|
| 431 | + 'event' => $evtcache[$evt_id], |
|
| 432 | + 'name' => $evtcache[$evt_id] instanceof EE_Event ? $evtcache[$evt_id]->name() : '', |
|
| 433 | + 'total_attendees' => $event_attendee_count[$evt_id], |
|
| 434 | + 'reg_objs' => $items['reg_objs'], |
|
| 435 | + 'tkt_objs' => $items['tkt_objs'], |
|
| 436 | + 'att_objs' => $items['att_objs'], |
|
| 437 | + 'dtt_objs' => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(), |
|
| 438 | + 'line_items' => $ticket_line_items_for_event, |
|
| 439 | + ); |
|
| 440 | + |
|
| 441 | + //make sure the tickets have the line items setup for them. |
|
| 442 | + foreach ($ticket_line_items_for_event as $line_id => $line_item) { |
|
| 443 | + if ($line_item instanceof EE_Line_Item) { |
|
| 444 | + $tickets[$line_item->ticket()->ID()]['line_item'] = $line_item; |
|
| 445 | + $tickets[$line_item->ticket()->ID()]['sub_line_items'] = $line_item->children(); |
|
| 446 | + $line_items[$line_item->ID()]['children'] = $line_item->children(); |
|
| 447 | + $line_items[$line_item->ID()]['EE_Ticket'] = $line_item->ticket(); |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + } |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + $this->grand_total_line_item = $this->txn instanceof EE_Transaction |
|
| 454 | + ? $this->txn->total_line_item() |
|
| 455 | + : null; |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + //lets set the attendees and events properties |
|
| 459 | + $this->attendees = $attendees; |
|
| 460 | + $this->events = $events; |
|
| 461 | + $this->tickets = $tickets; |
|
| 462 | + $this->line_items_with_children = $line_items; |
|
| 463 | + $this->datetimes = $datetimes; |
|
| 464 | + $this->questions = $questions; |
|
| 465 | + $this->answers = $answers; |
|
| 466 | + $this->total_ticket_count = $total_ticket_count; |
|
| 467 | + $this->registrations = $registrations; |
|
| 468 | + |
|
| 469 | + if ($this->txn instanceof EE_Transaction) { |
|
| 470 | + $this->tax_line_items = $this->txn->tax_items(); |
|
| 471 | + $this->additional_line_items = $this->txn->non_ticket_line_items(); |
|
| 472 | + $this->payments = $this->txn->payments(); |
|
| 473 | + |
|
| 474 | + //setup primary registration if we have a single transaction object to work with |
|
| 475 | + |
|
| 476 | + //let's get just the primary_attendee_data! First we get the primary registration object. |
|
| 477 | + $primary_reg = $this->txn->primary_registration(); |
|
| 478 | + // verify |
|
| 479 | + if ($primary_reg instanceof EE_Registration) { |
|
| 480 | + |
|
| 481 | + // get attendee object |
|
| 482 | + if ($primary_reg->attendee() instanceof EE_Attendee) { |
|
| 483 | + |
|
| 484 | + //now we can setup the primary_attendee_data array |
|
| 485 | + $this->primary_attendee_data = array( |
|
| 486 | + 'registration_id' => $primary_reg->ID(), |
|
| 487 | + 'att_obj' => $primary_reg->attendee(), |
|
| 488 | + 'reg_obj' => $primary_reg, |
|
| 489 | + 'primary_att_obj' => $primary_reg->attendee(), |
|
| 490 | + 'primary_reg_obj' => $primary_reg, |
|
| 491 | + ); |
|
| 492 | + |
|
| 493 | + } else { |
|
| 494 | + EE_Error::add_error( |
|
| 495 | + __( |
|
| 496 | + 'Incoming data does not have a valid Attendee object for the primary registrant.', |
|
| 497 | + 'event_espresso' |
|
| 498 | + ), |
|
| 499 | + __FILE__, |
|
| 500 | + __FUNCTION__, |
|
| 501 | + __LINE__ |
|
| 502 | + ); |
|
| 503 | + } |
|
| 504 | + } else { |
|
| 505 | + EE_Error::add_error( |
|
| 506 | + __( |
|
| 507 | + 'Incoming data does not have a valid Registration object for the primary registrant.', |
|
| 508 | + 'event_espresso' |
|
| 509 | + ), |
|
| 510 | + __FILE__, |
|
| 511 | + __FUNCTION__, |
|
| 512 | + __LINE__ |
|
| 513 | + ); |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + /** |
|
| 519 | + * This simply considers whether the given registration should be processed or not based on comparison with the |
|
| 520 | + * filtered_reg_status property. |
|
| 521 | + * |
|
| 522 | + * @param EE_Registration $registration |
|
| 523 | + * @return bool returning true means we DO want to skip processing. returning false means we DON'T want to skip |
|
| 524 | + * processing |
|
| 525 | + */ |
|
| 526 | + protected function _skip_registration_for_processing(EE_Registration $registration) |
|
| 527 | + { |
|
| 528 | + if (empty($this->filtered_reg_status)) { |
|
| 529 | + return false; |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + //if we made it here then we just compare the filtered_reg_status with the registration status and return that |
|
| 533 | + return $this->filtered_reg_status !== $registration->status_ID(); |
|
| 534 | + } |
|
| 535 | 535 | |
| 536 | 536 | |
| 537 | 537 | } //end EE_Messages_incoming_data class |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('NO direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | $answers = $questions = $attendees = $line_items = $registrations = array(); |
| 337 | 337 | $total_ticket_count = 0; |
| 338 | 338 | |
| 339 | - if (! empty($this->reg_objs)) { |
|
| 339 | + if ( ! empty($this->reg_objs)) { |
|
| 340 | 340 | $event_attendee_count = array(); |
| 341 | 341 | foreach ($this->reg_objs as $reg) { |
| 342 | 342 | |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | //set up answer objects |
| 388 | 388 | $rel_ans = $reg->get_many_related('Answer'); |
| 389 | 389 | foreach ($rel_ans as $ansid => $answer) { |
| 390 | - if (! isset($questions[$ansid])) { |
|
| 390 | + if ( ! isset($questions[$ansid])) { |
|
| 391 | 391 | $questions[$ansid] = $answer->get_first_related('Question'); |
| 392 | 392 | } |
| 393 | 393 | $answers[$ansid] = $answer; |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | |
| 412 | 412 | //let's loop through the unique event=>reg items and setup data on them |
| 413 | 413 | |
| 414 | - if (! empty($eventsetup)) { |
|
| 414 | + if ( ! empty($eventsetup)) { |
|
| 415 | 415 | foreach ($eventsetup as $evt_id => $items) { |
| 416 | 416 | if ($this->txn instanceof EE_Transaction) { |
| 417 | 417 | $ticket_line_items_for_event = EEM_Line_Item::instance()->get_all( |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('ABSPATH')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /* |
| 5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
| 40 | 40 | * @since 4.0 |
| 41 | 41 | */ |
| 42 | 42 | if (function_exists('espresso_version')) { |
| 43 | - /** |
|
| 44 | - * espresso_duplicate_plugin_error |
|
| 45 | - * displays if more than one version of EE is activated at the same time |
|
| 46 | - */ |
|
| 47 | - function espresso_duplicate_plugin_error() |
|
| 48 | - { |
|
| 49 | - ?> |
|
| 43 | + /** |
|
| 44 | + * espresso_duplicate_plugin_error |
|
| 45 | + * displays if more than one version of EE is activated at the same time |
|
| 46 | + */ |
|
| 47 | + function espresso_duplicate_plugin_error() |
|
| 48 | + { |
|
| 49 | + ?> |
|
| 50 | 50 | <div class="error"> |
| 51 | 51 | <p> |
| 52 | 52 | <?php echo esc_html__( |
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - /** |
|
| 97 | - * espresso_version |
|
| 98 | - * Returns the plugin version |
|
| 99 | - * |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - function espresso_version() |
|
| 103 | - { |
|
| 104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.041'); |
|
| 105 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + /** |
|
| 97 | + * espresso_version |
|
| 98 | + * Returns the plugin version |
|
| 99 | + * |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + function espresso_version() |
|
| 103 | + { |
|
| 104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.041'); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - // define versions |
|
| 108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | - if ( ! defined('DS')) { |
|
| 115 | - define('DS', '/'); |
|
| 116 | - } |
|
| 117 | - if ( ! defined('PS')) { |
|
| 118 | - define('PS', PATH_SEPARATOR); |
|
| 119 | - } |
|
| 120 | - if ( ! defined('SP')) { |
|
| 121 | - define('SP', ' '); |
|
| 122 | - } |
|
| 123 | - if ( ! defined('EENL')) { |
|
| 124 | - define('EENL', "\n"); |
|
| 125 | - } |
|
| 126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | - // define the plugin directory and URL |
|
| 128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | - // main root folder paths |
|
| 132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | - // core system paths |
|
| 141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | - // gateways |
|
| 154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | - // asset URL paths |
|
| 157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | - // define upload paths |
|
| 164 | - $uploads = wp_upload_dir(); |
|
| 165 | - // define the uploads directory and URL |
|
| 166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | - // define the templates directory and URL |
|
| 169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | - // define the gateway directory and URL |
|
| 172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | - // languages folder/path |
|
| 175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | - //check for dompdf fonts in uploads |
|
| 178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | - } |
|
| 181 | - //ajax constants |
|
| 182 | - define( |
|
| 183 | - 'EE_FRONT_AJAX', |
|
| 184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | - ); |
|
| 186 | - define( |
|
| 187 | - 'EE_ADMIN_AJAX', |
|
| 188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | - ); |
|
| 190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | - //want to change its default value! or find when -1 means infinity |
|
| 193 | - define('EE_INF_IN_DB', -1); |
|
| 194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | - define('EE_DEBUG', false); |
|
| 196 | - // for older WP versions |
|
| 197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | - } |
|
| 200 | - /** |
|
| 201 | - * espresso_plugin_activation |
|
| 202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | - */ |
|
| 204 | - function espresso_plugin_activation() |
|
| 205 | - { |
|
| 206 | - update_option('ee_espresso_activation', true); |
|
| 207 | - } |
|
| 107 | + // define versions |
|
| 108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | + if ( ! defined('DS')) { |
|
| 115 | + define('DS', '/'); |
|
| 116 | + } |
|
| 117 | + if ( ! defined('PS')) { |
|
| 118 | + define('PS', PATH_SEPARATOR); |
|
| 119 | + } |
|
| 120 | + if ( ! defined('SP')) { |
|
| 121 | + define('SP', ' '); |
|
| 122 | + } |
|
| 123 | + if ( ! defined('EENL')) { |
|
| 124 | + define('EENL', "\n"); |
|
| 125 | + } |
|
| 126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | + // define the plugin directory and URL |
|
| 128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | + // main root folder paths |
|
| 132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | + // core system paths |
|
| 141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | + // gateways |
|
| 154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | + // asset URL paths |
|
| 157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | + // define upload paths |
|
| 164 | + $uploads = wp_upload_dir(); |
|
| 165 | + // define the uploads directory and URL |
|
| 166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | + // define the templates directory and URL |
|
| 169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | + // define the gateway directory and URL |
|
| 172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | + // languages folder/path |
|
| 175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | + //check for dompdf fonts in uploads |
|
| 178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | + } |
|
| 181 | + //ajax constants |
|
| 182 | + define( |
|
| 183 | + 'EE_FRONT_AJAX', |
|
| 184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | + ); |
|
| 186 | + define( |
|
| 187 | + 'EE_ADMIN_AJAX', |
|
| 188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | + ); |
|
| 190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | + //want to change its default value! or find when -1 means infinity |
|
| 193 | + define('EE_INF_IN_DB', -1); |
|
| 194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | + define('EE_DEBUG', false); |
|
| 196 | + // for older WP versions |
|
| 197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | + } |
|
| 200 | + /** |
|
| 201 | + * espresso_plugin_activation |
|
| 202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | + */ |
|
| 204 | + function espresso_plugin_activation() |
|
| 205 | + { |
|
| 206 | + update_option('ee_espresso_activation', true); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | - /** |
|
| 211 | - * espresso_load_error_handling |
|
| 212 | - * this function loads EE's class for handling exceptions and errors |
|
| 213 | - */ |
|
| 214 | - function espresso_load_error_handling() |
|
| 215 | - { |
|
| 216 | - // load debugging tools |
|
| 217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | - EEH_Debug_Tools::instance(); |
|
| 220 | - } |
|
| 221 | - // load error handling |
|
| 222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | - } else { |
|
| 225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | - } |
|
| 227 | - } |
|
| 209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | + /** |
|
| 211 | + * espresso_load_error_handling |
|
| 212 | + * this function loads EE's class for handling exceptions and errors |
|
| 213 | + */ |
|
| 214 | + function espresso_load_error_handling() |
|
| 215 | + { |
|
| 216 | + // load debugging tools |
|
| 217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | + EEH_Debug_Tools::instance(); |
|
| 220 | + } |
|
| 221 | + // load error handling |
|
| 222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | + } else { |
|
| 225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * espresso_load_required |
|
| 231 | - * given a class name and path, this function will load that file or throw an exception |
|
| 232 | - * |
|
| 233 | - * @param string $classname |
|
| 234 | - * @param string $full_path_to_file |
|
| 235 | - * @throws EE_Error |
|
| 236 | - */ |
|
| 237 | - function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | - { |
|
| 239 | - static $error_handling_loaded = false; |
|
| 240 | - if ( ! $error_handling_loaded) { |
|
| 241 | - espresso_load_error_handling(); |
|
| 242 | - $error_handling_loaded = true; |
|
| 243 | - } |
|
| 244 | - if (is_readable($full_path_to_file)) { |
|
| 245 | - require_once($full_path_to_file); |
|
| 246 | - } else { |
|
| 247 | - throw new EE_Error ( |
|
| 248 | - sprintf( |
|
| 249 | - esc_html__( |
|
| 250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | - 'event_espresso' |
|
| 252 | - ), |
|
| 253 | - $classname |
|
| 254 | - ) |
|
| 255 | - ); |
|
| 256 | - } |
|
| 257 | - } |
|
| 229 | + /** |
|
| 230 | + * espresso_load_required |
|
| 231 | + * given a class name and path, this function will load that file or throw an exception |
|
| 232 | + * |
|
| 233 | + * @param string $classname |
|
| 234 | + * @param string $full_path_to_file |
|
| 235 | + * @throws EE_Error |
|
| 236 | + */ |
|
| 237 | + function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | + { |
|
| 239 | + static $error_handling_loaded = false; |
|
| 240 | + if ( ! $error_handling_loaded) { |
|
| 241 | + espresso_load_error_handling(); |
|
| 242 | + $error_handling_loaded = true; |
|
| 243 | + } |
|
| 244 | + if (is_readable($full_path_to_file)) { |
|
| 245 | + require_once($full_path_to_file); |
|
| 246 | + } else { |
|
| 247 | + throw new EE_Error ( |
|
| 248 | + sprintf( |
|
| 249 | + esc_html__( |
|
| 250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | + 'event_espresso' |
|
| 252 | + ), |
|
| 253 | + $classname |
|
| 254 | + ) |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | - new EE_Bootstrap(); |
|
| 263 | - } |
|
| 259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | + new EE_Bootstrap(); |
|
| 263 | + } |
|
| 264 | 264 | } |
| 265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
| 266 | - /** |
|
| 267 | - * deactivate_plugin |
|
| 268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | - * |
|
| 270 | - * @access public |
|
| 271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | - * @return void |
|
| 273 | - */ |
|
| 274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | - { |
|
| 276 | - if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | - } |
|
| 279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | - deactivate_plugins($plugin_basename); |
|
| 281 | - } |
|
| 266 | + /** |
|
| 267 | + * deactivate_plugin |
|
| 268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | + * |
|
| 270 | + * @access public |
|
| 271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | + * @return void |
|
| 273 | + */ |
|
| 274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | + { |
|
| 276 | + if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | + } |
|
| 279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | + deactivate_plugins($plugin_basename); |
|
| 281 | + } |
|
| 282 | 282 | } |
| 283 | 283 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('NO direct script access allowed'); |
|
| 2 | + exit('NO direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -17,585 +17,585 @@ discard block |
||
| 17 | 17 | class EEG_Paypal_Express extends EE_Offsite_Gateway |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Merchant API Username. |
|
| 22 | - * |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - protected $_api_username; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Merchant API Password. |
|
| 29 | - * |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - protected $_api_password; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * API Signature. |
|
| 36 | - * |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 39 | - protected $_api_signature; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Request Shipping address on PP checkout page. |
|
| 43 | - * |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 46 | - protected $_request_shipping_addr; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Business/personal logo. |
|
| 50 | - * |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 53 | - protected $_image_url; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * gateway URL variable |
|
| 57 | - * |
|
| 58 | - * @var string |
|
| 59 | - */ |
|
| 60 | - protected $_base_gateway_url = ''; |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * EEG_Paypal_Express constructor. |
|
| 66 | - */ |
|
| 67 | - public function __construct() |
|
| 68 | - { |
|
| 69 | - $this->_currencies_supported = array( |
|
| 70 | - 'USD', |
|
| 71 | - 'AUD', |
|
| 72 | - 'BRL', |
|
| 73 | - 'CAD', |
|
| 74 | - 'CZK', |
|
| 75 | - 'DKK', |
|
| 76 | - 'EUR', |
|
| 77 | - 'HKD', |
|
| 78 | - 'HUF', |
|
| 79 | - 'ILS', |
|
| 80 | - 'JPY', |
|
| 81 | - 'MYR', |
|
| 82 | - 'MXN', |
|
| 83 | - 'NOK', |
|
| 84 | - 'NZD', |
|
| 85 | - 'PHP', |
|
| 86 | - 'PLN', |
|
| 87 | - 'GBP', |
|
| 88 | - 'RUB', |
|
| 89 | - 'SGD', |
|
| 90 | - 'SEK', |
|
| 91 | - 'CHF', |
|
| 92 | - 'TWD', |
|
| 93 | - 'THB', |
|
| 94 | - 'TRY', |
|
| 95 | - ); |
|
| 96 | - parent::__construct(); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
| 103 | - * |
|
| 104 | - * @param array $settings_array |
|
| 105 | - */ |
|
| 106 | - public function set_settings($settings_array) |
|
| 107 | - { |
|
| 108 | - parent::set_settings($settings_array); |
|
| 109 | - // Redirect URL. |
|
| 110 | - $this->_base_gateway_url = $this->_debug_mode |
|
| 111 | - ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
| 112 | - : 'https://api-3t.paypal.com/nvp'; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @param EEI_Payment $payment |
|
| 119 | - * @param array $billing_info |
|
| 120 | - * @param string $return_url |
|
| 121 | - * @param string $notify_url |
|
| 122 | - * @param string $cancel_url |
|
| 123 | - * @return \EE_Payment|\EEI_Payment |
|
| 124 | - * @throws \EE_Error |
|
| 125 | - */ |
|
| 126 | - public function set_redirection_info( |
|
| 127 | - $payment, |
|
| 128 | - $billing_info = array(), |
|
| 129 | - $return_url = null, |
|
| 130 | - $notify_url = null, |
|
| 131 | - $cancel_url = null |
|
| 132 | - ) { |
|
| 133 | - if (! $payment instanceof EEI_Payment) { |
|
| 134 | - $payment->set_gateway_response( |
|
| 135 | - __( |
|
| 136 | - 'Error. No associated payment was found.', |
|
| 137 | - 'event_espresso' |
|
| 138 | - ) |
|
| 139 | - ); |
|
| 140 | - $payment->set_status($this->_pay_model->failed_status()); |
|
| 141 | - return $payment; |
|
| 142 | - } |
|
| 143 | - $transaction = $payment->transaction(); |
|
| 144 | - if (! $transaction instanceof EEI_Transaction) { |
|
| 145 | - $payment->set_gateway_response( |
|
| 146 | - __( |
|
| 147 | - 'Could not process this payment because it has no associated transaction.', |
|
| 148 | - 'event_espresso' |
|
| 149 | - ) |
|
| 150 | - ); |
|
| 151 | - $payment->set_status($this->_pay_model->failed_status()); |
|
| 152 | - return $payment; |
|
| 153 | - } |
|
| 154 | - $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
| 155 | - $primary_registration = $transaction->primary_registration(); |
|
| 156 | - $primary_attendee = $primary_registration instanceof EE_Registration |
|
| 157 | - ? $primary_registration->attendee() |
|
| 158 | - : false; |
|
| 159 | - $locale = explode('-', get_bloginfo('language')); |
|
| 160 | - // Gather request parameters. |
|
| 161 | - $token_request_dtls = array( |
|
| 162 | - 'METHOD' => 'SetExpressCheckout', |
|
| 163 | - 'PAYMENTREQUEST_0_AMT' => $payment->amount(), |
|
| 164 | - 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code(), |
|
| 165 | - 'PAYMENTREQUEST_0_DESC' => $order_description, |
|
| 166 | - 'RETURNURL' => $return_url, |
|
| 167 | - 'CANCELURL' => $cancel_url, |
|
| 168 | - 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
|
| 169 | - // Buyer does not need to create a PayPal account to check out. |
|
| 170 | - // This is referred to as PayPal Account Optional. |
|
| 171 | - 'SOLUTIONTYPE' => 'Sole', |
|
| 172 | - //EE will blow up if you change this |
|
| 173 | - 'BUTTONSOURCE' => 'EventEspresso_SP', |
|
| 174 | - // Locale of the pages displayed by PayPal during Express Checkout. |
|
| 175 | - 'LOCALECODE' => $locale[1] |
|
| 176 | - ); |
|
| 177 | - // Show itemized list. |
|
| 178 | - if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
| 179 | - $item_num = 0; |
|
| 180 | - $itemized_sum = 0; |
|
| 181 | - $total_line_items = $transaction->total_line_item(); |
|
| 182 | - // Go through each item in the list. |
|
| 183 | - foreach ($total_line_items->get_items() as $line_item) { |
|
| 184 | - if ($line_item instanceof EE_Line_Item) { |
|
| 185 | - // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
|
| 186 | - if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
| 187 | - continue; |
|
| 188 | - } |
|
| 189 | - $unit_price = $line_item->unit_price(); |
|
| 190 | - $line_item_quantity = $line_item->quantity(); |
|
| 191 | - // This is a discount. |
|
| 192 | - if ($line_item->is_percent()) { |
|
| 193 | - $unit_price = $line_item->total(); |
|
| 194 | - $line_item_quantity = 1; |
|
| 195 | - } |
|
| 196 | - // Item Name. |
|
| 197 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = substr( |
|
| 198 | - $this->_format_line_item_name($line_item, $payment), |
|
| 199 | - 0, |
|
| 200 | - 127 |
|
| 201 | - ); |
|
| 202 | - // Item description. |
|
| 203 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = substr( |
|
| 204 | - $this->_format_line_item_desc($line_item, $payment), |
|
| 205 | - 0, |
|
| 206 | - 127 |
|
| 207 | - ); |
|
| 208 | - // Cost of individual item. |
|
| 209 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency($unit_price); |
|
| 210 | - // Item Number. |
|
| 211 | - $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1; |
|
| 212 | - // Item quantity. |
|
| 213 | - $token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = $line_item_quantity; |
|
| 214 | - // Digital item is sold. |
|
| 215 | - $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical'; |
|
| 216 | - $itemized_sum += $line_item->total(); |
|
| 217 | - ++$item_num; |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - // Item's sales S/H and tax amount. |
|
| 221 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $total_line_items->get_items_total(); |
|
| 222 | - $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = $total_line_items->get_total_tax(); |
|
| 223 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
|
| 224 | - $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
|
| 225 | - $itemized_sum_diff_from_txn_total = round( |
|
| 226 | - $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), |
|
| 227 | - 2 |
|
| 228 | - ); |
|
| 229 | - // If we were not able to recognize some item like promotion, surcharge or cancellation, |
|
| 230 | - // add the difference as an extra line item. |
|
| 231 | - if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
|
| 232 | - // Item Name. |
|
| 233 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = substr( |
|
| 234 | - __( |
|
| 235 | - 'Other (promotion/surcharge/cancellation)', |
|
| 236 | - 'event_espresso' |
|
| 237 | - ), |
|
| 238 | - 0, |
|
| 239 | - 127 |
|
| 240 | - ); |
|
| 241 | - // Item description. |
|
| 242 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = ''; |
|
| 243 | - // Cost of individual item. |
|
| 244 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency( |
|
| 245 | - $itemized_sum_diff_from_txn_total |
|
| 246 | - ); |
|
| 247 | - // Item Number. |
|
| 248 | - $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1; |
|
| 249 | - // Item quantity. |
|
| 250 | - $token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = 1; |
|
| 251 | - // Digital item is sold. |
|
| 252 | - $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical'; |
|
| 253 | - $item_num++; |
|
| 254 | - } |
|
| 255 | - } else { |
|
| 256 | - // Just one Item. |
|
| 257 | - // Item Name. |
|
| 258 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( |
|
| 259 | - $this->_format_partial_payment_line_item_name($payment), |
|
| 260 | - 0, |
|
| 261 | - 127 |
|
| 262 | - ); |
|
| 263 | - // Item description. |
|
| 264 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( |
|
| 265 | - $this->_format_partial_payment_line_item_desc($payment), |
|
| 266 | - 0, |
|
| 267 | - 127 |
|
| 268 | - ); |
|
| 269 | - // Cost of individual item. |
|
| 270 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
| 271 | - // Item Number. |
|
| 272 | - $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
|
| 273 | - // Item quantity. |
|
| 274 | - $token_request_dtls['L_PAYMENTREQUEST_0_QTY0'] = 1; |
|
| 275 | - // Digital item is sold. |
|
| 276 | - $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
|
| 277 | - // Item's sales S/H and tax amount. |
|
| 278 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
| 279 | - $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
|
| 280 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
|
| 281 | - $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
|
| 282 | - } |
|
| 283 | - // Automatically filling out shipping and contact information. |
|
| 284 | - if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
| 285 | - // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
| 286 | - $token_request_dtls['NOSHIPPING'] = '2'; |
|
| 287 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
|
| 288 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
|
| 289 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
|
| 290 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTATE'] = $primary_attendee->state_abbrev(); |
|
| 291 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] = $primary_attendee->country_ID(); |
|
| 292 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
|
| 293 | - $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
|
| 294 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
|
| 295 | - } elseif (! $this->_request_shipping_addr) { |
|
| 296 | - // Do not request shipping details on the PP Checkout page. |
|
| 297 | - $token_request_dtls['NOSHIPPING'] = '1'; |
|
| 298 | - $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
|
| 299 | - } |
|
| 300 | - // Used a business/personal logo on the PayPal page. |
|
| 301 | - if (! empty($this->_image_url)) { |
|
| 302 | - $token_request_dtls['LOGOIMG'] = $this->_image_url; |
|
| 303 | - } |
|
| 304 | - $token_request_dtls = apply_filters( |
|
| 305 | - 'FHEE__EEG_Paypal_Express__set_redirection_info__arguments', |
|
| 306 | - $token_request_dtls, |
|
| 307 | - $this |
|
| 308 | - ); |
|
| 309 | - // Request PayPal token. |
|
| 310 | - $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
| 311 | - $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
| 312 | - $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) |
|
| 313 | - ? $token_rstatus['args'] |
|
| 314 | - : array(); |
|
| 315 | - if ($token_rstatus['status']) { |
|
| 316 | - // We got the Token so we may continue with the payment and redirect the client. |
|
| 317 | - $payment->set_details($response_args); |
|
| 318 | - $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
|
| 319 | - $payment->set_redirect_url( |
|
| 320 | - $gateway_url |
|
| 321 | - . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' |
|
| 322 | - . $response_args['TOKEN'] |
|
| 323 | - ); |
|
| 324 | - } else { |
|
| 325 | - if (isset($response_args['L_ERRORCODE'])) { |
|
| 326 | - $payment->set_gateway_response($response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE']); |
|
| 327 | - } else { |
|
| 328 | - $payment->set_gateway_response( |
|
| 329 | - esc_html__( |
|
| 330 | - 'Error occurred while trying to setup the Express Checkout.', |
|
| 331 | - 'event_espresso' |
|
| 332 | - ) |
|
| 333 | - ); |
|
| 334 | - } |
|
| 335 | - $payment->set_details($response_args); |
|
| 336 | - $payment->set_status($this->_pay_model->failed_status()); |
|
| 337 | - } |
|
| 338 | - return $payment; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * @param array $update_info { |
|
| 345 | - * @type string $gateway_txn_id |
|
| 346 | - * @type string status an EEMI_Payment status |
|
| 347 | - * } |
|
| 348 | - * @param EEI_Transaction $transaction |
|
| 349 | - * @return EEI_Payment |
|
| 350 | - */ |
|
| 351 | - public function handle_payment_update($update_info, $transaction) |
|
| 352 | - { |
|
| 353 | - $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null; |
|
| 354 | - if ($payment instanceof EEI_Payment) { |
|
| 355 | - $this->log(array('Return from Authorization' => $update_info), $payment); |
|
| 356 | - $transaction = $payment->transaction(); |
|
| 357 | - if (! $transaction instanceof EEI_Transaction) { |
|
| 358 | - $payment->set_gateway_response( |
|
| 359 | - __( |
|
| 360 | - 'Could not process this payment because it has no associated transaction.', |
|
| 361 | - 'event_espresso' |
|
| 362 | - ) |
|
| 363 | - ); |
|
| 364 | - $payment->set_status($this->_pay_model->failed_status()); |
|
| 365 | - return $payment; |
|
| 366 | - } |
|
| 367 | - $primary_registrant = $transaction->primary_registration(); |
|
| 368 | - $payment_details = $payment->details(); |
|
| 369 | - // Check if we still have the token. |
|
| 370 | - if (! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
| 371 | - $payment->set_status($this->_pay_model->failed_status()); |
|
| 372 | - return $payment; |
|
| 373 | - } |
|
| 374 | - $cdetails_request_dtls = array( |
|
| 375 | - 'METHOD' => 'GetExpressCheckoutDetails', |
|
| 376 | - 'TOKEN' => $payment_details['TOKEN'], |
|
| 377 | - ); |
|
| 378 | - // Request Customer Details. |
|
| 379 | - $cdetails_request_response = $this->_ppExpress_request( |
|
| 380 | - $cdetails_request_dtls, |
|
| 381 | - 'Customer Details', |
|
| 382 | - $payment |
|
| 383 | - ); |
|
| 384 | - $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
| 385 | - $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) |
|
| 386 | - ? $cdetails_rstatus['args'] |
|
| 387 | - : array(); |
|
| 388 | - if ($cdetails_rstatus['status']) { |
|
| 389 | - // We got the PayerID so now we can Complete the transaction. |
|
| 390 | - $docheckout_request_dtls = array( |
|
| 391 | - 'METHOD' => 'DoExpressCheckoutPayment', |
|
| 392 | - 'PAYERID' => $cdata_response_args['PAYERID'], |
|
| 393 | - 'TOKEN' => $payment_details['TOKEN'], |
|
| 394 | - 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
|
| 395 | - 'PAYMENTREQUEST_0_AMT' => $payment->amount(), |
|
| 396 | - 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code(), |
|
| 397 | - ); |
|
| 398 | - // Payment Checkout/Capture. |
|
| 399 | - $docheckout_request_response = $this->_ppExpress_request( |
|
| 400 | - $docheckout_request_dtls, |
|
| 401 | - 'Do Payment', |
|
| 402 | - $payment |
|
| 403 | - ); |
|
| 404 | - $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
| 405 | - $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) |
|
| 406 | - ? $docheckout_rstatus['args'] |
|
| 407 | - : array(); |
|
| 408 | - if ($docheckout_rstatus['status']) { |
|
| 409 | - // All is well, payment approved. |
|
| 410 | - $primary_registration_code = $primary_registrant instanceof EE_Registration ? |
|
| 411 | - $primary_registrant->reg_code() |
|
| 412 | - : ''; |
|
| 413 | - $payment->set_extra_accntng($primary_registration_code); |
|
| 414 | - $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) |
|
| 415 | - ? (float)$docheckout_response_args['PAYMENTINFO_0_AMT'] |
|
| 416 | - : 0); |
|
| 417 | - $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
| 418 | - ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] |
|
| 419 | - : null); |
|
| 420 | - $payment->set_details($cdata_response_args); |
|
| 421 | - $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) |
|
| 422 | - ? $docheckout_response_args['PAYMENTINFO_0_ACK'] |
|
| 423 | - : ''); |
|
| 424 | - $payment->set_status($this->_pay_model->approved_status()); |
|
| 425 | - } else { |
|
| 426 | - if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
| 427 | - $payment->set_gateway_response( |
|
| 428 | - $docheckout_response_args['L_ERRORCODE'] |
|
| 429 | - . '; ' |
|
| 430 | - . $docheckout_response_args['L_SHORTMESSAGE'] |
|
| 431 | - ); |
|
| 432 | - } else { |
|
| 433 | - $payment->set_gateway_response( |
|
| 434 | - __( |
|
| 435 | - 'Error occurred while trying to Capture the funds.', |
|
| 436 | - 'event_espresso' |
|
| 437 | - ) |
|
| 438 | - ); |
|
| 439 | - } |
|
| 440 | - $payment->set_details($docheckout_response_args); |
|
| 441 | - $payment->set_status($this->_pay_model->declined_status()); |
|
| 442 | - } |
|
| 443 | - } else { |
|
| 444 | - if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
| 445 | - $payment->set_gateway_response( |
|
| 446 | - $cdata_response_args['L_ERRORCODE'] |
|
| 447 | - . '; ' |
|
| 448 | - . $cdata_response_args['L_SHORTMESSAGE'] |
|
| 449 | - ); |
|
| 450 | - } else { |
|
| 451 | - $payment->set_gateway_response( |
|
| 452 | - __( |
|
| 453 | - 'Error occurred while trying to get payment Details from PayPal.', |
|
| 454 | - 'event_espresso' |
|
| 455 | - ) |
|
| 456 | - ); |
|
| 457 | - } |
|
| 458 | - $payment->set_details($cdata_response_args); |
|
| 459 | - $payment->set_status($this->_pay_model->failed_status()); |
|
| 460 | - } |
|
| 461 | - } else { |
|
| 462 | - $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
| 463 | - $payment->set_status($this->_pay_model->failed_status()); |
|
| 464 | - } |
|
| 465 | - return $payment; |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - |
|
| 469 | - |
|
| 470 | - /** |
|
| 471 | - * Make the Express checkout request. |
|
| 472 | - * |
|
| 473 | - * @param array $request_params |
|
| 474 | - * @param string $request_text |
|
| 475 | - * @param EEI_Payment $payment |
|
| 476 | - * @return mixed |
|
| 477 | - */ |
|
| 478 | - public function _ppExpress_request($request_params, $request_text, $payment) |
|
| 479 | - { |
|
| 480 | - $request_dtls = array( |
|
| 481 | - 'VERSION' => '204.0', |
|
| 482 | - 'USER' => urlencode($this->_api_username), |
|
| 483 | - 'PWD' => urlencode($this->_api_password), |
|
| 484 | - 'SIGNATURE' => urlencode($this->_api_signature), |
|
| 485 | - ); |
|
| 486 | - $dtls = array_merge($request_dtls, $request_params); |
|
| 487 | - $this->_log_clean_request($dtls, $payment, $request_text . ' Request'); |
|
| 488 | - // Request Customer Details. |
|
| 489 | - $request_response = wp_remote_post( |
|
| 490 | - $this->_base_gateway_url, |
|
| 491 | - array( |
|
| 492 | - 'method' => 'POST', |
|
| 493 | - 'timeout' => 45, |
|
| 494 | - 'httpversion' => '1.1', |
|
| 495 | - 'cookies' => array(), |
|
| 496 | - 'headers' => array(), |
|
| 497 | - 'body' => http_build_query($dtls), |
|
| 498 | - ) |
|
| 499 | - ); |
|
| 500 | - // Log the response. |
|
| 501 | - $this->log(array($request_text . ' Response' => $request_response), $payment); |
|
| 502 | - return $request_response; |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - |
|
| 506 | - |
|
| 507 | - /** |
|
| 508 | - * Check the response status. |
|
| 509 | - * |
|
| 510 | - * @param mixed $request_response |
|
| 511 | - * @return array |
|
| 512 | - */ |
|
| 513 | - public function _ppExpress_check_response($request_response) |
|
| 514 | - { |
|
| 515 | - if (is_wp_error($request_response) || empty($request_response['body'])) { |
|
| 516 | - // If we got here then there was an error in this request. |
|
| 517 | - return array('status' => false, 'args' => $request_response); |
|
| 518 | - } |
|
| 519 | - $response_args = array(); |
|
| 520 | - parse_str(urldecode($request_response['body']), $response_args); |
|
| 521 | - if (! isset($response_args['ACK'])) { |
|
| 522 | - return array('status' => false, 'args' => $request_response); |
|
| 523 | - } |
|
| 524 | - if ( |
|
| 525 | - ( |
|
| 526 | - isset($response_args['PAYERID']) |
|
| 527 | - || isset($response_args['TOKEN']) |
|
| 528 | - || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
| 529 | - || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
| 530 | - ) |
|
| 531 | - && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true) |
|
| 532 | - ) { |
|
| 533 | - // Response status OK, return response parameters for further processing. |
|
| 534 | - return array('status' => true, 'args' => $response_args); |
|
| 535 | - } |
|
| 536 | - $errors = $this->_get_errors($response_args); |
|
| 537 | - return array('status' => false, 'args' => $errors); |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - |
|
| 541 | - |
|
| 542 | - /** |
|
| 543 | - * Log a "Cleared" request. |
|
| 544 | - * |
|
| 545 | - * @param array $request |
|
| 546 | - * @param EEI_Payment $payment |
|
| 547 | - * @param string $info |
|
| 548 | - * @return void |
|
| 549 | - */ |
|
| 550 | - private function _log_clean_request($request, $payment, $info) |
|
| 551 | - { |
|
| 552 | - $cleaned_request_data = $request; |
|
| 553 | - unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']); |
|
| 554 | - $this->log(array($info => $cleaned_request_data), $payment); |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * Get error from the response data. |
|
| 561 | - * |
|
| 562 | - * @param array $data_array |
|
| 563 | - * @return array |
|
| 564 | - */ |
|
| 565 | - private function _get_errors($data_array) |
|
| 566 | - { |
|
| 567 | - $errors = array(); |
|
| 568 | - $n = 0; |
|
| 569 | - while (isset($data_array["L_ERRORCODE{$n}"])) { |
|
| 570 | - $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
|
| 571 | - ? $data_array["L_ERRORCODE{$n}"] |
|
| 572 | - : ''; |
|
| 573 | - $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"]) |
|
| 574 | - ? $data_array["L_SEVERITYCODE{$n}"] |
|
| 575 | - : ''; |
|
| 576 | - $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"]) |
|
| 577 | - ? $data_array["L_SHORTMESSAGE{$n}"] |
|
| 578 | - : ''; |
|
| 579 | - $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"]) |
|
| 580 | - ? $data_array["L_LONGMESSAGE{$n}"] |
|
| 581 | - : ''; |
|
| 582 | - if ($n === 0) { |
|
| 583 | - $errors = array( |
|
| 584 | - 'L_ERRORCODE' => $l_error_code, |
|
| 585 | - 'L_SHORTMESSAGE' => $l_short_message, |
|
| 586 | - 'L_LONGMESSAGE' => $l_long_message, |
|
| 587 | - 'L_SEVERITYCODE' => $l_severity_code, |
|
| 588 | - ); |
|
| 589 | - } else { |
|
| 590 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
| 591 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
| 592 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
| 593 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
| 594 | - } |
|
| 595 | - $n++; |
|
| 596 | - } |
|
| 597 | - return $errors; |
|
| 598 | - } |
|
| 20 | + /** |
|
| 21 | + * Merchant API Username. |
|
| 22 | + * |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + protected $_api_username; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Merchant API Password. |
|
| 29 | + * |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + protected $_api_password; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * API Signature. |
|
| 36 | + * |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | + protected $_api_signature; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Request Shipping address on PP checkout page. |
|
| 43 | + * |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | + protected $_request_shipping_addr; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Business/personal logo. |
|
| 50 | + * |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | + protected $_image_url; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * gateway URL variable |
|
| 57 | + * |
|
| 58 | + * @var string |
|
| 59 | + */ |
|
| 60 | + protected $_base_gateway_url = ''; |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * EEG_Paypal_Express constructor. |
|
| 66 | + */ |
|
| 67 | + public function __construct() |
|
| 68 | + { |
|
| 69 | + $this->_currencies_supported = array( |
|
| 70 | + 'USD', |
|
| 71 | + 'AUD', |
|
| 72 | + 'BRL', |
|
| 73 | + 'CAD', |
|
| 74 | + 'CZK', |
|
| 75 | + 'DKK', |
|
| 76 | + 'EUR', |
|
| 77 | + 'HKD', |
|
| 78 | + 'HUF', |
|
| 79 | + 'ILS', |
|
| 80 | + 'JPY', |
|
| 81 | + 'MYR', |
|
| 82 | + 'MXN', |
|
| 83 | + 'NOK', |
|
| 84 | + 'NZD', |
|
| 85 | + 'PHP', |
|
| 86 | + 'PLN', |
|
| 87 | + 'GBP', |
|
| 88 | + 'RUB', |
|
| 89 | + 'SGD', |
|
| 90 | + 'SEK', |
|
| 91 | + 'CHF', |
|
| 92 | + 'TWD', |
|
| 93 | + 'THB', |
|
| 94 | + 'TRY', |
|
| 95 | + ); |
|
| 96 | + parent::__construct(); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
| 103 | + * |
|
| 104 | + * @param array $settings_array |
|
| 105 | + */ |
|
| 106 | + public function set_settings($settings_array) |
|
| 107 | + { |
|
| 108 | + parent::set_settings($settings_array); |
|
| 109 | + // Redirect URL. |
|
| 110 | + $this->_base_gateway_url = $this->_debug_mode |
|
| 111 | + ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
| 112 | + : 'https://api-3t.paypal.com/nvp'; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @param EEI_Payment $payment |
|
| 119 | + * @param array $billing_info |
|
| 120 | + * @param string $return_url |
|
| 121 | + * @param string $notify_url |
|
| 122 | + * @param string $cancel_url |
|
| 123 | + * @return \EE_Payment|\EEI_Payment |
|
| 124 | + * @throws \EE_Error |
|
| 125 | + */ |
|
| 126 | + public function set_redirection_info( |
|
| 127 | + $payment, |
|
| 128 | + $billing_info = array(), |
|
| 129 | + $return_url = null, |
|
| 130 | + $notify_url = null, |
|
| 131 | + $cancel_url = null |
|
| 132 | + ) { |
|
| 133 | + if (! $payment instanceof EEI_Payment) { |
|
| 134 | + $payment->set_gateway_response( |
|
| 135 | + __( |
|
| 136 | + 'Error. No associated payment was found.', |
|
| 137 | + 'event_espresso' |
|
| 138 | + ) |
|
| 139 | + ); |
|
| 140 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 141 | + return $payment; |
|
| 142 | + } |
|
| 143 | + $transaction = $payment->transaction(); |
|
| 144 | + if (! $transaction instanceof EEI_Transaction) { |
|
| 145 | + $payment->set_gateway_response( |
|
| 146 | + __( |
|
| 147 | + 'Could not process this payment because it has no associated transaction.', |
|
| 148 | + 'event_espresso' |
|
| 149 | + ) |
|
| 150 | + ); |
|
| 151 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 152 | + return $payment; |
|
| 153 | + } |
|
| 154 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
| 155 | + $primary_registration = $transaction->primary_registration(); |
|
| 156 | + $primary_attendee = $primary_registration instanceof EE_Registration |
|
| 157 | + ? $primary_registration->attendee() |
|
| 158 | + : false; |
|
| 159 | + $locale = explode('-', get_bloginfo('language')); |
|
| 160 | + // Gather request parameters. |
|
| 161 | + $token_request_dtls = array( |
|
| 162 | + 'METHOD' => 'SetExpressCheckout', |
|
| 163 | + 'PAYMENTREQUEST_0_AMT' => $payment->amount(), |
|
| 164 | + 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code(), |
|
| 165 | + 'PAYMENTREQUEST_0_DESC' => $order_description, |
|
| 166 | + 'RETURNURL' => $return_url, |
|
| 167 | + 'CANCELURL' => $cancel_url, |
|
| 168 | + 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
|
| 169 | + // Buyer does not need to create a PayPal account to check out. |
|
| 170 | + // This is referred to as PayPal Account Optional. |
|
| 171 | + 'SOLUTIONTYPE' => 'Sole', |
|
| 172 | + //EE will blow up if you change this |
|
| 173 | + 'BUTTONSOURCE' => 'EventEspresso_SP', |
|
| 174 | + // Locale of the pages displayed by PayPal during Express Checkout. |
|
| 175 | + 'LOCALECODE' => $locale[1] |
|
| 176 | + ); |
|
| 177 | + // Show itemized list. |
|
| 178 | + if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
| 179 | + $item_num = 0; |
|
| 180 | + $itemized_sum = 0; |
|
| 181 | + $total_line_items = $transaction->total_line_item(); |
|
| 182 | + // Go through each item in the list. |
|
| 183 | + foreach ($total_line_items->get_items() as $line_item) { |
|
| 184 | + if ($line_item instanceof EE_Line_Item) { |
|
| 185 | + // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
|
| 186 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
| 187 | + continue; |
|
| 188 | + } |
|
| 189 | + $unit_price = $line_item->unit_price(); |
|
| 190 | + $line_item_quantity = $line_item->quantity(); |
|
| 191 | + // This is a discount. |
|
| 192 | + if ($line_item->is_percent()) { |
|
| 193 | + $unit_price = $line_item->total(); |
|
| 194 | + $line_item_quantity = 1; |
|
| 195 | + } |
|
| 196 | + // Item Name. |
|
| 197 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = substr( |
|
| 198 | + $this->_format_line_item_name($line_item, $payment), |
|
| 199 | + 0, |
|
| 200 | + 127 |
|
| 201 | + ); |
|
| 202 | + // Item description. |
|
| 203 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = substr( |
|
| 204 | + $this->_format_line_item_desc($line_item, $payment), |
|
| 205 | + 0, |
|
| 206 | + 127 |
|
| 207 | + ); |
|
| 208 | + // Cost of individual item. |
|
| 209 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency($unit_price); |
|
| 210 | + // Item Number. |
|
| 211 | + $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1; |
|
| 212 | + // Item quantity. |
|
| 213 | + $token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = $line_item_quantity; |
|
| 214 | + // Digital item is sold. |
|
| 215 | + $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical'; |
|
| 216 | + $itemized_sum += $line_item->total(); |
|
| 217 | + ++$item_num; |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + // Item's sales S/H and tax amount. |
|
| 221 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $total_line_items->get_items_total(); |
|
| 222 | + $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = $total_line_items->get_total_tax(); |
|
| 223 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
|
| 224 | + $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
|
| 225 | + $itemized_sum_diff_from_txn_total = round( |
|
| 226 | + $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), |
|
| 227 | + 2 |
|
| 228 | + ); |
|
| 229 | + // If we were not able to recognize some item like promotion, surcharge or cancellation, |
|
| 230 | + // add the difference as an extra line item. |
|
| 231 | + if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
|
| 232 | + // Item Name. |
|
| 233 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = substr( |
|
| 234 | + __( |
|
| 235 | + 'Other (promotion/surcharge/cancellation)', |
|
| 236 | + 'event_espresso' |
|
| 237 | + ), |
|
| 238 | + 0, |
|
| 239 | + 127 |
|
| 240 | + ); |
|
| 241 | + // Item description. |
|
| 242 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = ''; |
|
| 243 | + // Cost of individual item. |
|
| 244 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency( |
|
| 245 | + $itemized_sum_diff_from_txn_total |
|
| 246 | + ); |
|
| 247 | + // Item Number. |
|
| 248 | + $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1; |
|
| 249 | + // Item quantity. |
|
| 250 | + $token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = 1; |
|
| 251 | + // Digital item is sold. |
|
| 252 | + $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical'; |
|
| 253 | + $item_num++; |
|
| 254 | + } |
|
| 255 | + } else { |
|
| 256 | + // Just one Item. |
|
| 257 | + // Item Name. |
|
| 258 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( |
|
| 259 | + $this->_format_partial_payment_line_item_name($payment), |
|
| 260 | + 0, |
|
| 261 | + 127 |
|
| 262 | + ); |
|
| 263 | + // Item description. |
|
| 264 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( |
|
| 265 | + $this->_format_partial_payment_line_item_desc($payment), |
|
| 266 | + 0, |
|
| 267 | + 127 |
|
| 268 | + ); |
|
| 269 | + // Cost of individual item. |
|
| 270 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
| 271 | + // Item Number. |
|
| 272 | + $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
|
| 273 | + // Item quantity. |
|
| 274 | + $token_request_dtls['L_PAYMENTREQUEST_0_QTY0'] = 1; |
|
| 275 | + // Digital item is sold. |
|
| 276 | + $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
|
| 277 | + // Item's sales S/H and tax amount. |
|
| 278 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
| 279 | + $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
|
| 280 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
|
| 281 | + $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
|
| 282 | + } |
|
| 283 | + // Automatically filling out shipping and contact information. |
|
| 284 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
| 285 | + // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
| 286 | + $token_request_dtls['NOSHIPPING'] = '2'; |
|
| 287 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
|
| 288 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
|
| 289 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
|
| 290 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTATE'] = $primary_attendee->state_abbrev(); |
|
| 291 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] = $primary_attendee->country_ID(); |
|
| 292 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
|
| 293 | + $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
|
| 294 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
|
| 295 | + } elseif (! $this->_request_shipping_addr) { |
|
| 296 | + // Do not request shipping details on the PP Checkout page. |
|
| 297 | + $token_request_dtls['NOSHIPPING'] = '1'; |
|
| 298 | + $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
|
| 299 | + } |
|
| 300 | + // Used a business/personal logo on the PayPal page. |
|
| 301 | + if (! empty($this->_image_url)) { |
|
| 302 | + $token_request_dtls['LOGOIMG'] = $this->_image_url; |
|
| 303 | + } |
|
| 304 | + $token_request_dtls = apply_filters( |
|
| 305 | + 'FHEE__EEG_Paypal_Express__set_redirection_info__arguments', |
|
| 306 | + $token_request_dtls, |
|
| 307 | + $this |
|
| 308 | + ); |
|
| 309 | + // Request PayPal token. |
|
| 310 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
| 311 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
| 312 | + $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) |
|
| 313 | + ? $token_rstatus['args'] |
|
| 314 | + : array(); |
|
| 315 | + if ($token_rstatus['status']) { |
|
| 316 | + // We got the Token so we may continue with the payment and redirect the client. |
|
| 317 | + $payment->set_details($response_args); |
|
| 318 | + $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
|
| 319 | + $payment->set_redirect_url( |
|
| 320 | + $gateway_url |
|
| 321 | + . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' |
|
| 322 | + . $response_args['TOKEN'] |
|
| 323 | + ); |
|
| 324 | + } else { |
|
| 325 | + if (isset($response_args['L_ERRORCODE'])) { |
|
| 326 | + $payment->set_gateway_response($response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE']); |
|
| 327 | + } else { |
|
| 328 | + $payment->set_gateway_response( |
|
| 329 | + esc_html__( |
|
| 330 | + 'Error occurred while trying to setup the Express Checkout.', |
|
| 331 | + 'event_espresso' |
|
| 332 | + ) |
|
| 333 | + ); |
|
| 334 | + } |
|
| 335 | + $payment->set_details($response_args); |
|
| 336 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 337 | + } |
|
| 338 | + return $payment; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * @param array $update_info { |
|
| 345 | + * @type string $gateway_txn_id |
|
| 346 | + * @type string status an EEMI_Payment status |
|
| 347 | + * } |
|
| 348 | + * @param EEI_Transaction $transaction |
|
| 349 | + * @return EEI_Payment |
|
| 350 | + */ |
|
| 351 | + public function handle_payment_update($update_info, $transaction) |
|
| 352 | + { |
|
| 353 | + $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null; |
|
| 354 | + if ($payment instanceof EEI_Payment) { |
|
| 355 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
| 356 | + $transaction = $payment->transaction(); |
|
| 357 | + if (! $transaction instanceof EEI_Transaction) { |
|
| 358 | + $payment->set_gateway_response( |
|
| 359 | + __( |
|
| 360 | + 'Could not process this payment because it has no associated transaction.', |
|
| 361 | + 'event_espresso' |
|
| 362 | + ) |
|
| 363 | + ); |
|
| 364 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 365 | + return $payment; |
|
| 366 | + } |
|
| 367 | + $primary_registrant = $transaction->primary_registration(); |
|
| 368 | + $payment_details = $payment->details(); |
|
| 369 | + // Check if we still have the token. |
|
| 370 | + if (! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
| 371 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 372 | + return $payment; |
|
| 373 | + } |
|
| 374 | + $cdetails_request_dtls = array( |
|
| 375 | + 'METHOD' => 'GetExpressCheckoutDetails', |
|
| 376 | + 'TOKEN' => $payment_details['TOKEN'], |
|
| 377 | + ); |
|
| 378 | + // Request Customer Details. |
|
| 379 | + $cdetails_request_response = $this->_ppExpress_request( |
|
| 380 | + $cdetails_request_dtls, |
|
| 381 | + 'Customer Details', |
|
| 382 | + $payment |
|
| 383 | + ); |
|
| 384 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
| 385 | + $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) |
|
| 386 | + ? $cdetails_rstatus['args'] |
|
| 387 | + : array(); |
|
| 388 | + if ($cdetails_rstatus['status']) { |
|
| 389 | + // We got the PayerID so now we can Complete the transaction. |
|
| 390 | + $docheckout_request_dtls = array( |
|
| 391 | + 'METHOD' => 'DoExpressCheckoutPayment', |
|
| 392 | + 'PAYERID' => $cdata_response_args['PAYERID'], |
|
| 393 | + 'TOKEN' => $payment_details['TOKEN'], |
|
| 394 | + 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
|
| 395 | + 'PAYMENTREQUEST_0_AMT' => $payment->amount(), |
|
| 396 | + 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code(), |
|
| 397 | + ); |
|
| 398 | + // Payment Checkout/Capture. |
|
| 399 | + $docheckout_request_response = $this->_ppExpress_request( |
|
| 400 | + $docheckout_request_dtls, |
|
| 401 | + 'Do Payment', |
|
| 402 | + $payment |
|
| 403 | + ); |
|
| 404 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
| 405 | + $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) |
|
| 406 | + ? $docheckout_rstatus['args'] |
|
| 407 | + : array(); |
|
| 408 | + if ($docheckout_rstatus['status']) { |
|
| 409 | + // All is well, payment approved. |
|
| 410 | + $primary_registration_code = $primary_registrant instanceof EE_Registration ? |
|
| 411 | + $primary_registrant->reg_code() |
|
| 412 | + : ''; |
|
| 413 | + $payment->set_extra_accntng($primary_registration_code); |
|
| 414 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) |
|
| 415 | + ? (float)$docheckout_response_args['PAYMENTINFO_0_AMT'] |
|
| 416 | + : 0); |
|
| 417 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
| 418 | + ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] |
|
| 419 | + : null); |
|
| 420 | + $payment->set_details($cdata_response_args); |
|
| 421 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) |
|
| 422 | + ? $docheckout_response_args['PAYMENTINFO_0_ACK'] |
|
| 423 | + : ''); |
|
| 424 | + $payment->set_status($this->_pay_model->approved_status()); |
|
| 425 | + } else { |
|
| 426 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
| 427 | + $payment->set_gateway_response( |
|
| 428 | + $docheckout_response_args['L_ERRORCODE'] |
|
| 429 | + . '; ' |
|
| 430 | + . $docheckout_response_args['L_SHORTMESSAGE'] |
|
| 431 | + ); |
|
| 432 | + } else { |
|
| 433 | + $payment->set_gateway_response( |
|
| 434 | + __( |
|
| 435 | + 'Error occurred while trying to Capture the funds.', |
|
| 436 | + 'event_espresso' |
|
| 437 | + ) |
|
| 438 | + ); |
|
| 439 | + } |
|
| 440 | + $payment->set_details($docheckout_response_args); |
|
| 441 | + $payment->set_status($this->_pay_model->declined_status()); |
|
| 442 | + } |
|
| 443 | + } else { |
|
| 444 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
| 445 | + $payment->set_gateway_response( |
|
| 446 | + $cdata_response_args['L_ERRORCODE'] |
|
| 447 | + . '; ' |
|
| 448 | + . $cdata_response_args['L_SHORTMESSAGE'] |
|
| 449 | + ); |
|
| 450 | + } else { |
|
| 451 | + $payment->set_gateway_response( |
|
| 452 | + __( |
|
| 453 | + 'Error occurred while trying to get payment Details from PayPal.', |
|
| 454 | + 'event_espresso' |
|
| 455 | + ) |
|
| 456 | + ); |
|
| 457 | + } |
|
| 458 | + $payment->set_details($cdata_response_args); |
|
| 459 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 460 | + } |
|
| 461 | + } else { |
|
| 462 | + $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
| 463 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 464 | + } |
|
| 465 | + return $payment; |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + |
|
| 469 | + |
|
| 470 | + /** |
|
| 471 | + * Make the Express checkout request. |
|
| 472 | + * |
|
| 473 | + * @param array $request_params |
|
| 474 | + * @param string $request_text |
|
| 475 | + * @param EEI_Payment $payment |
|
| 476 | + * @return mixed |
|
| 477 | + */ |
|
| 478 | + public function _ppExpress_request($request_params, $request_text, $payment) |
|
| 479 | + { |
|
| 480 | + $request_dtls = array( |
|
| 481 | + 'VERSION' => '204.0', |
|
| 482 | + 'USER' => urlencode($this->_api_username), |
|
| 483 | + 'PWD' => urlencode($this->_api_password), |
|
| 484 | + 'SIGNATURE' => urlencode($this->_api_signature), |
|
| 485 | + ); |
|
| 486 | + $dtls = array_merge($request_dtls, $request_params); |
|
| 487 | + $this->_log_clean_request($dtls, $payment, $request_text . ' Request'); |
|
| 488 | + // Request Customer Details. |
|
| 489 | + $request_response = wp_remote_post( |
|
| 490 | + $this->_base_gateway_url, |
|
| 491 | + array( |
|
| 492 | + 'method' => 'POST', |
|
| 493 | + 'timeout' => 45, |
|
| 494 | + 'httpversion' => '1.1', |
|
| 495 | + 'cookies' => array(), |
|
| 496 | + 'headers' => array(), |
|
| 497 | + 'body' => http_build_query($dtls), |
|
| 498 | + ) |
|
| 499 | + ); |
|
| 500 | + // Log the response. |
|
| 501 | + $this->log(array($request_text . ' Response' => $request_response), $payment); |
|
| 502 | + return $request_response; |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + |
|
| 506 | + |
|
| 507 | + /** |
|
| 508 | + * Check the response status. |
|
| 509 | + * |
|
| 510 | + * @param mixed $request_response |
|
| 511 | + * @return array |
|
| 512 | + */ |
|
| 513 | + public function _ppExpress_check_response($request_response) |
|
| 514 | + { |
|
| 515 | + if (is_wp_error($request_response) || empty($request_response['body'])) { |
|
| 516 | + // If we got here then there was an error in this request. |
|
| 517 | + return array('status' => false, 'args' => $request_response); |
|
| 518 | + } |
|
| 519 | + $response_args = array(); |
|
| 520 | + parse_str(urldecode($request_response['body']), $response_args); |
|
| 521 | + if (! isset($response_args['ACK'])) { |
|
| 522 | + return array('status' => false, 'args' => $request_response); |
|
| 523 | + } |
|
| 524 | + if ( |
|
| 525 | + ( |
|
| 526 | + isset($response_args['PAYERID']) |
|
| 527 | + || isset($response_args['TOKEN']) |
|
| 528 | + || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
| 529 | + || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
| 530 | + ) |
|
| 531 | + && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true) |
|
| 532 | + ) { |
|
| 533 | + // Response status OK, return response parameters for further processing. |
|
| 534 | + return array('status' => true, 'args' => $response_args); |
|
| 535 | + } |
|
| 536 | + $errors = $this->_get_errors($response_args); |
|
| 537 | + return array('status' => false, 'args' => $errors); |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + |
|
| 541 | + |
|
| 542 | + /** |
|
| 543 | + * Log a "Cleared" request. |
|
| 544 | + * |
|
| 545 | + * @param array $request |
|
| 546 | + * @param EEI_Payment $payment |
|
| 547 | + * @param string $info |
|
| 548 | + * @return void |
|
| 549 | + */ |
|
| 550 | + private function _log_clean_request($request, $payment, $info) |
|
| 551 | + { |
|
| 552 | + $cleaned_request_data = $request; |
|
| 553 | + unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']); |
|
| 554 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * Get error from the response data. |
|
| 561 | + * |
|
| 562 | + * @param array $data_array |
|
| 563 | + * @return array |
|
| 564 | + */ |
|
| 565 | + private function _get_errors($data_array) |
|
| 566 | + { |
|
| 567 | + $errors = array(); |
|
| 568 | + $n = 0; |
|
| 569 | + while (isset($data_array["L_ERRORCODE{$n}"])) { |
|
| 570 | + $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
|
| 571 | + ? $data_array["L_ERRORCODE{$n}"] |
|
| 572 | + : ''; |
|
| 573 | + $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"]) |
|
| 574 | + ? $data_array["L_SEVERITYCODE{$n}"] |
|
| 575 | + : ''; |
|
| 576 | + $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"]) |
|
| 577 | + ? $data_array["L_SHORTMESSAGE{$n}"] |
|
| 578 | + : ''; |
|
| 579 | + $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"]) |
|
| 580 | + ? $data_array["L_LONGMESSAGE{$n}"] |
|
| 581 | + : ''; |
|
| 582 | + if ($n === 0) { |
|
| 583 | + $errors = array( |
|
| 584 | + 'L_ERRORCODE' => $l_error_code, |
|
| 585 | + 'L_SHORTMESSAGE' => $l_short_message, |
|
| 586 | + 'L_LONGMESSAGE' => $l_long_message, |
|
| 587 | + 'L_SEVERITYCODE' => $l_severity_code, |
|
| 588 | + ); |
|
| 589 | + } else { |
|
| 590 | + $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
| 591 | + $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
| 592 | + $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
| 593 | + $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
| 594 | + } |
|
| 595 | + $n++; |
|
| 596 | + } |
|
| 597 | + return $errors; |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | 600 | } |
| 601 | 601 | // End of file EEG_Paypal_Express.gateway.php |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('NO direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $notify_url = null, |
| 131 | 131 | $cancel_url = null |
| 132 | 132 | ) { |
| 133 | - if (! $payment instanceof EEI_Payment) { |
|
| 133 | + if ( ! $payment instanceof EEI_Payment) { |
|
| 134 | 134 | $payment->set_gateway_response( |
| 135 | 135 | __( |
| 136 | 136 | 'Error. No associated payment was found.', |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | return $payment; |
| 142 | 142 | } |
| 143 | 143 | $transaction = $payment->transaction(); |
| 144 | - if (! $transaction instanceof EEI_Transaction) { |
|
| 144 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
| 145 | 145 | $payment->set_gateway_response( |
| 146 | 146 | __( |
| 147 | 147 | 'Could not process this payment because it has no associated transaction.', |
@@ -194,25 +194,25 @@ discard block |
||
| 194 | 194 | $line_item_quantity = 1; |
| 195 | 195 | } |
| 196 | 196 | // Item Name. |
| 197 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = substr( |
|
| 197 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( |
|
| 198 | 198 | $this->_format_line_item_name($line_item, $payment), |
| 199 | 199 | 0, |
| 200 | 200 | 127 |
| 201 | 201 | ); |
| 202 | 202 | // Item description. |
| 203 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = substr( |
|
| 203 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr( |
|
| 204 | 204 | $this->_format_line_item_desc($line_item, $payment), |
| 205 | 205 | 0, |
| 206 | 206 | 127 |
| 207 | 207 | ); |
| 208 | 208 | // Cost of individual item. |
| 209 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency($unit_price); |
|
| 209 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price); |
|
| 210 | 210 | // Item Number. |
| 211 | - $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1; |
|
| 211 | + $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
|
| 212 | 212 | // Item quantity. |
| 213 | - $token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = $line_item_quantity; |
|
| 213 | + $token_request_dtls['L_PAYMENTREQUEST_0_QTY'.$item_num] = $line_item_quantity; |
|
| 214 | 214 | // Digital item is sold. |
| 215 | - $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical'; |
|
| 215 | + $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
| 216 | 216 | $itemized_sum += $line_item->total(); |
| 217 | 217 | ++$item_num; |
| 218 | 218 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | // add the difference as an extra line item. |
| 231 | 231 | if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
| 232 | 232 | // Item Name. |
| 233 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = substr( |
|
| 233 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( |
|
| 234 | 234 | __( |
| 235 | 235 | 'Other (promotion/surcharge/cancellation)', |
| 236 | 236 | 'event_espresso' |
@@ -239,17 +239,17 @@ discard block |
||
| 239 | 239 | 127 |
| 240 | 240 | ); |
| 241 | 241 | // Item description. |
| 242 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = ''; |
|
| 242 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = ''; |
|
| 243 | 243 | // Cost of individual item. |
| 244 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency( |
|
| 244 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( |
|
| 245 | 245 | $itemized_sum_diff_from_txn_total |
| 246 | 246 | ); |
| 247 | 247 | // Item Number. |
| 248 | - $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1; |
|
| 248 | + $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
|
| 249 | 249 | // Item quantity. |
| 250 | - $token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = 1; |
|
| 250 | + $token_request_dtls['L_PAYMENTREQUEST_0_QTY'.$item_num] = 1; |
|
| 251 | 251 | // Digital item is sold. |
| 252 | - $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical'; |
|
| 252 | + $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
| 253 | 253 | $item_num++; |
| 254 | 254 | } |
| 255 | 255 | } else { |
@@ -292,13 +292,13 @@ discard block |
||
| 292 | 292 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
| 293 | 293 | $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
| 294 | 294 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
| 295 | - } elseif (! $this->_request_shipping_addr) { |
|
| 295 | + } elseif ( ! $this->_request_shipping_addr) { |
|
| 296 | 296 | // Do not request shipping details on the PP Checkout page. |
| 297 | 297 | $token_request_dtls['NOSHIPPING'] = '1'; |
| 298 | 298 | $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
| 299 | 299 | } |
| 300 | 300 | // Used a business/personal logo on the PayPal page. |
| 301 | - if (! empty($this->_image_url)) { |
|
| 301 | + if ( ! empty($this->_image_url)) { |
|
| 302 | 302 | $token_request_dtls['LOGOIMG'] = $this->_image_url; |
| 303 | 303 | } |
| 304 | 304 | $token_request_dtls = apply_filters( |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | ); |
| 324 | 324 | } else { |
| 325 | 325 | if (isset($response_args['L_ERRORCODE'])) { |
| 326 | - $payment->set_gateway_response($response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE']); |
|
| 326 | + $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']); |
|
| 327 | 327 | } else { |
| 328 | 328 | $payment->set_gateway_response( |
| 329 | 329 | esc_html__( |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | if ($payment instanceof EEI_Payment) { |
| 355 | 355 | $this->log(array('Return from Authorization' => $update_info), $payment); |
| 356 | 356 | $transaction = $payment->transaction(); |
| 357 | - if (! $transaction instanceof EEI_Transaction) { |
|
| 357 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
| 358 | 358 | $payment->set_gateway_response( |
| 359 | 359 | __( |
| 360 | 360 | 'Could not process this payment because it has no associated transaction.', |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | $primary_registrant = $transaction->primary_registration(); |
| 368 | 368 | $payment_details = $payment->details(); |
| 369 | 369 | // Check if we still have the token. |
| 370 | - if (! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
| 370 | + if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
| 371 | 371 | $payment->set_status($this->_pay_model->failed_status()); |
| 372 | 372 | return $payment; |
| 373 | 373 | } |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | : ''; |
| 413 | 413 | $payment->set_extra_accntng($primary_registration_code); |
| 414 | 414 | $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) |
| 415 | - ? (float)$docheckout_response_args['PAYMENTINFO_0_AMT'] |
|
| 415 | + ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] |
|
| 416 | 416 | : 0); |
| 417 | 417 | $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) |
| 418 | 418 | ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | 'SIGNATURE' => urlencode($this->_api_signature), |
| 485 | 485 | ); |
| 486 | 486 | $dtls = array_merge($request_dtls, $request_params); |
| 487 | - $this->_log_clean_request($dtls, $payment, $request_text . ' Request'); |
|
| 487 | + $this->_log_clean_request($dtls, $payment, $request_text.' Request'); |
|
| 488 | 488 | // Request Customer Details. |
| 489 | 489 | $request_response = wp_remote_post( |
| 490 | 490 | $this->_base_gateway_url, |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | ) |
| 499 | 499 | ); |
| 500 | 500 | // Log the response. |
| 501 | - $this->log(array($request_text . ' Response' => $request_response), $payment); |
|
| 501 | + $this->log(array($request_text.' Response' => $request_response), $payment); |
|
| 502 | 502 | return $request_response; |
| 503 | 503 | } |
| 504 | 504 | |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | } |
| 519 | 519 | $response_args = array(); |
| 520 | 520 | parse_str(urldecode($request_response['body']), $response_args); |
| 521 | - if (! isset($response_args['ACK'])) { |
|
| 521 | + if ( ! isset($response_args['ACK'])) { |
|
| 522 | 522 | return array('status' => false, 'args' => $request_response); |
| 523 | 523 | } |
| 524 | 524 | if ( |
@@ -587,10 +587,10 @@ discard block |
||
| 587 | 587 | 'L_SEVERITYCODE' => $l_severity_code, |
| 588 | 588 | ); |
| 589 | 589 | } else { |
| 590 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
| 591 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
| 592 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
| 593 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
| 590 | + $errors['L_ERRORCODE'] .= ', '.$l_error_code; |
|
| 591 | + $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message; |
|
| 592 | + $errors['L_LONGMESSAGE'] .= ', '.$l_long_message; |
|
| 593 | + $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code; |
|
| 594 | 594 | } |
| 595 | 595 | $n++; |
| 596 | 596 | } |