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

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