| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $wpscfunction; |
| 7 |
|
| 8 |
$ticket_history_all = ''; |
| 9 |
|
| 10 |
$threads = get_posts(array( |
| 11 |
'post_type' => 'wpsc_ticket_thread', |
| 12 |
'post_status' => 'publish', |
| 13 |
'posts_per_page' => -1, |
| 14 |
'orderby' => 'date', |
| 15 |
'order' => 'DESC', |
| 16 |
'meta_query' => array( |
| 17 |
'relation' => 'AND', |
| 18 |
array( |
| 19 |
'key' => 'ticket_id', |
| 20 |
'value' => $ticket_id, |
| 21 |
'compare' => '=' |
| 22 |
), |
| 23 |
array( |
| 24 |
'key' => 'thread_type', |
| 25 |
'value' => array('reply','report'), |
| 26 |
'compare' => 'IN' |
| 27 |
), |
| 28 |
), |
| 29 |
)); |
| 30 |
|
| 31 |
$auth_id = $wpscfunction->get_ticket_fields($ticket_id,'ticket_auth_code'); |
| 32 |
|
| 33 |
if($threads){ |
| 34 |
foreach ($threads as $thread) { |
| 35 |
$user_name = get_post_meta($thread->ID,'customer_name',true); |
| 36 |
$attachments = get_post_meta( $thread->ID, 'attachments', true); |
| 37 |
$thread_type = get_post_meta($thread->ID, 'thread_type',true); |
| 38 |
$thread_type = '(' . $thread_type . ')'; |
| 39 |
|
| 40 |
$ticket_history_all .= '<hr><strong>'.$user_name.'</strong> <small><i>'.$wpscfunction->time_elapsed_timestamp($thread->post_date_gmt).'</i>'. $thread_type .'</small><br>'.$thread->post_content; |
| 41 |
if($attachments){ |
| 42 |
$ticket_history_all .= 'Attachments :'; |
| 43 |
|
| 44 |
foreach( $attachments as $attachment ): |
| 45 |
$attach = array(); |
| 46 |
$attach_meta = get_term_meta($attachment); |
| 47 |
foreach ($attach_meta as $key => $value) { |
| 48 |
$attach[$key] = $value[0]; |
| 49 |
} |
| 50 |
$download_url = home_url('/').'?wpsc_attachment='.$attachment.'&tid='.$ticket_id.'&tac='.$auth_id; |
| 51 |
$ticket_history_all.= '<br><a style="text-decoration:none;" href="'.$download_url.'" target="_blank">'.$attach['filename'].'</a>'; |
| 52 |
endforeach; |
| 53 |
|
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
|