2015-02-01 22:17:51 -05:00
< ? php
2015-02-03 00:21:06 -05:00
require ( HESK_PATH . 'hesk_settings.inc.php' );
function executeQuery ( $sql ) {
2015-03-14 01:28:14 -04:00
global $hesk_last_query ;
global $hesk_db_link ;
2015-02-04 23:51:12 -05:00
if ( function_exists ( 'mysqli_connect' ) ) {
if ( ! $hesk_db_link && ! hesk_dbConnect ())
{
return false ;
}
$hesk_last_query = $sql ;
if ( $res = @ mysqli_query ( $hesk_db_link , $sql ))
{
return $res ;
} else
{
2015-03-14 01:28:14 -04:00
print " Could not execute query: $sql . MySQL said: " . mysqli_error ( $hesk_db_link );
2015-02-04 23:51:12 -05:00
http_response_code ( 500 );
die ();
}
} else {
if ( ! $hesk_db_link && ! hesk_dbConnect ())
{
return false ;
}
$hesk_last_query = $sql ;
if ( $res = @ mysql_query ( $sql , $hesk_db_link ))
{
return $res ;
} else
{
print " Could not execute query: $sql . MySQL said: " . mysql_error ();
http_response_code ( 500 );
die ();
}
}
2015-02-03 00:21:06 -05:00
}
2015-02-01 22:17:51 -05:00
// Version 1.0.0 - <1.4.0
function executePre140Scripts () {
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
//-- Need to do this since we are no longer restricted on IDs and we want an INT for proper INNER JOINs
2015-02-03 00:21:06 -05:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `status_int` INT NOT NULL DEFAULT 0 AFTER `status`; " );
$ticketsRS = executeQuery ( " SELECT `id`, `status` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets`; " );
2015-02-01 22:17:51 -05:00
while ( $currentResult = $ticketsRS -> fetch_assoc ())
{
2015-02-03 00:21:06 -05: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-02-03 00:21:06 -05: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-02-03 00:21:06 -05: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 ,
`IsNewTicketStatus` BIT NOT NULL DEFAULT 0 ,
`IsClosed` BIT NOT NULL DEFAULT 0 ,
`IsClosedByClient` BIT NOT NULL DEFAULT 0 ,
`IsCustomerReplyStatus` BIT NOT NULL DEFAULT 0 ,
`IsStaffClosedOption` BIT NOT NULL DEFAULT 0 ,
`IsStaffReopenedStatus` BIT NOT NULL DEFAULT 0 ,
`IsDefaultStaffReplyStatus` BIT NOT NULL DEFAULT 0 ,
`LockedTicketStatus` BIT NOT NULL DEFAULT 0 ,
PRIMARY KEY ( `ID` )) " );
2015-02-03 00:21:06 -05: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-02-03 00:21:06 -05: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-02-03 00:21:06 -05: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-02-03 00:21:06 -05: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-02-03 00:21:06 -05: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-02-03 00:21:06 -05: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
$keyRs = executeQuery ( " SHOW KEYS FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` WHERE Key_name='statuses' " );
if ( hesk_dbNumRows ( $keyRs ) == 0 )
{
//-- Add the key
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD KEY `statuses` (`status`) " );
}
2015-02-01 22:17:51 -05:00
}
// Version 1.4.0
function execute140Scripts () {
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-02-03 00:21:06 -05: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-02-03 00:21:06 -05: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
function execute141Scripts () {
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-02-03 00:21:06 -05: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
function execute150Scripts () {
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-02-03 00:21:06 -05: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
function execute160Scripts () {
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-02-03 00:21:06 -05: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
function execute161Scripts () {
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-02-03 00:21:06 -05: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
function execute170Scripts () {
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-02-03 00:21:06 -05: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 ,
`dt` datetime NOT NULL DEFAULT '0000-00-00 00:00: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-02-03 00:21:06 -05: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
}
function execute170FileUpdate () {
2015-03-14 01:28:14 -04:00
2015-02-01 22:17:51 -05:00
//-- Add the new custom field property to modsForHesk_settings.inc.php
$file = file_get_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' );
//-- Only add the additional settings if they aren't already there.
2015-03-14 12:39:45 -04:00
if ( strpos ( $file , 'custom_field_setting' ) === false )
2015-02-01 22:17:51 -05:00
{
$file .= '
//-- Set this to 1 to enable custom field names as keys
$modsForHesk_settings [ \ ' custom_field_setting\ ' ] = 0 ;
//-- Set this to 1 to enable email verification for new customers
$modsForHesk_settings [ \ 'customer_email_verification_required\'] = 0;' ;
}
return file_put_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' , $file );
}
// END Version 1.7.0
// BEGIN Version 2.0.0
function execute200Scripts () {
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-02-03 00:21:06 -05: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' " );
2015-02-01 22:17:51 -05:00
2015-02-03 00:21:06 -05:00
$keyRs = executeQuery ( " SHOW KEYS FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` WHERE Key_name='statuses' " );
2015-02-01 22:17:51 -05:00
if ( hesk_dbNumRows ( $keyRs ) == 0 )
{
//-- Add the key
2015-02-03 00:21:06 -05:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD KEY `statuses` (`status`) " );
2015-02-01 22:17:51 -05:00
}
}
function execute200FileUpdate () {
//-- Add the new HTML email property to modsForHesk_settings.inc.php
$file = file_get_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' );
//-- Only add the additional settings if they aren't already there.
2015-03-14 12:39:45 -04:00
if ( strpos ( $file , 'html_emails' ) === false )
2015-02-01 22:17:51 -05:00
{
$file .= '
//-- Set this to 1 to enable HTML-formatted emails.
$modsForHesk_settings [ \ ' html_emails\ ' ] = 0 ;
//-- Mailgun Settings
$modsForHesk_settings [ \ ' use_mailgun\ ' ] = 0 ;
$modsForHesk_settings [ \ ' mailgun_api_key\ ' ] = \ ' API Key\ ' ;
$modsForHesk_settings [ \ 'mailgun_domain\'] = \'mail.domain.com\';' ;
}
return file_put_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' , $file );
}
function checkForIpOrEmailBans () {
2015-02-03 00:21:06 -05:00
global $hesk_settings ;
2015-02-01 22:17:51 -05:00
hesk_dbConnect ();
2015-02-03 00:21:06 -05:00
$banRS = executeQuery ( " SELECT `ID` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " denied_emails`
2015-02-01 22:17:51 -05:00
UNION ALL SELECT `ID` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."denied_ips` " );
return hesk_dbNumRows ( $banRS );
}
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-02-03 00:21:06 -05: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-02-04 23:51:12 -05: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-02-03 00:21:06 -05: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-02-03 00:21:06 -05:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " banned_emails` (`email`, `banned_by`, `dt`)
2015-02-01 22:17:51 -05:00
VALUES ( '".hesk_dbEscape($row[' Email '])."' , " . $creator . " , NOW ()) " );
}
// Insert the IP bans
2015-02-03 00:21:06 -05: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-02-03 00:21:06 -05:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " banned_ips` (`ip_from`, `ip_to`, `ip_display`, `banned_by`, `dt`)
2015-02-01 22:17:51 -05:00
VALUES ( " . $row['RangeStart'] . " , " . $row['RangeEnd'] . " , '".$ipDisplay."' , " . $creator . " , NOW ()) " );
}
2015-03-14 01:28:14 -04:00
// Migration Complete. Drop Tables.
2015-02-03 00:21:06 -05: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-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-03-08 00:09:24 -05:00
function execute201Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.0.1' WHERE `Key` = 'modsForHeskVersion' " );
}
2015-03-14 12:44:18 -04:00
// BEGIN Version 2.1.0
function execute210Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
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-04-08 11:41:43 -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
}
function execute210FileUpdate () {
//-- Add the boostrap theme property to modsForHesk_settings.inc.php
$file = file_get_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' );
//-- Only add the additional settings if they aren't already there.
if ( strpos ( $file , 'use_bootstrap_theme' ) === false )
{
$file .= '
//-- Set this to 1 to enable bootstrap-theme.css
$modsForHesk_settings [ \ 'use_bootstrap_theme\'] = 1;' ;
}
return file_put_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' , $file );
}
2015-03-22 19:51:03 -04:00
// END Version 2.1.0
// BEGIN Version 2.1.1
function execute211Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " ALTER IGNORE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` CHANGE `dt` `dt` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' " );
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets`
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` ) " );
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
}
function execute211FileUpdate () {
2015-04-09 11:37:47 -04:00
//-- Add the new kb article visibility property to modsForHesk_settings.inc.php
2015-03-23 01:23:15 -04:00
$file = file_get_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' );
//-- Only add the additional settings if they aren't already there.
if ( strpos ( $file , 'new_kb_article_visibility' ) === false )
{
$file .= '
//-- Default value for new Knowledgebase article: 0 = Published, 1 = Private, 2 = Draft
$modsForHesk_settings [ \ 'new_kb_article_visibility\'] = 0;' ;
}
return file_put_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' , $file );
}
2015-04-08 11:41:43 -04:00
// END Version 2.1.1
// BEGIN Version 2.2.0
function execute220Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
2015-04-09 16:41:13 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` ADD COLUMN `IsAutocloseOption` INT NOT NULL DEFAULT 0 " );
// There will only ever be one row
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` SET `IsAutocloseOption` = 1 WHERE `IsStaffClosedOption` = 1 " );
2015-04-09 11:37:47 -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' " );
2015-04-08 11:41:43 -04:00
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-12 23:47:14 -04:00
function execute220FileUpdate () {
//-- Add the new attachment property to modsForHesk_settings.inc.php
$file = file_get_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' );
//-- Only add the additional settings if they aren't already there.
if ( strpos ( $file , '$modsForHesk_settings[\'attachments\']' ) === false )
{
$file .= '
//-- Setting for adding attachments to email messages. Either 0 for default-HESK behavior, or 1 to send as attachments
$modsForHesk_settings [ \ 'attachments\'] = 0;' ;
}
return file_put_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' , $file );
}
2015-04-22 22:21:10 -04:00
// END Version 2.2.0
// BEGIN Version 2.2.1
function execute221Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.2.1' WHERE `Key` = 'modsForHeskVersion' " );
}
2015-05-08 11:55:16 -04:00
// END Version 2.2.1
// BEGIN Version 2.3.0
function execute230Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " service_messages` ADD COLUMN `icon` VARCHAR(150) " );
2015-05-12 22:08:17 -04:00
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` " );
2015-05-19 22:04:19 -04:00
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' " );
2015-06-04 21:52:30 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " categories` ADD COLUMN `manager` INT NOT NULL DEFAULT 0 " );
2015-06-13 01:20:28 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` ADD COLUMN `permission_template` INT " );
2015-06-12 22:14:09 -04:00
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-06-12 22:14:09 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " permission_templates` (`name`, `heskprivileges`, `categories`)
VALUES ( 'Administrator' , 'ALL' , 'ALL' ) " );
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " permission_templates` (`name`, `heskprivileges`, `categories`)
VALUES ( 'Staff' , 'can_view_tickets,can_reply_tickets,can_change_cat,can_assign_self,can_view_unassigned,can_view_online' , '1' ) " );
2015-06-13 01:20:28 -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
$res = executeQuery ( " SELECT `id`, `heskprivileges` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` WHERE `isadmin` = '0'
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-06-25 00:16:26 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` SET `heskprivileges` = ' " . hesk_dbEscape ( $newPrivileges ) . " '
2015-06-15 23:52:07 -04:00
WHERE `id` = " .intval( $row['id'] ));
} else {
2015-06-25 00:16:26 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` SET `heskprivileges` = 'can_man_settings'
2015-06-15 23:52:07 -04:00
WHERE `id` = " .intval( $row['id'] ));
}
}
$res = executeQuery ( " SELECT `id`, `heskprivileges` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` WHERE `isadmin` = '0'
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-06-25 00:16:26 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` SET `heskprivileges` = ' " . hesk_dbEscape ( $newPrivileges ) . " '
2015-06-15 23:52:07 -04:00
WHERE `id` = " .intval( $row['id'] ));
} else {
2015-06-25 00:16:26 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` SET `heskprivileges` = 'can_change_notification_settings'
2015-06-15 23:52:07 -04:00
WHERE `id` = " .intval( $row['id'] ));
}
}
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-05-08 11:55:16 -04:00
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.3.0' WHERE `Key` = 'modsForHeskVersion' " );
}
2015-05-15 11:28:58 -04:00
function execute230FileUpdate () {
//-- Add the new merged ticket property to modsForHesk_settings.inc.php
$file = file_get_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' );
//-- Only add the additional settings if they aren't already there.
if ( strpos ( $file , '$modsForHesk_settings[\'show_number_merged\']' ) === false )
{
$file .= '
//-- Setting for showing number of merged tickets in the ticket search screen. 0 = Disable, 1 = Enable
$modsForHesk_settings [ \ 'show_number_merged\'] = 1;' ;
}
2015-05-19 20:50:40 -04:00
if ( strpos ( $file , '$modsForHesk_settings[\'request_location\']' ) === false )
{
$file .= '
//-- Setting for requesting user\'s location. 0 = Disable, 1 = Enable
2015-06-28 00:58:24 -04:00
$modsForHesk_settings [ \ 'request_location\'] = 0;' ;
2015-05-19 20:50:40 -04:00
}
2015-05-15 11:28:58 -04:00
return file_put_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' , $file );
}
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
function execute231Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.3.1' WHERE `Key` = 'modsForHeskVersion' " );
}
2015-06-28 14:39:42 -04:00
// END Verison 2.3.1
// BEGIN Version 2.3.2
function execute232Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.3.2' WHERE `Key` = 'modsForHeskVersion' " );
}
2015-07-04 19:47:59 -04:00
// END Version 2.3.2
// BEGIN Version 2.4.0
function execute240Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
2015-08-03 22:10:57 -04:00
// Setup quick help sections
2015-07-04 19:47:59 -04:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " quick_help_sections` (
`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-08-08 14:15:51 -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-08-08 14:15:51 -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-08-08 14:15:51 -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-08-08 14:15:51 -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-08-15 15:26:55 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " quick_help_sections` (`location`, `show`)
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-07-25 01:11:08 -04:00
executeQuery ( " CREATE TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " text_to_status_xref` (
`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-07-26 22:17:30 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` ADD COLUMN `sort` INT " );
2015-07-27 00:06:57 -04:00
$statusesRs = executeQuery ( " SELECT `ID` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` ORDER BY `ID` ASC " );
$i = 10 ;
while ( $myStatus = hesk_dbFetchAssoc ( $statusesRs )) {
hesk_dbQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` SET `sort`= " . intval ( $i ) . "
WHERE `id` = '".intval($myStatus[' ID '])."' LIMIT 1 " );
$i += 10 ;
}
2015-08-03 22:10:57 -04:00
// Process attachment improvement tables
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " attachments` ADD COLUMN `download_count` INT NOT NULL DEFAULT 0 " );
2015-08-03 22:20:38 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " kb_attachments` ADD COLUMN `download_count` INT NOT NULL DEFAULT 0 " );
2015-08-19 07:46:52 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `html` ENUM('0','1') NOT NULL DEFAULT '0' " );
2015-08-19 19:48:46 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` ADD COLUMN `html` ENUM('0','1') NOT NULL DEFAULT '0' " );
2015-08-19 07:46:52 -04:00
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
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-07-27 22:11:53 -04:00
function initializeXrefTable () {
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' ];
}
$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-07-28 12:27:12 -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'] ). " ) " ;
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
}
function execute240FileUpdate () {
2015-08-06 12:46:14 -04:00
global $hesk_settings ;
2015-07-04 19:47:59 -04:00
$file = file_get_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' );
//-- Only add the additional settings if they aren't already there.
if ( strpos ( $file , '$modsForHesk_settings[\'category_order_column\']' ) === false )
{
$file .= '
//-- Column to sort categories by. Can be either \'name\' or \'cat_order\'
$modsForHesk_settings [ \ 'category_order_column\'] = \'cat_order\';' ;
}
2015-07-05 22:22:05 -04:00
if ( strpos ( $file , '$modsForHesk_settings[\'rich_text_for_tickets\']' ) === false )
{
$file .= '
//-- Setting for using rich-text editor for tickets. 0 = Disable, 1 = Enable
$modsForHesk_settings [ \ 'rich_text_for_tickets\'] = 0;' ;
}
2015-08-06 12:46:14 -04:00
if ( strpos ( $file , '$modsForHesk_settings[\'kb_attach_dir\']' ) === false )
{
$file .= '
//-- Directory to store knowledgebase articles in.
$modsForHesk_settings [ \ 'kb_attach_dir\'] = \'' . $hesk_settings [ 'attach_dir' ] . '\';' ;
}
2015-07-04 19:47:59 -04:00
2015-08-21 12:51:14 -04:00
return file_put_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' , $file );
}
// END Version 2.4.0
// BEGIN Version 2.4.1
function execute241Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
executeQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` SET `Value` = '2.4.1' WHERE `Key` = 'modsForHeskVersion' " );
}
function execute241FileUpdate () {
$file = file_get_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' );
if ( strpos ( $file , '$modsForHesk_settings[\'rich_text_for_tickets_for_customers\']' ) === false )
{
$file .= '
//-- Setting for using rich-text editor for customers. 0 = Disable, 1 = Enable
$modsForHesk_settings [ \ 'rich_text_for_tickets_for_customers\'] = 0;' ;
}
2015-07-04 19:47:59 -04:00
return file_put_contents ( HESK_PATH . 'modsForHesk_settings.inc.php' , $file );
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
function execute242Scripts () {
global $hesk_settings ;
hesk_dbConnect ();
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
function migrateSettings () {
global $hesk_settings ;
if ( file_exists ( HESK_PATH . 'modsForHesk_settings.inc.php' )) {
require_once ( HESK_PATH . 'modsForHesk_settings.inc.php' );
2015-08-27 16:57:18 -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 );
2015-09-02 22:04:32 -04:00
$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' );
2015-08-27 16:57:18 -04:00
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'rtl' , " .intval( $rtl ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'show_icons' , " .intval( $show_icons ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'custom_field_setting' , " .intval( $custom_field_setting ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'customer_email_verification_required' , " .intval( $customer_email_verification_required ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'html_emails' , " .intval( $html_emails ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'use_mailgun' , " .intval( $use_mailgun ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'mailgun_api_key' , '".hesk_dbEscape($mailgun_api_key)."' ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'mailgun_domain' , '".hesk_dbEscape($mailgun_domain)."' ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'use_bootstrap_theme' , " .intval( $use_bootstrap_theme ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'new_kb_article_visibility' , " .intval( $new_kb_article_visibility ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'attachments' , " .intval( $attachments ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'show_number_merged' , " .intval( $show_number_merged ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'request_location' , " .intval( $request_location ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'category_order_column' , '".hesk_dbEscape($category_order_column)."' ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'rich_text_for_tickets' , " .intval( $rich_text_for_tickets ). " ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'statuses_order_column' , '".hesk_dbEscape($statuses_order_column)."' ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'kb_attach_dir' , '".hesk_dbEscape($kb_attach_dir)."' ) " );
2015-08-25 22:18:27 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`)
2015-08-27 16:57:18 -04:00
VALUES ( 'rich_text_for_tickets_for_customers' , " .intval( $rich_text_for_tickets_for_customers ). " ) " );
2015-09-02 22:04:32 -04:00
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-25 22:18:27 -04:00
}
2015-08-27 16:57:18 -04:00
}
2015-09-06 22:12:49 -04:00
function getSettingValue ( $settings , $setting , $default ) {
return isset ( $settings [ $setting ]) ? $settings [ $setting ] : $default ;
}
2015-09-04 22:14:25 -04:00
function execute250Scripts () {
global $hesk_settings ;
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` ADD COLUMN `user_agent` TEXT " );
2015-09-06 17:52:51 -04:00
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 " );
2015-09-04 22:14:25 -04:00
executeQuery ( " ALTER TABLE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " stage_tickets` ADD COLUMN `user_agent` TEXT " );
2015-09-06 17:52:51 -04:00
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-06 22:12:49 -04:00
executeQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " settings` (`Key`, `Value`) VALUES ('display_user_agent_information', '0') " );
2015-09-04 22:14:25 -04:00
}
// END Version 2.5.0