PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.3.9
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.3.9
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 / settings / miscellaneous-settings / class-wpsc-ms-advanced.php

class-wpsc-ms-advanced.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 3.3.9, at includes/admin/settings/miscellaneous-settings/class-wpsc-ms-advanced.php

492 lines 24.9 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 if ( ! class_exists( 'WPSC_MS_Advanced' ) ) :
7
8 final class WPSC_MS_Advanced {
9
10 /**
11 * Initialize this class
12 *
13 * @return void
14 */
15 public static function init() {
16
17 // User interface.
18 add_action( 'wp_ajax_wpsc_get_ms_advanced', array( __CLASS__, 'load_settings_ui' ) );
19 add_action( 'wp_ajax_wpsc_set_ms_advanced', array( __CLASS__, 'save_settings' ) );
20 add_action( 'wp_ajax_wpsc_reset_ms_advanced', array( __CLASS__, 'reset_settings' ) );
21
22 // Print in create ticket form.
23 add_action( 'wpsc_print_tff', array( __CLASS__, 'print_tff' ) );
24 }
25
26 /**
27 * Reset settings
28 *
29 * @return void
30 */
31 public static function reset() {
32
33 $advanced = apply_filters(
34 'wpsc_ms_advanced_settings',
35 array(
36 'public-mode' => 0,
37 'public-mode-reply' => 0,
38 'reply-confirmation' => 1,
39 'note-confirmation' => 0,
40 'thread-date-display-as' => 'diff',
41 'thread-date-format' => 'F d, Y h:i A',
42 'do-not-notify-owner' => 1,
43 'do-not-notify-owner-status' => 1,
44 'ticket-id-format' => 'sequential',
45 'starting-ticket-id' => 1,
46 'random-id-length' => 8,
47 'ticket-history-macro-threads' => 5,
48 'register-user-if-not-exist' => 0,
49 'auto-delete-tickets-time' => 0,
50 'auto-delete-tickets-unit' => 'days',
51 'permanent-delete-tickets-time' => 0,
52 'permanent-delete-tickets-unit' => 'days',
53 'allow-bcc' => 0,
54 'allow-cc' => 0,
55 'view-more' => 1,
56 'allow-reply-to-close-ticket' => array( 'customer', 'agent' ),
57 'raised-by-user' => 'customer',
58 'allow-my-profile' => 1,
59 'allow-agent-profile' => 1,
60 'ticket-url-auth' => 0,
61 'rest-api' => 1,
62 'agent-collision' => 1,
63 'self-assign' => 1,
64 'reply-close' => 1,
65 )
66 );
67 update_option( 'wpsc-ms-advanced-settings', $advanced );
68 }
69
70 /**
71 * Settings user interface
72 *
73 * @return void
74 */
75 public static function load_settings_ui() {
76
77 if ( ! WPSC_Functions::is_site_admin() ) {
78 wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 );
79 }
80
81 $settings = get_option( 'wpsc-ms-advanced-settings', array() );
82
83 $close_reply = apply_filters(
84 'wpsc_allowed_close_ticket_reply',
85 array(
86 'customer' => esc_attr__( 'Customer', 'supportcandy' ),
87 'agent' => esc_attr__( 'Agent', 'supportcandy' ),
88 )
89 );
90 ?>
91
92 <form action="#" onsubmit="return false;" class="wpsc-frm-ms-advanced">
93 <div class="wpsc-dock-container">
94 <?php
95 printf(
96 /* translators: Click here to see the documentation */
97 esc_attr__( '%s to see the documentation!', 'supportcandy' ),
98 '<a href="https://supportcandy.net/docs/advanced-settings/" target="_blank">' . esc_attr__( 'Click here', 'supportcandy' ) . '</a>'
99 );
100 ?>
101 </div>
102 <div class="wpsc-input-group">
103 <div class="label-container">
104 <label for=""><?php esc_attr_e( 'Public mode', 'supportcandy' ); ?></label>
105 </div>
106 <select id="wpsc-public-mode" name="public-mode">
107 <option <?php selected( $settings['public-mode'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
108 <option <?php selected( $settings['public-mode'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
109 </select>
110 </div>
111 <div class="wpsc-input-group">
112 <div class="label-container">
113 <label for=""><?php esc_attr_e( 'Allow others to reply to public tickets', 'supportcandy' ); ?></label>
114 </div>
115 <select name="public-mode-reply">
116 <option <?php selected( $settings['public-mode-reply'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
117 <option <?php selected( $settings['public-mode-reply'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
118 </select>
119 </div>
120 <div class="wpsc-input-group">
121 <div class="label-container">
122 <label for=""><?php esc_attr_e( 'Reply confirmation', 'supportcandy' ); ?></label>
123 </div>
124 <select id="wpsc-reply-confirmation" name="reply-confirmation">
125 <option <?php selected( $settings['reply-confirmation'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
126 <option <?php selected( $settings['reply-confirmation'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
127 </select>
128 </div>
129 <div class="wpsc-input-group">
130 <div class="label-container">
131 <label for=""><?php esc_attr_e( 'Note confirmation', 'supportcandy' ); ?></label>
132 </div>
133 <select id="wpsc-note-confirmation" name="note-confirmation">
134 <option <?php selected( $settings['note-confirmation'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
135 <option <?php selected( $settings['note-confirmation'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
136 </select>
137 </div>
138 <div class="wpsc-input-group">
139 <div class="label-container">
140 <label for=""><?php esc_attr_e( 'Thread date display as', 'supportcandy' ); ?></label>
141 </div>
142 <select name="thread-date-display-as">
143 <option <?php selected( $settings['thread-date-display-as'], 'date' ); ?> value="date"><?php esc_attr_e( 'Date Format', 'supportcandy' ); ?></option>
144 <option <?php selected( $settings['thread-date-display-as'], 'diff' ); ?> value="diff"><?php esc_attr_e( 'Date Difference (e.g. 1 hour ago)', 'supportcandy' ); ?></option>
145 </select>
146 </div>
147 <div class="wpsc-input-group">
148 <div class="label-container">
149 <label for=""><?php esc_attr_e( 'Thread date format', 'supportcandy' ); ?></label>
150 </div>
151 <input type="text" id="wpsc-thread-date-format" name="thread-date-format" value="<?php echo esc_attr( $settings['thread-date-format'] ); ?>">
152 </div>
153 <div class="wpsc-input-group">
154 <div class="label-container">
155 <label for=""><?php esc_attr_e( 'Do not notify owner', 'supportcandy' ); ?></label>
156 </div>
157 <select id="wpsc-do-not-notify-owner" name="do-not-notify-owner">
158 <option <?php selected( $settings['do-not-notify-owner'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
159 <option <?php selected( $settings['do-not-notify-owner'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
160 </select>
161 </div>
162 <div class="wpsc-input-group">
163 <div class="label-container">
164 <label for=""><?php esc_attr_e( 'Do not notify owner status', 'supportcandy' ); ?></label>
165 </div>
166 <select id="wpsc-do-not-notify-owner-status" name="do-not-notify-owner-status">
167 <option <?php selected( $settings['do-not-notify-owner-status'], 1 ); ?> value="1"><?php esc_attr_e( 'Checked', 'supportcandy' ); ?></option>
168 <option <?php selected( $settings['do-not-notify-owner-status'], 0 ); ?> value="0"><?php esc_attr_e( 'Unchecked', 'supportcandy' ); ?></option>
169 </select>
170 </div>
171 <div class="wpsc-input-group">
172 <div class="label-container">
173 <label for=""><?php esc_attr_e( 'Ticket id', 'supportcandy' ); ?></label>
174 </div>
175 <select id="wpsc-ticket-id-format" name="ticket-id-format">
176 <option <?php selected( $settings['ticket-id-format'], 'sequential' ); ?> value="sequential"><?php esc_attr_e( 'Sequential', 'supportcandy' ); ?></option>
177 <option <?php selected( $settings['ticket-id-format'], 'random' ); ?> value="random"><?php esc_attr_e( 'Random', 'supportcandy' ); ?></option>
178 </select>
179 </div>
180 <script>
181 jQuery('#wpsc-ticket-id-format').change(function() {
182 if (this.value=='sequential') {
183 jQuery('#wpsc-starting-ticket-id').show();
184 jQuery('#wpsc-random-id-length').hide();
185 } else {
186 jQuery('#wpsc-starting-ticket-id').hide();
187 jQuery('#wpsc-random-id-length').show();
188 }
189 });
190 </script>
191 <?php
192 $display = $settings['ticket-id-format'] === 'random' ? 'display:none;' : ''
193 ?>
194 <div class="wpsc-input-group" id="wpsc-starting-ticket-id" style="<?php echo esc_attr( $display ); ?>">
195 <div class="label-container">
196 <label for=""><?php esc_attr_e( 'Starting ticket id', 'supportcandy' ); ?></label>
197 </div>
198 <input type="number" onkeydown="javascript: return event.keyCode == 69 ? false : true" id="wpsc-starting-ticket-id" name="starting-ticket-id" value="<?php echo esc_attr( $settings['starting-ticket-id'] ); ?>">
199 </div>
200 <?php
201 $display = $settings['ticket-id-format'] === 'sequential' ? 'display:none;' : ''
202 ?>
203 <div class="wpsc-input-group" id="wpsc-random-id-length" style="<?php echo esc_attr( $display ); ?>">
204 <div class="label-container">
205 <label for=""><?php esc_attr_e( 'Random id length', 'supportcandy' ); ?></label>
206 </div>
207 <input type="number" min="1" onkeydown="javascript: return event.keyCode == 69 ? false : true" name="random-id-length" value="<?php echo esc_attr( $settings['random-id-length'] ); ?>">
208 </div>
209 <div class="wpsc-input-group">
210 <div class="label-container">
211 <label for=""><?php esc_attr_e( 'Ticket history macro threads', 'supportcandy' ); ?></label>
212 </div>
213 <input type="number" onkeydown="javascript: return event.keyCode == 69 ? false : true" id="wpsc-ticket-history-macro-threads" name="ticket-history-macro-threads" value="<?php echo esc_attr( $settings['ticket-history-macro-threads'] ); ?>">
214 </div>
215 <div class="wpsc-input-group">
216 <div class="label-container">
217 <label for=""><?php esc_attr_e( 'Register user if not exist', 'supportcandy' ); ?></label>
218 </div>
219 <select id="wpsc-register-user-if-not-exist" name="register-user-if-not-exist">
220 <option <?php selected( $settings['register-user-if-not-exist'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
221 <option <?php selected( $settings['register-user-if-not-exist'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
222 </select>
223 </div>
224 <div class="wpsc-input-group">
225 <div class="label-container">
226 <label for=""><?php esc_attr_e( 'Auto delete closed tickets', 'supportcandy' ); ?></label>
227 </div>
228 <div class="divide-bar">
229 <input type="number" id="wpsc-auto-delete-tickets-time" name="auto-delete-tickets-time" value="<?php echo esc_attr( $settings['auto-delete-tickets-time'] ); ?>">
230 <select id="wpsc-auto-delete-tickets-unit" name="auto-delete-tickets-unit">
231 <option <?php selected( $settings['auto-delete-tickets-unit'], 'days' ); ?> value="days"><?php esc_attr_e( 'Day(s)', 'supportcandy' ); ?></option>
232 <option <?php selected( $settings['auto-delete-tickets-unit'], 'month' ); ?> value="month"><?php esc_attr_e( 'Month(s)', 'supportcandy' ); ?></option>
233 <option <?php selected( $settings['auto-delete-tickets-unit'], 'year' ); ?> value="year"><?php esc_attr_e( 'Year(s)', 'supportcandy' ); ?></option>
234 </select>
235 </div>
236 </div>
237 <div class="wpsc-input-group">
238 <div class="label-container">
239 <label for=""><?php esc_attr_e( 'Permanently delete tickets', 'supportcandy' ); ?></label>
240 </div>
241 <div class="divide-bar">
242 <input type="number" id="wpsc-permanent-delete-tickets-time" name="permanent-delete-tickets-time" value="<?php echo esc_attr( $settings['permanent-delete-tickets-time'] ); ?>">
243 <select id="wpsc-permanent-delete-tickets-unit" name="permanent-delete-tickets-unit">
244 <option <?php selected( $settings['permanent-delete-tickets-unit'], 'days' ); ?> value="days"><?php esc_attr_e( 'Day(s)', 'supportcandy' ); ?></option>
245 <option <?php selected( $settings['permanent-delete-tickets-unit'], 'month' ); ?> value="month"><?php esc_attr_e( 'Month(s)', 'supportcandy' ); ?></option>
246 <option <?php selected( $settings['permanent-delete-tickets-unit'], 'year' ); ?> value="year"><?php esc_attr_e( 'Year(s)', 'supportcandy' ); ?></option>
247 </select>
248 </div>
249 </div>
250 <div class="wpsc-input-group">
251 <div class="label-container">
252 <label for="">CC</label>
253 </div>
254 <select name="allow-cc">
255 <option <?php selected( $settings['allow-cc'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
256 <option <?php selected( $settings['allow-cc'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
257 </select>
258 </div>
259 <div class="wpsc-input-group">
260 <div class="label-container">
261 <label for="">BCC</label>
262 </div>
263 <select name="allow-bcc">
264 <option <?php selected( $settings['allow-bcc'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
265 <option <?php selected( $settings['allow-bcc'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
266 </select>
267 </div>
268 <div class="wpsc-input-group">
269 <div class="label-container">
270 <label for=""><?php esc_attr_e( 'View more/less thread', 'supportcandy' ); ?></label>
271 </div>
272 <select name="view-more">
273 <option <?php selected( $settings['view-more'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
274 <option <?php selected( $settings['view-more'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
275 </select>
276 </div>
277 <div class="wpsc-input-group">
278 <div class="label-container">
279 <label for=""><?php esc_attr_e( 'Allow reply to closed tickets', 'supportcandy' ); ?></label>
280 </div>
281 <select id="wpsc-allowed-close-ticket-reply" multiple name="allow-reply-to-close-ticket[]">
282 <?php
283 foreach ( $close_reply as $key => $tag ) :
284 $selected = in_array( $key, $settings['allow-reply-to-close-ticket'] ) ? 'selected' : '';
285 ?>
286 <option <?php echo esc_attr( $selected ); ?> value="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $tag ); ?></option>
287 <?php
288 endforeach;
289 ?>
290 </select>
291 <script>jQuery('#wpsc-allowed-close-ticket-reply').selectWoo();</script>
292 </div>
293 <div class="wpsc-input-group">
294 <div class="label-container">
295 <label for=""><?php esc_attr_e( 'Raised By User', 'supportcandy' ); ?></label>
296 </div>
297 <select name="raised-by-user">
298 <option <?php selected( $settings['raised-by-user'], 'customer' ); ?> value="customer"><?php esc_attr_e( 'Customer', 'supportcandy' ); ?></option>
299 <option <?php selected( $settings['raised-by-user'], 'agent' ); ?> value="agent"><?php esc_attr_e( 'Agent', 'supportcandy' ); ?></option>
300 </select>
301 </div>
302 <div class="wpsc-input-group">
303 <div class="label-container">
304 <label for=""><?php esc_attr_e( 'My Profile tab', 'supportcandy' ); ?></label>
305 </div>
306 <select id="wpsc-allow-my-profile" name="allow-my-profile">
307 <option <?php selected( $settings['allow-my-profile'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
308 <option <?php selected( $settings['allow-my-profile'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
309 </select>
310 </div>
311 <div class="wpsc-input-group">
312 <div class="label-container">
313 <label for=""><?php esc_attr_e( 'Agent Profile tab', 'supportcandy' ); ?></label>
314 </div>
315 <select id="wpsc-allow-agent-profile" name="allow-agent-profile">
316 <option <?php selected( $settings['allow-agent-profile'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
317 <option <?php selected( $settings['allow-agent-profile'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
318 </select>
319 </div>
320 <div class="wpsc-input-group">
321 <div class="label-container">
322 <label for=""><?php esc_attr_e( 'Ticket url authentication', 'supportcandy' ); ?></label>
323 </div>
324 <select name="ticket-url-auth">
325 <option <?php selected( $settings['ticket-url-auth'], '1' ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
326 <option <?php selected( $settings['ticket-url-auth'], '0' ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
327 </select>
328 </div>
329 <div class="wpsc-input-group">
330 <div class="label-container">
331 <label for=""><?php esc_attr_e( 'REST API', 'supportcandy' ); ?></label>
332 </div>
333 <select name="rest-api">
334 <option <?php selected( $settings['rest-api'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
335 <option <?php selected( $settings['rest-api'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
336 </select>
337 </div>
338 <div class="wpsc-input-group">
339 <div class="label-container">
340 <label for=""><?php esc_attr_e( 'Agent collision', 'supportcandy' ); ?></label>
341 </div>
342 <select name="agent-collision">
343 <option <?php selected( $settings['agent-collision'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
344 <option <?php selected( $settings['agent-collision'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
345 </select>
346 </div>
347 <div class="wpsc-input-group">
348 <div class="label-container">
349 <label for=""><?php esc_attr_e( 'Allow agent to self assign ticket', 'supportcandy' ); ?></label>
350 </div>
351 <select name="self-assign">
352 <option <?php selected( $settings['self-assign'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
353 <option <?php selected( $settings['self-assign'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
354 </select>
355 </div>
356 <div class="wpsc-input-group">
357 <div class="label-container">
358 <label for=""><?php esc_attr_e( 'Reply and Close button', 'supportcandy' ); ?></label>
359 </div>
360 <select name="reply-close">
361 <option <?php selected( $settings['reply-close'], 1 ); ?> value="1"><?php esc_attr_e( 'Enable', 'supportcandy' ); ?></option>
362 <option <?php selected( $settings['reply-close'], 0 ); ?> value="0"><?php esc_attr_e( 'Disable', 'supportcandy' ); ?></option>
363 </select>
364 </div>
365 <?php do_action( 'wpsc_ms_advanced_settings' ); ?>
366 <input type="hidden" name="action" value="wpsc_set_ms_advanced">
367 <input type="hidden" name="_ajax_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wpsc_set_ms_advanced' ) ); ?>">
368 </form>
369 <div class="setting-footer-actions">
370 <button
371 class="wpsc-button normal primary margin-right"
372 onclick="wpsc_set_ms_advanced(this);">
373 <?php esc_attr_e( 'Submit', 'supportcandy' ); ?></button>
374 <button
375 class="wpsc-button normal secondary"
376 onclick="wpsc_reset_ms_advanced(this, '<?php echo esc_attr( wp_create_nonce( 'wpsc_reset_ms_advanced' ) ); ?>');">
377 <?php esc_attr_e( 'Reset default', 'supportcandy' ); ?></button>
378 </div>
379 <?php
380 wp_die();
381 }
382
383 /**
384 * Save settings
385 *
386 * @return void
387 */
388 public static function save_settings() {
389
390 if ( check_ajax_referer( 'wpsc_set_ms_advanced', '_ajax_nonce', false ) != 1 ) {
391 wp_send_json_error( 'Unauthorised request!', 401 );
392 }
393
394 global $wpdb;
395
396 if ( ! WPSC_Functions::is_site_admin() ) {
397 wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 );
398 }
399
400 $advanced = apply_filters(
401 'wpsc_set_ms_advanced',
402 array(
403 'public-mode' => isset( $_POST['public-mode'] ) ? intval( $_POST['public-mode'] ) : 1,
404 'public-mode-reply' => isset( $_POST['public-mode-reply'] ) ? intval( $_POST['public-mode-reply'] ) : 0,
405 'reply-confirmation' => isset( $_POST['reply-confirmation'] ) ? intval( $_POST['reply-confirmation'] ) : 1,
406 'note-confirmation' => isset( $_POST['note-confirmation'] ) ? intval( $_POST['note-confirmation'] ) : 0,
407 'thread-date-display-as' => isset( $_POST['thread-date-display-as'] ) ? sanitize_text_field( wp_unslash( $_POST['thread-date-display-as'] ) ) : 'diff',
408 'thread-date-format' => isset( $_POST['thread-date-format'] ) ? sanitize_text_field( wp_unslash( $_POST['thread-date-format'] ) ) : 'F d, Y h:i A',
409 'do-not-notify-owner' => isset( $_POST['do-not-notify-owner'] ) ? intval( $_POST['do-not-notify-owner'] ) : 0,
410 'do-not-notify-owner-status' => isset( $_POST['do-not-notify-owner-status'] ) ? intval( $_POST['do-not-notify-owner-status'] ) : 0,
411 'ticket-id-format' => isset( $_POST['ticket-id-format'] ) ? sanitize_text_field( wp_unslash( $_POST['ticket-id-format'] ) ) : 'sequential',
412 'starting-ticket-id' => isset( $_POST['starting-ticket-id'] ) ? intval( $_POST['starting-ticket-id'] ) : 1,
413 'random-id-length' => isset( $_POST['random-id-length'] ) ? intval( $_POST['random-id-length'] ) : 8,
414 'ticket-history-macro-threads' => isset( $_POST['ticket-history-macro-threads'] ) ? intval( $_POST['ticket-history-macro-threads'] ) : 5,
415 'register-user-if-not-exist' => isset( $_POST['register-user-if-not-exist'] ) ? intval( $_POST['register-user-if-not-exist'] ) : '0',
416 'auto-delete-tickets-time' => isset( $_POST['auto-delete-tickets-time'] ) ? intval( $_POST['auto-delete-tickets-time'] ) : '0',
417 'auto-delete-tickets-unit' => isset( $_POST['auto-delete-tickets-unit'] ) ? sanitize_text_field( wp_unslash( $_POST['auto-delete-tickets-unit'] ) ) : 'days',
418 'permanent-delete-tickets-time' => isset( $_POST['permanent-delete-tickets-time'] ) ? intval( $_POST['permanent-delete-tickets-time'] ) : '0',
419 'permanent-delete-tickets-unit' => isset( $_POST['permanent-delete-tickets-unit'] ) ? sanitize_text_field( wp_unslash( $_POST['permanent-delete-tickets-unit'] ) ) : 'days',
420 'allow-bcc' => isset( $_POST['allow-bcc'] ) ? intval( $_POST['allow-bcc'] ) : 0,
421 'allow-cc' => isset( $_POST['allow-cc'] ) ? intval( $_POST['allow-cc'] ) : 0,
422 'view-more' => isset( $_POST['view-more'] ) ? intval( $_POST['view-more'] ) : 1,
423 'allow-reply-to-close-ticket' => isset( $_POST['allow-reply-to-close-ticket'] ) ? array_filter( array_map( 'sanitize_text_field', wp_unslash( $_POST['allow-reply-to-close-ticket'] ) ) ) : array(),
424 'raised-by-user' => isset( $_POST['raised-by-user'] ) ? sanitize_text_field( wp_unslash( $_POST['raised-by-user'] ) ) : 'customer',
425 'allow-my-profile' => isset( $_POST['allow-my-profile'] ) ? intval( $_POST['allow-my-profile'] ) : 0,
426 'allow-agent-profile' => isset( $_POST['allow-agent-profile'] ) ? intval( $_POST['allow-agent-profile'] ) : 0,
427 'ticket-url-auth' => isset( $_POST['ticket-url-auth'] ) ? intval( $_POST['ticket-url-auth'] ) : 0,
428 'rest-api' => isset( $_POST['rest-api'] ) ? intval( $_POST['rest-api'] ) : 0,
429 'agent-collision' => isset( $_POST['agent-collision'] ) ? intval( $_POST['agent-collision'] ) : 0,
430 'self-assign' => isset( $_POST['self-assign'] ) ? intval( $_POST['self-assign'] ) : 0,
431 'reply-close' => isset( $_POST['reply-close'] ) ? intval( $_POST['reply-close'] ) : 0,
432 )
433 );
434 update_option( 'wpsc-ms-advanced-settings', $advanced );
435
436 $new_id = isset( $_POST['starting-ticket-id'] ) ? intval( $_POST['starting-ticket-id'] ) : 1;
437 $old_id = $wpdb->get_var( 'SELECT MAX(id) FROM ' . $wpdb->prefix . 'psmsc_tickets' );
438
439 if ( $new_id > $old_id ) {
440 $wpdb->query( 'ALTER TABLE ' . $wpdb->prefix . "psmsc_tickets AUTO_INCREMENT = $new_id" );
441 }
442
443 wp_die();
444 }
445
446 /**
447 * Reset settings to default
448 *
449 * @return void
450 */
451 public static function reset_settings() {
452
453 if ( check_ajax_referer( 'wpsc_reset_ms_advanced', '_ajax_nonce', false ) != 1 ) {
454 wp_send_json_error( 'Unauthorised request!', 401 );
455 }
456
457 if ( ! WPSC_Functions::is_site_admin() ) {
458 wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 );
459 }
460 self::reset();
461 wp_die();
462 }
463
464 /**
465 * Print ticket form field
466 *
467 * @return void
468 */
469 public static function print_tff() {
470
471 $current_user = WPSC_Current_User::$current_user;
472 $advanced = get_option( 'wpsc-ms-advanced-settings' );
473 if ( $current_user->is_agent && $advanced['do-not-notify-owner'] ) {
474 ?>
475 <div class="wpsc-tff do-not-notify wpsc-xs-12 wpsc-sm-12 wpsc-md-12 wpsc-lg-12 required wpsc-visible" data-cft="do-not-notify">
476 <div class="checkbox-container">
477 <?php
478 $unique_id = uniqid( 'wpsc_' );
479 $status = $advanced['do-not-notify-owner-status'] ? 'checked' : '';
480 ?>
481 <input id="<?php echo esc_attr( $unique_id ); ?>" type="checkbox" class="notify_owner" name="notify_owner" <?php echo esc_attr( $status ); ?> value="1"/>
482 <label for="<?php echo esc_attr( $unique_id ); ?>"><?php esc_attr_e( 'Do not notify owner', 'supportcandy' ); ?></label>
483 </div>
484 </div>
485 <?php
486 }
487 }
488 }
489 endif;
490
491 WPSC_MS_Advanced::init();
492