From c99f75c908e4422a0302da807a581d4c2b0b4a6f Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 2 Oct 2017 22:02:26 -0400 Subject: [PATCH] Converted several other migrations --- .../migrations/AbstractUpdateMigration.php | 15 ++ install/migrations/core.php | 26 +++ install/migrations/v201/UpdateVersion.php | 15 ++ install/migrations/v210/UpdateVersion.php | 15 ++ .../migrations/v211/FixStageTicketsTable.php | 36 ++++ install/migrations/v211/UpdateVersion.php | 15 ++ .../v220/AddClosableColumnToStatuses.php | 16 ++ .../v220/AddIsAutocloseOptionToStatuses.php | 15 ++ install/migrations/v220/UpdateVersion.php | 15 ++ install/migrations/v221/UpdateVersion.php | 15 ++ .../migrations/v230/AddCategoryManager.php | 15 ++ .../v230/AddCoordinatesToTickets.php | 21 +++ .../v230/AddIconToServiceMessages.php | 15 ++ .../v230/ConsolidateStatusColumns.php | 21 +++ .../v230/CreatePermissionTemplates.php | 24 +++ .../MovePermissionsToHeskPrivilegesColumn.php | 53 ++++++ install/migrations/v230/UpdateVersion.php | 15 ++ install/migrations/v231/UpdateVersion.php | 15 ++ install/migrations/v232/UpdateVersion.php | 15 ++ .../v240/CreateQuickHelpSectionsTable.php | 30 +++ install/mods-for-hesk/sql/installSql.php | 176 ------------------ 21 files changed, 407 insertions(+), 176 deletions(-) create mode 100644 install/migrations/AbstractUpdateMigration.php create mode 100644 install/migrations/v201/UpdateVersion.php create mode 100644 install/migrations/v210/UpdateVersion.php create mode 100644 install/migrations/v211/FixStageTicketsTable.php create mode 100644 install/migrations/v211/UpdateVersion.php create mode 100644 install/migrations/v220/AddClosableColumnToStatuses.php create mode 100644 install/migrations/v220/AddIsAutocloseOptionToStatuses.php create mode 100644 install/migrations/v220/UpdateVersion.php create mode 100644 install/migrations/v221/UpdateVersion.php create mode 100644 install/migrations/v230/AddCategoryManager.php create mode 100644 install/migrations/v230/AddCoordinatesToTickets.php create mode 100644 install/migrations/v230/AddIconToServiceMessages.php create mode 100644 install/migrations/v230/ConsolidateStatusColumns.php create mode 100644 install/migrations/v230/CreatePermissionTemplates.php create mode 100644 install/migrations/v230/MovePermissionsToHeskPrivilegesColumn.php create mode 100644 install/migrations/v230/UpdateVersion.php create mode 100644 install/migrations/v231/UpdateVersion.php create mode 100644 install/migrations/v232/UpdateVersion.php create mode 100644 install/migrations/v240/CreateQuickHelpSectionsTable.php diff --git a/install/migrations/AbstractUpdateMigration.php b/install/migrations/AbstractUpdateMigration.php new file mode 100644 index 00000000..c1f9ce16 --- /dev/null +++ b/install/migrations/AbstractUpdateMigration.php @@ -0,0 +1,15 @@ +updateVersion($this->getUpVersion(), $hesk_settings); + } + + function down($hesk_settings) { + $this->updateVersion($this->getDownVersion(), $hesk_settings); + } +} \ No newline at end of file diff --git a/install/migrations/core.php b/install/migrations/core.php index 864377ff..c09834a0 100644 --- a/install/migrations/core.php +++ b/install/migrations/core.php @@ -35,5 +35,31 @@ function getAllMigrations() { 24 => new \v200\AddMissingKeyToTickets(), 25 => new \v200\MigrateIpAndEmailBans(), 26 => new \v200\UpdateVersion(), + //2.0.1 + 27 => new \v201\UpdateVersion(), + //2.1.0 + 28 => new \v210\UpdateVersion(), + //2.1.1 + 29 => new \v211\FixStageTicketsTable(), + 30 => new \v211\UpdateVersion(), + //2.2.0 + 31 => new \v220\AddIsAutocloseOptionToStatuses(), + 32 => new \v220\AddClosableColumnToStatuses(), + 33 => new \v220\UpdateVersion(), + //2.2.1 + 34 => new \v221\UpdateVersion(), + //2.3.0 + 35 => new \v230\AddIconToServiceMessages(), + 36 => new \v230\ConsolidateStatusColumns(), + 37 => new \v230\AddCoordinatesToTickets(), + 38 => new \v230\AddCategoryManager(), + 39 => new \v230\MovePermissionsToHeskPrivilegesColumn(), + 40 => new \v230\UpdateVersion(), + //2.3.1 + 41 => new \v231\UpdateVersion(), + //2.3.2 + 42 => new \v232\UpdateVersion(), + //2.4.0 + 43 => new \v240\CreateQuickHelpSectionsTable(), ); } \ No newline at end of file diff --git a/install/migrations/v201/UpdateVersion.php b/install/migrations/v201/UpdateVersion.php new file mode 100644 index 00000000..d9d93464 --- /dev/null +++ b/install/migrations/v201/UpdateVersion.php @@ -0,0 +1,15 @@ +updateVersion('2.0.1', $hesk_settings); + } + + function down($hesk_settings) { + $this->updateVersion('2.0.0', $hesk_settings); + } +} \ No newline at end of file diff --git a/install/migrations/v210/UpdateVersion.php b/install/migrations/v210/UpdateVersion.php new file mode 100644 index 00000000..aa815c03 --- /dev/null +++ b/install/migrations/v210/UpdateVersion.php @@ -0,0 +1,15 @@ +updateVersion('2.1.0', $hesk_settings); + } + + function down($hesk_settings) { + $this->updateVersion('2.0.1', $hesk_settings); + } +} \ No newline at end of file diff --git a/install/migrations/v211/FixStageTicketsTable.php b/install/migrations/v211/FixStageTicketsTable.php new file mode 100644 index 00000000..1019fd64 --- /dev/null +++ b/install/migrations/v211/FixStageTicketsTable.php @@ -0,0 +1,36 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` CHANGE `dt` `dt` TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00'"); + $this->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`)"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` + CHANGE `email` `email` VARCHAR(255) NOT NULL DEFAULT '', + CHANGE `ip` `ip` VARCHAR(46) NOT NULL DEFAULT '', + DROP `firstreply`, + DROP `closedat`, + DROP `articles`, + DROP `firstreplyby`, + DROP `closedby`, + DROP `replies`, + DROP `staffreplies`"); + } +} \ No newline at end of file diff --git a/install/migrations/v211/UpdateVersion.php b/install/migrations/v211/UpdateVersion.php new file mode 100644 index 00000000..4b12c3c0 --- /dev/null +++ b/install/migrations/v211/UpdateVersion.php @@ -0,0 +1,15 @@ +updateVersion('2.1.1', $hesk_settings); + } + + function down($hesk_settings) { + $this->updateVersion('2.1.0', $hesk_settings); + } +} \ No newline at end of file diff --git a/install/migrations/v220/AddClosableColumnToStatuses.php b/install/migrations/v220/AddClosableColumnToStatuses.php new file mode 100644 index 00000000..b60210ae --- /dev/null +++ b/install/migrations/v220/AddClosableColumnToStatuses.php @@ -0,0 +1,16 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `Closable` VARCHAR(10) NOT NULL"); + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `Closable` = 'yes'"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `Closable`"); + } +} \ No newline at end of file diff --git a/install/migrations/v220/AddIsAutocloseOptionToStatuses.php b/install/migrations/v220/AddIsAutocloseOptionToStatuses.php new file mode 100644 index 00000000..f9c1f167 --- /dev/null +++ b/install/migrations/v220/AddIsAutocloseOptionToStatuses.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `IsAutocloseOption` INT NOT NULL DEFAULT 0"); + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `IsAutocloseOption` = 1 WHERE `IsStaffClosedOption` = 1"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `IsAutocloseOption`"); + } +} \ No newline at end of file diff --git a/install/migrations/v220/UpdateVersion.php b/install/migrations/v220/UpdateVersion.php new file mode 100644 index 00000000..28364d6f --- /dev/null +++ b/install/migrations/v220/UpdateVersion.php @@ -0,0 +1,15 @@ +updateVersion('2.2.0', $hesk_settings); + } + + function down($hesk_settings) { + $this->updateVersion('2.1.1', $hesk_settings); + } +} \ No newline at end of file diff --git a/install/migrations/v221/UpdateVersion.php b/install/migrations/v221/UpdateVersion.php new file mode 100644 index 00000000..085e17c1 --- /dev/null +++ b/install/migrations/v221/UpdateVersion.php @@ -0,0 +1,15 @@ +updateVersion('2.2.1', $hesk_settings); + } + + function down($hesk_settings) { + $this->updateVersion('2.2.0', $hesk_settings); + } +} \ No newline at end of file diff --git a/install/migrations/v230/AddCategoryManager.php b/install/migrations/v230/AddCategoryManager.php new file mode 100644 index 00000000..a0b3daa8 --- /dev/null +++ b/install/migrations/v230/AddCategoryManager.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` ADD COLUMN `manager` INT NOT NULL DEFAULT 0"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` DROP COLUMN `manager`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/AddCoordinatesToTickets.php b/install/migrations/v230/AddCoordinatesToTickets.php new file mode 100644 index 00000000..cb9fae73 --- /dev/null +++ b/install/migrations/v230/AddCoordinatesToTickets.php @@ -0,0 +1,21 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `latitude`"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `longitude`"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` DROP COLUMN `latitude`"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` DROP COLUMN `longitude`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/AddIconToServiceMessages.php b/install/migrations/v230/AddIconToServiceMessages.php new file mode 100644 index 00000000..c7fad46e --- /dev/null +++ b/install/migrations/v230/AddIconToServiceMessages.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` ADD COLUMN `icon` VARCHAR(150)"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` DROP COLUMN `icon`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/ConsolidateStatusColumns.php b/install/migrations/v230/ConsolidateStatusColumns.php new file mode 100644 index 00000000..675d0e8d --- /dev/null +++ b/install/migrations/v230/ConsolidateStatusColumns.php @@ -0,0 +1,21 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `Key` TEXT"); + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `Key` = `ShortNameContentKey`"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `ShortNameContentKey`"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `TicketViewContentKey`"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `TicketViewContentKey` TEXT"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `ShortNameContentKey` TEXT"); + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `TicketViewContentKey` = `Key`, `ShortNameContentKey` = `Key`"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `Key`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/CreatePermissionTemplates.php b/install/migrations/v230/CreatePermissionTemplates.php new file mode 100644 index 00000000..bd7365ca --- /dev/null +++ b/install/migrations/v230/CreatePermissionTemplates.php @@ -0,0 +1,24 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `permission_template` INT"); + $this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(255) NOT NULL, + `heskprivileges` VARCHAR(1000), + `categories` VARCHAR(500))"); + $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates` (`name`, `heskprivileges`, `categories`) + VALUES ('Administrator', 'ALL', 'ALL')"); + $this->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')"); + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `permission_template` = 1 WHERE `isadmin` = '1'"); + } + + function down($hesk_settings) { + // TODO: Implement down() method. + } +} \ No newline at end of file diff --git a/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn.php b/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn.php new file mode 100644 index 00000000..9ace4515 --- /dev/null +++ b/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn.php @@ -0,0 +1,53 @@ +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); + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = '" . hesk_dbEscape($newPrivileges) . "' + WHERE `id` = " . intval($row['id'])); + } else { + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = 'can_man_settings' + WHERE `id` = " . intval($row['id'])); + } + } + $res = $this->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); + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = '" . hesk_dbEscape($newPrivileges) . "' + WHERE `id` = " . intval($row['id'])); + } else { + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = 'can_change_notification_settings' + WHERE `id` = " . intval($row['id'])); + } + } + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `can_manage_settings`"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `can_change_notification_settings`"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `can_change_notification_settings` ENUM('0', '1') NOT NULL DEFAULT '1'"); + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `can_manage_settings` ENUM ('0', '1') NOT NULL DEFAULT '1'"); + + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` + SET `can_change_settings` = '0' + WHERE `heskprivileges` NOT LIKE '%can_man_settings%'"); + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` + SET `can_change_notification_settings` = '0' + WHERE `heskprivileges` NOT LIKE '%can_change_notification_settings%'"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/UpdateVersion.php b/install/migrations/v230/UpdateVersion.php new file mode 100644 index 00000000..18b7bf65 --- /dev/null +++ b/install/migrations/v230/UpdateVersion.php @@ -0,0 +1,15 @@ +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"); + + $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`) + VALUES ('create_ticket', '1')"); + $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`) + VALUES ('view_ticket_form', '1')"); + $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`) + VALUES ('view_ticket', '1')"); + $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`) + VALUES ('knowledgebase', '1')"); + $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`) + VALUES ('staff_create_ticket', '1')"); + } + + function down($hesk_settings) { + $this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections`"); + } +} \ No newline at end of file diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index 46a95982..95ef5e8d 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -37,165 +37,6 @@ function executeQuery($sql) } } -// Version 2.0.1 -function execute201Scripts() -{ - global $hesk_settings; - - hesk_dbConnect(); - executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '2.0.1' WHERE `Key` = 'modsForHeskVersion'"); -} - -// 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'"); - - // Some old tables may not have been dropped during the 2.0.0 upgrade. Check and drop if necessary - 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`"); -} -// END Version 2.1.0 - -// BEGIN Version 2.1.1 -function execute211Scripts() -{ - global $hesk_settings; - - hesk_dbConnect(); - executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` CHANGE `dt` `dt` TIMESTAMP NOT NULL DEFAULT '2000-01-01 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'"); -} -// END Version 2.1.1 - -// BEGIN Version 2.2.0 -function execute220Scripts() -{ - global $hesk_settings; - - hesk_dbConnect(); - 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"); - - 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'"); -} -// 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'"); -} - -// 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)"); - 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, - `name` VARCHAR(255) NOT NULL, - `heskprivileges` VARCHAR(1000), - `categories` VARCHAR(500))"); - 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')"); - executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `permission_template` = 1 WHERE `isadmin` = '1'"); - - // 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); - executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = '" . hesk_dbEscape($newPrivileges) . "' - WHERE `id` = " . intval($row['id'])); - } else { - executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = 'can_man_settings' - 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); - executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = '" . hesk_dbEscape($newPrivileges) . "' - WHERE `id` = " . intval($row['id'])); - } else { - executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = 'can_change_notification_settings' - 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`"); - - executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '2.3.0' WHERE `Key` = 'modsForHeskVersion'"); -} -// END Version 2.3.0 - - -// 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'"); -} - -// 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'"); -} - // END Version 2.3.2 // BEGIN Version 2.4.0 @@ -205,23 +46,6 @@ function execute240Scripts() hesk_dbConnect(); - // Setup quick help sections - 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"); - - executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`) - VALUES ('create_ticket', '1')"); - executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`) - VALUES ('view_ticket_form', '1')"); - executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`) - VALUES ('view_ticket', '1')"); - executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`) - VALUES ('knowledgebase', '1')"); - executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`) - VALUES ('staff_create_ticket', '1')"); // Setup status improvement tables executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "text_to_status_xref` (