PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.3.9
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.3.9
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / class-wpsc-installation.php

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

2,606 lines 85.4 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 // update string translations.
1927 update_option( 'wpsc-string-translation', $string_translations );
1928 }
1929
1930 /**
1931 * Upgrade the version
1932 */
1933 public static function upgrade() {
1934
1935 global $wpdb;
1936 $string_translations = get_option( 'wpsc-string-translation' );
1937
1938 if ( version_compare( self::$current_version, '3.0.4', '<' ) ) {
1939
1940 $advanced = get_option( 'wpsc-ms-advanced-settings' );
1941 $advanced['allow-my-profile'] = 1;
1942 $advanced['allow-agent-profile'] = 1;
1943 update_option( 'wpsc-ms-advanced-settings', $advanced );
1944 }
1945
1946 if ( version_compare( self::$current_version, '3.0.5', '<' ) ) {
1947
1948 $advanced = get_option( 'wpsc-ms-advanced-settings' );
1949 $page_settings = get_option( 'wpsc-gs-page-settings' );
1950 if ( ! isset( $advanced['allow-my-profile'] ) ) {
1951 $advanced['allow-my-profile'] = 1;
1952 $advanced['allow-agent-profile'] = 1;
1953 }
1954 $page_settings['otp-login'] = 1;
1955 update_option( 'wpsc-gs-page-settings', $page_settings );
1956 $advanced['ticket-url-auth'] = 0;
1957 update_option( 'wpsc-ms-advanced-settings', $advanced );
1958 }
1959
1960 if ( version_compare( self::$current_version, '3.0.7', '<' ) ) {
1961
1962 $page_settings = get_option( 'wpsc-gs-page-settings' );
1963 $page_settings['load-scripts'] = 'all-pages';
1964 $page_settings['load-script-pages'] = array();
1965 update_option( 'wpsc-gs-page-settings', $page_settings );
1966 }
1967
1968 if ( version_compare( self::$current_version, '3.1.1', '<' ) ) {
1969
1970 $ap_general = get_option( 'wpsc-ap-general' );
1971 $ap_general['menu-link-color'] = '#fff';
1972 update_option( 'wpsc-ap-general', $ap_general );
1973 }
1974
1975 if ( version_compare( self::$current_version, '3.1.3', '<' ) ) {
1976
1977 $advanced = get_option( 'wpsc-ms-advanced-settings' );
1978 $advanced['rest-api'] = 1;
1979 update_option( 'wpsc-ms-advanced-settings', $advanced );
1980 }
1981
1982 if ( version_compare( self::$current_version, '3.1.4', '<' ) ) {
1983
1984 // add scheduled task for ticket data upgrade.
1985 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='update_ticket_attachment_path'" ) ) {
1986 $wpdb->insert(
1987 $wpdb->prefix . 'psmsc_scheduled_tasks',
1988 array(
1989 'class' => 'WPSC_SC_Upgrade',
1990 'method' => 'update_ticket_attachment_path',
1991 'is_manual' => 1,
1992 'warning_text' => 'SupportCandy - Database attachment paths upgrade needed.',
1993 'warning_link_text' => 'Upgrade Now',
1994 'progressbar_text' => 'Updating attachment paths...',
1995 )
1996 );
1997 }
1998
1999 self::attachment_security_file();
2000 }
2001
2002 if ( version_compare( self::$current_version, '3.1.5', '<' ) ) {
2003
2004 // scheduled task for setting conditions upgrade.
2005 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='upgrade_setting_conditions'" ) ) {
2006 $wpdb->insert(
2007 $wpdb->prefix . 'psmsc_scheduled_tasks',
2008 array(
2009 'class' => 'WPSC_SC_Upgrade',
2010 'method' => 'upgrade_setting_conditions',
2011 'is_manual' => 0,
2012 )
2013 );
2014 }
2015
2016 // scheduled task for saved filter conditions upgrade.
2017 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='upgrade_saved_filter_conditions'" ) ) {
2018 $wpdb->insert(
2019 $wpdb->prefix . 'psmsc_scheduled_tasks',
2020 array(
2021 'class' => 'WPSC_SC_Upgrade',
2022 'method' => 'upgrade_saved_filter_conditions',
2023 'is_manual' => 1,
2024 'warning_text' => 'SupportCandy - Filters database upgrade needed.',
2025 'warning_link_text' => 'Upgrade Now',
2026 'progressbar_text' => 'Upgrading filters...',
2027 )
2028 );
2029 }
2030 }
2031
2032 if ( version_compare( self::$current_version, '3.1.6', '<' ) ) {
2033
2034 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='repaire_setting_conditions'" ) ) {
2035 $wpdb->insert(
2036 $wpdb->prefix . 'psmsc_scheduled_tasks',
2037 array(
2038 'class' => 'WPSC_SC_Upgrade',
2039 'method' => 'repaire_setting_conditions',
2040 'is_manual' => 0,
2041 )
2042 );
2043 }
2044
2045 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='repaire_saved_filter_conditions'" ) ) {
2046 $wpdb->insert(
2047 $wpdb->prefix . 'psmsc_scheduled_tasks',
2048 array(
2049 'class' => 'WPSC_SC_Upgrade',
2050 'method' => 'repaire_saved_filter_conditions',
2051 'is_manual' => 1,
2052 'warning_text' => 'SupportCandy - Filters database upgrade needed.',
2053 'warning_link_text' => 'Upgrade Now',
2054 'progressbar_text' => 'Upgrading filters...',
2055 )
2056 );
2057 }
2058 }
2059
2060 if ( version_compare( self::$current_version, '3.1.7', '<' ) ) {
2061
2062 $gs = get_option( 'wpsc-gs-general' );
2063 $gs['allowed-search-fields'] = array( 'id', 'customer', 'subject', 'threads' );
2064 update_option( 'wpsc-gs-general', $gs );
2065
2066 $en = get_option( 'wpsc-en-general' );
2067 $en['attachments-in-notification'] = 'actual-files';
2068 update_option( 'wpsc-en-general', $en );
2069 }
2070
2071 if ( version_compare( self::$current_version, '3.1.9', '<' ) ) {
2072
2073 // add scheduled task for attachment status upgrade.
2074 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='update_ticket_attachment_status'" ) ) {
2075 $wpdb->insert(
2076 $wpdb->prefix . 'psmsc_scheduled_tasks',
2077 array(
2078 'class' => 'WPSC_SC_Upgrade',
2079 'method' => 'update_ticket_attachment_status',
2080 'is_manual' => 1,
2081 'warning_text' => 'SupportCandy - Database attachment status upgrade needed.',
2082 'warning_link_text' => 'Upgrade Now',
2083 'progressbar_text' => 'Updating attachment status...',
2084 )
2085 );
2086 }
2087 }
2088
2089 if ( version_compare( self::$current_version, '3.2.0', '<' ) ) {
2090
2091 $roles = get_option( 'wpsc-agent-roles' );
2092 foreach ( $roles as $key => $role ) {
2093 $role['caps']['dt-unassigned'] = true;
2094 $role['caps']['dt-assigned-me'] = true;
2095 $role['caps']['dt-assigned-others'] = true;
2096
2097 $roles[ $key ] = $role;
2098 }
2099 update_option( 'wpsc-agent-roles', $roles );
2100
2101 // set customer custom fields as personal info.
2102 $wpdb->update(
2103 $wpdb->prefix . 'psmsc_custom_fields',
2104 array( 'is_personal_info' => 1 ),
2105 array( 'field' => 'customer' )
2106 );
2107 }
2108
2109 if ( version_compare( self::$current_version, '3.2.1', '<' ) ) {
2110
2111 $thankyou = get_option( 'wpsc-gs-thankyou-page-settings' );
2112 if ( $thankyou['thank-you-page-url'] ) {
2113 $action = 'url';
2114 } else {
2115 $action = 'text';
2116 }
2117
2118 update_option(
2119 'wpsc-gs-thankyou-page-settings',
2120 array(
2121 'action-agent' => $action,
2122 'action-customer' => $action,
2123 'html-agent' => $thankyou['thankyou-html'],
2124 'html-customer' => $thankyou['thankyou-html'],
2125 'page-url-agent' => $thankyou['thank-you-page-url'],
2126 'page-url-customer' => $thankyou['thank-you-page-url'],
2127 'editor-agent' => $thankyou['editor'],
2128 'editor-customer' => $thankyou['editor'],
2129 )
2130 );
2131 $string_translations['wpsc-thankyou-html-agent'] = $thankyou['thankyou-html'];
2132
2133 update_option( 'wpsc-string-translation', $string_translations );
2134
2135 // ticket tags.
2136 $widgets = get_option( 'wpsc-ticket-widget', array() );
2137 if ( ! isset( $widgets['tags'] ) ) {
2138
2139 $agent_roles = array_keys( get_option( 'wpsc-agent-roles', array() ) );
2140 $label = esc_attr( wpsc__( 'Tags', 'supportcandy' ) );
2141 $widgets['tags'] = array(
2142 'title' => $label,
2143 'is_enable' => 1,
2144 'allow-customer' => 0,
2145 'allowed-agent-roles' => $agent_roles,
2146 'callback' => 'wpsc_get_tw_ticket_tags()',
2147 'class' => 'WPSC_ITW_Ticket_Tags',
2148 );
2149 update_option( 'wpsc-ticket-widget', $widgets );
2150
2151 $string_translations['wpsc-twt-tags'] = $label;
2152
2153 }
2154
2155 $tag_exists = $wpdb->get_results( "SELECT id from {$wpdb->prefix}psmsc_custom_fields WHERE slug = 'tags'" );
2156 if ( empty( $tag_exists ) ) {
2157 $name = esc_attr__( 'Tags', 'supportcandy' );
2158 $wpdb->insert(
2159 $wpdb->prefix . 'psmsc_custom_fields',
2160 array(
2161 'name' => $name,
2162 'slug' => 'tags',
2163 'field' => 'ticket',
2164 'type' => 'df_tags',
2165 'is_personal_info' => 0,
2166 'tl_width' => 100,
2167 'load_order' => 24,
2168 )
2169 );
2170 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
2171 }
2172
2173 $roles = get_option( 'wpsc-agent-roles' );
2174 foreach ( $roles as $key => $role ) {
2175 $role['caps']['tt-unassigned'] = true;
2176 $role['caps']['tt-assigned-me'] = true;
2177 $role['caps']['tt-assigned-others'] = true;
2178
2179 $roles[ $key ] = $role;
2180 }
2181 update_option( 'wpsc-agent-roles', $roles );
2182
2183 // ticket tags general setting.
2184 update_option(
2185 'wpsc-ticket-tags-general-settings',
2186 array(
2187 'color' => '#000000',
2188 'bg-color' => '#ffc300',
2189 )
2190 );
2191
2192 // Add agent collision appearance setting.
2193 update_option(
2194 'wpsc-ap-agent-collision',
2195 array(
2196 'header-bg-color' => '#e6e6e6',
2197 'header-text-color' => '#2c3e50',
2198 )
2199 );
2200
2201 // Add agent collision setting.
2202 $ms_advanced = get_option( 'wpsc-ms-advanced-settings' );
2203 $ms_advanced['agent-collision'] = 1;
2204 update_option( 'wpsc-ms-advanced-settings', $ms_advanced );
2205 }
2206
2207 if ( version_compare( self::$current_version, '3.2.2', '<' ) ) {
2208
2209 // add anonymuos customer to customer table.
2210 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_customers WHERE email='[email protected]'" ) ) {
2211
2212 $success = $wpdb->insert(
2213 $wpdb->prefix . 'psmsc_customers',
2214 array(
2215 'name' => 'Anonymous',
2216 'email' => '[email protected]',
2217 )
2218 );
2219 if ( $success ) {
2220 update_option( 'wpsc-anonymous-user-id', $wpdb->insert_id );
2221 }
2222 }
2223
2224 $advanced = get_option( 'wpsc-ms-advanced-settings' );
2225 $advanced['self-assign'] = 0;
2226 update_option( 'wpsc-ms-advanced-settings', $advanced );
2227 }
2228
2229 if ( version_compare( self::$current_version, '3.2.4', '<' ) ) {
2230
2231 // add default true to admin and agent dashboard access.
2232 $roles = get_option( 'wpsc-agent-roles' );
2233 $role_keys = array();
2234 foreach ( $roles as $key => $role ) {
2235 $role['caps']['dash-access'] = true;
2236 $roles[ $key ] = $role;
2237 $role_keys[] = $key;
2238 }
2239
2240 // Dashboard cards.
2241 $labels = array(
2242 'new-tickets' => esc_attr__( 'New Tickets', 'supportcandy' ),
2243 'unresolved' => esc_attr__( 'Unresolved', 'supportcandy' ),
2244 'unassigned' => esc_attr__( 'Unassigned', 'supportcandy' ),
2245 'closed' => esc_attr__( 'Closed', 'supportcandy' ),
2246 'mine' => esc_attr__( 'Mine', 'supportcandy' ),
2247 );
2248 foreach ( $labels as $key => $string ) {
2249 $string_translations[ 'wpsc-dashboard-card-' . $key ] = $string;
2250 }
2251 update_option(
2252 'wpsc-dashboard-cards',
2253 array(
2254 'new-tickets' => array(
2255 'title' => $labels['new-tickets'],
2256 'is_enable' => 1,
2257 'allowed-agent-roles' => $role_keys,
2258 'callback' => 'wpsc_dbc_new_tickets()',
2259 'class' => 'WPSC_DBC_New_Tickets',
2260 'type' => 'default',
2261 ),
2262 'unresolved' => array(
2263 'title' => $labels['unresolved'],
2264 'is_enable' => 1,
2265 'allowed-agent-roles' => $role_keys,
2266 'callback' => 'wpsc_dbc_unresolved_tickets()',
2267 'class' => 'WPSC_DBC_Unresolved_Tickets',
2268 'type' => 'default',
2269 ),
2270 'unassigned' => array(
2271 'title' => $labels['unassigned'],
2272 'is_enable' => 1,
2273 'allowed-agent-roles' => array( 1 ),
2274 'callback' => 'wpsc_dbc_unassigned_tickets()',
2275 'class' => 'WPSC_DBC_Unassigned_Tickets',
2276 'type' => 'default',
2277 ),
2278 'closed' => array(
2279 'title' => $labels['closed'],
2280 'is_enable' => 1,
2281 'allowed-agent-roles' => $role_keys,
2282 'callback' => 'wpsc_dbc_closed_tickets()',
2283 'class' => 'WPSC_DBC_Closed_Tickets',
2284 'type' => 'default',
2285 ),
2286 'mine' => array(
2287 'title' => $labels['mine'],
2288 'is_enable' => 1,
2289 'allowed-agent-roles' => $role_keys,
2290 'callback' => 'wpsc_dbc_mine_tickets()',
2291 'class' => 'WPSC_DBC_Mine_Tickets',
2292 'type' => 'default',
2293 ),
2294 )
2295 );
2296
2297 // Dashboard widget.
2298 $labels = array(
2299 'ticket-statistics' => esc_attr__( 'Ticket Statistics', 'supportcandy' ),
2300 'todays-trends' => esc_attr__( 'Todays Trends', 'supportcandy' ),
2301 'agent-list' => esc_attr__( 'Agent Workload', 'supportcandy' ),
2302 'recent-activities' => esc_attr__( 'Recent Activities', 'supportcandy' ),
2303 'recent-tickets' => esc_attr__( 'Recent Tickets', 'supportcandy' ),
2304 'category-report' => esc_attr__( 'Unresolved tickets by Category', 'supportcandy' ),
2305 'unresolved-priorities' => esc_attr__( 'Unresolved tickets by Priority', 'supportcandy' ),
2306 'unresolved-statuses' => esc_attr__( 'Unresolved tickets by Status', 'supportcandy' ),
2307 );
2308 foreach ( $labels as $key => $string ) {
2309 $string_translations[ 'wpsc-dashboard-widget-' . $key ] = $string;
2310 }
2311 update_option(
2312 'wpsc-dashboard-widgets',
2313 array(
2314 'ticket-statistics' => array(
2315 'title' => $labels['ticket-statistics'],
2316 'is_enable' => 1,
2317 'allowed-agent-roles' => $role_keys,
2318 'callback' => 'wpsc_dbw_ticket_statistics()',
2319 'class' => 'WPSC_DBW_Ticket_Statistics',
2320 'type' => 'default',
2321 'chart-type' => '',
2322 ),
2323 'todays-trends' => array(
2324 'title' => $labels['todays-trends'],
2325 'is_enable' => 1,
2326 'allowed-agent-roles' => $role_keys,
2327 'callback' => 'wpsc_dbw_todays_trends()',
2328 'class' => 'WPSC_DBW_Todays_Trends',
2329 'type' => 'default',
2330 'chart-type' => '',
2331 ),
2332 'agent-list' => array(
2333 'title' => $labels['agent-list'],
2334 'is_enable' => 1,
2335 'allowed-agent-roles' => array( 1 ),
2336 'callback' => 'wpsc_dbw_agent_list()',
2337 'class' => 'WPSC_DBW_Agent_List',
2338 'type' => 'default',
2339 'chart-type' => '',
2340 ),
2341 'recent-activities' => array(
2342 'title' => $labels['recent-activities'],
2343 'is_enable' => 1,
2344 'allowed-agent-roles' => $role_keys,
2345 'callback' => 'wpsc_dbw_recent_activities()',
2346 'class' => 'WPSC_DBW_Recent_Activities',
2347 'type' => 'default',
2348 'chart-type' => '',
2349 ),
2350 'recent-tickets' => array(
2351 'title' => $labels['recent-tickets'],
2352 'is_enable' => 1,
2353 'allowed-agent-roles' => $role_keys,
2354 'callback' => 'wpsc_dbw_recent_tickets()',
2355 'class' => 'WPSC_DBW_Recent_Tickets',
2356 'type' => 'default',
2357 'chart-type' => '',
2358 ),
2359 'category-report' => array(
2360 'title' => $labels['category-report'],
2361 'is_enable' => 1,
2362 'allowed-agent-roles' => $role_keys,
2363 'callback' => 'wpsc_dbw_category_reports()',
2364 'class' => 'WPSC_DBW_Category_Reports',
2365 'type' => 'default',
2366 'chart-type' => 'doughnut',
2367 ),
2368 'unresolved-priorities' => array(
2369 'title' => $labels['unresolved-priorities'],
2370 'is_enable' => 1,
2371 'allowed-agent-roles' => $role_keys,
2372 'callback' => 'wpsc_dbw_unresolved_priorities()',
2373 'class' => 'WPSC_DBW_Unresolved_Priorities',
2374 'type' => 'default',
2375 'chart-type' => 'horizontal-bar',
2376 ),
2377 'unresolved-statuses' => array(
2378 'title' => $labels['unresolved-statuses'],
2379 'is_enable' => 1,
2380 'allowed-agent-roles' => $role_keys,
2381 'callback' => 'wpsc_dbw_unresolved_statuses()',
2382 'class' => 'WPSC_DBW_Unresolved_Statuses',
2383 'type' => 'default',
2384 'chart-type' => 'vertical-bar',
2385 ),
2386 )
2387 );
2388
2389 // dashboard appreance general setting.
2390 update_option(
2391 'wpsc-ap-dashboard',
2392 array(
2393 'card-body-bg-color' => '#f9f9f9',
2394 'card-body-svg-color' => '#777',
2395 'card-body-text-color' => '#2c3e50',
2396 'widget-body-bg-color' => '#f9f9f9',
2397 'widget-body-svg-color' => '#777',
2398 'widget-body-text-color' => '#2c3e50',
2399 )
2400 );
2401
2402 // Add dashboard general settings.
2403 update_option(
2404 'wpsc-db-gs-settings',
2405 array(
2406 'default-date-range' => 'last-week',
2407 'allowed-recent-activity-logs' => array( 'report', 'reply', 'note', 'assigned_agent' ),
2408 )
2409 );
2410 update_option( 'wpsc-agent-roles', $roles );
2411 }
2412
2413 if ( version_compare( self::$current_version, '3.2.5', '<' ) ) {
2414
2415 $file_attachments = get_option( 'wpsc-gs-file-attachments' );
2416
2417 require_once WPSC_ABSPATH . 'includes/class-wpsc-mime-types.php';
2418
2419 $exts = $file_attachments['allowed-file-extensions'] ? explode( ',', $file_attachments['allowed-file-extensions'] ) : array();
2420 $exts = array_map( 'trim', $exts );
2421 $mimes = array();
2422 foreach ( $exts as $key => $value ) {
2423 $mime = WPSC_MIME_TYPES::get_mime_type( $value );
2424 if ( $mime ) {
2425 $mimes[ $value ] = $mime;
2426 }
2427 }
2428 $file_attachments['allowed-file-ext-mimes'] = $mimes;
2429 $file_attachments['mime-exceptions'] = array();
2430
2431 update_option( 'wpsc-gs-file-attachments', $file_attachments );
2432 }
2433
2434 if ( version_compare( self::$current_version, '3.2.6', '<' ) ) {
2435
2436 // Add dashboard general settings.
2437 $db_gs = get_option( 'wpsc-db-gs-settings', array() );
2438 $db_gs['dash-auto-refresh'] = 0;
2439 update_option( 'wpsc-db-gs-settings', $db_gs );
2440
2441 $wpdb->update(
2442 $wpdb->prefix . 'psmsc_custom_fields',
2443 array( 'number_type' => 'integer' ),
2444 array( 'type' => 'cf_number' )
2445 );
2446 }
2447
2448 if ( version_compare( self::$current_version, '3.2.7', '<' ) ) {
2449
2450 $ms_advanced = get_option( 'wpsc-ms-advanced-settings' );
2451 $ms_advanced['reply-close'] = 1;
2452 update_option( 'wpsc-ms-advanced-settings', $ms_advanced );
2453
2454 $appearance = get_option( 'wpsc-ap-individual-ticket' );
2455 $appearance['reply-close-bg-color'] = '#fff';
2456 $appearance['reply-close-text-color'] = '#707070';
2457 update_option( 'wpsc-ap-individual-ticket', $appearance );
2458
2459 $lrs_exists = $wpdb->get_results( "SELECT id from {$wpdb->prefix}psmsc_custom_fields WHERE slug = 'last_reply_source'" );
2460 if ( empty( $lrs_exists ) ) {
2461
2462 $name = esc_attr__( 'Last Reply Source', 'supportcandy' );
2463 $wpdb->insert(
2464 $wpdb->prefix . 'psmsc_custom_fields',
2465 array(
2466 'name' => $name,
2467 'slug' => 'last_reply_source',
2468 'field' => 'ticket',
2469 'type' => 'df_last_reply_source',
2470 'is_personal_info' => 0,
2471 'tl_width' => 100,
2472 'load_order' => 26,
2473 )
2474 );
2475 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
2476 }
2477
2478 // GDPR option in user registration.
2479 $gdpr = get_option( 'wpsc-gdpr-settings', array() );
2480 $gdpr_text = '<p>I understand my personal information like Name, Email address, IP address, etc. will be stored in database.</p>';
2481 $gdpr['allow-gdpr-reg-user'] = 0;
2482 $gdpr['gdpr-text-reg-user'] = $gdpr_text;
2483 $gdpr['editor-reg-user'] = 'html';
2484 update_option( 'wpsc-gdpr-settings', $gdpr );
2485 $string_translations['wpsc-gdpr-reg-user'] = $gdpr_text;
2486
2487 // T&C option in user registration.
2488 $tandc = get_option( 'wpsc-term-and-conditions', array() );
2489 $tandc_text = '<p>I agree to the terms and conditions</p>';
2490 $tandc['allow-term-and-conditions-reg-user'] = 0;
2491 $tandc['tandc-text-reg-user'] = $tandc_text;
2492 $tandc['editor-reg-user'] = 'html';
2493 update_option( 'wpsc-term-and-conditions', $tandc );
2494 $string_translations['wpsc-term-and-conditions-reg-user'] = $tandc_text;
2495 }
2496
2497 if ( version_compare( self::$current_version, '3.2.8', '<' ) ) {
2498
2499 $widgets = get_option( 'wpsc-dashboard-widgets', array() );
2500 if ( ! isset( $widgets['week-trends'] ) ) {
2501 $label = esc_attr__( 'Ticket statistics by day of week', 'supportcandy' );
2502 $string_translations['wpsc-dashboard-widget-week-trends'] = $label;
2503 $widgets['week-trends'] = array(
2504 'title' => $label,
2505 'is_enable' => 1,
2506 'allowed-agent-roles' => array( 1 ),
2507 'callback' => 'wpsc_dbw_week_trend_tickets()',
2508 'class' => 'WPSC_DBW_Week_Trend_Tickets',
2509 'type' => 'default',
2510 'chart-type' => 'vertical-bar',
2511 );
2512 }
2513 update_option( 'wpsc-dashboard-widgets', $widgets );
2514 }
2515
2516 if ( version_compare( self::$current_version, '3.2.9', '<' ) ) {
2517
2518 // scheduled task for updating image editor attachment path in thread body.
2519 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='upgrade_ie_attachment_path'" ) ) {
2520 $wpdb->insert(
2521 $wpdb->prefix . 'psmsc_scheduled_tasks',
2522 array(
2523 'class' => 'WPSC_SC_Upgrade',
2524 'method' => 'upgrade_ie_attachment_path',
2525 'is_manual' => 1,
2526 'warning_text' => 'SupportCandy - attachment security upgrade needed.',
2527 'warning_link_text' => 'Upgrade Now',
2528 'progressbar_text' => 'Updating attachment ...',
2529 )
2530 );
2531 }
2532
2533 // unschedule old upgrade task.
2534 $upgrade = get_option( 'wpsc_upgrade_cleanup', array() );
2535 if ( empty( $upgrade ) ) {
2536
2537 $timestamp = wp_next_scheduled( 'wpsc_v1_upgrade_cleanup' );
2538 if ( $timestamp ) {
2539 wp_unschedule_event( $timestamp, 'wpsc_v1_upgrade_cleanup' );
2540 }
2541 $timestamp = wp_next_scheduled( 'wpsc_v2_upgrade_cleanup' );
2542 if ( $timestamp ) {
2543 wp_unschedule_event( $timestamp, 'wpsc_v2_upgrade_cleanup' );
2544 }
2545 }
2546 }
2547
2548 if ( version_compare( self::$current_version, '3.3.7', '<' ) ) {
2549 $advanced = get_option( 'wpsc-ms-advanced-settings' );
2550 $advanced['note-confirmation'] = 0;
2551 update_option( 'wpsc-ms-advanced-settings', $advanced );
2552 }
2553
2554 if ( version_compare( self::$current_version, '3.3.8', '<' ) ) {
2555
2556 $gdpr = get_option( 'wpsc-gdpr-settings', array() );
2557 $gdpr['ip-address-collection'] = 1;
2558 update_option( 'wpsc-gdpr-settings', $gdpr );
2559
2560 $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_email_otp MODIFY otp VARCHAR(10) NOT NULL" );
2561 }
2562
2563 update_option( 'wpsc-string-translation', $string_translations );
2564 self::set_upgrade_complete();
2565 }
2566
2567 /**
2568 * Mark upgrade as complete
2569 */
2570 public static function set_upgrade_complete() {
2571
2572 update_option( 'wpsc_current_version', WPSC_VERSION );
2573 update_option( 'wpsc_db_version', WPSC_DB_VERSION );
2574 self::$current_version = WPSC_VERSION;
2575 self::$is_upgrade = false;
2576 }
2577
2578 /**
2579 * Actions to perform after plugin deactivated
2580 *
2581 * @return void
2582 */
2583 public static function deactivate() {
2584
2585 // Remove cron jobs.
2586 WPSC_Cron::unschedule_events();
2587 }
2588
2589 /**
2590 * Add htaccess file in supportcandy attachment folder
2591 *
2592 * @return void
2593 */
2594 public static function attachment_security_file() {
2595
2596 $upload_dir = wp_upload_dir();
2597 $wpsc_dir = $upload_dir['basedir'] . '/wpsc';
2598 if ( ! is_file( $wpsc_dir . '/.htaccess' ) ) {
2599 @file_put_contents( $wpsc_dir . '/.htaccess', 'deny from all' ); //phpcs:ignore
2600 }
2601 }
2602 }
2603 endif;
2604
2605 WPSC_Installation::init();
2606