PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.4.1
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.4.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 / class-wpsc-installation.php

class-wpsc-installation.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 3.4.1, at class-wpsc-installation.php

2,653 lines 86.6 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_Installation' ) ) :
7
8 final class WPSC_Installation {
9
10 /**
11 * Currently installed version
12 *
13 * @var string
14 */
15 public static $current_version;
16
17 /**
18 * Current database version
19 *
20 * @var string
21 */
22 public static $current_db_version;
23
24 /**
25 * For checking whether upgrade available or not
26 *
27 * @var boolean
28 */
29 public static $is_upgrade = false;
30
31 /**
32 * Initialize installation
33 */
34 public static function init() {
35
36 self::get_current_version();
37 self::check_upgrade();
38
39 // database upgrade available.
40 if ( self::$current_version > 0 && self::$current_db_version < WPSC_DB_VERSION ) {
41
42 define( 'WPSC_DB_UPGRADING', true );
43 return;
44 }
45
46 // fresh installation or regular update.
47 if ( self::$is_upgrade ) {
48
49 define( 'WPSC_INSTALLING', true );
50
51 // Do not allow parallel process to run.
52 if ( 'yes' === get_transient( 'wpsc_installing' ) ) {
53 return;
54 }
55
56 // Set transient.
57 set_transient( 'wpsc_installing', 'yes', MINUTE_IN_SECONDS * 10 );
58
59 // Create or update database tables.
60 self::create_db_tables();
61
62 // Run installation.
63 if ( self::$current_version == 0 ) {
64
65 add_action( 'init', array( __CLASS__, 'initial_setup' ), 1 );
66 add_action( 'init', array( __CLASS__, 'set_upgrade_complete' ), 1 );
67
68 } else {
69
70 add_action( 'init', array( __CLASS__, 'upgrade' ), 1 );
71 }
72
73 // Delete transient.
74 delete_transient( 'wpsc_installing' );
75 }
76
77 // Deactivate functionality.
78 register_deactivation_hook( WPSC_PLUGIN_FILE, array( __CLASS__, 'deactivate' ) );
79 }
80
81 /**
82 * Check version
83 */
84 public static function get_current_version() {
85
86 self::$current_version = get_option( 'wpsc_current_version', '0' );
87 self::$current_db_version = get_option( 'wpsc_db_version', '1.0' );
88 }
89
90 /**
91 * Check for upgrade
92 */
93 public static function check_upgrade() {
94
95 if ( self::$current_version != WPSC_VERSION ) {
96 self::$is_upgrade = true;
97 }
98 }
99
100 /**
101 * Create database tables
102 */
103 public static function create_db_tables() {
104
105 global $wpdb;
106
107 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
108
109 $collate = '';
110 if ( $wpdb->has_cap( 'collation' ) ) {
111 $collate = $wpdb->get_charset_collate();
112 }
113
114 $tables = "
115 CREATE TABLE {$wpdb->prefix}psmsc_tickets (
116 id BIGINT NOT NULL AUTO_INCREMENT,
117 is_active INT(1) NOT NULL DEFAULT '1',
118 customer BIGINT NOT NULL,
119 subject TEXT NOT NULL,
120 status INT NOT NULL,
121 priority INT NOT NULL,
122 category INT NOT NULL,
123 assigned_agent TEXT NULL,
124 date_created DATETIME NOT NULL,
125 date_updated DATETIME NOT NULL,
126 agent_created INT DEFAULT NULL,
127 ip_address VARCHAR(50) DEFAULT NULL,
128 source VARCHAR(50) DEFAULT NULL,
129 browser VARCHAR(50) DEFAULT NULL,
130 os VARCHAR(50) DEFAULT NULL,
131 add_recipients TEXT NULL,
132 prev_assignee TEXT NULL,
133 date_closed DATETIME DEFAULT NULL,
134 user_type VARCHAR(100) NOT NULL,
135 last_reply_on DATETIME DEFAULT NULL,
136 last_reply_by BIGINT NOT NULL,
137 last_reply_source VARCHAR(50) DEFAULT NULL,
138 auth_code VARCHAR(50) DEFAULT NULL,
139 tags TINYTEXT NULL DEFAULT NULL,
140 live_agents TINYTEXT NULL DEFAULT NULL,
141 misc LONGTEXT NULL DEFAULT NULL,
142 PRIMARY KEY (id)
143 ) $collate;
144 CREATE TABLE {$wpdb->prefix}psmsc_customers (
145 id BIGINT NOT NULL AUTO_INCREMENT,
146 user BIGINT NOT NULL,
147 ticket_count INT NOT NULL DEFAULT '0',
148 name VARCHAR(200) NOT NULL,
149 email VARCHAR(200) NOT NULL,
150 PRIMARY KEY (id)
151 ) $collate;
152 CREATE TABLE {$wpdb->prefix}psmsc_custom_fields (
153 id INT NOT NULL AUTO_INCREMENT,
154 name VARCHAR(200) NOT NULL,
155 extra_info TEXT NULL,
156 slug VARCHAR(200) NULL,
157 field VARCHAR(50) NULL,
158 type VARCHAR(100) NULL,
159 default_value TEXT NULL,
160 placeholder_text TEXT NULL,
161 char_limit INT NULL,
162 date_display_as VARCHAR(50) NULL,
163 date_format VARCHAR(50) NULL,
164 date_range VARCHAR(50) NULL,
165 start_range DATETIME NULL,
166 end_range DATETIME NULL,
167 time_format INT NULL,
168 is_personal_info INT(1) NOT NULL DEFAULT 0,
169 is_auto_fill INT(1) NULL,
170 allow_ticket_form INT(1) NULL DEFAULT 1,
171 allow_my_profile INT(1) NULL DEFAULT 1,
172 tl_width INT(3) NOT NULL DEFAULT 100,
173 load_order INT NOT NULL DEFAULT 1,
174 number_type VARCHAR(50) NULL,
175 PRIMARY KEY (id)
176 ) $collate;
177 CREATE TABLE {$wpdb->prefix}psmsc_options (
178 id INT NOT NULL AUTO_INCREMENT,
179 name VARCHAR(200) NOT NULL,
180 custom_field INT NOT NULL DEFAULT 0,
181 date_created DATETIME NOT NULL,
182 load_order INT NOT NULL DEFAULT 1,
183 PRIMARY KEY (id)
184 ) $collate;
185 CREATE TABLE {$wpdb->prefix}psmsc_threads (
186 id BIGINT NOT NULL AUTO_INCREMENT,
187 ticket BIGINT NOT NULL,
188 is_active INT(1) NOT NULL DEFAULT 1,
189 customer BIGINT NULL DEFAULT NULL,
190 type VARCHAR(50) NOT NULL,
191 body LONGTEXT NOT NULL,
192 attachments TEXT NULL DEFAULT NULL,
193 ip_address VARCHAR(50) NULL DEFAULT NULL,
194 source VARCHAR(50) NULL DEFAULT NULL,
195 os VARCHAR(50) NULL DEFAULT NULL,
196 browser VARCHAR(100) NULL DEFAULT NULL,
197 seen DATETIME NULL DEFAULT NULL,
198 date_created DATETIME NOT NULL,
199 date_updated DATETIME NOT NULL,
200 PRIMARY KEY (id)
201 ) $collate;
202 CREATE TABLE {$wpdb->prefix}psmsc_statuses (
203 id BIGINT NOT NULL AUTO_INCREMENT,
204 name VARCHAR(200) NOT NULL,
205 color VARCHAR(50) NOT NULL,
206 bg_color VARCHAR(50) NOT NULL,
207 load_order INT NOT NULL DEFAULT 1,
208 PRIMARY KEY (id)
209 ) $collate;
210 CREATE TABLE {$wpdb->prefix}psmsc_categories (
211 id BIGINT NOT NULL AUTO_INCREMENT,
212 name VARCHAR(200) NOT NULL,
213 load_order INT NOT NULL DEFAULT 1,
214 PRIMARY KEY (id)
215 ) $collate;
216 CREATE TABLE {$wpdb->prefix}psmsc_priorities (
217 id BIGINT NOT NULL AUTO_INCREMENT,
218 name VARCHAR(200) NOT NULL,
219 color VARCHAR(50) NOT NULL,
220 bg_color VARCHAR(50) NOT NULL,
221 load_order INT NOT NULL DEFAULT 1,
222 PRIMARY KEY (id)
223 ) $collate;
224 CREATE TABLE {$wpdb->prefix}psmsc_attachments (
225 id BIGINT NOT NULL AUTO_INCREMENT,
226 name VARCHAR(200) NOT NULL,
227 file_path TEXT NOT NULL,
228 is_image INT(1) NOT NULL DEFAULT 0,
229 is_active INT(1) NOT NULL DEFAULT 0,
230 is_uploaded INT(1) NOT NULL DEFAULT 0,
231 date_created DATETIME NOT NULL,
232 source VARCHAR(200) NOT NULL,
233 source_id BIGINT NOT NULL DEFAULT 0,
234 ticket_id BIGINT NOT NULL DEFAULT 0,
235 customer_id BIGINT NOT NULL DEFAULT 0,
236 PRIMARY KEY (id)
237 ) $collate;
238 CREATE TABLE {$wpdb->prefix}psmsc_agents (
239 id BIGINT NOT NULL AUTO_INCREMENT,
240 user BIGINT NULL DEFAULT 0,
241 customer BIGINT NULL DEFAULT 0,
242 role INT NOT NULL DEFAULT 0,
243 name VARCHAR(200) NOT NULL,
244 workload INT NULL DEFAULT NULL,
245 unresolved_count INT NULL DEFAULT NULL,
246 is_agentgroup INT(1) NOT NULL DEFAULT 0,
247 is_active INT(1) NOT NULL DEFAULT 0,
248 PRIMARY KEY (id)
249 ) $collate;
250 CREATE TABLE {$wpdb->prefix}psmsc_logs (
251 id BIGINT NOT NULL AUTO_INCREMENT,
252 type VARCHAR(200) NOT NULL,
253 ref_id BIGINT NOT NULL,
254 modified_by BIGINT NOT NULL,
255 body LONGTEXT NOT NULL,
256 date_created DATETIME NOT NULL,
257 PRIMARY KEY (id)
258 ) $collate;
259 CREATE TABLE {$wpdb->prefix}psmsc_working_hrs (
260 id INT NOT NULL AUTO_INCREMENT,
261 agent BIGINT NOT NULL,
262 day TINYINT NOT NULL,
263 start_time VARCHAR(20) NOT NULL,
264 end_time VARCHAR(20) NOT NULL,
265 PRIMARY KEY (id)
266 ) $collate;
267 CREATE TABLE {$wpdb->prefix}psmsc_holidays (
268 id INT NOT NULL AUTO_INCREMENT,
269 agent BIGINT NOT NULL,
270 holiday DATETIME NOT NULL,
271 is_recurring TINYINT NOT NULL,
272 PRIMARY KEY (id)
273 ) $collate;
274 CREATE TABLE {$wpdb->prefix}psmsc_wh_exceptions (
275 id INT NOT NULL AUTO_INCREMENT,
276 agent BIGINT NOT NULL,
277 title VARCHAR(200) NOT NULL,
278 exception_date DATETIME NOT NULL,
279 start_time VARCHAR(20) NOT NULL,
280 end_time VARCHAR(20) NOT NULL,
281 PRIMARY KEY (id)
282 ) $collate;
283 CREATE TABLE {$wpdb->prefix}psmsc_email_otp (
284 id INT NOT NULL AUTO_INCREMENT,
285 email VARCHAR(200) NOT NULL,
286 otp VARCHAR(10) NOT NULL,
287 date_expiry DATETIME NOT NULL,
288 data LONGTEXT NULL DEFAULT NULL,
289 PRIMARY KEY (id)
290 ) $collate;
291 CREATE TABLE {$wpdb->prefix}psmsc_email_notifications (
292 id INT NOT NULL AUTO_INCREMENT,
293 from_name VARCHAR(200) NULL DEFAULT NULL,
294 from_email VARCHAR(200) NULL DEFAULT NULL,
295 reply_to VARCHAR(200) NULL DEFAULT NULL,
296 subject TEXT NULL DEFAULT NULL,
297 body LONGTEXT NULL DEFAULT NULL,
298 to_email TEXT NULL DEFAULT NULL,
299 cc_email TEXT NULL DEFAULT NULL,
300 bcc_email TEXT NULL DEFAULT NULL,
301 attachments TEXT NULL DEFAULT NULL,
302 priority INT(1) NOT NULL DEFAULT 1,
303 attempt INT(1) DEFAULT 0,
304 PRIMARY KEY (id)
305 ) $collate;
306 CREATE TABLE {$wpdb->prefix}psmsc_scheduled_tasks (
307 id INT NOT NULL AUTO_INCREMENT,
308 class VARCHAR(200) NOT NULL,
309 method VARCHAR(200) NOT NULL,
310 args TINYTEXT NULL DEFAULT NULL,
311 is_manual INT(1) NOT NULL DEFAULT 0,
312 warning_text TINYTEXT NULL DEFAULT NULL,
313 warning_link_text TINYTEXT NULL DEFAULT NULL,
314 progressbar_text TINYTEXT NULL DEFAULT NULL,
315 pages INT NOT NULL DEFAULT 0,
316 PRIMARY KEY (id)
317 ) $collate;
318 CREATE TABLE {$wpdb->prefix}psmsc_ticket_tags (
319 id INT NOT NULL AUTO_INCREMENT,
320 name VARCHAR(200) NOT NULL,
321 description TINYTEXT NOT NULL,
322 color VARCHAR(50) NOT NULL,
323 bg_color VARCHAR(50) NOT NULL,
324 PRIMARY KEY (id)
325 ) $collate;
326 ";
327
328 dbDelta( $tables );
329 }
330
331 /**
332 * First time installation
333 */
334 public static function initial_setup() {
335
336 global $wpdb;
337
338 $wpdb->query( 'SET auto_increment_increment = 1' );
339 $wpdb->query( 'SET auto_increment_offset = 1' );
340
341 // string translations.
342 $string_translations = array();
343
344 // Insert default custom fields.
345 $name = esc_attr__( 'ID', 'supportcandy' );
346 $wpdb->insert(
347 $wpdb->prefix . 'psmsc_custom_fields',
348 array(
349 'name' => $name,
350 'slug' => 'id',
351 'field' => 'ticket',
352 'type' => 'df_id',
353 'tl_width' => 50,
354 'load_order' => 1,
355 )
356 );
357 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
358
359 $name = esc_attr__( 'Customer', 'supportcandy' );
360 $extra_info = esc_attr__( 'Select customer for whom you wish to create a ticket', 'supportcandy' );
361 $wpdb->insert(
362 $wpdb->prefix . 'psmsc_custom_fields',
363 array(
364 'name' => $name,
365 'extra_info' => $extra_info,
366 'slug' => 'customer',
367 'field' => 'ticket',
368 'type' => 'df_customer',
369 'load_order' => 2,
370 )
371 );
372 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
373 $string_translations[ 'wpsc-cf-exi-' . $wpdb->insert_id ] = $extra_info;
374
375 $name = esc_attr__( 'Name', 'supportcandy' );
376 $extra_info = esc_attr__( 'Please insert your name', 'supportcandy' );
377 $wpdb->insert(
378 $wpdb->prefix . 'psmsc_custom_fields',
379 array(
380 'name' => $name,
381 'extra_info' => $extra_info,
382 'slug' => 'name',
383 'field' => 'customer',
384 'type' => 'df_customer_name',
385 'tl_width' => 150,
386 'load_order' => 3,
387 'is_personal_info' => 1,
388 )
389 );
390 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
391 $string_translations[ 'wpsc-cf-exi-' . $wpdb->insert_id ] = $extra_info;
392
393 $name = esc_attr__( 'Email Address', 'supportcandy' );
394 $extra_info = esc_attr__( 'Please insert your email address', 'supportcandy' );
395 $wpdb->insert(
396 $wpdb->prefix . 'psmsc_custom_fields',
397 array(
398 'name' => $name,
399 'extra_info' => $extra_info,
400 'slug' => 'email',
401 'field' => 'customer',
402 'type' => 'df_customer_email',
403 'tl_width' => 150,
404 'load_order' => 4,
405 'is_personal_info' => 1,
406 )
407 );
408 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
409 $string_translations[ 'wpsc-cf-exi-' . $wpdb->insert_id ] = $extra_info;
410
411 $name = esc_attr__( 'Subject', 'supportcandy' );
412 $extra_info = esc_attr__( 'Short description of the ticket', 'supportcandy' );
413 $wpdb->insert(
414 $wpdb->prefix . 'psmsc_custom_fields',
415 array(
416 'name' => $name,
417 'extra_info' => $extra_info,
418 'slug' => 'subject',
419 'field' => 'ticket',
420 'type' => 'df_subject',
421 'tl_width' => 200,
422 'default_value' => 'Not Applicable',
423 'load_order' => 5,
424 )
425 );
426 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
427 $string_translations[ 'wpsc-cf-exi-' . $wpdb->insert_id ] = $extra_info;
428
429 $name = esc_attr__( 'Description', 'supportcandy' );
430 $extra_info = esc_attr__( 'Detailed description of the ticket', 'supportcandy' );
431 $wpdb->insert(
432 $wpdb->prefix . 'psmsc_custom_fields',
433 array(
434 'name' => $name,
435 'extra_info' => $extra_info,
436 'slug' => 'description',
437 'field' => 'ticket',
438 'type' => 'df_description',
439 'default_value' => 'Not Applicable',
440 'load_order' => 6,
441 )
442 );
443 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
444 $string_translations[ 'wpsc-cf-exi-' . $wpdb->insert_id ] = $extra_info;
445
446 $name = esc_attr__( 'Status', 'supportcandy' );
447 $extra_info = esc_attr__( 'Please select status', 'supportcandy' );
448 $wpdb->insert(
449 $wpdb->prefix . 'psmsc_custom_fields',
450 array(
451 'name' => $name,
452 'extra_info' => $extra_info,
453 'slug' => 'status',
454 'field' => 'ticket',
455 'type' => 'df_status',
456 'tl_width' => 100,
457 'default_value' => 1,
458 'load_order' => 7,
459 )
460 );
461 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
462 $string_translations[ 'wpsc-cf-exi-' . $wpdb->insert_id ] = $extra_info;
463
464 $name = esc_attr__( 'Priority', 'supportcandy' );
465 $extra_info = esc_attr__( 'Please select priority', 'supportcandy' );
466 $wpdb->insert(
467 $wpdb->prefix . 'psmsc_custom_fields',
468 array(
469 'name' => $name,
470 'extra_info' => $extra_info,
471 'slug' => 'priority',
472 'field' => 'ticket',
473 'type' => 'df_priority',
474 'tl_width' => 100,
475 'default_value' => 1,
476 'load_order' => 8,
477 )
478 );
479 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
480 $string_translations[ 'wpsc-cf-exi-' . $wpdb->insert_id ] = $extra_info;
481
482 $name = esc_attr__( 'Category', 'supportcandy' );
483 $extra_info = esc_attr__( 'Please select category', 'supportcandy' );
484 $wpdb->insert(
485 $wpdb->prefix . 'psmsc_custom_fields',
486 array(
487 'name' => $name,
488 'extra_info' => $extra_info,
489 'slug' => 'category',
490 'field' => 'ticket',
491 'type' => 'df_category',
492 'tl_width' => 100,
493 'default_value' => 1,
494 'load_order' => 9,
495 )
496 );
497 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
498 $string_translations[ 'wpsc-cf-exi-' . $wpdb->insert_id ] = $extra_info;
499
500 $name = esc_attr__( 'Assignee', 'supportcandy' );
501 $extra_info = esc_attr__( 'Please select an agent', 'supportcandy' );
502 $wpdb->insert(
503 $wpdb->prefix . 'psmsc_custom_fields',
504 array(
505 'name' => $name,
506 'extra_info' => $extra_info,
507 'slug' => 'assigned_agent',
508 'field' => 'ticket',
509 'type' => 'df_assigned_agent',
510 'tl_width' => 150,
511 'load_order' => 10,
512 )
513 );
514 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
515 $string_translations[ 'wpsc-cf-exi-' . $wpdb->insert_id ] = $extra_info;
516
517 $name = esc_attr__( 'Date Created', 'supportcandy' );
518 $wpdb->insert(
519 $wpdb->prefix . 'psmsc_custom_fields',
520 array(
521 'name' => $name,
522 'slug' => 'date_created',
523 'field' => 'ticket',
524 'type' => 'df_date_created',
525 'date_display_as' => 'date',
526 'tl_width' => 165,
527 'load_order' => 11,
528 )
529 );
530 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
531
532 $name = esc_attr__( 'Date Updated', 'supportcandy' );
533 $wpdb->insert(
534 $wpdb->prefix . 'psmsc_custom_fields',
535 array(
536 'name' => $name,
537 'slug' => 'date_updated',
538 'field' => 'ticket',
539 'type' => 'df_date_updated',
540 'date_display_as' => 'diff',
541 'tl_width' => 165,
542 'load_order' => 12,
543 )
544 );
545 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
546
547 $name = esc_attr__( 'Agent Created', 'supportcandy' );
548 $wpdb->insert(
549 $wpdb->prefix . 'psmsc_custom_fields',
550 array(
551 'name' => $name,
552 'slug' => 'agent_created',
553 'field' => 'ticket',
554 'type' => 'df_agent_created',
555 'tl_width' => 100,
556 'load_order' => 13,
557 )
558 );
559 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
560
561 $name = esc_attr__( 'IP Address', 'supportcandy' );
562 $wpdb->insert(
563 $wpdb->prefix . 'psmsc_custom_fields',
564 array(
565 'name' => $name,
566 'slug' => 'ip_address',
567 'field' => 'ticket',
568 'type' => 'df_ip_address',
569 'tl_width' => 100,
570 'load_order' => 14,
571 'is_personal_info' => 1,
572 )
573 );
574 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
575
576 $name = esc_attr__( 'Source', 'supportcandy' );
577 $wpdb->insert(
578 $wpdb->prefix . 'psmsc_custom_fields',
579 array(
580 'name' => $name,
581 'slug' => 'source',
582 'field' => 'ticket',
583 'type' => 'df_source',
584 'tl_width' => 100,
585 'load_order' => 15,
586 )
587 );
588 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
589
590 $name = esc_attr__( 'Browser', 'supportcandy' );
591 $wpdb->insert(
592 $wpdb->prefix . 'psmsc_custom_fields',
593 array(
594 'name' => $name,
595 'slug' => 'browser',
596 'field' => 'ticket',
597 'type' => 'df_browser',
598 'tl_width' => 100,
599 'load_order' => 16,
600 )
601 );
602 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
603
604 $name = esc_attr__( 'Operating System', 'supportcandy' );
605 $wpdb->insert(
606 $wpdb->prefix . 'psmsc_custom_fields',
607 array(
608 'name' => $name,
609 'slug' => 'os',
610 'field' => 'ticket',
611 'type' => 'df_os',
612 'tl_width' => 100,
613 'load_order' => 17,
614 )
615 );
616 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
617
618 $name = esc_attr__( 'Additional Recipients', 'supportcandy' );
619 $extra_info = esc_attr__( 'Please insert email addresses (one per line)', 'supportcandy' );
620 $wpdb->insert(
621 $wpdb->prefix . 'psmsc_custom_fields',
622 array(
623 'name' => $name,
624 'extra_info' => $extra_info,
625 'slug' => 'add_recipients',
626 'field' => 'ticket',
627 'type' => 'df_add_recipients',
628 'is_personal_info' => 1,
629 'load_order' => 18,
630 )
631 );
632 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
633 $string_translations[ 'wpsc-cf-exi-' . $wpdb->insert_id ] = $extra_info;
634
635 $name = esc_attr__( 'Previous Assignee', 'supportcandy' );
636 $wpdb->insert(
637 $wpdb->prefix . 'psmsc_custom_fields',
638 array(
639 'name' => $name,
640 'slug' => 'prev_assignee',
641 'field' => 'ticket',
642 'type' => 'df_prev_assignee',
643 'tl_width' => 100,
644 'is_personal_info' => 0,
645 'load_order' => 19,
646 )
647 );
648 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
649
650 $name = esc_attr__( 'Date Closed', 'supportcandy' );
651 $wpdb->insert(
652 $wpdb->prefix . 'psmsc_custom_fields',
653 array(
654 'name' => $name,
655 'slug' => 'date_closed',
656 'field' => 'ticket',
657 'type' => 'df_date_closed',
658 'date_display_as' => 'date',
659 'is_personal_info' => 0,
660 'tl_width' => 165,
661 'load_order' => 20,
662 )
663 );
664 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
665
666 $name = esc_attr__( 'User Type', 'supportcandy' );
667 $wpdb->insert(
668 $wpdb->prefix . 'psmsc_custom_fields',
669 array(
670 'name' => $name,
671 'slug' => 'user_type',
672 'field' => 'ticket',
673 'type' => 'df_user_type',
674 'tl_width' => 100,
675 'is_personal_info' => 0,
676 'load_order' => 21,
677 )
678 );
679 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
680
681 $name = esc_attr__( 'Last Reply On', 'supportcandy' );
682 $wpdb->insert(
683 $wpdb->prefix . 'psmsc_custom_fields',
684 array(
685 'name' => $name,
686 'slug' => 'last_reply_on',
687 'field' => 'ticket',
688 'type' => 'df_last_reply_on',
689 'date_display_as' => 'date',
690 'is_personal_info' => 0,
691 'tl_width' => 165,
692 'load_order' => 22,
693 )
694 );
695 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
696
697 $name = esc_attr__( 'Last Reply By', 'supportcandy' );
698 $wpdb->insert(
699 $wpdb->prefix . 'psmsc_custom_fields',
700 array(
701 'name' => $name,
702 'slug' => 'last_reply_by',
703 'field' => 'ticket',
704 'type' => 'df_last_reply_by',
705 'is_personal_info' => 0,
706 'tl_width' => 100,
707 'load_order' => 23,
708 )
709 );
710 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
711
712 $name = esc_attr__( 'Tags', 'supportcandy' );
713 $wpdb->insert(
714 $wpdb->prefix . 'psmsc_custom_fields',
715 array(
716 'name' => $name,
717 'slug' => 'tags',
718 'field' => 'ticket',
719 'type' => 'df_tags',
720 'is_personal_info' => 0,
721 'tl_width' => 100,
722 'load_order' => 24,
723 )
724 );
725 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
726
727 $name = esc_attr__( 'Last Reply Source', 'supportcandy' );
728 $wpdb->insert(
729 $wpdb->prefix . 'psmsc_custom_fields',
730 array(
731 'name' => $name,
732 'slug' => 'last_reply_source',
733 'field' => 'ticket',
734 'type' => 'df_last_reply_source',
735 'is_personal_info' => 0,
736 'tl_width' => 100,
737 'load_order' => 26,
738 )
739 );
740 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
741
742 // Insert default category.
743 $name = esc_attr__( 'General', 'supportcandy' );
744 $wpdb->insert(
745 $wpdb->prefix . 'psmsc_categories',
746 array(
747 'name' => $name,
748 'load_order' => 1,
749 )
750 );
751 $string_translations[ 'wpsc-category-' . $wpdb->insert_id ] = $name;
752
753 // Insert default statuses.
754 $name = esc_attr__( 'Open', 'supportcandy' );
755 $wpdb->insert(
756 $wpdb->prefix . 'psmsc_statuses',
757 array(
758 'name' => $name,
759 'color' => '#ec1010',
760 'bg_color' => '#ffe7e1',
761 'load_order' => 1,
762 )
763 );
764 $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
765
766 $name = esc_attr__( 'Awaiting customer reply', 'supportcandy' );
767 $wpdb->insert(
768 $wpdb->prefix . 'psmsc_statuses',
769 array(
770 'name' => $name,
771 'color' => '#8222E6',
772 'bg_color' => '#E9D3FF',
773 'load_order' => 2,
774 )
775 );
776 $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
777
778 $name = esc_attr__( 'Awaiting agent reply', 'supportcandy' );
779 $wpdb->insert(
780 $wpdb->prefix . 'psmsc_statuses',
781 array(
782 'name' => $name,
783 'color' => '#EB961C',
784 'bg_color' => '#FFEBCE',
785 'load_order' => 3,
786 )
787 );
788 $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
789
790 $name = esc_attr__( 'Closed', 'supportcandy' );
791 $wpdb->insert(
792 $wpdb->prefix . 'psmsc_statuses',
793 array(
794 'name' => $name,
795 'color' => '#22940d',
796 'bg_color' => '#c1ffcf',
797 'load_order' => 4,
798 )
799 );
800 $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
801
802 // Insert default priorities.
803 $name = esc_attr__( 'Low', 'supportcandy' );
804 $wpdb->insert(
805 $wpdb->prefix . 'psmsc_priorities',
806 array(
807 'name' => $name,
808 'color' => '#22940d',
809 'bg_color' => '#c1ffcf',
810 'load_order' => 1,
811 )
812 );
813 $string_translations[ 'wpsc-priority-' . $wpdb->insert_id ] = $name;
814
815 $name = esc_attr__( 'Medium', 'supportcandy' );
816 $wpdb->insert(
817 $wpdb->prefix . 'psmsc_priorities',
818 array(
819 'name' => $name,
820 'color' => '#EB961C',
821 'bg_color' => '#FFEBCE',
822 'load_order' => 2,
823 )
824 );
825 $string_translations[ 'wpsc-priority-' . $wpdb->insert_id ] = $name;
826
827 $name = esc_attr__( 'High', 'supportcandy' );
828 $wpdb->insert(
829 $wpdb->prefix . 'psmsc_priorities',
830 array(
831 'name' => $name,
832 'color' => '#ec1010',
833 'bg_color' => '#ffe7e1',
834 'load_order' => 3,
835 )
836 );
837 $string_translations[ 'wpsc-priority-' . $wpdb->insert_id ] = $name;
838
839 // company working hrs.
840 for ( $i = 1; $i <= 7; $i++ ) {
841 $wpdb->insert(
842 $wpdb->prefix . 'psmsc_working_hrs',
843 array(
844 'agent' => 0,
845 'day' => $i,
846 'start_time' => '00:00:00',
847 'end_time' => '23:59:59',
848 )
849 );
850 }
851
852 // Agent roles.
853 update_option(
854 'wpsc-agent-roles',
855 array(
856 1 => array(
857 'label' => 'Administrator',
858 'caps' => array(
859
860 'view-unassigned' => true, // View ticket.
861 'view-assigned-me' => true,
862 'view-assigned-others' => true,
863
864 'reply-unassigned' => true, // Reply ticket.
865 'reply-assigned-me' => true,
866 'reply-assigned-others' => true,
867
868 'pn-unassigned' => true, // Private notes.
869 'pn-assigned-me' => true,
870 'pn-assigned-others' => true,
871
872 'aa-unassigned' => true, // Assignee.
873 'aa-assigned-me' => true,
874 'aa-assigned-others' => true,
875
876 'cs-unassigned' => true, // Change status.
877 'cs-assigned-me' => true,
878 'cs-assigned-others' => true,
879
880 'ctf-unassigned' => true, // Change ticket fields.
881 'ctf-assigned-me' => true,
882 'ctf-assigned-others' => true,
883
884 'caof-unassigned' => true, // Change agent only fields.
885 'caof-assigned-me' => true,
886 'caof-assigned-others' => true,
887
888 'crb-unassigned' => true, // Change raised by.
889 'crb-assigned-me' => true,
890 'crb-assigned-others' => true,
891
892 'eth-unassigned' => true, // Edit thread.
893 'eth-assigned-me' => true,
894 'eth-assigned-others' => true,
895
896 'dth-unassigned' => true, // Delete thread.
897 'dth-assigned-me' => true,
898 'dth-assigned-others' => true,
899
900 'vl-unassigned' => true, // View logs.
901 'vl-assigned-me' => true,
902 'vl-assigned-others' => true,
903
904 'dtt-unassigned' => true, // Delete ticket.
905 'dtt-assigned-me' => true,
906 'dtt-assigned-others' => true,
907
908 'dt-unassigned' => true, // Duplicate ticket.
909 'dt-assigned-me' => true,
910 'dt-assigned-others' => true,
911
912 'ar-unassigned' => true, // Additional recipients.
913 'ar-assigned-me' => true,
914 'ar-assigned-others' => true,
915
916 'backend-access' => true, // Dashboard support menu access.
917 'create-as' => true, // Create ticket on others behalf.
918 'dtt-access' => true, // Deleted ticket access.
919 'eci-access' => true, // Edit customer info.
920 'dash-access' => true, // Dashboard access.
921
922 'tt-unassigned' => true, // Ticket tags.
923 'tt-assigned-me' => true,
924 'tt-assigned-others' => true,
925 ),
926 ),
927 2 => array(
928 'label' => 'Agent',
929 'caps' => array(
930
931 'view-unassigned' => true,
932 'view-assigned-me' => true,
933 'view-assigned-others' => false,
934
935 'reply-unassigned' => true,
936 'reply-assigned-me' => true,
937 'reply-assigned-others' => false,
938
939 'pn-unassigned' => true,
940 'pn-assigned-me' => true,
941 'pn-assigned-others' => false,
942
943 'aa-unassigned' => true,
944 'aa-assigned-me' => true,
945 'aa-assigned-others' => false,
946
947 'cs-unassigned' => true,
948 'cs-assigned-me' => true,
949 'cs-assigned-others' => false,
950
951 'ctf-unassigned' => true,
952 'ctf-assigned-me' => true,
953 'ctf-assigned-others' => false,
954
955 'caof-unassigned' => true,
956 'caof-assigned-me' => true,
957 'caof-assigned-others' => false,
958
959 'crb-unassigned' => false,
960 'crb-assigned-me' => false,
961 'crb-assigned-others' => false,
962
963 'eth-unassigned' => false,
964 'eth-assigned-me' => false,
965 'eth-assigned-others' => false,
966
967 'dth-unassigned' => false,
968 'dth-assigned-me' => false,
969 'dth-assigned-others' => false,
970
971 'vl-unassigned' => true,
972 'vl-assigned-me' => true,
973 'vl-assigned-others' => true,
974
975 'dtt-unassigned' => false,
976 'dtt-assigned-me' => false,
977 'dtt-assigned-others' => false,
978
979 'dt-unassigned' => true,
980 'dt-assigned-me' => true,
981 'dt-assigned-others' => true,
982
983 'ar-unassigned' => true,
984 'ar-assigned-me' => true,
985 'ar-assigned-others' => false,
986
987 'backend-access' => true,
988 'create-as' => true,
989 'dtt-access' => false,
990 'eci-access' => false,
991 'dash-access' => true, // Dashboard access.
992
993 'tt-unassigned' => true, // Ticket tags.
994 'tt-assigned-me' => true,
995 'tt-assigned-others' => false,
996 ),
997 ),
998 )
999 );
1000
1001 // default agents.
1002 $users = get_users( array( 'role' => 'administrator' ) );
1003 foreach ( $users as $user ) {
1004 // customer record.
1005 $wpdb->insert(
1006 $wpdb->prefix . 'psmsc_customers',
1007 array(
1008 'user' => $user->ID,
1009 'name' => $user->display_name,
1010 'email' => $user->user_email,
1011 )
1012 );
1013 // agent record.
1014 $wpdb->insert(
1015 $wpdb->prefix . 'psmsc_agents',
1016 array(
1017 'user' => $user->ID,
1018 'customer' => $wpdb->insert_id,
1019 'role' => 1,
1020 'name' => $user->display_name,
1021 'is_active' => 1,
1022 )
1023 );
1024 // agent working hrs.
1025 $agent_id = $wpdb->insert_id;
1026 for ( $i = 1; $i <= 7; $i++ ) {
1027 $wpdb->insert(
1028 $wpdb->prefix . 'psmsc_working_hrs',
1029 array(
1030 'agent' => $agent_id,
1031 'day' => $i,
1032 'start_time' => '00:00:00',
1033 'end_time' => '23:59:59',
1034 )
1035 );
1036 }
1037 if ( ! is_multisite() && ! $user->has_cap( 'wpsc_agent' ) ) {
1038 $user->add_cap( 'wpsc_agent' );
1039 }
1040 }
1041
1042 // ticket form fields.
1043 update_option(
1044 'wpsc-tff',
1045 array(
1046 'name' => array(
1047 'is-required' => 1,
1048 'width' => 'half',
1049 'visibility' => '',
1050 ),
1051 'email' => array(
1052 'is-required' => 1,
1053 'width' => 'half',
1054 'visibility' => '',
1055 ),
1056 'subject' => array(
1057 'is-required' => 1,
1058 'width' => 'full',
1059 'visibility' => '',
1060 'relation' => 'AND',
1061 ),
1062 'description' => array(
1063 'is-required' => 1,
1064 'width' => 'full',
1065 'visibility' => '',
1066 'relation' => 'AND',
1067 ),
1068 'category' => array(
1069 'is-required' => 1,
1070 'width' => 'half',
1071 'visibility' => '',
1072 'relation' => 'AND',
1073 ),
1074 )
1075 );
1076
1077 // agent ticket list.
1078 update_option(
1079 'wpsc-atl-list-items',
1080 array( 'id', 'status', 'subject', 'name', 'category', 'priority', 'assigned_agent', 'date_updated' )
1081 );
1082 update_option(
1083 'wpsc-atl-filter-items',
1084 array( 'id', 'status', 'customer', 'subject', 'category', 'priority', 'assigned_agent', 'date_updated', 'date_created' )
1085 );
1086 $labels = array(
1087 'all' => esc_attr__( 'All', 'supportcandy' ),
1088 'unresolved' => esc_attr__( 'Unresolved', 'supportcandy' ),
1089 'unassigned' => esc_attr__( 'Unassigned', 'supportcandy' ),
1090 'mine' => esc_attr__( 'Mine', 'supportcandy' ),
1091 'closed' => esc_attr__( 'Closed', 'supportcandy' ),
1092 'deleted' => esc_attr__( 'Deleted', 'supportcandy' ),
1093 );
1094 foreach ( $labels as $key => $string ) {
1095 $string_translations[ 'wpsc-atl-' . $key ] = $string;
1096 }
1097 update_option(
1098 'wpsc-atl-default-filters',
1099 array(
1100 'all' => array(
1101 'label' => $labels['all'],
1102 'is_enable' => 1,
1103 ),
1104 'unresolved' => array(
1105 'label' => $labels['unresolved'],
1106 'is_enable' => 1,
1107 ),
1108 'unassigned' => array(
1109 'label' => $labels['unassigned'],
1110 'is_enable' => 1,
1111 ),
1112 'mine' => array(
1113 'label' => $labels['mine'],
1114 'is_enable' => 1,
1115 ),
1116 'closed' => array(
1117 'label' => $labels['closed'],
1118 'is_enable' => 1,
1119 ),
1120 'deleted' => array(
1121 'label' => $labels['deleted'],
1122 'is_enable' => 1,
1123 ),
1124 )
1125 );
1126
1127 // customer ticket list.
1128 update_option(
1129 'wpsc-ctl-list-items',
1130 array( 'id', 'status', 'subject', 'category', 'date_created', 'date_updated' )
1131 );
1132 update_option(
1133 'wpsc-ctl-filter-items',
1134 array( 'id', 'status', 'subject', 'category', 'date_updated', 'date_created' )
1135 );
1136 $labels = array(
1137 'all' => esc_attr__( 'All', 'supportcandy' ),
1138 'unresolved' => esc_attr__( 'Unresolved', 'supportcandy' ),
1139 'closed' => esc_attr__( 'Closed', 'supportcandy' ),
1140 );
1141 foreach ( $labels as $key => $string ) {
1142 $string_translations[ 'wpsc-ctl-' . $key ] = $string;
1143 }
1144 update_option(
1145 'wpsc-ctl-default-filters',
1146 array(
1147 'all' => array(
1148 'label' => $labels['all'],
1149 'is_enable' => 1,
1150 ),
1151 'unresolved' => array(
1152 'label' => $labels['unresolved'],
1153 'is_enable' => 1,
1154 ),
1155 'closed' => array(
1156 'label' => $labels['closed'],
1157 'is_enable' => 1,
1158 ),
1159 )
1160 );
1161
1162 // ticket list more settings.
1163 update_option(
1164 'wpsc-tl-ms-agent-view',
1165 array(
1166 'default-sort-by' => 'date_updated',
1167 'default-sort-order' => 'DESC',
1168 'number-of-tickets' => 20,
1169 'unresolved-ticket-statuses' => array( 1, 2, 3 ),
1170 'default-filter' => 'all',
1171 'ticket-reply-redirect' => 'no-redirect',
1172 )
1173 );
1174 update_option(
1175 'wpsc-tl-ms-customer-view',
1176 array(
1177 'default-sort-by' => 'date_updated',
1178 'default-sort-order' => 'DESC',
1179 'number-of-tickets' => 20,
1180 'unresolved-ticket-statuses' => array( 1, 2, 3 ),
1181 'default-filter' => 'all',
1182 'ticket-reply-redirect' => 'no-redirect',
1183 )
1184 );
1185 update_option(
1186 'wpsc-tl-ms-advanced',
1187 array(
1188 'closed-ticket-statuses' => array( 4 ),
1189 'auto-refresh-list-status' => 0,
1190 )
1191 );
1192
1193 // email notifications.
1194 update_option(
1195 'wpsc-en-general',
1196 array(
1197 'from-name' => '',
1198 'from-email' => '',
1199 'reply-to' => '',
1200 'cron-email-count' => 5,
1201 'blocked-emails' => array(),
1202 'attachments-in-notification' => 'actual-files',
1203 )
1204 );
1205 $translations = array(
1206 1 => array(
1207 'subject' => 'Your ticket has been created successfully!',
1208 'body' => '<p>Thanks for reaching out, we\'ve received your request!</p>',
1209 ),
1210 2 => array(
1211 'body' => '<p>You have received a new ticket!</p><p><strong>{{customer}}</strong><em>reported</em></p><p>{{description}}</p><p>{{ticket_url}}</p>',
1212 ),
1213 3 => array(
1214 'body' => '<p><strong>{{last_reply_user_name}}</strong> <em>replied</em></p><p>{{last_reply}}</p><p>{{ticket_url}}</p><p>{{ticket_history}}</p>',
1215 ),
1216 4 => array(
1217 'subject' => 'Your ticket has been closed!',
1218 'body' => '<p>Dear {{customer}},</p><p>Your ticket #{{id}} has been closed.</p>',
1219 ),
1220 );
1221 foreach ( $translations as $index => $translation ) {
1222 if ( isset( $translation['subject'] ) ) {
1223 $string_translations[ 'wpsc-en-tn-subject-' . $index ] = $translation['subject'];
1224 }
1225 $string_translations[ 'wpsc-en-tn-body-' . $index ] = $translation['body'];
1226 }
1227 update_option(
1228 'wpsc-email-templates',
1229 array(
1230 '1' => array(
1231 'title' => 'New ticket customer confirmation',
1232 'event' => 'create-ticket',
1233 'is_enable' => 1,
1234 'subject' => $translations[1]['subject'],
1235 'body' => array(
1236 'text' => $translations[1]['body'],
1237 'editor' => 'html',
1238 ),
1239 'to' => array(
1240 'general-recipients' => array( 'customer' ),
1241 'agent-roles' => array(),
1242 'custom' => array(),
1243 ),
1244 'cc' => array(
1245 'general-recipients' => array(),
1246 'agent-roles' => array(),
1247 'custom' => array(),
1248 ),
1249 'bcc' => array(
1250 'general-recipients' => array(),
1251 'agent-roles' => array(),
1252 'custom' => array(),
1253 ),
1254 'conditions' => '',
1255 ),
1256 '2' => array(
1257 'title' => 'New ticket staff notification',
1258 'event' => 'create-ticket',
1259 'is_enable' => 1,
1260 'subject' => '{{subject}}',
1261 'body' => array(
1262 'text' => $translations[2]['body'],
1263 'editor' => 'html',
1264 ),
1265 'to' => array(
1266 'general-recipients' => array( 'assignee' ),
1267 'agent-roles' => array( 1 ),
1268 'custom' => array(),
1269 ),
1270 'cc' => array(
1271 'general-recipients' => array(),
1272 'agent-roles' => array(),
1273 'custom' => array(),
1274 ),
1275 'bcc' => array(
1276 'general-recipients' => array(),
1277 'agent-roles' => array(),
1278 'custom' => array(),
1279 ),
1280 'conditions' => '',
1281 ),
1282 '3' => array(
1283 'title' => 'Reply ticket notification',
1284 'event' => 'reply-ticket',
1285 'is_enable' => 1,
1286 'subject' => '{{subject}}',
1287 'body' => array(
1288 'text' => $translations[3]['body'],
1289 'editor' => 'html',
1290 ),
1291 'to' => array(
1292 'general-recipients' => array( 'customer', 'assignee' ),
1293 'agent-roles' => array( 1 ),
1294 'custom' => array(),
1295 ),
1296 'cc' => array(
1297 'general-recipients' => array(),
1298 'agent-roles' => array(),
1299 'custom' => array(),
1300 ),
1301 'bcc' => array(
1302 'general-recipients' => array(),
1303 'agent-roles' => array(),
1304 'custom' => array(),
1305 ),
1306 'conditions' => '',
1307 ),
1308 '4' => array(
1309 'title' => 'Close ticket customer notification',
1310 'event' => 'change-ticket-status',
1311 'is_enable' => 1,
1312 'subject' => $translations[4]['subject'],
1313 'body' => array(
1314 'text' => $translations[4]['body'],
1315 'editor' => 'html',
1316 ),
1317 'to' => array(
1318 'general-recipients' => array( 'customer' ),
1319 'agent-roles' => array(),
1320 'custom' => array(),
1321 ),
1322 'cc' => array(
1323 'general-recipients' => array(),
1324 'agent-roles' => array(),
1325 'custom' => array(),
1326 ),
1327 'bcc' => array(
1328 'general-recipients' => array(),
1329 'agent-roles' => array(),
1330 'custom' => array(),
1331 ),
1332 'conditions' => '[[{"slug":"status","operator":"=","operand_val_1":"4"}]]',
1333 ),
1334 )
1335 );
1336
1337 // user registration otp.
1338 $subject = 'User registration OTP - {{otp}}';
1339 $body = '<p>Hello {{firstname}},</p><p>Below is your one time password for user registration:</p><p><strong>{{otp}}</strong></p>';
1340 update_option(
1341 'wpsc-en-user-reg',
1342 array(
1343 'subject' => $subject,
1344 'body' => $body,
1345 'editor' => 'html',
1346 )
1347 );
1348 $string_translations['wpsc-user-otp-subject'] = $subject;
1349 $string_translations['wpsc-user-otp-body'] = $body;
1350
1351 // guest login otp.
1352 $subject = 'Guest Login - {{otp}}';
1353 $body = '<p>Hello {{name}},</p><p>Below is your one time password for guest login:</p><p><strong>{{otp}}</strong></p>';
1354 update_option(
1355 'wpsc-en-guest-login',
1356 array(
1357 'subject' => $subject,
1358 'body' => $body,
1359 'editor' => 'html',
1360 )
1361 );
1362 $string_translations['wpsc-guest-otp-subject'] = $subject;
1363 $string_translations['wpsc-guest-otp-body'] = $body;
1364
1365 // General settings.
1366 update_option(
1367 'wpsc-gs-general',
1368 array(
1369 'ticket-status-after-customer-reply' => 3,
1370 'ticket-status-after-agent-reply' => 2,
1371 'close-ticket-status' => 4,
1372 'reply-form-position' => 'top',
1373 'default-date-format' => 'Y-m-d H:i:s',
1374 'ticket-alice' => 'Ticket #',
1375 'allow-close-ticket' => array( 'customer', 1, 2 ),
1376 'allow-ar-thread-email' => array( 1, 2 ),
1377 'allow-create-ticket' => array( 'registered-user', 1, 2 ),
1378 'allowed-search-fields' => array( 'id', 'customer', 'subject', 'threads' ),
1379 )
1380 );
1381
1382 update_option(
1383 'wpsc-gs-page-settings',
1384 array(
1385 'support-page' => 0,
1386 'open-ticket-page' => 0,
1387 'ticket-url-page' => 'support-page',
1388 'new-ticket-page' => 'default',
1389 'new-ticket-url' => '',
1390 'user-login' => 'default',
1391 'custom-login-url' => '',
1392 'user-registration' => 'disable',
1393 'custom-registration-url' => '',
1394 'otp-login' => 1,
1395 'load-scripts' => 'all-pages',
1396 'load-script-pages' => array(),
1397 )
1398 );
1399
1400 // File attachment settings.
1401 require_once WPSC_ABSPATH . 'includes/class-wpsc-mime-types.php';
1402
1403 $extensions = 'jpg, jpeg, png, gif, pdf, doc, docx, ppt, pptx, pps, ppsx, odt, xls, xlsx, mp3, m4a, ogg, wav, mp4, m4v, mov, wmv, avi, mpg, ogv, 3gp, 3g2, zip, eml';
1404 $exts = $extensions ? explode( ',', $extensions ) : array();
1405 $exts = array_map( 'trim', $exts );
1406 $mimes = array();
1407 foreach ( $exts as $key => $value ) {
1408 $mime = WPSC_MIME_TYPES::get_mime_type( $value );
1409 if ( $mime ) {
1410 $mimes[ $value ] = $mime;
1411 }
1412 }
1413
1414 update_option(
1415 'wpsc-gs-file-attachments',
1416 array(
1417 'attachments-max-filesize' => 20,
1418 'allowed-file-extensions' => $extensions,
1419 'allowed-file-ext-mimes' => $mimes,
1420 'mime-exceptions' => array(),
1421 'image-download-behaviour' => 'open-browser',
1422 )
1423 );
1424
1425 $translation = '<p>Thanks for reaching out, we\'ve received your request!</p><p>{{ticket_url}}</p>';
1426 $string_translations['wpsc-thankyou-html'] = $translation;
1427 $string_translations['wpsc-thankyou-html-agent'] = $translation;
1428 update_option(
1429 'wpsc-gs-thankyou-page-settings',
1430 array(
1431 'action-agent' => 'text',
1432 'action-customer' => 'text',
1433 'html-agent' => $translation,
1434 'html-customer' => $translation,
1435 'page-url-agent' => '',
1436 'page-url-customer' => '',
1437 'editor-agent' => 'html',
1438 'editor-customer' => 'html',
1439 )
1440 );
1441
1442 // misc settings.
1443 $translation = '<p>I understand my personal information like Name, Email address, IP address, etc. will be stored in database.</p>';
1444 $string_translations['wpsc-gdpr'] = $translation;
1445 $string_translations['wpsc-gdpr-reg-user'] = $translation;
1446 update_option(
1447 'wpsc-gdpr-settings',
1448 array(
1449 'allow-gdpr' => 1,
1450 'gdpr-text' => $translation,
1451 'personal-data-retention-time' => 0,
1452 'personal-data-retention-unit' => 'days',
1453 'editor' => 'html',
1454 'allow-gdpr-reg-user' => 1,
1455 'gdpr-text-reg-user' => $translation,
1456 'editor-reg-user' => 'html',
1457 'ip-address-collection' => 1,
1458 )
1459 );
1460
1461 update_option(
1462 'wpsc-recaptcha-settings',
1463 array(
1464 'allow-recaptcha' => 0,
1465 'recaptcha-version' => 3,
1466 'recaptcha-site-key' => '',
1467 'recaptcha-secret-key' => '',
1468 )
1469 );
1470
1471 update_option(
1472 'wpsc-ms-advanced-settings',
1473 array(
1474 'public-mode' => 0,
1475 'public-mode-reply' => 0,
1476 'reply-confirmation' => 1,
1477 'note-confirmation' => 0,
1478 'thread-date-display-as' => 'diff',
1479 'thread-date-format' => 'F d, Y h:i A',
1480 'do-not-notify-owner' => 1,
1481 'do-not-notify-owner-status' => 1,
1482 'ticket-id-format' => 'sequential',
1483 'starting-ticket-id' => 1,
1484 'random-id-length' => 8,
1485 'ticket-history-macro-threads' => 5,
1486 'register-user-if-not-exist' => 0,
1487 'auto-delete-tickets-time' => 0,
1488 'auto-delete-tickets-unit' => 'days',
1489 'permanent-delete-tickets-time' => 0,
1490 'permanent-delete-tickets-unit' => 'days',
1491 'allow-bcc' => 0,
1492 'allow-cc' => 0,
1493 'view-more' => 1,
1494 'allow-reply-to-close-ticket' => array( 'customer', 'agent' ),
1495 'raised-by-user' => 'customer',
1496 'allow-my-profile' => 1,
1497 'allow-agent-profile' => 1,
1498 'ticket-url-auth' => 0,
1499 'rest-api' => 1,
1500 'agent-collision' => 1,
1501 'self-assign' => 1,
1502 'reply-close' => 0,
1503 )
1504 );
1505
1506 $translation = '<p>I agree to the terms and conditions</p>';
1507 $string_translations['wpsc-term-and-conditions'] = $translation;
1508 $string_translations['wpsc-term-and-conditions-reg-user'] = $translation;
1509 update_option(
1510 'wpsc-term-and-conditions',
1511 array(
1512 'allow-term-and-conditions' => 1,
1513 'tandc-text' => $translation,
1514 'editor' => 'html',
1515 'allow-term-and-conditions-reg-user' => 1,
1516 'tandc-text-reg-user' => $translation,
1517 'editor-reg-user' => 'html',
1518 )
1519 );
1520
1521 // ticket widgets.
1522 $labels = array(
1523 'change-status' => esc_attr__( 'Ticket status', 'supportcandy' ),
1524 'raised-by' => esc_attr__( 'Customer', 'supportcandy' ),
1525 'ticket-info' => esc_attr__( 'Ticket info', 'supportcandy' ),
1526 'assignee' => esc_attr__( 'Assignee', 'supportcandy' ),
1527 'ticket-fields' => esc_attr__( 'Ticket fields', 'supportcandy' ),
1528 'agentonly-fields' => esc_attr__( 'Agent only fields', 'supportcandy' ),
1529 'additional-recipients' => esc_attr__( 'Additional recipients', 'supportcandy' ),
1530 'biographical-info' => esc_attr__( 'Biographical Info', 'supportcandy' ),
1531 'tags' => esc_attr__( 'Tags', 'supportcandy' ),
1532 );
1533 foreach ( $labels as $key => $string ) {
1534 $string_translations[ 'wpsc-twt-' . $key ] = $string;
1535 }
1536 update_option(
1537 'wpsc-ticket-widget',
1538 array(
1539 'change-status' => array(
1540 'title' => $labels['change-status'],
1541 'is_enable' => 1,
1542 'allow-customer' => 1,
1543 'allowed-agent-roles' => array( 1, 2 ),
1544 'show-priority-to-customer' => 0,
1545 'callback' => 'wpsc_get_tw_ticket_status()',
1546 'class' => 'WPSC_ITW_Change_Status',
1547 ),
1548 'raised-by' => array(
1549 'title' => $labels['raised-by'],
1550 'is_enable' => 1,
1551 'allow-customer' => 0,
1552 'allowed-agent-roles' => array( 1, 2 ),
1553 'callback' => 'wpsc_get_tw_raised_by()',
1554 'class' => 'WPSC_ITW_Raisedby',
1555 ),
1556 'ticket-info' => array(
1557 'title' => $labels['ticket-info'],
1558 'is_enable' => 1,
1559 'allow-customer' => 0,
1560 'allowed-agent-roles' => array( 1, 2 ),
1561 'callback' => 'wpsc_get_tw_ticket_info()',
1562 'class' => 'WPSC_ITW_Ticket_Info',
1563 ),
1564 'assignee' => array(
1565 'title' => $labels['assignee'],
1566 'is_enable' => 1,
1567 'allow-customer' => 0,
1568 'allowed-agent-roles' => array( 1, 2 ),
1569 'callback' => 'wpsc_get_tw_agents()',
1570 'class' => 'WPSC_ITW_Assigned_Agents',
1571 ),
1572 'ticket-fields' => array(
1573 'title' => $labels['ticket-fields'],
1574 'is_enable' => 1,
1575 'allow-customer' => 1,
1576 'allowed-agent-roles' => array( 1, 2 ),
1577 'callback' => 'wpsc_get_tw_ticket_fields()',
1578 'class' => 'WPSC_ITW_Ticket_Fields',
1579 ),
1580 'agentonly-fields' => array(
1581 'title' => $labels['agentonly-fields'],
1582 'is_enable' => 1,
1583 'allow-customer' => 0,
1584 'allowed-agent-roles' => array( 1, 2 ),
1585 'callback' => 'wpsc_get_tw_agentonly_fields()',
1586 'class' => 'WPSC_ITW_Agentonly_Fields',
1587 ),
1588 'additional-recipients' => array(
1589 'title' => $labels['additional-recipients'],
1590 'is_enable' => 1,
1591 'allow-customer' => 1,
1592 'allowed-agent-roles' => array( 1, 2 ),
1593 'callback' => 'wpsc_get_tw_additional_recipients()',
1594 'class' => 'WPSC_ITW_Additional_Recipients',
1595 ),
1596 'biographical-info' => array(
1597 'title' => $labels['biographical-info'],
1598 'is_enable' => 0,
1599 'allow-customer' => 1,
1600 'allowed-agent-roles' => array( 1, 2 ),
1601 'callback' => 'wpsc_get_tw_biographical_info()',
1602 'class' => 'WPSC_ITW_Biographical_Info',
1603 ),
1604 'tags' => array(
1605 'title' => $labels['tags'],
1606 'is_enable' => 1,
1607 'allow-customer' => 0,
1608 'allowed-agent-roles' => array( 1, 2 ),
1609 'callback' => 'wpsc_get_tw_ticket_tags()',
1610 'class' => 'WPSC_ITW_Ticket_Tags',
1611 ),
1612 )
1613 );
1614
1615 // Rich text editor.
1616 $notice = sprintf(
1617 /* translators: %1$s: attachment max file size, %2$s: allowed file extenstions. */
1618 esc_attr__( 'You can upload files maximum size %1$s mb of types %2$s.', 'supportcandy' ),
1619 20,
1620 'jpg, jpeg, png, gif, pdf, doc, docx, ppt, pptx, pps, ppsx, odt, xls, xlsx, mp3, m4a, ogg, wav, mp4, m4v, mov, wmv, avi, mpg, ogv, 3gp, 3g2, zip, eml'
1621 );
1622 update_option(
1623 'wpsc-te-agent',
1624 array(
1625 'enable' => 1,
1626 'allow-attachments' => 1,
1627 'toolbar' => array( 'bold', 'italic', 'underline', 'blockquote', 'alignleft aligncenter alignright', 'bullist', 'numlist', 'rtl', 'link', 'wpsc_insert_editor_img' ),
1628 'file-attachment-notice' => 0,
1629 'file-attachment-notice-text' => $notice,
1630 )
1631 );
1632 update_option(
1633 'wpsc-te-registered-user',
1634 array(
1635 'enable' => 1,
1636 'allow-attachments' => 1,
1637 'toolbar' => array( 'bold', 'italic', 'underline', 'blockquote', 'alignleft aligncenter alignright', 'bullist', 'numlist', 'rtl', 'link', 'wpsc_insert_editor_img' ),
1638 'file-attachment-notice' => 0,
1639 'file-attachment-notice-text' => $notice,
1640 )
1641 );
1642 update_option(
1643 'wpsc-te-guest-user',
1644 array(
1645 'enable' => 0,
1646 'allow-attachments' => 0,
1647 'toolbar' => array( 'bold', 'italic', 'underline', 'blockquote', 'alignleft aligncenter alignright', 'bullist', 'numlist', 'rtl', 'link', 'wpsc_insert_editor_img' ),
1648 'file-attachment-notice' => 0,
1649 'file-attachment-notice-text' => $notice,
1650 )
1651 );
1652 update_option( 'wpsc-te-advanced', array( 'html-pasting' => 0 ) );
1653
1654 // working hrs settings.
1655 update_option(
1656 'wpsc-wh-settings',
1657 array(
1658 'allow-agent-modify-wh' => 0,
1659 'allow-agent-modify-leaves' => 0,
1660 )
1661 );
1662
1663 // appearence settings.
1664 update_option(
1665 'wpsc-ap-general',
1666 array(
1667 'primary-color' => '#313042',
1668 'menu-link-color' => '#fff',
1669 'main-background-color' => '#fff',
1670 'main-text-color' => '#2c3e50',
1671 'link-color' => '#2271b1',
1672 )
1673 );
1674 update_option(
1675 'wpsc-ap-individual-ticket',
1676 array(
1677 'reply-primary-color' => '#2c3e50',
1678 'reply-secondary-color' => '#777777',
1679 'reply-icon-color' => '#777777',
1680 'note-primary-color' => '#8e6600',
1681 'note-secondary-color' => '#8e8d45',
1682 'note-icon-color' => '#8e8d45',
1683 'log-text' => '#2c3e50',
1684 'widget-header-bg-color' => '#fff8e5',
1685 'widget-header-text-color' => '#ff8f2b',
1686 'widget-body-bg-color' => '#f9f9f9',
1687 'widget-body-label-color' => '#777',
1688 'widget-body-text-color' => '#2c3e50',
1689 'reply-close-bg-color' => '#fff',
1690 'reply-close-text-color' => '#707070',
1691 )
1692 );
1693 update_option(
1694 'wpsc-ap-modal',
1695 array(
1696 'header-bg-color' => '#fff8e5',
1697 'header-text-color' => '#ff8f2b',
1698 'body-bg-color' => '#fff',
1699 'body-label-color' => '#777',
1700 'body-text-color' => '#2c3e50',
1701 'footer-bg-color' => '#fff',
1702 'z-index' => 900000000,
1703 )
1704 );
1705 update_option(
1706 'wpsc-ap-agent-collision',
1707 array(
1708 'header-bg-color' => '#e6e6e6',
1709 'header-text-color' => '#2c3e50',
1710 )
1711 );
1712 update_option(
1713 'wpsc-ap-ticket-list',
1714 array(
1715 'list-header-background-color' => '#2c3e50',
1716 'list-header-text-color' => '#fff',
1717 'list-item-odd-background-color' => '#fff',
1718 'list-item-odd-text-color' => '#2c3e50',
1719 'list-item-even-background-color' => '#f2f2f2',
1720 'list-item-even-text-color' => '#2c3e50',
1721 'list-item-hover-background-color' => '#dfe4ea',
1722 'list-item-hover-text-color' => '#2c3e50',
1723 )
1724 );
1725
1726 // ticket tags general setting.
1727 update_option(
1728 'wpsc-ticket-tags-general-settings',
1729 array(
1730 'color' => '#000000',
1731 'bg-color' => '#ffc300',
1732 )
1733 );
1734
1735 // dashboard general setting.
1736 update_option(
1737 'wpsc-ap-dashboard',
1738 array(
1739 'card-body-bg-color' => '#f9f9f9',
1740 'card-body-svg-color' => '#777',
1741 'card-body-text-color' => '#2c3e50',
1742 'widget-body-bg-color' => '#f9f9f9',
1743 'widget-body-svg-color' => '#777',
1744 'widget-body-text-color' => '#2c3e50',
1745 )
1746 );
1747
1748 // upload directory.
1749 $upload_dir = wp_upload_dir();
1750 $filepath = $upload_dir['basedir'] . '/wpsc';
1751 if ( ! file_exists( $filepath ) ) {
1752 mkdir( $filepath, 0755, true );
1753 }
1754
1755 // Dashboard cards.
1756 $labels = array(
1757 'new-tickets' => esc_attr__( 'New Tickets', 'supportcandy' ),
1758 'unresolved' => esc_attr__( 'Unresolved', 'supportcandy' ),
1759 'unassigned' => esc_attr__( 'Unassigned', 'supportcandy' ),
1760 'closed' => esc_attr__( 'Closed', 'supportcandy' ),
1761 'mine' => esc_attr__( 'Mine', 'supportcandy' ),
1762 );
1763 foreach ( $labels as $key => $string ) {
1764 $string_translations[ 'wpsc-dashboard-card-' . $key ] = $string;
1765 }
1766 update_option(
1767 'wpsc-dashboard-cards',
1768 array(
1769 'new-tickets' => array(
1770 'title' => $labels['new-tickets'],
1771 'is_enable' => 1,
1772 'allowed-agent-roles' => array( 1, 2 ),
1773 'callback' => 'wpsc_dbc_new_tickets()',
1774 'class' => 'WPSC_DBC_New_Tickets',
1775 'type' => 'default',
1776 ),
1777 'unresolved' => array(
1778 'title' => $labels['unresolved'],
1779 'is_enable' => 1,
1780 'allowed-agent-roles' => array( 1, 2 ),
1781 'callback' => 'wpsc_dbc_unresolved_tickets()',
1782 'class' => 'WPSC_DBC_Unresolved_Tickets',
1783 'type' => 'default',
1784 ),
1785 'unassigned' => array(
1786 'title' => $labels['unassigned'],
1787 'is_enable' => 1,
1788 'allowed-agent-roles' => array( 1 ),
1789 'callback' => 'wpsc_dbc_unassigned_tickets()',
1790 'class' => 'WPSC_DBC_Unassigned_Tickets',
1791 'type' => 'default',
1792 ),
1793 'closed' => array(
1794 'title' => $labels['closed'],
1795 'is_enable' => 1,
1796 'allowed-agent-roles' => array( 1, 2 ),
1797 'callback' => 'wpsc_dbc_closed_tickets()',
1798 'class' => 'WPSC_DBC_Closed_Tickets',
1799 'type' => 'default',
1800 ),
1801 'mine' => array(
1802 'title' => $labels['mine'],
1803 'is_enable' => 1,
1804 'allowed-agent-roles' => array( 1, 2 ),
1805 'callback' => 'wpsc_dbc_mine_tickets()',
1806 'class' => 'WPSC_DBC_Mine_Tickets',
1807 'type' => 'default',
1808 ),
1809 )
1810 );
1811
1812 // Dashboard widget.
1813 $labels = array(
1814 'ticket-statistics' => esc_attr__( 'Ticket Statistics', 'supportcandy' ),
1815 'todays-trends' => esc_attr__( 'Todays Trends', 'supportcandy' ),
1816 'agent-list' => esc_attr__( 'Agent Workload', 'supportcandy' ),
1817 'recent-activities' => esc_attr__( 'Recent Activities', 'supportcandy' ),
1818 'recent-tickets' => esc_attr__( 'Recent Tickets', 'supportcandy' ),
1819 'category-report' => esc_attr__( 'Tickets by Category', 'supportcandy' ),
1820 'unresolved-priorities' => esc_attr__( 'Tickets by Priority', 'supportcandy' ),
1821 'unresolved-statuses' => esc_attr__( 'Tickets by Status', 'supportcandy' ),
1822 'week-trends' => esc_attr__( 'Ticket statistics by day of week', 'supportcandy' ),
1823 );
1824 foreach ( $labels as $key => $string ) {
1825 $string_translations[ 'wpsc-dashboard-widget-' . $key ] = $string;
1826 }
1827 update_option(
1828 'wpsc-dashboard-widgets',
1829 array(
1830 'ticket-statistics' => array(
1831 'title' => $labels['ticket-statistics'],
1832 'is_enable' => 1,
1833 'allowed-agent-roles' => array( 1, 2 ),
1834 'callback' => 'wpsc_dbw_ticket_statistics()',
1835 'class' => 'WPSC_DBW_Ticket_Statistics',
1836 'type' => 'default',
1837 'chart-type' => '',
1838 ),
1839 'todays-trends' => array(
1840 'title' => $labels['todays-trends'],
1841 'is_enable' => 1,
1842 'allowed-agent-roles' => array( 1, 2 ),
1843 'callback' => 'wpsc_dbw_todays_trends()',
1844 'class' => 'WPSC_DBW_Todays_Trends',
1845 'type' => 'default',
1846 'chart-type' => '',
1847 ),
1848 'agent-list' => array(
1849 'title' => $labels['agent-list'],
1850 'is_enable' => 1,
1851 'allowed-agent-roles' => array( 1 ),
1852 'callback' => 'wpsc_dbw_agent_list()',
1853 'class' => 'WPSC_DBW_Agent_List',
1854 'type' => 'default',
1855 'chart-type' => '',
1856 ),
1857 'recent-activities' => array(
1858 'title' => $labels['recent-activities'],
1859 'is_enable' => 1,
1860 'allowed-agent-roles' => array( 1, 2 ),
1861 'callback' => 'wpsc_dbw_recent_activities()',
1862 'class' => 'WPSC_DBW_Recent_Activities',
1863 'type' => 'default',
1864 'chart-type' => '',
1865 ),
1866 'recent-tickets' => array(
1867 'title' => $labels['recent-tickets'],
1868 'is_enable' => 1,
1869 'allowed-agent-roles' => array( 1, 2 ),
1870 'callback' => 'wpsc_dbw_recent_tickets()',
1871 'class' => 'WPSC_DBW_Recent_Tickets',
1872 'type' => 'default',
1873 'chart-type' => '',
1874 ),
1875 'category-report' => array(
1876 'title' => $labels['category-report'],
1877 'is_enable' => 1,
1878 'allowed-agent-roles' => array( 1, 2 ),
1879 'callback' => 'wpsc_dbw_category_reports()',
1880 'class' => 'WPSC_DBW_Category_Reports',
1881 'type' => 'default',
1882 'chart-type' => 'doughnut',
1883 ),
1884 'unresolved-priorities' => array(
1885 'title' => $labels['unresolved-priorities'],
1886 'is_enable' => 1,
1887 'allowed-agent-roles' => array( 1, 2 ),
1888 'callback' => 'wpsc_dbw_unresolved_priorities()',
1889 'class' => 'WPSC_DBW_Unresolved_Priorities',
1890 'type' => 'default',
1891 'chart-type' => 'horizontal-bar',
1892 ),
1893 'unresolved-statuses' => array(
1894 'title' => $labels['unresolved-statuses'],
1895 'is_enable' => 1,
1896 'allowed-agent-roles' => array( 1, 2 ),
1897 'callback' => 'wpsc_dbw_unresolved_statuses()',
1898 'class' => 'WPSC_DBW_Unresolved_Statuses',
1899 'type' => 'default',
1900 'chart-type' => 'vertical-bar',
1901 ),
1902 'week-trends' => array(
1903 'title' => $labels['week-trends'],
1904 'is_enable' => 1,
1905 'allowed-agent-roles' => array( 1, 2 ),
1906 'callback' => 'WPSC_dbw_week_trend_tickets()',
1907 'class' => 'WPSC_DBW_Week_Trend_Tickets',
1908 'type' => 'default',
1909 'chart-type' => 'vertical-bar',
1910 ),
1911 )
1912 );
1913
1914 // Add dashboard general settings.
1915 update_option(
1916 'wpsc-db-gs-settings',
1917 array(
1918 'default-date-range' => 'last-week',
1919 'allowed-recent-activity-logs' => array( 'report', 'reply', 'note', 'assigned_agent' ),
1920 'dash-auto-refresh' => 0,
1921 )
1922 );
1923
1924 self::attachment_security_file();
1925
1926 // Create required database indexes.
1927 self::create_indexing();
1928
1929 // update string translations.
1930 update_option( 'wpsc-string-translation', $string_translations );
1931 }
1932
1933 /**
1934 * Upgrade the version
1935 */
1936 public static function upgrade() {
1937
1938 global $wpdb;
1939 $string_translations = get_option( 'wpsc-string-translation' );
1940
1941 if ( version_compare( self::$current_version, '3.0.4', '<' ) ) {
1942
1943 $advanced = get_option( 'wpsc-ms-advanced-settings' );
1944 $advanced['allow-my-profile'] = 1;
1945 $advanced['allow-agent-profile'] = 1;
1946 update_option( 'wpsc-ms-advanced-settings', $advanced );
1947 }
1948
1949 if ( version_compare( self::$current_version, '3.0.5', '<' ) ) {
1950
1951 $advanced = get_option( 'wpsc-ms-advanced-settings' );
1952 $page_settings = get_option( 'wpsc-gs-page-settings' );
1953 if ( ! isset( $advanced['allow-my-profile'] ) ) {
1954 $advanced['allow-my-profile'] = 1;
1955 $advanced['allow-agent-profile'] = 1;
1956 }
1957 $page_settings['otp-login'] = 1;
1958 update_option( 'wpsc-gs-page-settings', $page_settings );
1959 $advanced['ticket-url-auth'] = 0;
1960 update_option( 'wpsc-ms-advanced-settings', $advanced );
1961 }
1962
1963 if ( version_compare( self::$current_version, '3.0.7', '<' ) ) {
1964
1965 $page_settings = get_option( 'wpsc-gs-page-settings' );
1966 $page_settings['load-scripts'] = 'all-pages';
1967 $page_settings['load-script-pages'] = array();
1968 update_option( 'wpsc-gs-page-settings', $page_settings );
1969 }
1970
1971 if ( version_compare( self::$current_version, '3.1.1', '<' ) ) {
1972
1973 $ap_general = get_option( 'wpsc-ap-general' );
1974 $ap_general['menu-link-color'] = '#fff';
1975 update_option( 'wpsc-ap-general', $ap_general );
1976 }
1977
1978 if ( version_compare( self::$current_version, '3.1.3', '<' ) ) {
1979
1980 $advanced = get_option( 'wpsc-ms-advanced-settings' );
1981 $advanced['rest-api'] = 1;
1982 update_option( 'wpsc-ms-advanced-settings', $advanced );
1983 }
1984
1985 if ( version_compare( self::$current_version, '3.1.4', '<' ) ) {
1986
1987 // add scheduled task for ticket data upgrade.
1988 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='update_ticket_attachment_path'" ) ) {
1989 $wpdb->insert(
1990 $wpdb->prefix . 'psmsc_scheduled_tasks',
1991 array(
1992 'class' => 'WPSC_SC_Upgrade',
1993 'method' => 'update_ticket_attachment_path',
1994 'is_manual' => 1,
1995 'warning_text' => 'SupportCandy - Database attachment paths upgrade needed.',
1996 'warning_link_text' => 'Upgrade Now',
1997 'progressbar_text' => 'Updating attachment paths...',
1998 )
1999 );
2000 }
2001
2002 self::attachment_security_file();
2003 }
2004
2005 if ( version_compare( self::$current_version, '3.1.5', '<' ) ) {
2006
2007 // scheduled task for setting conditions upgrade.
2008 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='upgrade_setting_conditions'" ) ) {
2009 $wpdb->insert(
2010 $wpdb->prefix . 'psmsc_scheduled_tasks',
2011 array(
2012 'class' => 'WPSC_SC_Upgrade',
2013 'method' => 'upgrade_setting_conditions',
2014 'is_manual' => 0,
2015 )
2016 );
2017 }
2018
2019 // scheduled task for saved filter conditions upgrade.
2020 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='upgrade_saved_filter_conditions'" ) ) {
2021 $wpdb->insert(
2022 $wpdb->prefix . 'psmsc_scheduled_tasks',
2023 array(
2024 'class' => 'WPSC_SC_Upgrade',
2025 'method' => 'upgrade_saved_filter_conditions',
2026 'is_manual' => 1,
2027 'warning_text' => 'SupportCandy - Filters database upgrade needed.',
2028 'warning_link_text' => 'Upgrade Now',
2029 'progressbar_text' => 'Upgrading filters...',
2030 )
2031 );
2032 }
2033 }
2034
2035 if ( version_compare( self::$current_version, '3.1.6', '<' ) ) {
2036
2037 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='repaire_setting_conditions'" ) ) {
2038 $wpdb->insert(
2039 $wpdb->prefix . 'psmsc_scheduled_tasks',
2040 array(
2041 'class' => 'WPSC_SC_Upgrade',
2042 'method' => 'repaire_setting_conditions',
2043 'is_manual' => 0,
2044 )
2045 );
2046 }
2047
2048 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='repaire_saved_filter_conditions'" ) ) {
2049 $wpdb->insert(
2050 $wpdb->prefix . 'psmsc_scheduled_tasks',
2051 array(
2052 'class' => 'WPSC_SC_Upgrade',
2053 'method' => 'repaire_saved_filter_conditions',
2054 'is_manual' => 1,
2055 'warning_text' => 'SupportCandy - Filters database upgrade needed.',
2056 'warning_link_text' => 'Upgrade Now',
2057 'progressbar_text' => 'Upgrading filters...',
2058 )
2059 );
2060 }
2061 }
2062
2063 if ( version_compare( self::$current_version, '3.1.7', '<' ) ) {
2064
2065 $gs = get_option( 'wpsc-gs-general' );
2066 $gs['allowed-search-fields'] = array( 'id', 'customer', 'subject', 'threads' );
2067 update_option( 'wpsc-gs-general', $gs );
2068
2069 $en = get_option( 'wpsc-en-general' );
2070 $en['attachments-in-notification'] = 'actual-files';
2071 update_option( 'wpsc-en-general', $en );
2072 }
2073
2074 if ( version_compare( self::$current_version, '3.1.9', '<' ) ) {
2075
2076 // add scheduled task for attachment status upgrade.
2077 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='update_ticket_attachment_status'" ) ) {
2078 $wpdb->insert(
2079 $wpdb->prefix . 'psmsc_scheduled_tasks',
2080 array(
2081 'class' => 'WPSC_SC_Upgrade',
2082 'method' => 'update_ticket_attachment_status',
2083 'is_manual' => 1,
2084 'warning_text' => 'SupportCandy - Database attachment status upgrade needed.',
2085 'warning_link_text' => 'Upgrade Now',
2086 'progressbar_text' => 'Updating attachment status...',
2087 )
2088 );
2089 }
2090 }
2091
2092 if ( version_compare( self::$current_version, '3.2.0', '<' ) ) {
2093
2094 $roles = get_option( 'wpsc-agent-roles' );
2095 foreach ( $roles as $key => $role ) {
2096 $role['caps']['dt-unassigned'] = true;
2097 $role['caps']['dt-assigned-me'] = true;
2098 $role['caps']['dt-assigned-others'] = true;
2099
2100 $roles[ $key ] = $role;
2101 }
2102 update_option( 'wpsc-agent-roles', $roles );
2103
2104 // set customer custom fields as personal info.
2105 $wpdb->update(
2106 $wpdb->prefix . 'psmsc_custom_fields',
2107 array( 'is_personal_info' => 1 ),
2108 array( 'field' => 'customer' )
2109 );
2110 }
2111
2112 if ( version_compare( self::$current_version, '3.2.1', '<' ) ) {
2113
2114 $thankyou = get_option( 'wpsc-gs-thankyou-page-settings' );
2115 if ( $thankyou['thank-you-page-url'] ) {
2116 $action = 'url';
2117 } else {
2118 $action = 'text';
2119 }
2120
2121 update_option(
2122 'wpsc-gs-thankyou-page-settings',
2123 array(
2124 'action-agent' => $action,
2125 'action-customer' => $action,
2126 'html-agent' => $thankyou['thankyou-html'],
2127 'html-customer' => $thankyou['thankyou-html'],
2128 'page-url-agent' => $thankyou['thank-you-page-url'],
2129 'page-url-customer' => $thankyou['thank-you-page-url'],
2130 'editor-agent' => $thankyou['editor'],
2131 'editor-customer' => $thankyou['editor'],
2132 )
2133 );
2134 $string_translations['wpsc-thankyou-html-agent'] = $thankyou['thankyou-html'];
2135
2136 update_option( 'wpsc-string-translation', $string_translations );
2137
2138 // ticket tags.
2139 $widgets = get_option( 'wpsc-ticket-widget', array() );
2140 if ( ! isset( $widgets['tags'] ) ) {
2141
2142 $agent_roles = array_keys( get_option( 'wpsc-agent-roles', array() ) );
2143 $label = esc_attr( wpsc__( 'Tags', 'supportcandy' ) );
2144 $widgets['tags'] = array(
2145 'title' => $label,
2146 'is_enable' => 1,
2147 'allow-customer' => 0,
2148 'allowed-agent-roles' => $agent_roles,
2149 'callback' => 'wpsc_get_tw_ticket_tags()',
2150 'class' => 'WPSC_ITW_Ticket_Tags',
2151 );
2152 update_option( 'wpsc-ticket-widget', $widgets );
2153
2154 $string_translations['wpsc-twt-tags'] = $label;
2155
2156 }
2157
2158 $tag_exists = $wpdb->get_results( "SELECT id from {$wpdb->prefix}psmsc_custom_fields WHERE slug = 'tags'" );
2159 if ( empty( $tag_exists ) ) {
2160 $name = esc_attr__( 'Tags', 'supportcandy' );
2161 $wpdb->insert(
2162 $wpdb->prefix . 'psmsc_custom_fields',
2163 array(
2164 'name' => $name,
2165 'slug' => 'tags',
2166 'field' => 'ticket',
2167 'type' => 'df_tags',
2168 'is_personal_info' => 0,
2169 'tl_width' => 100,
2170 'load_order' => 24,
2171 )
2172 );
2173 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
2174 }
2175
2176 $roles = get_option( 'wpsc-agent-roles' );
2177 foreach ( $roles as $key => $role ) {
2178 $role['caps']['tt-unassigned'] = true;
2179 $role['caps']['tt-assigned-me'] = true;
2180 $role['caps']['tt-assigned-others'] = true;
2181
2182 $roles[ $key ] = $role;
2183 }
2184 update_option( 'wpsc-agent-roles', $roles );
2185
2186 // ticket tags general setting.
2187 update_option(
2188 'wpsc-ticket-tags-general-settings',
2189 array(
2190 'color' => '#000000',
2191 'bg-color' => '#ffc300',
2192 )
2193 );
2194
2195 // Add agent collision appearance setting.
2196 update_option(
2197 'wpsc-ap-agent-collision',
2198 array(
2199 'header-bg-color' => '#e6e6e6',
2200 'header-text-color' => '#2c3e50',
2201 )
2202 );
2203
2204 // Add agent collision setting.
2205 $ms_advanced = get_option( 'wpsc-ms-advanced-settings' );
2206 $ms_advanced['agent-collision'] = 1;
2207 update_option( 'wpsc-ms-advanced-settings', $ms_advanced );
2208 }
2209
2210 if ( version_compare( self::$current_version, '3.2.2', '<' ) ) {
2211
2212 // add anonymuos customer to customer table.
2213 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_customers WHERE email='[email protected]'" ) ) {
2214
2215 $success = $wpdb->insert(
2216 $wpdb->prefix . 'psmsc_customers',
2217 array(
2218 'name' => 'Anonymous',
2219 'email' => '[email protected]',
2220 )
2221 );
2222 if ( $success ) {
2223 update_option( 'wpsc-anonymous-user-id', $wpdb->insert_id );
2224 }
2225 }
2226
2227 $advanced = get_option( 'wpsc-ms-advanced-settings' );
2228 $advanced['self-assign'] = 0;
2229 update_option( 'wpsc-ms-advanced-settings', $advanced );
2230 }
2231
2232 if ( version_compare( self::$current_version, '3.2.4', '<' ) ) {
2233
2234 // add default true to admin and agent dashboard access.
2235 $roles = get_option( 'wpsc-agent-roles' );
2236 $role_keys = array();
2237 foreach ( $roles as $key => $role ) {
2238 $role['caps']['dash-access'] = true;
2239 $roles[ $key ] = $role;
2240 $role_keys[] = $key;
2241 }
2242
2243 // Dashboard cards.
2244 $labels = array(
2245 'new-tickets' => esc_attr__( 'New Tickets', 'supportcandy' ),
2246 'unresolved' => esc_attr__( 'Unresolved', 'supportcandy' ),
2247 'unassigned' => esc_attr__( 'Unassigned', 'supportcandy' ),
2248 'closed' => esc_attr__( 'Closed', 'supportcandy' ),
2249 'mine' => esc_attr__( 'Mine', 'supportcandy' ),
2250 );
2251 foreach ( $labels as $key => $string ) {
2252 $string_translations[ 'wpsc-dashboard-card-' . $key ] = $string;
2253 }
2254 update_option(
2255 'wpsc-dashboard-cards',
2256 array(
2257 'new-tickets' => array(
2258 'title' => $labels['new-tickets'],
2259 'is_enable' => 1,
2260 'allowed-agent-roles' => $role_keys,
2261 'callback' => 'wpsc_dbc_new_tickets()',
2262 'class' => 'WPSC_DBC_New_Tickets',
2263 'type' => 'default',
2264 ),
2265 'unresolved' => array(
2266 'title' => $labels['unresolved'],
2267 'is_enable' => 1,
2268 'allowed-agent-roles' => $role_keys,
2269 'callback' => 'wpsc_dbc_unresolved_tickets()',
2270 'class' => 'WPSC_DBC_Unresolved_Tickets',
2271 'type' => 'default',
2272 ),
2273 'unassigned' => array(
2274 'title' => $labels['unassigned'],
2275 'is_enable' => 1,
2276 'allowed-agent-roles' => array( 1 ),
2277 'callback' => 'wpsc_dbc_unassigned_tickets()',
2278 'class' => 'WPSC_DBC_Unassigned_Tickets',
2279 'type' => 'default',
2280 ),
2281 'closed' => array(
2282 'title' => $labels['closed'],
2283 'is_enable' => 1,
2284 'allowed-agent-roles' => $role_keys,
2285 'callback' => 'wpsc_dbc_closed_tickets()',
2286 'class' => 'WPSC_DBC_Closed_Tickets',
2287 'type' => 'default',
2288 ),
2289 'mine' => array(
2290 'title' => $labels['mine'],
2291 'is_enable' => 1,
2292 'allowed-agent-roles' => $role_keys,
2293 'callback' => 'wpsc_dbc_mine_tickets()',
2294 'class' => 'WPSC_DBC_Mine_Tickets',
2295 'type' => 'default',
2296 ),
2297 )
2298 );
2299
2300 // Dashboard widget.
2301 $labels = array(
2302 'ticket-statistics' => esc_attr__( 'Ticket Statistics', 'supportcandy' ),
2303 'todays-trends' => esc_attr__( 'Todays Trends', 'supportcandy' ),
2304 'agent-list' => esc_attr__( 'Agent Workload', 'supportcandy' ),
2305 'recent-activities' => esc_attr__( 'Recent Activities', 'supportcandy' ),
2306 'recent-tickets' => esc_attr__( 'Recent Tickets', 'supportcandy' ),
2307 'category-report' => esc_attr__( 'Unresolved tickets by Category', 'supportcandy' ),
2308 'unresolved-priorities' => esc_attr__( 'Unresolved tickets by Priority', 'supportcandy' ),
2309 'unresolved-statuses' => esc_attr__( 'Unresolved tickets by Status', 'supportcandy' ),
2310 );
2311 foreach ( $labels as $key => $string ) {
2312 $string_translations[ 'wpsc-dashboard-widget-' . $key ] = $string;
2313 }
2314 update_option(
2315 'wpsc-dashboard-widgets',
2316 array(
2317 'ticket-statistics' => array(
2318 'title' => $labels['ticket-statistics'],
2319 'is_enable' => 1,
2320 'allowed-agent-roles' => $role_keys,
2321 'callback' => 'wpsc_dbw_ticket_statistics()',
2322 'class' => 'WPSC_DBW_Ticket_Statistics',
2323 'type' => 'default',
2324 'chart-type' => '',
2325 ),
2326 'todays-trends' => array(
2327 'title' => $labels['todays-trends'],
2328 'is_enable' => 1,
2329 'allowed-agent-roles' => $role_keys,
2330 'callback' => 'wpsc_dbw_todays_trends()',
2331 'class' => 'WPSC_DBW_Todays_Trends',
2332 'type' => 'default',
2333 'chart-type' => '',
2334 ),
2335 'agent-list' => array(
2336 'title' => $labels['agent-list'],
2337 'is_enable' => 1,
2338 'allowed-agent-roles' => array( 1 ),
2339 'callback' => 'wpsc_dbw_agent_list()',
2340 'class' => 'WPSC_DBW_Agent_List',
2341 'type' => 'default',
2342 'chart-type' => '',
2343 ),
2344 'recent-activities' => array(
2345 'title' => $labels['recent-activities'],
2346 'is_enable' => 1,
2347 'allowed-agent-roles' => $role_keys,
2348 'callback' => 'wpsc_dbw_recent_activities()',
2349 'class' => 'WPSC_DBW_Recent_Activities',
2350 'type' => 'default',
2351 'chart-type' => '',
2352 ),
2353 'recent-tickets' => array(
2354 'title' => $labels['recent-tickets'],
2355 'is_enable' => 1,
2356 'allowed-agent-roles' => $role_keys,
2357 'callback' => 'wpsc_dbw_recent_tickets()',
2358 'class' => 'WPSC_DBW_Recent_Tickets',
2359 'type' => 'default',
2360 'chart-type' => '',
2361 ),
2362 'category-report' => array(
2363 'title' => $labels['category-report'],
2364 'is_enable' => 1,
2365 'allowed-agent-roles' => $role_keys,
2366 'callback' => 'wpsc_dbw_category_reports()',
2367 'class' => 'WPSC_DBW_Category_Reports',
2368 'type' => 'default',
2369 'chart-type' => 'doughnut',
2370 ),
2371 'unresolved-priorities' => array(
2372 'title' => $labels['unresolved-priorities'],
2373 'is_enable' => 1,
2374 'allowed-agent-roles' => $role_keys,
2375 'callback' => 'wpsc_dbw_unresolved_priorities()',
2376 'class' => 'WPSC_DBW_Unresolved_Priorities',
2377 'type' => 'default',
2378 'chart-type' => 'horizontal-bar',
2379 ),
2380 'unresolved-statuses' => array(
2381 'title' => $labels['unresolved-statuses'],
2382 'is_enable' => 1,
2383 'allowed-agent-roles' => $role_keys,
2384 'callback' => 'wpsc_dbw_unresolved_statuses()',
2385 'class' => 'WPSC_DBW_Unresolved_Statuses',
2386 'type' => 'default',
2387 'chart-type' => 'vertical-bar',
2388 ),
2389 )
2390 );
2391
2392 // dashboard appreance general setting.
2393 update_option(
2394 'wpsc-ap-dashboard',
2395 array(
2396 'card-body-bg-color' => '#f9f9f9',
2397 'card-body-svg-color' => '#777',
2398 'card-body-text-color' => '#2c3e50',
2399 'widget-body-bg-color' => '#f9f9f9',
2400 'widget-body-svg-color' => '#777',
2401 'widget-body-text-color' => '#2c3e50',
2402 )
2403 );
2404
2405 // Add dashboard general settings.
2406 update_option(
2407 'wpsc-db-gs-settings',
2408 array(
2409 'default-date-range' => 'last-week',
2410 'allowed-recent-activity-logs' => array( 'report', 'reply', 'note', 'assigned_agent' ),
2411 )
2412 );
2413 update_option( 'wpsc-agent-roles', $roles );
2414 }
2415
2416 if ( version_compare( self::$current_version, '3.2.5', '<' ) ) {
2417
2418 $file_attachments = get_option( 'wpsc-gs-file-attachments' );
2419
2420 require_once WPSC_ABSPATH . 'includes/class-wpsc-mime-types.php';
2421
2422 $exts = $file_attachments['allowed-file-extensions'] ? explode( ',', $file_attachments['allowed-file-extensions'] ) : array();
2423 $exts = array_map( 'trim', $exts );
2424 $mimes = array();
2425 foreach ( $exts as $key => $value ) {
2426 $mime = WPSC_MIME_TYPES::get_mime_type( $value );
2427 if ( $mime ) {
2428 $mimes[ $value ] = $mime;
2429 }
2430 }
2431 $file_attachments['allowed-file-ext-mimes'] = $mimes;
2432 $file_attachments['mime-exceptions'] = array();
2433
2434 update_option( 'wpsc-gs-file-attachments', $file_attachments );
2435 }
2436
2437 if ( version_compare( self::$current_version, '3.2.6', '<' ) ) {
2438
2439 // Add dashboard general settings.
2440 $db_gs = get_option( 'wpsc-db-gs-settings', array() );
2441 $db_gs['dash-auto-refresh'] = 0;
2442 update_option( 'wpsc-db-gs-settings', $db_gs );
2443
2444 $wpdb->update(
2445 $wpdb->prefix . 'psmsc_custom_fields',
2446 array( 'number_type' => 'integer' ),
2447 array( 'type' => 'cf_number' )
2448 );
2449 }
2450
2451 if ( version_compare( self::$current_version, '3.2.7', '<' ) ) {
2452
2453 $ms_advanced = get_option( 'wpsc-ms-advanced-settings' );
2454 $ms_advanced['reply-close'] = 1;
2455 update_option( 'wpsc-ms-advanced-settings', $ms_advanced );
2456
2457 $appearance = get_option( 'wpsc-ap-individual-ticket' );
2458 $appearance['reply-close-bg-color'] = '#fff';
2459 $appearance['reply-close-text-color'] = '#707070';
2460 update_option( 'wpsc-ap-individual-ticket', $appearance );
2461
2462 $lrs_exists = $wpdb->get_results( "SELECT id from {$wpdb->prefix}psmsc_custom_fields WHERE slug = 'last_reply_source'" );
2463 if ( empty( $lrs_exists ) ) {
2464
2465 $name = esc_attr__( 'Last Reply Source', 'supportcandy' );
2466 $wpdb->insert(
2467 $wpdb->prefix . 'psmsc_custom_fields',
2468 array(
2469 'name' => $name,
2470 'slug' => 'last_reply_source',
2471 'field' => 'ticket',
2472 'type' => 'df_last_reply_source',
2473 'is_personal_info' => 0,
2474 'tl_width' => 100,
2475 'load_order' => 26,
2476 )
2477 );
2478 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
2479 }
2480
2481 // GDPR option in user registration.
2482 $gdpr = get_option( 'wpsc-gdpr-settings', array() );
2483 $gdpr_text = '<p>I understand my personal information like Name, Email address, IP address, etc. will be stored in database.</p>';
2484 $gdpr['allow-gdpr-reg-user'] = 0;
2485 $gdpr['gdpr-text-reg-user'] = $gdpr_text;
2486 $gdpr['editor-reg-user'] = 'html';
2487 update_option( 'wpsc-gdpr-settings', $gdpr );
2488 $string_translations['wpsc-gdpr-reg-user'] = $gdpr_text;
2489
2490 // T&C option in user registration.
2491 $tandc = get_option( 'wpsc-term-and-conditions', array() );
2492 $tandc_text = '<p>I agree to the terms and conditions</p>';
2493 $tandc['allow-term-and-conditions-reg-user'] = 0;
2494 $tandc['tandc-text-reg-user'] = $tandc_text;
2495 $tandc['editor-reg-user'] = 'html';
2496 update_option( 'wpsc-term-and-conditions', $tandc );
2497 $string_translations['wpsc-term-and-conditions-reg-user'] = $tandc_text;
2498 }
2499
2500 if ( version_compare( self::$current_version, '3.2.8', '<' ) ) {
2501
2502 $widgets = get_option( 'wpsc-dashboard-widgets', array() );
2503 if ( ! isset( $widgets['week-trends'] ) ) {
2504 $label = esc_attr__( 'Ticket statistics by day of week', 'supportcandy' );
2505 $string_translations['wpsc-dashboard-widget-week-trends'] = $label;
2506 $widgets['week-trends'] = array(
2507 'title' => $label,
2508 'is_enable' => 1,
2509 'allowed-agent-roles' => array( 1 ),
2510 'callback' => 'wpsc_dbw_week_trend_tickets()',
2511 'class' => 'WPSC_DBW_Week_Trend_Tickets',
2512 'type' => 'default',
2513 'chart-type' => 'vertical-bar',
2514 );
2515 }
2516 update_option( 'wpsc-dashboard-widgets', $widgets );
2517 }
2518
2519 if ( version_compare( self::$current_version, '3.2.9', '<' ) ) {
2520
2521 // scheduled task for updating image editor attachment path in thread body.
2522 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='upgrade_ie_attachment_path'" ) ) {
2523 $wpdb->insert(
2524 $wpdb->prefix . 'psmsc_scheduled_tasks',
2525 array(
2526 'class' => 'WPSC_SC_Upgrade',
2527 'method' => 'upgrade_ie_attachment_path',
2528 'is_manual' => 1,
2529 'warning_text' => 'SupportCandy - attachment security upgrade needed.',
2530 'warning_link_text' => 'Upgrade Now',
2531 'progressbar_text' => 'Updating attachment ...',
2532 )
2533 );
2534 }
2535
2536 // unschedule old upgrade task.
2537 $upgrade = get_option( 'wpsc_upgrade_cleanup', array() );
2538 if ( empty( $upgrade ) ) {
2539
2540 $timestamp = wp_next_scheduled( 'wpsc_v1_upgrade_cleanup' );
2541 if ( $timestamp ) {
2542 wp_unschedule_event( $timestamp, 'wpsc_v1_upgrade_cleanup' );
2543 }
2544 $timestamp = wp_next_scheduled( 'wpsc_v2_upgrade_cleanup' );
2545 if ( $timestamp ) {
2546 wp_unschedule_event( $timestamp, 'wpsc_v2_upgrade_cleanup' );
2547 }
2548 }
2549 }
2550
2551 if ( version_compare( self::$current_version, '3.3.7', '<' ) ) {
2552 $advanced = get_option( 'wpsc-ms-advanced-settings' );
2553 $advanced['note-confirmation'] = 0;
2554 update_option( 'wpsc-ms-advanced-settings', $advanced );
2555 }
2556
2557 if ( version_compare( self::$current_version, '3.3.8', '<' ) ) {
2558
2559 $gdpr = get_option( 'wpsc-gdpr-settings', array() );
2560 $gdpr['ip-address-collection'] = 1;
2561 update_option( 'wpsc-gdpr-settings', $gdpr );
2562
2563 $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_email_otp MODIFY otp VARCHAR(10) NOT NULL" );
2564 }
2565
2566 if ( version_compare( self::$current_version, '3.4.0', '<' ) ) {
2567 // Create required database indexes.
2568 self::create_indexing();
2569 }
2570
2571 update_option( 'wpsc-string-translation', $string_translations );
2572 self::set_upgrade_complete();
2573 }
2574
2575 /**
2576 * Mark upgrade as complete
2577 */
2578 public static function set_upgrade_complete() {
2579
2580 update_option( 'wpsc_current_version', WPSC_VERSION );
2581 update_option( 'wpsc_db_version', WPSC_DB_VERSION );
2582 self::$current_version = WPSC_VERSION;
2583 self::$is_upgrade = false;
2584 }
2585
2586 /**
2587 * Actions to perform after plugin deactivated
2588 *
2589 * @return void
2590 */
2591 public static function deactivate() {
2592
2593 // Remove cron jobs.
2594 WPSC_Cron::unschedule_events();
2595 }
2596
2597 /**
2598 * Add htaccess file in supportcandy attachment folder
2599 *
2600 * @return void
2601 */
2602 public static function attachment_security_file() {
2603
2604 $upload_dir = wp_upload_dir();
2605 $wpsc_dir = $upload_dir['basedir'] . '/wpsc';
2606 if ( ! is_file( $wpsc_dir . '/.htaccess' ) ) {
2607 @file_put_contents( $wpsc_dir . '/.htaccess', 'deny from all' ); //phpcs:ignore
2608 }
2609 }
2610
2611 /**
2612 * Create required database indexes
2613 *
2614 * @return void
2615 */
2616 private static function create_indexing() {
2617
2618 global $wpdb;
2619
2620 $column_slugs = array( 'status', 'customer', 'category', 'priority', 'date_updated', 'date_created', 'date_closed' );
2621 foreach ( $column_slugs as $slug ) {
2622 $index_name = "idx_cf_{$slug}";
2623
2624 // Check if index already exists.
2625 $index_exists = $wpdb->get_var(
2626 $wpdb->prepare(
2627 "SHOW INDEX FROM {$wpdb->prefix}psmsc_tickets WHERE Key_name = %s",
2628 $index_name
2629 )
2630 );
2631
2632 if ( ! $index_exists ) {
2633 $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_tickets ADD INDEX {$index_name} (`{$slug}`)" );
2634 }
2635 }
2636
2637 // create index on thread table.
2638 $index_name = 'idx_ticket_id';
2639 $index_exists = $wpdb->get_var(
2640 $wpdb->prepare(
2641 "SHOW INDEX FROM {$wpdb->prefix}psmsc_threads WHERE Key_name = %s",
2642 $index_name
2643 )
2644 );
2645 if ( ! $index_exists ) {
2646 $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_threads ADD INDEX {$index_name} (ticket)" );
2647 }
2648 }
2649 }
2650 endif;
2651
2652 WPSC_Installation::init();
2653