PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.3.6
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.3.6
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.6, at class-wpsc-installation.php

2,589 lines 84.8 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 INT 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 )
1458 );
1459
1460 update_option(
1461 'wpsc-recaptcha-settings',
1462 array(
1463 'allow-recaptcha' => 0,
1464 'recaptcha-version' => 3,
1465 'recaptcha-site-key' => '',
1466 'recaptcha-secret-key' => '',
1467 )
1468 );
1469
1470 update_option(
1471 'wpsc-ms-advanced-settings',
1472 array(
1473 'public-mode' => 0,
1474 'public-mode-reply' => 0,
1475 'reply-confirmation' => 1,
1476 'thread-date-display-as' => 'diff',
1477 'thread-date-format' => 'F d, Y h:i A',
1478 'do-not-notify-owner' => 1,
1479 'do-not-notify-owner-status' => 1,
1480 'ticket-id-format' => 'sequential',
1481 'starting-ticket-id' => 1,
1482 'random-id-length' => 8,
1483 'ticket-history-macro-threads' => 5,
1484 'register-user-if-not-exist' => 0,
1485 'auto-delete-tickets-time' => 0,
1486 'auto-delete-tickets-unit' => 'days',
1487 'permanent-delete-tickets-time' => 0,
1488 'permanent-delete-tickets-unit' => 'days',
1489 'allow-bcc' => 0,
1490 'allow-cc' => 0,
1491 'view-more' => 1,
1492 'allow-reply-to-close-ticket' => array( 'customer', 'agent' ),
1493 'raised-by-user' => 'customer',
1494 'allow-my-profile' => 1,
1495 'allow-agent-profile' => 1,
1496 'ticket-url-auth' => 0,
1497 'rest-api' => 1,
1498 'agent-collision' => 1,
1499 'self-assign' => 1,
1500 'reply-close' => 0,
1501 )
1502 );
1503
1504 $translation = '<p>I agree to the terms and conditions</p>';
1505 $string_translations['wpsc-term-and-conditions'] = $translation;
1506 $string_translations['wpsc-term-and-conditions-reg-user'] = $translation;
1507 update_option(
1508 'wpsc-term-and-conditions',
1509 array(
1510 'allow-term-and-conditions' => 1,
1511 'tandc-text' => $translation,
1512 'editor' => 'html',
1513 'allow-term-and-conditions-reg-user' => 1,
1514 'tandc-text-reg-user' => $translation,
1515 'editor-reg-user' => 'html',
1516 )
1517 );
1518
1519 // ticket widgets.
1520 $labels = array(
1521 'change-status' => esc_attr__( 'Ticket status', 'supportcandy' ),
1522 'raised-by' => esc_attr__( 'Customer', 'supportcandy' ),
1523 'ticket-info' => esc_attr__( 'Ticket info', 'supportcandy' ),
1524 'assignee' => esc_attr__( 'Assignee', 'supportcandy' ),
1525 'ticket-fields' => esc_attr__( 'Ticket fields', 'supportcandy' ),
1526 'agentonly-fields' => esc_attr__( 'Agent only fields', 'supportcandy' ),
1527 'additional-recipients' => esc_attr__( 'Additional recipients', 'supportcandy' ),
1528 'biographical-info' => esc_attr__( 'Biographical Info', 'supportcandy' ),
1529 'tags' => esc_attr__( 'Tags', 'supportcandy' ),
1530 );
1531 foreach ( $labels as $key => $string ) {
1532 $string_translations[ 'wpsc-twt-' . $key ] = $string;
1533 }
1534 update_option(
1535 'wpsc-ticket-widget',
1536 array(
1537 'change-status' => array(
1538 'title' => $labels['change-status'],
1539 'is_enable' => 1,
1540 'allow-customer' => 1,
1541 'allowed-agent-roles' => array( 1, 2 ),
1542 'show-priority-to-customer' => 0,
1543 'callback' => 'wpsc_get_tw_ticket_status()',
1544 'class' => 'WPSC_ITW_Change_Status',
1545 ),
1546 'raised-by' => array(
1547 'title' => $labels['raised-by'],
1548 'is_enable' => 1,
1549 'allow-customer' => 0,
1550 'allowed-agent-roles' => array( 1, 2 ),
1551 'callback' => 'wpsc_get_tw_raised_by()',
1552 'class' => 'WPSC_ITW_Raisedby',
1553 ),
1554 'ticket-info' => array(
1555 'title' => $labels['ticket-info'],
1556 'is_enable' => 1,
1557 'allow-customer' => 0,
1558 'allowed-agent-roles' => array( 1, 2 ),
1559 'callback' => 'wpsc_get_tw_ticket_info()',
1560 'class' => 'WPSC_ITW_Ticket_Info',
1561 ),
1562 'assignee' => array(
1563 'title' => $labels['assignee'],
1564 'is_enable' => 1,
1565 'allow-customer' => 0,
1566 'allowed-agent-roles' => array( 1, 2 ),
1567 'callback' => 'wpsc_get_tw_agents()',
1568 'class' => 'WPSC_ITW_Assigned_Agents',
1569 ),
1570 'ticket-fields' => array(
1571 'title' => $labels['ticket-fields'],
1572 'is_enable' => 1,
1573 'allow-customer' => 1,
1574 'allowed-agent-roles' => array( 1, 2 ),
1575 'callback' => 'wpsc_get_tw_ticket_fields()',
1576 'class' => 'WPSC_ITW_Ticket_Fields',
1577 ),
1578 'agentonly-fields' => array(
1579 'title' => $labels['agentonly-fields'],
1580 'is_enable' => 1,
1581 'allow-customer' => 0,
1582 'allowed-agent-roles' => array( 1, 2 ),
1583 'callback' => 'wpsc_get_tw_agentonly_fields()',
1584 'class' => 'WPSC_ITW_Agentonly_Fields',
1585 ),
1586 'additional-recipients' => array(
1587 'title' => $labels['additional-recipients'],
1588 'is_enable' => 1,
1589 'allow-customer' => 1,
1590 'allowed-agent-roles' => array( 1, 2 ),
1591 'callback' => 'wpsc_get_tw_additional_recipients()',
1592 'class' => 'WPSC_ITW_Additional_Recipients',
1593 ),
1594 'biographical-info' => array(
1595 'title' => $labels['biographical-info'],
1596 'is_enable' => 0,
1597 'allow-customer' => 1,
1598 'allowed-agent-roles' => array( 1, 2 ),
1599 'callback' => 'wpsc_get_tw_biographical_info()',
1600 'class' => 'WPSC_ITW_Biographical_Info',
1601 ),
1602 'tags' => array(
1603 'title' => $labels['tags'],
1604 'is_enable' => 1,
1605 'allow-customer' => 0,
1606 'allowed-agent-roles' => array( 1, 2 ),
1607 'callback' => 'wpsc_get_tw_ticket_tags()',
1608 'class' => 'WPSC_ITW_Ticket_Tags',
1609 ),
1610 )
1611 );
1612
1613 // Rich text editor.
1614 $notice = sprintf(
1615 /* translators: %1$s: attachment max file size, %2$s: allowed file extenstions. */
1616 esc_attr__( 'You can upload files maximum size %1$s mb of types %2$s.', 'supportcandy' ),
1617 20,
1618 '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'
1619 );
1620 update_option(
1621 'wpsc-te-agent',
1622 array(
1623 'enable' => 1,
1624 'allow-attachments' => 1,
1625 'toolbar' => array( 'bold', 'italic', 'underline', 'blockquote', 'alignleft aligncenter alignright', 'bullist', 'numlist', 'rtl', 'link', 'wpsc_insert_editor_img' ),
1626 'file-attachment-notice' => 0,
1627 'file-attachment-notice-text' => $notice,
1628 )
1629 );
1630 update_option(
1631 'wpsc-te-registered-user',
1632 array(
1633 'enable' => 1,
1634 'allow-attachments' => 1,
1635 'toolbar' => array( 'bold', 'italic', 'underline', 'blockquote', 'alignleft aligncenter alignright', 'bullist', 'numlist', 'rtl', 'link', 'wpsc_insert_editor_img' ),
1636 'file-attachment-notice' => 0,
1637 'file-attachment-notice-text' => $notice,
1638 )
1639 );
1640 update_option(
1641 'wpsc-te-guest-user',
1642 array(
1643 'enable' => 0,
1644 'allow-attachments' => 0,
1645 'toolbar' => array( 'bold', 'italic', 'underline', 'blockquote', 'alignleft aligncenter alignright', 'bullist', 'numlist', 'rtl', 'link', 'wpsc_insert_editor_img' ),
1646 'file-attachment-notice' => 0,
1647 'file-attachment-notice-text' => $notice,
1648 )
1649 );
1650 update_option( 'wpsc-te-advanced', array( 'html-pasting' => 0 ) );
1651
1652 // working hrs settings.
1653 update_option(
1654 'wpsc-wh-settings',
1655 array(
1656 'allow-agent-modify-wh' => 0,
1657 'allow-agent-modify-leaves' => 0,
1658 )
1659 );
1660
1661 // appearence settings.
1662 update_option(
1663 'wpsc-ap-general',
1664 array(
1665 'primary-color' => '#313042',
1666 'menu-link-color' => '#fff',
1667 'main-background-color' => '#fff',
1668 'main-text-color' => '#2c3e50',
1669 'link-color' => '#2271b1',
1670 )
1671 );
1672 update_option(
1673 'wpsc-ap-individual-ticket',
1674 array(
1675 'reply-primary-color' => '#2c3e50',
1676 'reply-secondary-color' => '#777777',
1677 'reply-icon-color' => '#777777',
1678 'note-primary-color' => '#8e6600',
1679 'note-secondary-color' => '#8e8d45',
1680 'note-icon-color' => '#8e8d45',
1681 'log-text' => '#2c3e50',
1682 'widget-header-bg-color' => '#fff8e5',
1683 'widget-header-text-color' => '#ff8f2b',
1684 'widget-body-bg-color' => '#f9f9f9',
1685 'widget-body-label-color' => '#777',
1686 'widget-body-text-color' => '#2c3e50',
1687 'reply-close-bg-color' => '#fff',
1688 'reply-close-text-color' => '#707070',
1689 )
1690 );
1691 update_option(
1692 'wpsc-ap-modal',
1693 array(
1694 'header-bg-color' => '#fff8e5',
1695 'header-text-color' => '#ff8f2b',
1696 'body-bg-color' => '#fff',
1697 'body-label-color' => '#777',
1698 'body-text-color' => '#2c3e50',
1699 'footer-bg-color' => '#fff',
1700 'z-index' => 900000000,
1701 )
1702 );
1703 update_option(
1704 'wpsc-ap-agent-collision',
1705 array(
1706 'header-bg-color' => '#e6e6e6',
1707 'header-text-color' => '#2c3e50',
1708 )
1709 );
1710 update_option(
1711 'wpsc-ap-ticket-list',
1712 array(
1713 'list-header-background-color' => '#2c3e50',
1714 'list-header-text-color' => '#fff',
1715 'list-item-odd-background-color' => '#fff',
1716 'list-item-odd-text-color' => '#2c3e50',
1717 'list-item-even-background-color' => '#f2f2f2',
1718 'list-item-even-text-color' => '#2c3e50',
1719 'list-item-hover-background-color' => '#dfe4ea',
1720 'list-item-hover-text-color' => '#2c3e50',
1721 )
1722 );
1723
1724 // ticket tags general setting.
1725 update_option(
1726 'wpsc-ticket-tags-general-settings',
1727 array(
1728 'color' => '#000000',
1729 'bg-color' => '#ffc300',
1730 )
1731 );
1732
1733 // dashboard general setting.
1734 update_option(
1735 'wpsc-ap-dashboard',
1736 array(
1737 'card-body-bg-color' => '#f9f9f9',
1738 'card-body-svg-color' => '#777',
1739 'card-body-text-color' => '#2c3e50',
1740 'widget-body-bg-color' => '#f9f9f9',
1741 'widget-body-svg-color' => '#777',
1742 'widget-body-text-color' => '#2c3e50',
1743 )
1744 );
1745
1746 // upload directory.
1747 $upload_dir = wp_upload_dir();
1748 $filepath = $upload_dir['basedir'] . '/wpsc';
1749 if ( ! file_exists( $filepath ) ) {
1750 mkdir( $filepath, 0755, true );
1751 }
1752
1753 // Dashboard cards.
1754 $labels = array(
1755 'new-tickets' => esc_attr__( 'New Tickets', 'supportcandy' ),
1756 'unresolved' => esc_attr__( 'Unresolved', 'supportcandy' ),
1757 'unassigned' => esc_attr__( 'Unassigned', 'supportcandy' ),
1758 'closed' => esc_attr__( 'Closed', 'supportcandy' ),
1759 'mine' => esc_attr__( 'Mine', 'supportcandy' ),
1760 );
1761 foreach ( $labels as $key => $string ) {
1762 $string_translations[ 'wpsc-dashboard-card-' . $key ] = $string;
1763 }
1764 update_option(
1765 'wpsc-dashboard-cards',
1766 array(
1767 'new-tickets' => array(
1768 'title' => $labels['new-tickets'],
1769 'is_enable' => 1,
1770 'allowed-agent-roles' => array( 1, 2 ),
1771 'callback' => 'wpsc_dbc_new_tickets()',
1772 'class' => 'WPSC_DBC_New_Tickets',
1773 'type' => 'default',
1774 ),
1775 'unresolved' => array(
1776 'title' => $labels['unresolved'],
1777 'is_enable' => 1,
1778 'allowed-agent-roles' => array( 1, 2 ),
1779 'callback' => 'wpsc_dbc_unresolved_tickets()',
1780 'class' => 'WPSC_DBC_Unresolved_Tickets',
1781 'type' => 'default',
1782 ),
1783 'unassigned' => array(
1784 'title' => $labels['unassigned'],
1785 'is_enable' => 1,
1786 'allowed-agent-roles' => array( 1 ),
1787 'callback' => 'wpsc_dbc_unassigned_tickets()',
1788 'class' => 'WPSC_DBC_Unassigned_Tickets',
1789 'type' => 'default',
1790 ),
1791 'closed' => array(
1792 'title' => $labels['closed'],
1793 'is_enable' => 1,
1794 'allowed-agent-roles' => array( 1, 2 ),
1795 'callback' => 'wpsc_dbc_closed_tickets()',
1796 'class' => 'WPSC_DBC_Closed_Tickets',
1797 'type' => 'default',
1798 ),
1799 'mine' => array(
1800 'title' => $labels['mine'],
1801 'is_enable' => 1,
1802 'allowed-agent-roles' => array( 1, 2 ),
1803 'callback' => 'wpsc_dbc_mine_tickets()',
1804 'class' => 'WPSC_DBC_Mine_Tickets',
1805 'type' => 'default',
1806 ),
1807 )
1808 );
1809
1810 // Dashboard widget.
1811 $labels = array(
1812 'ticket-statistics' => esc_attr__( 'Ticket Statistics', 'supportcandy' ),
1813 'todays-trends' => esc_attr__( 'Todays Trends', 'supportcandy' ),
1814 'agent-list' => esc_attr__( 'Agent Workload', 'supportcandy' ),
1815 'recent-activities' => esc_attr__( 'Recent Activities', 'supportcandy' ),
1816 'recent-tickets' => esc_attr__( 'Recent Tickets', 'supportcandy' ),
1817 'category-report' => esc_attr__( 'Tickets by Category', 'supportcandy' ),
1818 'unresolved-priorities' => esc_attr__( 'Tickets by Priority', 'supportcandy' ),
1819 'unresolved-statuses' => esc_attr__( 'Tickets by Status', 'supportcandy' ),
1820 'week-trends' => esc_attr__( 'Ticket statistics by day of week', 'supportcandy' ),
1821 );
1822 foreach ( $labels as $key => $string ) {
1823 $string_translations[ 'wpsc-dashboard-widget-' . $key ] = $string;
1824 }
1825 update_option(
1826 'wpsc-dashboard-widgets',
1827 array(
1828 'ticket-statistics' => array(
1829 'title' => $labels['ticket-statistics'],
1830 'is_enable' => 1,
1831 'allowed-agent-roles' => array( 1, 2 ),
1832 'callback' => 'wpsc_dbw_ticket_statistics()',
1833 'class' => 'WPSC_DBW_Ticket_Statistics',
1834 'type' => 'default',
1835 'chart-type' => '',
1836 ),
1837 'todays-trends' => array(
1838 'title' => $labels['todays-trends'],
1839 'is_enable' => 1,
1840 'allowed-agent-roles' => array( 1, 2 ),
1841 'callback' => 'wpsc_dbw_todays_trends()',
1842 'class' => 'WPSC_DBW_Todays_Trends',
1843 'type' => 'default',
1844 'chart-type' => '',
1845 ),
1846 'agent-list' => array(
1847 'title' => $labels['agent-list'],
1848 'is_enable' => 1,
1849 'allowed-agent-roles' => array( 1 ),
1850 'callback' => 'wpsc_dbw_agent_list()',
1851 'class' => 'WPSC_DBW_Agent_List',
1852 'type' => 'default',
1853 'chart-type' => '',
1854 ),
1855 'recent-activities' => array(
1856 'title' => $labels['recent-activities'],
1857 'is_enable' => 1,
1858 'allowed-agent-roles' => array( 1, 2 ),
1859 'callback' => 'wpsc_dbw_recent_activities()',
1860 'class' => 'WPSC_DBW_Recent_Activities',
1861 'type' => 'default',
1862 'chart-type' => '',
1863 ),
1864 'recent-tickets' => array(
1865 'title' => $labels['recent-tickets'],
1866 'is_enable' => 1,
1867 'allowed-agent-roles' => array( 1, 2 ),
1868 'callback' => 'wpsc_dbw_recent_tickets()',
1869 'class' => 'WPSC_DBW_Recent_Tickets',
1870 'type' => 'default',
1871 'chart-type' => '',
1872 ),
1873 'category-report' => array(
1874 'title' => $labels['category-report'],
1875 'is_enable' => 1,
1876 'allowed-agent-roles' => array( 1, 2 ),
1877 'callback' => 'wpsc_dbw_category_reports()',
1878 'class' => 'WPSC_DBW_Category_Reports',
1879 'type' => 'default',
1880 'chart-type' => 'doughnut',
1881 ),
1882 'unresolved-priorities' => array(
1883 'title' => $labels['unresolved-priorities'],
1884 'is_enable' => 1,
1885 'allowed-agent-roles' => array( 1, 2 ),
1886 'callback' => 'wpsc_dbw_unresolved_priorities()',
1887 'class' => 'WPSC_DBW_Unresolved_Priorities',
1888 'type' => 'default',
1889 'chart-type' => 'horizontal-bar',
1890 ),
1891 'unresolved-statuses' => array(
1892 'title' => $labels['unresolved-statuses'],
1893 'is_enable' => 1,
1894 'allowed-agent-roles' => array( 1, 2 ),
1895 'callback' => 'wpsc_dbw_unresolved_statuses()',
1896 'class' => 'WPSC_DBW_Unresolved_Statuses',
1897 'type' => 'default',
1898 'chart-type' => 'vertical-bar',
1899 ),
1900 'week-trends' => array(
1901 'title' => $labels['week-trends'],
1902 'is_enable' => 1,
1903 'allowed-agent-roles' => array( 1, 2 ),
1904 'callback' => 'WPSC_dbw_week_trend_tickets()',
1905 'class' => 'WPSC_DBW_Week_Trend_Tickets',
1906 'type' => 'default',
1907 'chart-type' => 'vertical-bar',
1908 ),
1909 )
1910 );
1911
1912 // Add dashboard general settings.
1913 update_option(
1914 'wpsc-db-gs-settings',
1915 array(
1916 'default-date-range' => 'last-week',
1917 'allowed-recent-activity-logs' => array( 'report', 'reply', 'note', 'assigned_agent' ),
1918 'dash-auto-refresh' => 0,
1919 )
1920 );
1921
1922 self::attachment_security_file();
1923
1924 // update string translations.
1925 update_option( 'wpsc-string-translation', $string_translations );
1926 }
1927
1928 /**
1929 * Upgrade the version
1930 */
1931 public static function upgrade() {
1932
1933 global $wpdb;
1934 $string_translations = get_option( 'wpsc-string-translation' );
1935
1936 if ( version_compare( self::$current_version, '3.0.4', '<' ) ) {
1937
1938 $advanced = get_option( 'wpsc-ms-advanced-settings' );
1939 $advanced['allow-my-profile'] = 1;
1940 $advanced['allow-agent-profile'] = 1;
1941 update_option( 'wpsc-ms-advanced-settings', $advanced );
1942 }
1943
1944 if ( version_compare( self::$current_version, '3.0.5', '<' ) ) {
1945
1946 $advanced = get_option( 'wpsc-ms-advanced-settings' );
1947 $page_settings = get_option( 'wpsc-gs-page-settings' );
1948 if ( ! isset( $advanced['allow-my-profile'] ) ) {
1949 $advanced['allow-my-profile'] = 1;
1950 $advanced['allow-agent-profile'] = 1;
1951 }
1952 $page_settings['otp-login'] = 1;
1953 update_option( 'wpsc-gs-page-settings', $page_settings );
1954 $advanced['ticket-url-auth'] = 0;
1955 update_option( 'wpsc-ms-advanced-settings', $advanced );
1956 }
1957
1958 if ( version_compare( self::$current_version, '3.0.7', '<' ) ) {
1959
1960 $page_settings = get_option( 'wpsc-gs-page-settings' );
1961 $page_settings['load-scripts'] = 'all-pages';
1962 $page_settings['load-script-pages'] = array();
1963 update_option( 'wpsc-gs-page-settings', $page_settings );
1964 }
1965
1966 if ( version_compare( self::$current_version, '3.1.1', '<' ) ) {
1967
1968 $ap_general = get_option( 'wpsc-ap-general' );
1969 $ap_general['menu-link-color'] = '#fff';
1970 update_option( 'wpsc-ap-general', $ap_general );
1971 }
1972
1973 if ( version_compare( self::$current_version, '3.1.3', '<' ) ) {
1974
1975 $advanced = get_option( 'wpsc-ms-advanced-settings' );
1976 $advanced['rest-api'] = 1;
1977 update_option( 'wpsc-ms-advanced-settings', $advanced );
1978 }
1979
1980 if ( version_compare( self::$current_version, '3.1.4', '<' ) ) {
1981
1982 // add scheduled task for ticket data upgrade.
1983 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='update_ticket_attachment_path'" ) ) {
1984 $wpdb->insert(
1985 $wpdb->prefix . 'psmsc_scheduled_tasks',
1986 array(
1987 'class' => 'WPSC_SC_Upgrade',
1988 'method' => 'update_ticket_attachment_path',
1989 'is_manual' => 1,
1990 'warning_text' => 'SupportCandy - Database attachment paths upgrade needed.',
1991 'warning_link_text' => 'Upgrade Now',
1992 'progressbar_text' => 'Updating attachment paths...',
1993 )
1994 );
1995 }
1996
1997 self::attachment_security_file();
1998 }
1999
2000 if ( version_compare( self::$current_version, '3.1.5', '<' ) ) {
2001
2002 // scheduled task for setting conditions upgrade.
2003 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='upgrade_setting_conditions'" ) ) {
2004 $wpdb->insert(
2005 $wpdb->prefix . 'psmsc_scheduled_tasks',
2006 array(
2007 'class' => 'WPSC_SC_Upgrade',
2008 'method' => 'upgrade_setting_conditions',
2009 'is_manual' => 0,
2010 )
2011 );
2012 }
2013
2014 // scheduled task for saved filter conditions upgrade.
2015 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='upgrade_saved_filter_conditions'" ) ) {
2016 $wpdb->insert(
2017 $wpdb->prefix . 'psmsc_scheduled_tasks',
2018 array(
2019 'class' => 'WPSC_SC_Upgrade',
2020 'method' => 'upgrade_saved_filter_conditions',
2021 'is_manual' => 1,
2022 'warning_text' => 'SupportCandy - Filters database upgrade needed.',
2023 'warning_link_text' => 'Upgrade Now',
2024 'progressbar_text' => 'Upgrading filters...',
2025 )
2026 );
2027 }
2028 }
2029
2030 if ( version_compare( self::$current_version, '3.1.6', '<' ) ) {
2031
2032 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='repaire_setting_conditions'" ) ) {
2033 $wpdb->insert(
2034 $wpdb->prefix . 'psmsc_scheduled_tasks',
2035 array(
2036 'class' => 'WPSC_SC_Upgrade',
2037 'method' => 'repaire_setting_conditions',
2038 'is_manual' => 0,
2039 )
2040 );
2041 }
2042
2043 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='repaire_saved_filter_conditions'" ) ) {
2044 $wpdb->insert(
2045 $wpdb->prefix . 'psmsc_scheduled_tasks',
2046 array(
2047 'class' => 'WPSC_SC_Upgrade',
2048 'method' => 'repaire_saved_filter_conditions',
2049 'is_manual' => 1,
2050 'warning_text' => 'SupportCandy - Filters database upgrade needed.',
2051 'warning_link_text' => 'Upgrade Now',
2052 'progressbar_text' => 'Upgrading filters...',
2053 )
2054 );
2055 }
2056 }
2057
2058 if ( version_compare( self::$current_version, '3.1.7', '<' ) ) {
2059
2060 $gs = get_option( 'wpsc-gs-general' );
2061 $gs['allowed-search-fields'] = array( 'id', 'customer', 'subject', 'threads' );
2062 update_option( 'wpsc-gs-general', $gs );
2063
2064 $en = get_option( 'wpsc-en-general' );
2065 $en['attachments-in-notification'] = 'actual-files';
2066 update_option( 'wpsc-en-general', $en );
2067 }
2068
2069 if ( version_compare( self::$current_version, '3.1.9', '<' ) ) {
2070
2071 // add scheduled task for attachment status upgrade.
2072 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='update_ticket_attachment_status'" ) ) {
2073 $wpdb->insert(
2074 $wpdb->prefix . 'psmsc_scheduled_tasks',
2075 array(
2076 'class' => 'WPSC_SC_Upgrade',
2077 'method' => 'update_ticket_attachment_status',
2078 'is_manual' => 1,
2079 'warning_text' => 'SupportCandy - Database attachment status upgrade needed.',
2080 'warning_link_text' => 'Upgrade Now',
2081 'progressbar_text' => 'Updating attachment status...',
2082 )
2083 );
2084 }
2085 }
2086
2087 if ( version_compare( self::$current_version, '3.2.0', '<' ) ) {
2088
2089 $roles = get_option( 'wpsc-agent-roles' );
2090 foreach ( $roles as $key => $role ) {
2091 $role['caps']['dt-unassigned'] = true;
2092 $role['caps']['dt-assigned-me'] = true;
2093 $role['caps']['dt-assigned-others'] = true;
2094
2095 $roles[ $key ] = $role;
2096 }
2097 update_option( 'wpsc-agent-roles', $roles );
2098
2099 // set customer custom fields as personal info.
2100 $wpdb->update(
2101 $wpdb->prefix . 'psmsc_custom_fields',
2102 array( 'is_personal_info' => 1 ),
2103 array( 'field' => 'customer' )
2104 );
2105 }
2106
2107 if ( version_compare( self::$current_version, '3.2.1', '<' ) ) {
2108
2109 $thankyou = get_option( 'wpsc-gs-thankyou-page-settings' );
2110 if ( $thankyou['thank-you-page-url'] ) {
2111 $action = 'url';
2112 } else {
2113 $action = 'text';
2114 }
2115
2116 update_option(
2117 'wpsc-gs-thankyou-page-settings',
2118 array(
2119 'action-agent' => $action,
2120 'action-customer' => $action,
2121 'html-agent' => $thankyou['thankyou-html'],
2122 'html-customer' => $thankyou['thankyou-html'],
2123 'page-url-agent' => $thankyou['thank-you-page-url'],
2124 'page-url-customer' => $thankyou['thank-you-page-url'],
2125 'editor-agent' => $thankyou['editor'],
2126 'editor-customer' => $thankyou['editor'],
2127 )
2128 );
2129 $string_translations['wpsc-thankyou-html-agent'] = $thankyou['thankyou-html'];
2130
2131 update_option( 'wpsc-string-translation', $string_translations );
2132
2133 // ticket tags.
2134 $widgets = get_option( 'wpsc-ticket-widget', array() );
2135 if ( ! isset( $widgets['tags'] ) ) {
2136
2137 $agent_roles = array_keys( get_option( 'wpsc-agent-roles', array() ) );
2138 $label = esc_attr( wpsc__( 'Tags', 'supportcandy' ) );
2139 $widgets['tags'] = array(
2140 'title' => $label,
2141 'is_enable' => 1,
2142 'allow-customer' => 0,
2143 'allowed-agent-roles' => $agent_roles,
2144 'callback' => 'wpsc_get_tw_ticket_tags()',
2145 'class' => 'WPSC_ITW_Ticket_Tags',
2146 );
2147 update_option( 'wpsc-ticket-widget', $widgets );
2148
2149 $string_translations['wpsc-twt-tags'] = $label;
2150
2151 }
2152
2153 $tag_exists = $wpdb->get_results( "SELECT id from {$wpdb->prefix}psmsc_custom_fields WHERE slug = 'tags'" );
2154 if ( empty( $tag_exists ) ) {
2155 $name = esc_attr__( 'Tags', 'supportcandy' );
2156 $wpdb->insert(
2157 $wpdb->prefix . 'psmsc_custom_fields',
2158 array(
2159 'name' => $name,
2160 'slug' => 'tags',
2161 'field' => 'ticket',
2162 'type' => 'df_tags',
2163 'is_personal_info' => 0,
2164 'tl_width' => 100,
2165 'load_order' => 24,
2166 )
2167 );
2168 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
2169 }
2170
2171 $roles = get_option( 'wpsc-agent-roles' );
2172 foreach ( $roles as $key => $role ) {
2173 $role['caps']['tt-unassigned'] = true;
2174 $role['caps']['tt-assigned-me'] = true;
2175 $role['caps']['tt-assigned-others'] = true;
2176
2177 $roles[ $key ] = $role;
2178 }
2179 update_option( 'wpsc-agent-roles', $roles );
2180
2181 // ticket tags general setting.
2182 update_option(
2183 'wpsc-ticket-tags-general-settings',
2184 array(
2185 'color' => '#000000',
2186 'bg-color' => '#ffc300',
2187 )
2188 );
2189
2190 // Add agent collision appearance setting.
2191 update_option(
2192 'wpsc-ap-agent-collision',
2193 array(
2194 'header-bg-color' => '#e6e6e6',
2195 'header-text-color' => '#2c3e50',
2196 )
2197 );
2198
2199 // Add agent collision setting.
2200 $ms_advanced = get_option( 'wpsc-ms-advanced-settings' );
2201 $ms_advanced['agent-collision'] = 1;
2202 update_option( 'wpsc-ms-advanced-settings', $ms_advanced );
2203 }
2204
2205 if ( version_compare( self::$current_version, '3.2.2', '<' ) ) {
2206
2207 // add anonymuos customer to customer table.
2208 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_customers WHERE email='[email protected]'" ) ) {
2209
2210 $success = $wpdb->insert(
2211 $wpdb->prefix . 'psmsc_customers',
2212 array(
2213 'name' => 'Anonymous',
2214 'email' => '[email protected]',
2215 )
2216 );
2217 if ( $success ) {
2218 update_option( 'wpsc-anonymous-user-id', $wpdb->insert_id );
2219 }
2220 }
2221
2222 $advanced = get_option( 'wpsc-ms-advanced-settings' );
2223 $advanced['self-assign'] = 0;
2224 update_option( 'wpsc-ms-advanced-settings', $advanced );
2225 }
2226
2227 if ( version_compare( self::$current_version, '3.2.4', '<' ) ) {
2228
2229 // add default true to admin and agent dashboard access.
2230 $roles = get_option( 'wpsc-agent-roles' );
2231 $role_keys = array();
2232 foreach ( $roles as $key => $role ) {
2233 $role['caps']['dash-access'] = true;
2234 $roles[ $key ] = $role;
2235 $role_keys[] = $key;
2236 }
2237
2238 // Dashboard cards.
2239 $labels = array(
2240 'new-tickets' => esc_attr__( 'New Tickets', 'supportcandy' ),
2241 'unresolved' => esc_attr__( 'Unresolved', 'supportcandy' ),
2242 'unassigned' => esc_attr__( 'Unassigned', 'supportcandy' ),
2243 'closed' => esc_attr__( 'Closed', 'supportcandy' ),
2244 'mine' => esc_attr__( 'Mine', 'supportcandy' ),
2245 );
2246 foreach ( $labels as $key => $string ) {
2247 $string_translations[ 'wpsc-dashboard-card-' . $key ] = $string;
2248 }
2249 update_option(
2250 'wpsc-dashboard-cards',
2251 array(
2252 'new-tickets' => array(
2253 'title' => $labels['new-tickets'],
2254 'is_enable' => 1,
2255 'allowed-agent-roles' => $role_keys,
2256 'callback' => 'wpsc_dbc_new_tickets()',
2257 'class' => 'WPSC_DBC_New_Tickets',
2258 'type' => 'default',
2259 ),
2260 'unresolved' => array(
2261 'title' => $labels['unresolved'],
2262 'is_enable' => 1,
2263 'allowed-agent-roles' => $role_keys,
2264 'callback' => 'wpsc_dbc_unresolved_tickets()',
2265 'class' => 'WPSC_DBC_Unresolved_Tickets',
2266 'type' => 'default',
2267 ),
2268 'unassigned' => array(
2269 'title' => $labels['unassigned'],
2270 'is_enable' => 1,
2271 'allowed-agent-roles' => array( 1 ),
2272 'callback' => 'wpsc_dbc_unassigned_tickets()',
2273 'class' => 'WPSC_DBC_Unassigned_Tickets',
2274 'type' => 'default',
2275 ),
2276 'closed' => array(
2277 'title' => $labels['closed'],
2278 'is_enable' => 1,
2279 'allowed-agent-roles' => $role_keys,
2280 'callback' => 'wpsc_dbc_closed_tickets()',
2281 'class' => 'WPSC_DBC_Closed_Tickets',
2282 'type' => 'default',
2283 ),
2284 'mine' => array(
2285 'title' => $labels['mine'],
2286 'is_enable' => 1,
2287 'allowed-agent-roles' => $role_keys,
2288 'callback' => 'wpsc_dbc_mine_tickets()',
2289 'class' => 'WPSC_DBC_Mine_Tickets',
2290 'type' => 'default',
2291 ),
2292 )
2293 );
2294
2295 // Dashboard widget.
2296 $labels = array(
2297 'ticket-statistics' => esc_attr__( 'Ticket Statistics', 'supportcandy' ),
2298 'todays-trends' => esc_attr__( 'Todays Trends', 'supportcandy' ),
2299 'agent-list' => esc_attr__( 'Agent Workload', 'supportcandy' ),
2300 'recent-activities' => esc_attr__( 'Recent Activities', 'supportcandy' ),
2301 'recent-tickets' => esc_attr__( 'Recent Tickets', 'supportcandy' ),
2302 'category-report' => esc_attr__( 'Unresolved tickets by Category', 'supportcandy' ),
2303 'unresolved-priorities' => esc_attr__( 'Unresolved tickets by Priority', 'supportcandy' ),
2304 'unresolved-statuses' => esc_attr__( 'Unresolved tickets by Status', 'supportcandy' ),
2305 );
2306 foreach ( $labels as $key => $string ) {
2307 $string_translations[ 'wpsc-dashboard-widget-' . $key ] = $string;
2308 }
2309 update_option(
2310 'wpsc-dashboard-widgets',
2311 array(
2312 'ticket-statistics' => array(
2313 'title' => $labels['ticket-statistics'],
2314 'is_enable' => 1,
2315 'allowed-agent-roles' => $role_keys,
2316 'callback' => 'wpsc_dbw_ticket_statistics()',
2317 'class' => 'WPSC_DBW_Ticket_Statistics',
2318 'type' => 'default',
2319 'chart-type' => '',
2320 ),
2321 'todays-trends' => array(
2322 'title' => $labels['todays-trends'],
2323 'is_enable' => 1,
2324 'allowed-agent-roles' => $role_keys,
2325 'callback' => 'wpsc_dbw_todays_trends()',
2326 'class' => 'WPSC_DBW_Todays_Trends',
2327 'type' => 'default',
2328 'chart-type' => '',
2329 ),
2330 'agent-list' => array(
2331 'title' => $labels['agent-list'],
2332 'is_enable' => 1,
2333 'allowed-agent-roles' => array( 1 ),
2334 'callback' => 'wpsc_dbw_agent_list()',
2335 'class' => 'WPSC_DBW_Agent_List',
2336 'type' => 'default',
2337 'chart-type' => '',
2338 ),
2339 'recent-activities' => array(
2340 'title' => $labels['recent-activities'],
2341 'is_enable' => 1,
2342 'allowed-agent-roles' => $role_keys,
2343 'callback' => 'wpsc_dbw_recent_activities()',
2344 'class' => 'WPSC_DBW_Recent_Activities',
2345 'type' => 'default',
2346 'chart-type' => '',
2347 ),
2348 'recent-tickets' => array(
2349 'title' => $labels['recent-tickets'],
2350 'is_enable' => 1,
2351 'allowed-agent-roles' => $role_keys,
2352 'callback' => 'wpsc_dbw_recent_tickets()',
2353 'class' => 'WPSC_DBW_Recent_Tickets',
2354 'type' => 'default',
2355 'chart-type' => '',
2356 ),
2357 'category-report' => array(
2358 'title' => $labels['category-report'],
2359 'is_enable' => 1,
2360 'allowed-agent-roles' => $role_keys,
2361 'callback' => 'wpsc_dbw_category_reports()',
2362 'class' => 'WPSC_DBW_Category_Reports',
2363 'type' => 'default',
2364 'chart-type' => 'doughnut',
2365 ),
2366 'unresolved-priorities' => array(
2367 'title' => $labels['unresolved-priorities'],
2368 'is_enable' => 1,
2369 'allowed-agent-roles' => $role_keys,
2370 'callback' => 'wpsc_dbw_unresolved_priorities()',
2371 'class' => 'WPSC_DBW_Unresolved_Priorities',
2372 'type' => 'default',
2373 'chart-type' => 'horizontal-bar',
2374 ),
2375 'unresolved-statuses' => array(
2376 'title' => $labels['unresolved-statuses'],
2377 'is_enable' => 1,
2378 'allowed-agent-roles' => $role_keys,
2379 'callback' => 'wpsc_dbw_unresolved_statuses()',
2380 'class' => 'WPSC_DBW_Unresolved_Statuses',
2381 'type' => 'default',
2382 'chart-type' => 'vertical-bar',
2383 ),
2384 )
2385 );
2386
2387 // dashboard appreance general setting.
2388 update_option(
2389 'wpsc-ap-dashboard',
2390 array(
2391 'card-body-bg-color' => '#f9f9f9',
2392 'card-body-svg-color' => '#777',
2393 'card-body-text-color' => '#2c3e50',
2394 'widget-body-bg-color' => '#f9f9f9',
2395 'widget-body-svg-color' => '#777',
2396 'widget-body-text-color' => '#2c3e50',
2397 )
2398 );
2399
2400 // Add dashboard general settings.
2401 update_option(
2402 'wpsc-db-gs-settings',
2403 array(
2404 'default-date-range' => 'last-week',
2405 'allowed-recent-activity-logs' => array( 'report', 'reply', 'note', 'assigned_agent' ),
2406 )
2407 );
2408 update_option( 'wpsc-agent-roles', $roles );
2409 }
2410
2411 if ( version_compare( self::$current_version, '3.2.5', '<' ) ) {
2412
2413 $file_attachments = get_option( 'wpsc-gs-file-attachments' );
2414
2415 require_once WPSC_ABSPATH . 'includes/class-wpsc-mime-types.php';
2416
2417 $exts = $file_attachments['allowed-file-extensions'] ? explode( ',', $file_attachments['allowed-file-extensions'] ) : array();
2418 $exts = array_map( 'trim', $exts );
2419 $mimes = array();
2420 foreach ( $exts as $key => $value ) {
2421 $mime = WPSC_MIME_TYPES::get_mime_type( $value );
2422 if ( $mime ) {
2423 $mimes[ $value ] = $mime;
2424 }
2425 }
2426 $file_attachments['allowed-file-ext-mimes'] = $mimes;
2427 $file_attachments['mime-exceptions'] = array();
2428
2429 update_option( 'wpsc-gs-file-attachments', $file_attachments );
2430 }
2431
2432 if ( version_compare( self::$current_version, '3.2.6', '<' ) ) {
2433
2434 // Add dashboard general settings.
2435 $db_gs = get_option( 'wpsc-db-gs-settings', array() );
2436 $db_gs['dash-auto-refresh'] = 0;
2437 update_option( 'wpsc-db-gs-settings', $db_gs );
2438
2439 $wpdb->update(
2440 $wpdb->prefix . 'psmsc_custom_fields',
2441 array( 'number_type' => 'integer' ),
2442 array( 'type' => 'cf_number' )
2443 );
2444 }
2445
2446 if ( version_compare( self::$current_version, '3.2.7', '<' ) ) {
2447
2448 $ms_advanced = get_option( 'wpsc-ms-advanced-settings' );
2449 $ms_advanced['reply-close'] = 1;
2450 update_option( 'wpsc-ms-advanced-settings', $ms_advanced );
2451
2452 $appearance = get_option( 'wpsc-ap-individual-ticket' );
2453 $appearance['reply-close-bg-color'] = '#fff';
2454 $appearance['reply-close-text-color'] = '#707070';
2455 update_option( 'wpsc-ap-individual-ticket', $appearance );
2456
2457 $lrs_exists = $wpdb->get_results( "SELECT id from {$wpdb->prefix}psmsc_custom_fields WHERE slug = 'last_reply_source'" );
2458 if ( empty( $lrs_exists ) ) {
2459
2460 $name = esc_attr__( 'Last Reply Source', 'supportcandy' );
2461 $wpdb->insert(
2462 $wpdb->prefix . 'psmsc_custom_fields',
2463 array(
2464 'name' => $name,
2465 'slug' => 'last_reply_source',
2466 'field' => 'ticket',
2467 'type' => 'df_last_reply_source',
2468 'is_personal_info' => 0,
2469 'tl_width' => 100,
2470 'load_order' => 26,
2471 )
2472 );
2473 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
2474 }
2475
2476 // GDPR option in user registration.
2477 $gdpr = get_option( 'wpsc-gdpr-settings', array() );
2478 $gdpr_text = '<p>I understand my personal information like Name, Email address, IP address, etc. will be stored in database.</p>';
2479 $gdpr['allow-gdpr-reg-user'] = 0;
2480 $gdpr['gdpr-text-reg-user'] = $gdpr_text;
2481 $gdpr['editor-reg-user'] = 'html';
2482 update_option( 'wpsc-gdpr-settings', $gdpr );
2483 $string_translations['wpsc-gdpr-reg-user'] = $gdpr_text;
2484
2485 // T&C option in user registration.
2486 $tandc = get_option( 'wpsc-term-and-conditions', array() );
2487 $tandc_text = '<p>I agree to the terms and conditions</p>';
2488 $tandc['allow-term-and-conditions-reg-user'] = 0;
2489 $tandc['tandc-text-reg-user'] = $tandc_text;
2490 $tandc['editor-reg-user'] = 'html';
2491 update_option( 'wpsc-term-and-conditions', $tandc );
2492 $string_translations['wpsc-term-and-conditions-reg-user'] = $tandc_text;
2493 }
2494
2495 if ( version_compare( self::$current_version, '3.2.8', '<' ) ) {
2496
2497 $widgets = get_option( 'wpsc-dashboard-widgets', array() );
2498 if ( ! isset( $widgets['week-trends'] ) ) {
2499 $label = esc_attr__( 'Ticket statistics by day of week', 'supportcandy' );
2500 $string_translations['wpsc-dashboard-widget-week-trends'] = $label;
2501 $widgets['week-trends'] = array(
2502 'title' => $label,
2503 'is_enable' => 1,
2504 'allowed-agent-roles' => array( 1 ),
2505 'callback' => 'wpsc_dbw_week_trend_tickets()',
2506 'class' => 'WPSC_DBW_Week_Trend_Tickets',
2507 'type' => 'default',
2508 'chart-type' => 'vertical-bar',
2509 );
2510 }
2511 update_option( 'wpsc-dashboard-widgets', $widgets );
2512 }
2513
2514 if ( version_compare( self::$current_version, '3.2.9', '<' ) ) {
2515
2516 // scheduled task for updating image editor attachment path in thread body.
2517 if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_scheduled_tasks WHERE class='WPSC_SC_Upgrade' AND method='upgrade_ie_attachment_path'" ) ) {
2518 $wpdb->insert(
2519 $wpdb->prefix . 'psmsc_scheduled_tasks',
2520 array(
2521 'class' => 'WPSC_SC_Upgrade',
2522 'method' => 'upgrade_ie_attachment_path',
2523 'is_manual' => 1,
2524 'warning_text' => 'SupportCandy - attachment security upgrade needed.',
2525 'warning_link_text' => 'Upgrade Now',
2526 'progressbar_text' => 'Updating attachment ...',
2527 )
2528 );
2529 }
2530
2531 // unschedule old upgrade task.
2532 $upgrade = get_option( 'wpsc_upgrade_cleanup', array() );
2533 if ( empty( $upgrade ) ) {
2534
2535 $timestamp = wp_next_scheduled( 'wpsc_v1_upgrade_cleanup' );
2536 if ( $timestamp ) {
2537 wp_unschedule_event( $timestamp, 'wpsc_v1_upgrade_cleanup' );
2538 }
2539 $timestamp = wp_next_scheduled( 'wpsc_v2_upgrade_cleanup' );
2540 if ( $timestamp ) {
2541 wp_unschedule_event( $timestamp, 'wpsc_v2_upgrade_cleanup' );
2542 }
2543 }
2544 }
2545
2546 update_option( 'wpsc-string-translation', $string_translations );
2547 self::set_upgrade_complete();
2548 }
2549
2550 /**
2551 * Mark upgrade as complete
2552 */
2553 public static function set_upgrade_complete() {
2554
2555 update_option( 'wpsc_current_version', WPSC_VERSION );
2556 update_option( 'wpsc_db_version', WPSC_DB_VERSION );
2557 self::$current_version = WPSC_VERSION;
2558 self::$is_upgrade = false;
2559 }
2560
2561 /**
2562 * Actions to perform after plugin deactivated
2563 *
2564 * @return void
2565 */
2566 public static function deactivate() {
2567
2568 // Remove cron jobs.
2569 WPSC_Cron::unschedule_events();
2570 }
2571
2572 /**
2573 * Add htaccess file in supportcandy attachment folder
2574 *
2575 * @return void
2576 */
2577 public static function attachment_security_file() {
2578
2579 $upload_dir = wp_upload_dir();
2580 $wpsc_dir = $upload_dir['basedir'] . '/wpsc';
2581 if ( ! is_file( $wpsc_dir . '/.htaccess' ) ) {
2582 @file_put_contents( $wpsc_dir . '/.htaccess', 'deny from all' ); //phpcs:ignore
2583 }
2584 }
2585 }
2586 endif;
2587
2588 WPSC_Installation::init();
2589