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_note.php

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

76 lines 2.5 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
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
19 if ($current_user->ID) {
20 $customer_name = $current_user->display_name;
21 $customer_email = $current_user->user_email;
22 }
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 // Get reply body
29 $rich_editing = $wpscfunction->rich_editing_status($current_user);
30
31 $flag = false;
32 if((in_array('register_user',$wpsc_allow_rich_text_editor) && !$current_user->has_cap('wpsc_agent')) && $rich_editing){
33 $flag = true;
34 }elseif($current_user->has_cap('wpsc_agent') && $rich_editing){
35 $flag = true;
36 }
37
38 if ($flag) {
39 $reply_body = isset($_POST['reply_body']) ? wp_kses_post(htmlspecialchars_decode($_POST['reply_body'], ENT_QUOTES)) : '';
40 } else {
41 $reply_body = isset($_POST['reply_body']) ? sanitize_textarea_field($_POST['reply_body']) : '';
42 }
43
44 // Get reply attachments
45 $description_attachment = isset($_POST['desc_attachment']) ? $wpscfunction->sanitize_array($_POST['desc_attachment']) : array();
46 $attachments = array();
47 foreach ($description_attachment as $key => $value) {
48 $attachment_id = intval($value);
49 $attachments[] = $attachment_id;
50 update_term_meta ($attachment_id, 'active', '1');
51 }
52
53 $ip_address = isset($_SERVER) && isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'';
54 if (strlen($ip_address)>28) {
55 $ip_address = '';
56 }
57 $os_platform = $wpscfunction->get_os();
58 $browser = $wpscfunction->get_browser();
59 // Prepare arguments
60 $args = array(
61 'ticket_id' => $ticket_id,
62 'reply_body' => $wpscfunction->replace_macro($reply_body,$ticket_id),
63 'customer_name' => $customer_name,
64 'customer_email' => $customer_email,
65 'attachments' => $attachments,
66 'thread_type' => 'note',
67 'ip_address' => $ip_address,
68 'reply_source' => 'browser',
69 'os' => $os_platform,
70 'browser' => $browser
71 );
72 $args = apply_filters( 'wpsc_thread_args', $args );
73 $thread_id = $wpscfunction->submit_ticket_thread($args);
74
75 do_action( 'wpsc_after_submit_note', $thread_id, $ticket_id );
76