| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user, $wpscfunction; |
| 7 |
|
| 8 |
// Get tiket id |
| 9 |
$ticket_id = isset($_POST['ticket_id']) ? intval($_POST['ticket_id']) : 0; |
| 10 |
if(!$ticket_id) die(); |
| 11 |
|
| 12 |
// Check if auth code is there |
| 13 |
$auth_code = isset($_POST['auth_code']) ? sanitize_text_field($_POST['auth_code']) : ''; |
| 14 |
|
| 15 |
// Check ticket permanently deleted |
| 16 |
if(!$ticket_id){ |
| 17 |
_e('Ticket not found.','supportcandy'); |
| 18 |
die(); |
| 19 |
} |
| 20 |
|
| 21 |
$ticket_auth_code = $wpscfunction->get_ticket_fields($ticket_id,'ticket_auth_code'); |
| 22 |
|
| 23 |
// Check ticket in trash |
| 24 |
$ticket_status = $wpscfunction->get_ticket_status($ticket_id); |
| 25 |
if(!$ticket_status && $current_user && !$current_user->has_cap('wpsc_agent')){ |
| 26 |
_e('Ticket not found.','supportcandy'); |
| 27 |
die(); |
| 28 |
} |
| 29 |
|
| 30 |
$wpsc_ticket_url_permission = get_option('wpsc_ticket_url_permission'); |
| 31 |
if( !is_user_logged_in() && !$wpsc_ticket_url_permission){ |
| 32 |
include WPSC_ABSPATH . 'includes/admin/tickets/sign_in/sign_in.php'; |
| 33 |
die(); |
| 34 |
} |
| 35 |
|
| 36 |
$wpsc_ticket_public_mode = get_option('wpsc_ticket_public_mode'); |
| 37 |
if( ($wpscfunction->has_permission('view_ticket',$ticket_id) || $wpsc_ticket_public_mode) && is_user_logged_in()){ |
| 38 |
|
| 39 |
include WPSC_ABSPATH . 'includes/admin/tickets/individual_ticket/load_individual_ticket.php'; |
| 40 |
|
| 41 |
} else if ( $ticket_auth_code == $auth_code && $wpsc_ticket_url_permission) { |
| 42 |
|
| 43 |
include WPSC_ABSPATH . 'includes/admin/tickets/individual_ticket/load_guest_individual_ticket.php'; |
| 44 |
|
| 45 |
} else { |
| 46 |
|
| 47 |
_e('You are not authorized to view this ticket.','supportcandy'); |
| 48 |
|
| 49 |
} |
| 50 |
|