PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 2.3.1
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v2.3.1
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / includes / admin / tickets / individual_ticket / submit_reply.php

submit_reply.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 2.3.1, at includes/admin/tickets/individual_ticket/submit_reply.php

111 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6 global $wpscfunction, $current_user;
7 $wpsc_guest_can_upload_files = get_option('wpsc_guest_can_upload_files');
8 // Get tiket id
9 $ticket_id = isset($_POST['ticket_id']) ? intval($_POST['ticket_id']) : 0;
10 if(!$ticket_id) die();
11
12 $wpsc_allow_rich_text_editor = get_option('wpsc_allow_rich_text_editor');
13
14 // Check nonce
15 if( !isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'],$ticket_id) ){
16 die(__('Cheating huh?', 'supportcandy'));
17 }
18 setcookie('wpsc_secure_code','123');
19
20 if ($current_user->ID) {
21 $customer_name = $current_user->display_name;
22 $customer_email = $current_user->user_email;
23 } else {
24 $customer_name = isset($_POST['customer_name']) ? sanitize_text_field($_POST['customer_name']) : '';
25 $customer_email = isset($_POST['customer_email']) ? sanitize_email($_POST['customer_email']) : '';
26 }
27
28 if ( !$customer_name || !$customer_email ) die();
29
30 // Get reply body
31 $rich_editing = $wpscfunction->rich_editing_status($current_user);
32
33 $flag = false;
34
35 if((in_array('register_user',$wpsc_allow_rich_text_editor) && !$current_user->has_cap('wpsc_agent')) && $rich_editing){
36 $flag = true;
37 } elseif($current_user->has_cap('wpsc_agent') && $rich_editing){
38 $flag = true;
39 } elseif ( in_array('guest_user',$wpsc_allow_rich_text_editor) && (!is_user_logged_in())) {
40 $flag = true;
41 }
42
43 if ( $flag ) {
44 $reply_body = isset($_POST['reply_body']) ? wp_kses_post(htmlspecialchars_decode($_POST['reply_body'], ENT_QUOTES)) : '';
45 } else {
46 $reply_body = isset($_POST['reply_body']) ? sanitize_textarea_field($_POST['reply_body']) : '';
47 }
48
49 // Get reply attachments
50 $description_attachment = isset($_POST['desc_attachment']) ? $wpscfunction->sanitize_array($_POST['desc_attachment']) : array();
51 $attachments = array();
52 if(is_user_logged_in() || $wpsc_guest_can_upload_files ){
53 foreach ($description_attachment as $key => $value) {
54 $attachment_id = intval($value);
55 $attachments[] = $attachment_id;
56 update_term_meta ($attachment_id, 'active', '1');
57 }
58 }
59
60 $signature = get_user_meta($current_user->ID,'wpsc_agent_signature',true);
61 if($signature){
62 $signature= stripcslashes(htmlspecialchars_decode($signature, ENT_QUOTES));
63 $reply_body.= $signature;
64 }
65
66 $ip_address = isset($_SERVER) && isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'';
67 if (strlen($ip_address)>28) {
68 $ip_address = '';
69 }
70 $os_platform = $wpscfunction->get_os();
71 $browser = $wpscfunction->get_browser();
72
73 $ticket_raised_by = $wpscfunction->get_ticket_fields($ticket_id,'customer_email');
74 $user_seen = 'null';
75 if($current_user->user_email == $ticket_raised_by){
76 $user_seen = date("Y-m-d H:i:s");
77 }
78
79 // Prepare arguments
80 $args = array(
81 'ticket_id' => $ticket_id,
82 'reply_body' => $wpscfunction->replace_macro($reply_body,$ticket_id),
83 'customer_name' => $customer_name,
84 'customer_email' => $customer_email,
85 'attachments' => $attachments,
86 'thread_type' => 'reply',
87 'ip_address' => $ip_address,
88 'reply_source' => 'browser',
89 'os' => $os_platform,
90 'browser' => $browser,
91 'user_seen' => $user_seen
92 );
93 $args = apply_filters( 'wpsc_thread_args', $args );
94 $thread_id = $wpscfunction->submit_ticket_thread($args);
95
96 $last_reply_by = $wpscfunction->get_ticket_meta($ticket_id,'last_reply_by',true);
97 if($last_reply_by){
98 $wpscfunction->update_ticket_meta($ticket_id,'last_reply_by',array('meta_value' => $customer_name));
99 }else{
100 $wpscfunction->add_ticket_meta($ticket_id,'last_reply_by',$customer_name);
101 }
102
103 $last_reply_on = $wpscfunction->get_ticket_meta($ticket_id,'last_reply_on',true);
104 if($last_reply_on){
105 $wpscfunction->update_ticket_meta($ticket_id,'last_reply_on',array('meta_value' => date("Y-m-d H:i:s")));
106 }else{
107 $wpscfunction->add_ticket_meta($ticket_id,'last_reply_on',date("Y-m-d H:i:s"));
108 }
109
110 do_action( 'wpsc_after_submit_reply', $thread_id, $ticket_id );
111