PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.4.7
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.4.7
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.4.7, at includes/admin/settings/miscellaneous-settings/class-wpsc-ms-advanced.php

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