2015-02-01 22:17:51 -05:00
< ? php
2015-02-03 00:21:06 -05:00
require ( HESK_PATH . 'hesk_settings.inc.php' );
2015-09-12 00:46:46 -04:00
function executeQuery ( $sql )
{
2015-03-14 01:28:14 -04:00
global $hesk_last_query ;
global $hesk_db_link ;
2015-09-12 00:46:46 -04:00
if ( function_exists ( 'mysqli_connect' )) {
2015-02-04 23:51:12 -05:00
2015-09-12 00:46:46 -04:00
if ( ! $hesk_db_link && ! hesk_dbConnect ()) {
2015-02-04 23:51:12 -05:00
return false ;
}
$hesk_last_query = $sql ;
2015-09-12 00:46:46 -04:00
if ( $res = @ mysqli_query ( $hesk_db_link , $sql )) {
2015-02-04 23:51:12 -05:00
return $res ;
2015-09-12 00:46:46 -04:00
} else {
2015-02-04 23:51:12 -05:00
http_response_code ( 500 );
2016-11-25 15:59:43 -05:00
print " Could not execute query: $sql . MySQL said: " . mysqli_error ( $hesk_db_link );
2015-02-04 23:51:12 -05:00
die ();
}
} else {
2015-09-12 00:46:46 -04:00
if ( ! $hesk_db_link && ! hesk_dbConnect ()) {
2015-02-04 23:51:12 -05:00
return false ;
}
$hesk_last_query = $sql ;
2015-09-12 00:46:46 -04:00
if ( $res = @ mysql_query ( $sql , $hesk_db_link )) {
2015-02-04 23:51:12 -05:00
return $res ;
2015-09-12 00:46:46 -04:00
} else {
2015-02-04 23:51:12 -05:00
http_response_code ( 500 );
2016-11-25 15:59:43 -05:00
print " Could not execute query: $sql . MySQL said: " . mysql_error ();
2015-02-04 23:51:12 -05:00
die ();
}
}
2015-02-03 00:21:06 -05:00
}
2015-02-01 22:17:51 -05:00
// Version 1.0.0 - <1.4.0
2015-09-12 00:46:46 -04:00
function executePre140Scripts ()
{
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2016-11-25 15:59:43 -05:00
2015-02-01 22:17:51 -05:00
//-- Need to do this since we are no longer restricted on IDs and we want an INT for proper INNER JOINs
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `status_int` INT NOT NULL DEFAULT 0 AFTER `status`; " );
2015-02-03 00:21:06 -05:00
2015-09-12 00:46:46 -04:00
$ticketsRS = executeQuery ( " SELECT `id`, `status` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets`; " );
2016-06-07 12:16:17 -04:00
while ( $currentResult = hesk_dbFetchAssoc ( $ticketsRS )) {
2015-02-03 00:21:06 -05:00
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` SET `status_int` = " . $currentResult [ 'status' ] . " WHERE `id` = " . $currentResult [ 'id' ]);
2015-02-01 22:17:51 -05:00
}
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` DROP COLUMN `status` " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` CHANGE COLUMN `status_int` `status` INT NOT NULL " );
2015-02-01 22:17:51 -05:00
2015-09-12 00:46:46 -04:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` (
2015-02-01 22:17:51 -05:00
`ID` INT NOT NULL ,
`ShortNameContentKey` TEXT NOT NULL ,
`TicketViewContentKey` TEXT NOT NULL ,
`TextColor` TEXT NOT NULL ,
2016-06-07 12:19:56 -04:00
`IsNewTicketStatus` INT NOT NULL DEFAULT 0 ,
`IsClosed` INT NOT NULL DEFAULT 0 ,
`IsClosedByClient` INT NOT NULL DEFAULT 0 ,
`IsCustomerReplyStatus` INT NOT NULL DEFAULT 0 ,
`IsStaffClosedOption` INT NOT NULL DEFAULT 0 ,
`IsStaffReopenedStatus` INT NOT NULL DEFAULT 0 ,
`IsDefaultStaffReplyStatus` INT NOT NULL DEFAULT 0 ,
`LockedTicketStatus` INT NOT NULL DEFAULT 0 ,
2015-02-01 22:17:51 -05:00
PRIMARY KEY ( `ID` )) " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
2015-02-01 22:17:51 -05:00
IsStaffClosedOption , IsStaffReopenedStatus , IsDefaultStaffReplyStatus , LockedTicketStatus )
VALUES ( 0 , 'open' , 'open' , '#FF0000' , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ); " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
2015-02-01 22:17:51 -05:00
IsStaffClosedOption , IsStaffReopenedStatus , IsDefaultStaffReplyStatus , LockedTicketStatus )
VALUES ( 1 , 'wait_reply' , 'wait_staff_reply' , '#FF9933' , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 ); " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
2015-02-01 22:17:51 -05:00
IsStaffClosedOption , IsStaffReopenedStatus , IsDefaultStaffReplyStatus , LockedTicketStatus )
VALUES ( 2 , 'replied' , 'wait_cust_reply' , '#0000FF' , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 ); " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
2015-02-01 22:17:51 -05:00
IsStaffClosedOption , IsStaffReopenedStatus , IsDefaultStaffReplyStatus , LockedTicketStatus )
VALUES ( 3 , 'resolved' , 'resolved' , '#008000' , 0 , 1 , 1 , 0 , 1 , 0 , 0 , 1 ); " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
2015-02-01 22:17:51 -05:00
IsStaffClosedOption , IsStaffReopenedStatus , IsDefaultStaffReplyStatus , LockedTicketStatus )
VALUES ( 4 , 'in_progress' , 'in_progress' , '#000000' , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ); " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
2015-02-01 22:17:51 -05:00
IsStaffClosedOption , IsStaffReopenedStatus , IsDefaultStaffReplyStatus , LockedTicketStatus )
VALUES ( 5 , 'on_hold' , 'on_hold' , '#000000' , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ); " );
2015-08-02 16:32:23 -04:00
2015-09-12 00:46:46 -04:00
$keyRs = executeQuery ( " SHOW KEYS FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` WHERE Key_name='statuses' " );
if ( hesk_dbNumRows ( $keyRs ) == 0 ) {
2015-08-02 16:32:23 -04:00
//-- Add the key
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD KEY `statuses` (`status`) " );
2015-08-02 16:32:23 -04:00
}
2015-02-01 22:17:51 -05:00
}
// Version 1.4.0
2015-09-12 00:46:46 -04:00
function execute140Scripts ()
{
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` ADD COLUMN `autorefresh` BIGINT NOT NULL DEFAULT 0 AFTER `replies`; " );
2015-02-01 22:17:51 -05:00
2015-09-12 00:46:46 -04:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " denied_ips` (
2015-02-01 22:17:51 -05:00
`ID` INT NOT NULL PRIMARY KEY AUTO_INCREMENT ,
`RangeStart` VARCHAR ( 100 ) NOT NULL ,
`RangeEnd` VARCHAR ( 100 ) NOT NULL ) " );
}
// Version 1.4.1
2015-09-12 00:46:46 -04:00
function execute141Scripts ()
{
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " denied_emails` (ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, Email VARCHAR(100) NOT NULL); " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `parent` MEDIUMINT(8) NULL AFTER `custom20`; " );
2015-02-01 22:17:51 -05:00
}
// Version 1.5.0
2015-09-12 00:46:46 -04:00
function execute150Scripts ()
{
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` ADD COLUMN `active` ENUM('0', '1') NOT NULL DEFAULT '1' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` ADD COLUMN `can_manage_settings` ENUM('0', '1') NOT NULL DEFAULT '1' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` ADD COLUMN `default_notify_customer_email` ENUM ('0', '1') NOT NULL DEFAULT '1' " );
2015-02-01 22:17:51 -05:00
}
// Version 1.6.0
2015-09-12 00:46:46 -04:00
function execute160Scripts ()
{
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` ADD COLUMN `notify_note_unassigned` ENUM('0', '1') NOT NULL DEFAULT '0' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` ADD COLUMN `can_change_notification_settings` ENUM('0', '1') NOT NULL DEFAULT '1' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " notes` ADD COLUMN `edit_date` DATETIME NULL " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " notes` ADD COLUMN `number_of_edits` INT NOT NULL DEFAULT 0 " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " attachments` ADD COLUMN `note_id` INT NULL AFTER `ticket_id` " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " attachments` MODIFY COLUMN `ticket_id` VARCHAR(13) NULL " );
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key` NVARCHAR(200) NOT NULL, `Value` NVARCHAR(200) NOT NULL) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('modsForHeskVersion', '1.6.0') " );
2015-02-01 22:17:51 -05:00
}
// Version 1.6.1
2015-09-12 00:46:46 -04:00
function execute161Scripts ()
{
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '1.6.1' WHERE `Key` = 'modsForHeskVersion' " );
2015-02-01 22:17:51 -05:00
}
// BEGIN Version 1.7.0
2015-09-12 00:46:46 -04:00
function execute170Scripts ()
{
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " verified_emails` (`Email` VARCHAR(255) NOT NULL) " );
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " pending_verification_emails` (`Email` VARCHAR(255) NOT NULL, `ActivationKey` VARCHAR(500) NOT NULL) " );
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` (
2015-02-01 22:17:51 -05:00
`id` mediumint ( 8 ) unsigned NOT NULL AUTO_INCREMENT ,
`trackid` varchar ( 13 ) COLLATE utf8_unicode_ci NOT NULL ,
`name` varchar ( 50 ) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' ,
`email` varchar ( 255 ) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' ,
`category` smallint ( 5 ) unsigned NOT NULL DEFAULT '1' ,
`priority` enum ( '0' , '1' , '2' , '3' ) COLLATE utf8_unicode_ci NOT NULL DEFAULT '3' ,
`subject` varchar ( 70 ) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' ,
`message` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
2016-11-25 15:59:43 -05:00
`dt` timestamp NOT NULL DEFAULT '2000-01-01 00:00:00' ,
2015-02-01 22:17:51 -05:00
`lastchange` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
`ip` varchar ( 46 ) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' ,
`language` varchar ( 50 ) COLLATE utf8_unicode_ci DEFAULT NULL ,
`status` int ( 11 ) NOT NULL DEFAULT '0' ,
`owner` smallint ( 5 ) unsigned NOT NULL DEFAULT '0' ,
`time_worked` time NOT NULL DEFAULT '00:00:00' ,
`lastreplier` enum ( '0' , '1' ) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0' ,
`replierid` smallint ( 5 ) unsigned DEFAULT NULL ,
`archive` enum ( '0' , '1' ) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0' ,
`locked` enum ( '0' , '1' ) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0' ,
`attachments` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`merged` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`history` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom1` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom2` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom3` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom4` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom5` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom6` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom7` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom8` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom9` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom10` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom11` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom12` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom13` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom14` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom15` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom16` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom17` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom18` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom19` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`custom20` mediumtext COLLATE utf8_unicode_ci NOT NULL ,
`parent` mediumint ( 8 ) DEFAULT NULL ,
PRIMARY KEY ( `id` ),
KEY `trackid` ( `trackid` ),
KEY `archive` ( `archive` ),
KEY `categories` ( `category` ),
KEY `statuses` ( `status` ),
KEY `owner` ( `owner` )
) " );
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '1.7.0' WHERE `Key` = 'modsForHeskVersion' " );
2015-02-01 22:17:51 -05:00
}
// END Version 1.7.0
// BEGIN Version 2.0.0
2015-09-12 00:46:46 -04:00
function execute200Scripts ()
{
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " attachments` DROP COLUMN `note_id` " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " notes` DROP COLUMN `edit_date` " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " notes` DROP COLUMN `number_of_edits` " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` DROP COLUMN `default_notify_customer_email` " );
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.0.0' WHERE `Key` = 'modsForHeskVersion' " );
$keyRs = executeQuery ( " SHOW KEYS FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` WHERE Key_name='statuses' " );
if ( hesk_dbNumRows ( $keyRs ) == 0 ) {
2015-02-01 22:17:51 -05:00
//-- Add the key
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD KEY `statuses` (`status`) " );
2015-02-01 22:17:51 -05:00
}
}
2015-09-12 00:46:46 -04:00
function checkForIpOrEmailBans ()
{
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
$banRS = executeQuery ( " SELECT `ID` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " denied_emails`
UNION ALL SELECT `ID` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips` " );
2015-02-01 22:17:51 -05:00
return hesk_dbNumRows ( $banRS );
}
2015-09-12 00:46:46 -04:00
function getUsers ()
{
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
$users = array ();
2015-09-12 00:46:46 -04:00
$usersRS = executeQuery ( " SELECT `id`, `name` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` WHERE `active` = '1' ORDER BY `name` " );
2015-02-01 22:17:51 -05:00
while ( $row = hesk_dbFetchAssoc ( $usersRS )) {
2015-02-04 23:51:12 -05:00
array_push ( $users , $row );
2015-02-01 22:17:51 -05:00
}
return $users ;
}
2015-09-12 00:46:46 -04:00
function migrateBans ( $creator )
{
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-03-14 01:28:14 -04:00
2015-02-01 22:17:51 -05:00
// Insert the email bans
2015-09-12 00:46:46 -04:00
$emailBanRS = executeQuery ( " SELECT `Email` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " denied_emails` " );
2015-02-01 22:17:51 -05:00
while ( $row = hesk_dbFetchAssoc ( $emailBanRS )) {
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " banned_emails` (`email`, `banned_by`, `dt`)
VALUES ( '" . hesk_dbEscape($row[' Email ']) . "' , " . $creator . " , NOW ()) " );
2015-02-01 22:17:51 -05:00
}
// Insert the IP bans
2015-09-12 00:46:46 -04:00
$ipBanRS = executeQuery ( " SELECT `RangeStart`, `RangeEnd` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " denied_ips` " );
2015-02-01 22:17:51 -05:00
while ( $row = hesk_dbFetchAssoc ( $ipBanRS )) {
$ipFrom = long2ip ( $row [ 'RangeStart' ]);
$ipTo = long2ip ( $row [ 'RangeEnd' ]);
$ipDisplay = $ipFrom == $ipTo ? $ipFrom : $ipFrom . ' - ' . $ipTo ;
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " banned_ips` (`ip_from`, `ip_to`, `ip_display`, `banned_by`, `dt`)
VALUES ( " . $row['RangeStart'] . " , " . $row['RangeEnd'] . " , '" . $ipDisplay . "' , " . $creator . " , NOW ()) " );
2015-02-01 22:17:51 -05:00
}
2015-03-14 01:28:14 -04:00
// Migration Complete. Drop Tables.
2015-09-12 00:46:46 -04:00
executeQuery ( " DROP TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " denied_ips` " );
executeQuery ( " DROP TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " denied_emails` " );
2015-02-01 22:17:51 -05:00
}
2015-09-12 00:46:46 -04:00
2015-03-08 00:09:24 -05:00
// END Version 2.0.0
2015-03-14 12:44:18 -04:00
// Version 2.0.1
2015-09-12 00:46:46 -04:00
function execute201Scripts ()
{
2015-03-08 00:09:24 -05:00
global $hesk_settings ;
2015-09-12 00:46:46 -04:00
2015-03-08 00:09:24 -05:00
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.0.1' WHERE `Key` = 'modsForHeskVersion' " );
2015-03-08 00:09:24 -05:00
}
2015-03-14 12:44:18 -04:00
// BEGIN Version 2.1.0
2015-09-12 00:46:46 -04:00
function execute210Scripts ()
{
2015-03-14 12:44:18 -04:00
global $hesk_settings ;
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.1.0' WHERE `Key` = 'modsForHeskVersion' " );
2015-03-19 20:48:46 -04:00
// Some old tables may not have been dropped during the 2.0.0 upgrade. Check and drop if necessary
2015-09-12 00:46:46 -04:00
executeQuery ( " DROP TABLE IF EXISTS ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " denied_ips` " );
executeQuery ( " DROP TABLE IF EXISTS ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " denied_emails` " );
2015-03-14 12:44:18 -04:00
}
2015-03-22 19:51:03 -04:00
// END Version 2.1.0
// BEGIN Version 2.1.1
2015-09-12 00:46:46 -04:00
function execute211Scripts ()
{
2015-03-22 19:51:03 -04:00
global $hesk_settings ;
hesk_dbConnect ();
2016-11-25 15:59:43 -05:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` CHANGE `dt` `dt` TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00' " );
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets`
2015-03-22 19:51:03 -04:00
CHANGE `email` `email` VARCHAR ( 1000 ) NOT NULL DEFAULT '' ,
CHANGE `ip` `ip` VARCHAR ( 45 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' ,
ADD `firstreply` TIMESTAMP NULL DEFAULT NULL AFTER `lastchange` ,
ADD `closedat` TIMESTAMP NULL DEFAULT NULL AFTER `firstreply` ,
ADD `articles` VARCHAR ( 255 ) NULL DEFAULT NULL AFTER `closedat` ,
ADD `openedby` MEDIUMINT ( 8 ) DEFAULT '0' AFTER `status` ,
ADD `firstreplyby` SMALLINT ( 5 ) UNSIGNED NULL DEFAULT NULL AFTER `openedby` ,
ADD `closedby` MEDIUMINT ( 8 ) NULL DEFAULT NULL AFTER `firstreplyby` ,
ADD `replies` SMALLINT ( 5 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `closedby` ,
ADD `staffreplies` SMALLINT ( 5 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `replies` ,
ADD INDEX ( `openedby` , `firstreplyby` , `closedby` ),
ADD INDEX ( `dt` ) " );
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.1.1' WHERE `Key` = 'modsForHeskVersion' " );
2015-03-23 01:23:15 -04:00
}
2015-04-08 11:41:43 -04:00
// END Version 2.1.1
// BEGIN Version 2.2.0
2015-09-12 00:46:46 -04:00
function execute220Scripts ()
{
2015-04-08 11:41:43 -04:00
global $hesk_settings ;
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` ADD COLUMN `IsAutocloseOption` INT NOT NULL DEFAULT 0 " );
2015-04-09 16:41:13 -04:00
// There will only ever be one row
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` SET `IsAutocloseOption` = 1 WHERE `IsStaffClosedOption` = 1 " );
2015-04-09 16:41:13 -04:00
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` ADD COLUMN `Closable` VARCHAR(10) NOT NULL " );
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` SET `Closable` = 'yes' " );
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.2.0' WHERE `Key` = 'modsForHeskVersion' " );
2015-04-09 11:37:47 -04:00
}
2015-04-22 22:21:10 -04:00
// END Version 2.2.0
// BEGIN Version 2.2.1
2015-09-12 00:46:46 -04:00
function execute221Scripts ()
{
2015-04-22 22:21:10 -04:00
global $hesk_settings ;
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.2.1' WHERE `Key` = 'modsForHeskVersion' " );
2015-04-22 22:21:10 -04:00
}
2015-09-12 00:46:46 -04:00
2015-05-08 11:55:16 -04:00
// END Version 2.2.1
// BEGIN Version 2.3.0
2015-09-12 00:46:46 -04:00
function execute230Scripts ()
{
2015-05-08 11:55:16 -04:00
global $hesk_settings ;
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " service_messages` ADD COLUMN `icon` VARCHAR(150) " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` ADD COLUMN `Key` TEXT " );
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` SET `Key` = `ShortNameContentKey` " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` DROP COLUMN `ShortNameContentKey` " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` DROP COLUMN `TicketViewContentKey` " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " categories` ADD COLUMN `manager` INT NOT NULL DEFAULT 0 " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` ADD COLUMN `permission_template` INT " );
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " permission_templates` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
2015-06-11 22:03:33 -04:00
`name` VARCHAR ( 255 ) NOT NULL ,
`heskprivileges` VARCHAR ( 1000 ),
`categories` VARCHAR ( 500 )) " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " permission_templates` (`name`, `heskprivileges`, `categories`)
2015-06-12 22:14:09 -04:00
VALUES ( 'Administrator' , 'ALL' , 'ALL' ) " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " permission_templates` (`name`, `heskprivileges`, `categories`)
2015-06-12 22:14:09 -04:00
VALUES ( 'Staff' , 'can_view_tickets,can_reply_tickets,can_change_cat,can_assign_self,can_view_unassigned,can_view_online' , '1' ) " );
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` SET `permission_template` = 1 WHERE `isadmin` = '1' " );
2015-06-15 23:52:07 -04:00
// Move can_manage_settings and can_change_notification_settings into the heskprivileges list
2015-09-12 00:46:46 -04:00
$res = executeQuery ( " SELECT `id`, `heskprivileges` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` WHERE `isadmin` = '0'
2015-06-15 23:52:07 -04:00
AND `can_manage_settings` = '1' " );
while ( $row = hesk_dbFetchAssoc ( $res )) {
if ( $row [ 'heskprivileges' ] != '' ) {
$currentPrivileges = explode ( ',' , $row [ 'heskprivileges' ]);
array_push ( $currentPrivileges , 'can_man_settings' );
$newPrivileges = implode ( ',' , $currentPrivileges );
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` SET `heskprivileges` = ' " . hesk_dbEscape ( $newPrivileges ) . " '
WHERE `id` = " . intval( $row['id'] ));
2015-06-15 23:52:07 -04:00
} else {
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` SET `heskprivileges` = 'can_man_settings'
WHERE `id` = " . intval( $row['id'] ));
2015-06-15 23:52:07 -04:00
}
}
2015-09-12 00:46:46 -04:00
$res = executeQuery ( " SELECT `id`, `heskprivileges` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` WHERE `isadmin` = '0'
2015-06-15 23:52:07 -04:00
AND `can_change_notification_settings` = '1' " );
while ( $row = hesk_dbFetchAssoc ( $res )) {
if ( $row [ 'heskprivileges' ] != '' ) {
$currentPrivileges = explode ( ',' , $row [ 'heskprivileges' ]);
array_push ( $currentPrivileges , 'can_change_notification_settings' );
$newPrivileges = implode ( ',' , $currentPrivileges );
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` SET `heskprivileges` = ' " . hesk_dbEscape ( $newPrivileges ) . " '
WHERE `id` = " . intval( $row['id'] ));
2015-06-15 23:52:07 -04:00
} else {
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` SET `heskprivileges` = 'can_change_notification_settings'
WHERE `id` = " . intval( $row['id'] ));
2015-06-15 23:52:07 -04:00
}
}
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` DROP COLUMN `can_manage_settings` " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` DROP COLUMN `can_change_notification_settings` " );
2015-06-11 22:03:33 -04:00
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.3.0' WHERE `Key` = 'modsForHeskVersion' " );
2015-05-08 11:55:16 -04:00
}
2015-06-28 00:58:24 -04:00
// END Version 2.3.0
2015-06-28 11:27:28 -04:00
// BEGIN Version 2.3.1
2015-09-12 00:46:46 -04:00
function execute231Scripts ()
{
2015-06-28 11:27:28 -04:00
global $hesk_settings ;
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.3.1' WHERE `Key` = 'modsForHeskVersion' " );
2015-06-28 11:27:28 -04:00
}
2015-09-12 00:46:46 -04:00
2015-06-28 14:39:42 -04:00
// END Verison 2.3.1
// BEGIN Version 2.3.2
2015-09-12 00:46:46 -04:00
function execute232Scripts ()
{
2015-06-28 14:39:42 -04:00
global $hesk_settings ;
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.3.2' WHERE `Key` = 'modsForHeskVersion' " );
2015-06-28 14:39:42 -04:00
}
2015-09-12 00:46:46 -04:00
2015-07-04 19:47:59 -04:00
// END Version 2.3.2
// BEGIN Version 2.4.0
2015-09-12 00:46:46 -04:00
function execute240Scripts ()
{
2015-07-04 19:47:59 -04:00
global $hesk_settings ;
hesk_dbConnect ();
2015-08-03 22:10:57 -04:00
// Setup quick help sections
2015-09-12 00:46:46 -04:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " quick_help_sections` (
2015-07-04 19:47:59 -04:00
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`location` VARCHAR ( 100 ) NOT NULL ,
`show` ENUM ( '0' , '1' ) NOT NULL
) ENGINE = MyISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " quick_help_sections` (`location`, `show`)
2015-07-04 19:47:59 -04:00
VALUES ( 'create_ticket' , '1' ) " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " quick_help_sections` (`location`, `show`)
2015-07-04 19:47:59 -04:00
VALUES ( 'view_ticket_form' , '1' ) " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " quick_help_sections` (`location`, `show`)
2015-07-04 19:47:59 -04:00
VALUES ( 'view_ticket' , '1' ) " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " quick_help_sections` (`location`, `show`)
2015-07-04 19:47:59 -04:00
VALUES ( 'knowledgebase' , '1' ) " );
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " quick_help_sections` (`location`, `show`)
2015-08-15 15:26:55 -04:00
VALUES ( 'staff_create_ticket' , '1' ) " );
2015-07-25 01:11:08 -04:00
2015-08-03 22:10:57 -04:00
// Setup status improvement tables
2015-09-12 00:46:46 -04:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " text_to_status_xref` (
2015-07-25 01:11:08 -04:00
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`language` VARCHAR ( 200 ) NOT NULL ,
`text` VARCHAR ( 200 ) NOT NULL ,
2015-08-08 14:15:51 -04:00
`status_id` INT NOT NULL ) ENGINE = MyISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci " );
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` ADD COLUMN `sort` INT " );
$statusesRs = executeQuery ( " SELECT `ID` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` ORDER BY `ID` ASC " );
2015-07-27 00:06:57 -04:00
$i = 10 ;
while ( $myStatus = hesk_dbFetchAssoc ( $statusesRs )) {
2015-09-12 00:46:46 -04:00
hesk_dbQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` SET `sort`= " . intval ( $i ) . "
WHERE `id` = '" . intval($myStatus[' ID ']) . "' LIMIT 1 " );
2015-07-27 00:06:57 -04:00
$i += 10 ;
}
2015-08-03 22:10:57 -04:00
// Process attachment improvement tables
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " attachments` ADD COLUMN `download_count` INT NOT NULL DEFAULT 0 " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " kb_attachments` ADD COLUMN `download_count` INT NOT NULL DEFAULT 0 " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `html` ENUM('0','1') NOT NULL DEFAULT '0' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` ADD COLUMN `html` ENUM('0','1') NOT NULL DEFAULT '0' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " replies` ADD COLUMN `html` ENUM('0','1') NOT NULL DEFAULT '0' " );
2015-08-03 22:10:57 -04:00
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.4.0' WHERE `Key` = 'modsForHeskVersion' " );
2015-07-04 19:47:59 -04:00
}
2015-09-12 00:46:46 -04:00
function initializeXrefTable ()
{
2015-07-27 22:11:53 -04:00
global $hesk_settings , $hesklang ;
2015-08-08 14:15:51 -04:00
hesk_dbConnect ();
2015-07-28 12:27:12 -04:00
$languages = array ();
foreach ( $hesk_settings [ 'languages' ] as $key => $value ) {
$languages [ $key ] = $hesk_settings [ 'languages' ][ $key ][ 'folder' ];
}
2015-09-12 00:46:46 -04:00
$statusesRs = executeQuery ( " SELECT `ID`, `Key` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` " );
2015-08-08 15:53:35 -04:00
$oldSetting = $hesk_settings [ 'can_sel_lang' ];
$hesk_settings [ 'can_sel_lang' ] = 1 ;
2015-07-28 12:27:12 -04:00
while ( $row = hesk_dbFetchAssoc ( $statusesRs )) {
foreach ( $languages as $language => $languageCode ) {
2015-08-08 14:15:51 -04:00
hesk_setLanguage ( $language );
2015-09-12 00:46:46 -04:00
$sql = " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " text_to_status_xref` (`language`, `text`, `status_id`)
VALUES ( '" . hesk_dbEscape($language) . "' , '" . hesk_dbEscape($hesklang[$row[' Key ']]) . "' , " . intval( $row['ID'] ) . " ) " ;
2015-07-28 12:27:12 -04:00
executeQuery ( $sql );
}
}
2015-08-08 15:53:35 -04:00
$hesk_settings [ 'can_sel_lang' ] = $oldSetting ;
hesk_resetLanguage ();
2015-07-04 19:47:59 -04:00
}
2015-08-21 12:51:14 -04:00
// END Version 2.4.0
// BEGIN Version 2.4.1
2015-09-12 00:46:46 -04:00
function execute241Scripts ()
{
2015-08-21 12:51:14 -04:00
global $hesk_settings ;
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.4.1' WHERE `Key` = 'modsForHeskVersion' " );
2015-08-21 12:51:14 -04:00
}
2015-08-25 22:18:27 -04:00
// END Version 2.4.1
2015-08-30 22:07:41 -04:00
// Version 2.4.2
2015-09-12 00:46:46 -04:00
function execute242Scripts ()
{
2015-08-30 22:07:41 -04:00
global $hesk_settings ;
hesk_dbConnect ();
2015-09-12 00:46:46 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.4.2' WHERE `Key` = 'modsForHeskVersion' " );
2015-09-03 22:01:38 -04:00
}
2015-08-25 22:18:27 -04:00
// BEGIN Version 2.5.0
2015-09-12 00:46:46 -04:00
function migrateSettings ()
{
2015-08-25 22:18:27 -04:00
global $hesk_settings ;
2015-10-18 23:55:29 -04:00
hesk_dbConnect ();
2015-10-19 00:15:55 -04:00
$modsForHesk_settings = array ();
2015-08-25 22:18:27 -04:00
if ( file_exists ( HESK_PATH . 'modsForHesk_settings.inc.php' )) {
require_once ( HESK_PATH . 'modsForHesk_settings.inc.php' );
}
2015-10-19 00:15:55 -04:00
$rtl = getSettingValue ( $modsForHesk_settings , 'rtl' , 0 );
$show_icons = getSettingValue ( $modsForHesk_settings , 'show_icons' , 0 );
$custom_field_setting = getSettingValue ( $modsForHesk_settings , 'custom_field_setting' , 0 );
$customer_email_verification_required = getSettingValue ( $modsForHesk_settings , 'customer_email_verification_required' , 0 );
$html_emails = getSettingValue ( $modsForHesk_settings , 'html_emails' , 1 );
$use_mailgun = getSettingValue ( $modsForHesk_settings , 'use_mailgun' , 0 );
$mailgun_api_key = getSettingValue ( $modsForHesk_settings , 'mailgun_api_key' , '' );
$mailgun_domain = getSettingValue ( $modsForHesk_settings , 'mailgun_domain' , '' );
$use_bootstrap_theme = getSettingValue ( $modsForHesk_settings , 'use_bootstrap_theme' , 1 );
$new_kb_article_visibility = getSettingValue ( $modsForHesk_settings , 'new_kb_article_visibility' , 0 );
$attachments = getSettingValue ( $modsForHesk_settings , 'attachments' , 0 );
$show_number_merged = getSettingValue ( $modsForHesk_settings , 'show_number_merged' , 1 );
$request_location = getSettingValue ( $modsForHesk_settings , 'request_location' , 0 );
$category_order_column = getSettingValue ( $modsForHesk_settings , 'category_order_column' , 'cat_order' );
$rich_text_for_tickets = getSettingValue ( $modsForHesk_settings , 'rich_text_for_tickets' , 0 );
$statuses_order_column = getSettingValue ( $modsForHesk_settings , 'statuses_order_column' , 'sort' );
$kb_attach_dir = getSettingValue ( $modsForHesk_settings , 'kb_attach_dir' , 'attachments' );
$rich_text_for_tickets_for_customers = getSettingValue ( $modsForHesk_settings , 'rich_text_for_tickets_for_customers' , 0 );
$navbar_background_color = getSettingValue ( $modsForHesk_settings , 'navbarBackgroundColor' , '#414a5c' );
$navbar_brand_color = getSettingValue ( $modsForHesk_settings , 'navbarBrandColor' , '#d4dee7' );
$navbar_brand_hover_color = getSettingValue ( $modsForHesk_settings , 'navbarBrandHoverColor' , '#ffffff' );
$navbar_item_text_color = getSettingValue ( $modsForHesk_settings , 'navbarItemTextColor' , '#d4dee7' );
$navbar_item_text_hover_color = getSettingValue ( $modsForHesk_settings , 'navbarItemTextHoverColor' , '#ffffff' );
$navbar_item_text_selected_color = getSettingValue ( $modsForHesk_settings , 'navbarItemTextSelectedColor' , '#ffffff' );
$navbar_item_selected_background_color = getSettingValue ( $modsForHesk_settings , 'navbarItemSelectedBackgroundColor' , '#2d3646' );
$dropdown_item_text_color = getSettingValue ( $modsForHesk_settings , 'dropdownItemTextColor' , '#333333' );
$dropdown_item_text_hover_color = getSettingValue ( $modsForHesk_settings , 'dropdownItemTextHoverColor' , '#262626' );
$dropdown_item_text_hover_background_color = getSettingValue ( $modsForHesk_settings , 'dropdownItemTextHoverBackgroundColor' , '#f5f5f5' );
$question_mark_color = getSettingValue ( $modsForHesk_settings , 'questionMarkColor' , '#000000' );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'rtl' , " . intval( $rtl ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'show_icons' , " . intval( $show_icons ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'custom_field_setting' , " . intval( $custom_field_setting ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'customer_email_verification_required' , " . intval( $customer_email_verification_required ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'html_emails' , " . intval( $html_emails ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'use_mailgun' , " . intval( $use_mailgun ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'mailgun_api_key' , '" . hesk_dbEscape($mailgun_api_key) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'mailgun_domain' , '" . hesk_dbEscape($mailgun_domain) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'use_bootstrap_theme' , " . intval( $use_bootstrap_theme ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'new_kb_article_visibility' , " . intval( $new_kb_article_visibility ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'attachments' , " . intval( $attachments ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'show_number_merged' , " . intval( $show_number_merged ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'request_location' , " . intval( $request_location ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'category_order_column' , '" . hesk_dbEscape($category_order_column) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'rich_text_for_tickets' , " . intval( $rich_text_for_tickets ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'statuses_order_column' , '" . hesk_dbEscape($statuses_order_column) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'kb_attach_dir' , '" . hesk_dbEscape($kb_attach_dir) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'rich_text_for_tickets_for_customers' , " . intval( $rich_text_for_tickets_for_customers ) . " ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'navbarBackgroundColor' , '" . hesk_dbEscape($navbar_background_color) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'navbarBrandColor' , '" . hesk_dbEscape($navbar_brand_color) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'navbarBrandHoverColor' , '" . hesk_dbEscape($navbar_brand_hover_color) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'navbarItemTextColor' , '" . hesk_dbEscape($navbar_item_text_color) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'navbarItemTextHoverColor' , '" . hesk_dbEscape($navbar_item_text_hover_color) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'navbarItemTextSelectedColor' , '" . hesk_dbEscape($navbar_item_text_selected_color) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'navbarItemSelectedBackgroundColor' , '" . hesk_dbEscape($navbar_item_selected_background_color) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'dropdownItemTextColor' , '" . hesk_dbEscape($dropdown_item_text_color) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'dropdownItemTextHoverColor' , '" . hesk_dbEscape($dropdown_item_text_hover_color) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'dropdownItemTextHoverBackgroundColor' , '" . hesk_dbEscape($dropdown_item_text_hover_background_color) . "' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'questionMarkColor' , '" . hesk_dbEscape($question_mark_color) . "' ) " );
2015-08-27 16:57:18 -04:00
}
2015-09-12 00:46:46 -04:00
function getSettingValue ( $settings , $setting , $default )
{
2015-09-06 22:12:49 -04:00
return isset ( $settings [ $setting ]) ? $settings [ $setting ] : $default ;
}
2015-09-12 00:46:46 -04:00
function execute250Scripts ()
{
2015-09-04 22:14:25 -04:00
global $hesk_settings ;
2015-09-12 00:46:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `user_agent` TEXT " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `screen_resolution_width` INT " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `screen_resolution_height` INT " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` ADD COLUMN `user_agent` TEXT " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` ADD COLUMN `screen_resolution_width` INT " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` ADD COLUMN `screen_resolution_height` INT " );
2015-09-04 22:14:25 -04:00
2015-09-12 00:46:46 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('display_user_agent_information', '0') " );
2015-09-13 11:37:54 -04:00
2015-10-18 23:55:29 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('navbar_title_url', ' " . hesk_dbEscape ( $hesk_settings [ 'hesk_url' ]) . " ') " );
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.5.0' WHERE `Key` = 'modsForHeskVersion' " );
2015-09-04 22:14:25 -04:00
}
2015-10-23 00:19:12 -04:00
// END Version 2.5.0
// Version 2.5.1
function execute251Scripts ()
{
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.5.1' WHERE `Key` = 'modsForHeskVersion' " );
2015-10-29 21:49:13 -04:00
}
// Version 2.5.2
function execute252Scripts ()
{
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.5.2' WHERE `Key` = 'modsForHeskVersion' " );
2015-11-29 20:12:12 -05:00
}
2016-01-09 21:38:25 -05:00
// Version 2.5.3
2016-05-04 23:42:53 -04:00
function execute253Scripts ()
2016-01-09 21:38:25 -05:00
{
2016-05-04 23:42:53 -04:00
global $hesk_settings ;
hesk_dbConnect ();
2016-01-09 21:38:25 -05:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.5.3' WHERE `Key` = 'modsForHeskVersion' " );
2016-02-02 13:22:08 -05:00
}
// Version 2.5.4
function execute254Scripts ()
{
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.5.4' WHERE `Key` = 'modsForHeskVersion' " );
2016-04-18 19:35:14 -04:00
}
// Version 2.5.5
function execute255Scripts ()
{
2016-04-18 19:37:53 -04:00
updateVersion ( '2.5.5' );
2016-04-18 19:35:14 -04:00
}
function updateVersion ( $version ) {
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = ' { $version } ' WHERE `Key` = 'modsForHeskVersion' " );
2016-05-04 23:42:53 -04:00
}
2015-11-17 21:27:57 -05:00
// Version 2.6.0
2015-11-29 20:12:12 -05:00
function execute260Scripts ()
{
global $hesk_settings ;
hesk_dbConnect ();
2016-05-04 23:42:53 -04:00
2016-05-05 12:07:35 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('public_api', '0') " );
2015-11-29 21:23:17 -05:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " logging` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` VARCHAR ( 200 ),
`message` MEDIUMTEXT NOT NULL ,
`severity` INT NOT NULL ,
`location` MEDIUMTEXT ,
`timestamp` TIMESTAMP NOT NULL ) ENGINE = MyISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci " );
2015-11-17 22:14:34 -05:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " user_api_tokens` (
2015-11-29 20:12:12 -05:00
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
2015-11-17 22:14:34 -05:00
`user_id` INT NOT NULL ,
`token` VARCHAR ( 500 ) NOT NULL ) ENGINE = MyISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci " );
2015-12-21 13:11:12 -05:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " temp_attachment` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`file_name` VARCHAR ( 255 ) NOT NULL ,
2015-12-22 22:20:30 -05:00
`saved_name` VARCHAR ( 255 ) NOT NULL ,
2015-12-21 13:11:12 -05:00
`size` INT ( 10 ) UNSIGNED NOT NULL ,
`type` ENUM ( '0' , '1' ) NOT NULL ,
`date_uploaded` TIMESTAMP NOT NULL ) ENGINE = MyISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci " );
2016-01-12 21:31:59 -05:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " calendar_event` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
2016-01-16 20:04:12 -05:00
`start` DATETIME ,
`end` DATETIME ,
2016-01-12 21:31:59 -05:00
`all_day` ENUM ( '0' , '1' ) NOT NULL ,
`name` VARCHAR ( 255 ) NOT NULL ,
`location` VARCHAR ( 255 ),
2016-02-13 22:11:20 -05:00
`comments` MEDIUMTEXT ,
2016-02-18 13:28:00 -05:00
`category` INT NOT NULL ) ENGINE = MyISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci " );
2016-02-20 22:22:27 -05:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " calendar_event_reminder` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`user_id` INT NOT NULL ,
`event_id` INT NOT NULL ,
`amount` INT NOT NULL ,
2016-03-28 21:55:09 -04:00
`unit` INT NOT NULL ,
`email_sent` ENUM ( '0' , '1' ) NOT NULL DEFAULT '0' ) ENGINE = MyISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci " );
2016-01-26 13:28:07 -05:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `due_date` DATETIME " );
2016-04-20 18:38:52 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `overdue_email_sent` ENUM('0','1') " );
2016-02-14 22:25:55 -05:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " categories` ADD COLUMN `color` VARCHAR(7) " );
2016-03-03 22:11:40 -05:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " categories` ADD COLUMN `usage` INT NOT NULL DEFAULT 0 " );
2016-04-21 22:05:45 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` ADD COLUMN `notify_overdue_unassigned` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `notify_note_unassigned` " );
2016-04-25 21:56:52 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` ADD COLUMN `default_calendar_view` INT NOT NULL DEFAULT '0' AFTER `notify_note_unassigned` " );
2016-04-24 22:15:07 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('enable_calendar', '1') " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('first_day_of_week', '0') " );
2016-04-25 14:00:52 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('default_calendar_view', 'month') " );
2016-06-07 12:11:25 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` ADD PRIMARY KEY ( `Key` ) " );
2016-06-07 12:19:56 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` CHANGE `IsNewTicketStatus` `IsNewTicketStatus` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsClosed` `IsClosed` INT ( 1 ) NOT NULL DEFAULT '0' ,
CHANGE `IsClosedByClient` `IsClosedByClient` INT ( 1 ) NOT NULL DEFAULT '0' ,
CHANGE `IsCustomerReplyStatus` `IsCustomerReplyStatus` INT ( 1 ) NOT NULL DEFAULT '0' ,
CHANGE `IsStaffClosedOption` `IsStaffClosedOption` INT ( 1 ) NOT NULL DEFAULT '0' ,
CHANGE `IsStaffReopenedStatus` `IsStaffReopenedStatus` INT ( 1 ) NOT NULL DEFAULT '0' ,
CHANGE `IsDefaultStaffReplyStatus` `IsDefaultStaffReplyStatus` INT ( 1 ) NOT NULL DEFAULT '0' ,
CHANGE `LockedTicketStatus` `LockedTicketStatus` INT ( 1 ) NOT NULL DEFAULT '0' " );
2016-05-05 12:13:33 -04:00
updateVersion ( '2.6.0' );
2016-06-13 12:18:07 -04:00
}
2016-06-19 22:04:49 -04:00
// Version 2.6.1
function execute261Scripts () {
updateVersion ( '2.6.1' );
}
2016-07-17 16:02:34 -04:00
// Version 2.6.2
function execute262Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` ADD COLUMN `due_date` DATETIME " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` ADD COLUMN `overdue_email_sent` ENUM('0','1') " );
updateVersion ( '2.6.2' );
}
2016-07-24 22:00:47 -04:00
// Version 2.6.3
function execute263Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
updateVersion ( '2.6.3' );
}
2016-08-11 00:03:06 -04:00
// Version 2.6.4
function execute264Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
updateVersion ( '2.6.4' );
2016-11-16 22:06:36 -05:00
}
2016-11-17 21:12:41 -05:00
// Verison 3.0.0 Beta 1
function execute300Beta1Scripts () {
2016-11-16 22:06:36 -05:00
global $hesk_settings ;
hesk_dbConnect ();
$hesk_statuses = executeQuery ( " SELECT * FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " custom_statuses` ORDER BY `order` " );
$next_status_id_rs = executeQuery ( " SELECT MAX(`ID`) AS `last_id` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` " );
$next_status_id_row = hesk_dbFetchAssoc ( $next_status_id_rs );
$next_status_id = intval ( $next_status_id_row [ 'last_id' ]) + 1 ;
$next_sort_rs = executeQuery ( " SELECT MAX(`sort`) AS `last_sort` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` " );
$next_sort_row = hesk_dbFetchAssoc ( $next_sort_rs );
$next_sort = intval ( $next_sort_row [ 'last_sort' ]) + 10 ;
while ( $row = hesk_dbFetchAssoc ( $hesk_statuses )) {
$closable = $row [ 'can_customers_change' ] == '1' ? 'yes' : 'sonly' ;
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` (`ID`,
`TextColor` ,
`IsNewTicketStatus` ,
`IsClosed` ,
`IsClosedByClient` ,
`IsCustomerReplyStatus` ,
`IsStaffClosedOption` ,
`IsStaffReopenedStatus` ,
`IsDefaultStaffReplyStatus` ,
`LockedTicketStatus` ,
`IsAutocloseOption` ,
`Closable` ,
`Key` ,
`sort` )
VALUES ( " . $next_status_id . " ,
'#" . $row[' color '] . "' ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
'" . $closable . "' ,
'STORED IN XREF TABLE' ,
" . $next_sort . " ) " );
$languages = json_decode ( $row [ 'name' ]);
foreach ( $languages as $language => $text ) {
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " text_to_status_xref` (`language`, `text`, `status_id`)
VALUES ( '" . $language . "' , '" . $text . "' , " . $next_status_id . " ) " );
}
// Increment the next ID and sort
$next_status_id ++ ;
$next_sort += 10 ;
}
// Migrate user's autorefresh columns to the new autoreload column
// Mods for HESK is in millis; HESK is in seconds.
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` SET `autoreload` = `autorefresh` / 10 " );
// Add the admin_color_scheme setting
2016-11-17 20:20:30 -05:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('admin_color_scheme', 'skin-blue') " );
2016-11-16 22:06:36 -05:00
2016-11-17 21:12:41 -05:00
updateVersion ( '3.0.0 beta 1' );
2016-11-17 20:20:30 -05:00
}
2016-11-18 22:00:39 -05:00
2016-11-30 21:58:24 -05:00
function execute300RC1Scripts () {
2016-11-18 22:00:39 -05:00
global $hesk_settings ;
hesk_dbConnect ();
2016-11-30 21:58:24 -05:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` DROP COLUMN `autorefresh` " );
updateVersion ( '3.0.0 RC 1' );
2016-12-31 22:00:43 -05:00
}
function execute300Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
updateVersion ( '3.0.0' );
2017-01-03 22:02:23 -05:00
}
function execute301Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
updateVersion ( '3.0.1' );
2017-01-06 20:59:43 -05:00
}
function execute302Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets`
ADD COLUMN `custom21` MEDIUMTEXT ,
ADD COLUMN `custom22` MEDIUMTEXT ,
ADD COLUMN `custom23` MEDIUMTEXT ,
ADD COLUMN `custom24` MEDIUMTEXT ,
ADD COLUMN `custom25` MEDIUMTEXT ,
ADD COLUMN `custom26` MEDIUMTEXT ,
ADD COLUMN `custom27` MEDIUMTEXT ,
ADD COLUMN `custom28` MEDIUMTEXT ,
ADD COLUMN `custom29` MEDIUMTEXT ,
ADD COLUMN `custom30` MEDIUMTEXT ,
ADD COLUMN `custom31` MEDIUMTEXT ,
ADD COLUMN `custom32` MEDIUMTEXT ,
ADD COLUMN `custom33` MEDIUMTEXT ,
ADD COLUMN `custom34` MEDIUMTEXT ,
ADD COLUMN `custom35` MEDIUMTEXT ,
ADD COLUMN `custom36` MEDIUMTEXT ,
ADD COLUMN `custom37` MEDIUMTEXT ,
ADD COLUMN `custom38` MEDIUMTEXT ,
ADD COLUMN `custom39` MEDIUMTEXT ,
ADD COLUMN `custom40` MEDIUMTEXT ,
ADD COLUMN `custom41` MEDIUMTEXT ,
ADD COLUMN `custom42` MEDIUMTEXT ,
ADD COLUMN `custom43` MEDIUMTEXT ,
ADD COLUMN `custom44` MEDIUMTEXT ,
ADD COLUMN `custom45` MEDIUMTEXT ,
ADD COLUMN `custom46` MEDIUMTEXT ,
ADD COLUMN `custom47` MEDIUMTEXT ,
ADD COLUMN `custom48` MEDIUMTEXT ,
ADD COLUMN `custom49` MEDIUMTEXT ,
ADD COLUMN `custom50` MEDIUMTEXT " );
updateVersion ( '3.0.2' );
2017-01-07 20:49:44 -05:00
}
function execute303Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
updateVersion ( '3.0.3' );
2017-03-12 20:50:54 -04:00
}
2017-03-29 22:11:01 -04:00
function execute304Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
updateVersion ( '3.0.4' );
2017-04-04 12:26:30 -04:00
}
function execute305Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
updateVersion ( '3.0.5' );
2017-04-04 22:31:11 -04:00
}
2017-04-11 12:13:59 -04:00
function execute306Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
updateVersion ( '3.0.6' );
}
2017-04-12 19:36:23 -04:00
function execute307Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
updateVersion ( '3.0.7' );
2017-04-12 19:58:30 -04:00
}
2017-03-12 20:50:54 -04:00
function execute310Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " logging` ADD COLUMN `stack_trace` TEXT " );
2017-05-06 22:17:22 -04:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " custom_nav_element`
( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
image_url TEXT ,
font_icon VARCHAR ( 200 ),
2017-05-19 12:52:47 -04:00
place INT NOT NULL ,
2017-05-19 22:08:50 -04:00
url VARCHAR ( 500 ) NOT NULL ,
2017-05-19 12:52:47 -04:00
sort INT NOT NULL ) " );
2017-05-06 22:17:22 -04:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " custom_nav_element_to_text`
( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
nav_element_id INT NOT NULL ,
language VARCHAR ( 200 ) NOT NULL ,
text VARCHAR ( 200 ) NOT NULL ,
subtext VARCHAR ( 200 )) " );
2017-05-30 13:02:39 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " categories` ADD COLUMN `foreground_color` VARCHAR(7) NOT NULL DEFAULT 'AUTO' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " categories` ADD COLUMN `display_border_outline` ENUM('0','1') NOT NULL DEFAULT '0' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " categories` CHANGE `color` `background_color` VARCHAR(7) NOT NULL DEFAULT '#FFFFFF' " );
2017-06-06 13:02:53 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('login_background_type', 'color') " );
2017-06-01 12:56:36 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('login_background', '#d2d6de') " );
2017-06-09 22:39:00 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('login_box_header', 'helpdesk-title') " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('login_box_header_image', '') " );
2017-06-15 22:06:13 -04:00
executeQuery ( " DELETE FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` WHERE `Key` IN ('rtl', 'admin_color_scheme') " );
2017-05-06 22:17:22 -04:00
2017-06-10 22:29:29 -04:00
// Copy over color presets to the custom values
$theme_preset_rs = executeQuery ( " SELECT `Value` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` WHERE `Key` = 'admin_color_scheme' " );
if ( hesk_dbNumRows ( $theme_preset_rs ) === 0 ) {
$theme = 'skin-blue' ;
} else {
$theme_preset_row = hesk_dbFetchAssoc ( $theme_preset_rs );
$theme = $theme_preset_row [ 'Value' ];
}
2017-06-11 22:04:19 -04:00
$light_theme = preg_match ( '/.*-light/g' , $theme );
2017-06-10 22:29:29 -04:00
$navbar = array (
'background' => '' ,
2017-06-11 22:04:19 -04:00
'text' => '#fff' ,
'text_hover' => '#fff' ,
2017-06-10 22:29:29 -04:00
'background_hover' => ''
);
$navbar_brand = array (
'background' => '' ,
2017-06-11 22:04:19 -04:00
'text' => '#fff' ,
'text_hover' => '#fff' ,
2017-06-10 22:29:29 -04:00
'background_hover' => ''
);
$sidebar = array (
2017-06-11 22:04:19 -04:00
'background' => $light_theme ? '#f9fafc' : '#222d32' ,
'text' => $light_theme ? '#444' : '#b8c7ce' ,
2017-06-18 21:21:26 -04:00
'text_hover' => $light_theme ? '#444' : '#fff' ,
2017-06-11 22:04:19 -04:00
'background_hover' => $light_theme ? '#f4f4f5' : '#1e282c' ,
2017-06-12 21:51:11 -04:00
'font_weight' => $light_theme ? 'bold' : 'normal'
2017-06-10 22:29:29 -04:00
);
$sidebar_header = array (
2017-06-11 22:04:19 -04:00
'background' => $light_theme ? '#f9fafc' : '#1a2226' ,
'text' => $light_theme ? '#848484' : '#4b646f' ,
2017-06-10 22:29:29 -04:00
);
2017-06-11 22:04:19 -04:00
if ( preg_match ( '/skin-blue.*/g' , $theme )) {
$navbar [ 'background' ] = '#3c8dbc' ;
$navbar [ 'background_hover' ] = '#367fa9' ;
$navbar_brand [ 'background' ] = $light_theme ? '#3c8dbc' : '#367fa9' ;
2017-06-12 08:21:28 -04:00
$navbar_brand [ 'background_hover' ] = $light_theme ? '#3b8ab8' : '#357ca5' ;
2017-06-11 22:04:19 -04:00
} elseif ( preg_match ( '/skin-yellow.*/g' , $theme )) {
$navbar [ 'background' ] = '#f39c12' ;
$navbar [ 'background_hover' ] = '#da8c10' ;
$navbar_brand [ 'background' ] = $light_theme ? '#f39c12' : '#e08e0b' ;
$navbar_brand [ 'background_hover' ] = $light_theme ? '#f39a0d' : '#db8b0b' ;
} elseif ( preg_match ( '/skin-green.*/g' , $theme )) {
$navbar [ 'background' ] = '#00a65a' ;
$navbar [ 'background_hover' ] = '#009551' ;
$navbar_brand [ 'background' ] = $light_theme ? '#00a65a' : '#008d4c' ;
$navbar_brand [ 'background_hover' ] = $light_theme ? '#00a157' : '#008749' ;
} elseif ( preg_match ( '/skin-purple.*/g' , $theme )) {
$navbar [ 'background' ] = '#605ca8' ;
$navbar [ 'background_hover' ] = '#565397' ;
$navbar_brand [ 'background' ] = $light_theme ? '#605ca8' : '#555299' ;
$navbar_brand [ 'background_hover' ] = $light_theme ? '#5d59a6' : '#545096' ;
} elseif ( preg_match ( '/skin-red.*/g' , $theme )) {
$navbar [ 'background' ] = '#dd4b39' ;
$navbar [ 'background_hover' ] = '#c64333' ;
$navbar_brand [ 'background' ] = $light_theme ? '#dd4b39' : '#d73925' ;
$navbar_brand [ 'background_hover' ] = $light_theme ? '#dc4735' : '#d33724' ;
} else {
$navbar [ 'background' ] = '#fff' ;
$navbar [ 'background_hover' ] = '#eee' ;
2017-06-10 22:29:29 -04:00
2017-06-11 22:04:19 -04:00
$navbar_brand [ 'background' ] = '#fff' ;
$navbar_brand [ 'background_hover' ] = '#fcfcfc' ;
2017-06-10 22:29:29 -04:00
}
2017-06-11 22:04:19 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2017-06-12 08:21:28 -04:00
VALUES ( 'admin_navbar_background' , '{$navbar[' background ']}' ) " );
2017-06-11 22:04:19 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2017-06-12 08:21:28 -04:00
VALUES ( 'admin_navbar_background_hover' , '{$navbar[' background_hover ']}' ) " );
2017-06-11 22:04:19 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_navbar_text' , '{$navbar[' text ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_navbar_text_hover' , '{$navbar[' text_hover ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_navbar_brand_background' , '{$navbar_brand[' background ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_navbar_brand_background_hover' , '{$navbar_brand[' background_hover ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_navbar_brand_text' , '{$navbar_brand[' text ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_navbar_brand_text_hover' , '{$navbar_brand[' text_hover ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_sidebar_background' , '{$sidebar[' background ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_sidebar_background_hover' , '{$sidebar[' background_hover ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_sidebar_text' , '{$sidebar[' text ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_sidebar_text_hover' , '{$sidebar[' text_hover ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_sidebar_font_weight' , '{$sidebar[' font_weight ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
VALUES ( 'admin_sidebar_header_background' , '{$sidebar_header[' background ']}' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2017-06-12 08:21:28 -04:00
VALUES ( 'admin_sidebar_header_text' , '{$sidebar_header[' text ']}' ) " );
2017-06-11 22:04:19 -04:00
2017-05-06 22:17:22 -04:00
updateVersion ( '3.1.0' );
2016-11-18 22:00:39 -05:00
}