From c3134b459ad6fc394e46c198ff95ea4c52b95b37 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 17 Mar 2015 22:02:19 -0400 Subject: [PATCH] #168 Add SQL scripts, start JavaScript code --- ...ase-ajax.php => install-database-ajax.php} | 2 +- install/mods-for-hesk/ajax/task-ajax.php | 2 +- .../ajax/uninstall-database-ajax.php | 16 +++ install/mods-for-hesk/js/uninstall-scripts.js | 28 ++++ install/mods-for-hesk/js/version-scripts.js | 2 +- .../installSql.php} | 0 install/mods-for-hesk/sql/uninstallSql.php | 130 ++++++++++++++++++ .../mods-for-hesk/uninstallModsForHesk.php | 44 +++++- 8 files changed, 219 insertions(+), 5 deletions(-) rename install/mods-for-hesk/ajax/{database-ajax.php => install-database-ajax.php} (96%) create mode 100644 install/mods-for-hesk/ajax/uninstall-database-ajax.php create mode 100644 install/mods-for-hesk/js/uninstall-scripts.js rename install/mods-for-hesk/{modsForHeskSql.php => sql/installSql.php} (100%) create mode 100644 install/mods-for-hesk/sql/uninstallSql.php diff --git a/install/mods-for-hesk/ajax/database-ajax.php b/install/mods-for-hesk/ajax/install-database-ajax.php similarity index 96% rename from install/mods-for-hesk/ajax/database-ajax.php rename to install/mods-for-hesk/ajax/install-database-ajax.php index 69ed2cf0..d5078e4d 100644 --- a/install/mods-for-hesk/ajax/database-ajax.php +++ b/install/mods-for-hesk/ajax/install-database-ajax.php @@ -4,7 +4,7 @@ define('HESK_PATH','../../../'); require(HESK_PATH . 'hesk_settings.inc.php'); require(HESK_PATH . 'inc/common.inc.php'); hesk_load_database_functions(); -require('../modsForHeskSql.php'); +require('../sql/installSql.php'); $version = $_POST['version']; if ($version == 1) { diff --git a/install/mods-for-hesk/ajax/task-ajax.php b/install/mods-for-hesk/ajax/task-ajax.php index 56d8342c..b5e3d503 100644 --- a/install/mods-for-hesk/ajax/task-ajax.php +++ b/install/mods-for-hesk/ajax/task-ajax.php @@ -4,7 +4,7 @@ define('HESK_PATH','../../../'); require(HESK_PATH . 'hesk_settings.inc.php'); require(HESK_PATH . 'inc/common.inc.php'); hesk_load_database_functions(); -require('../modsForHeskSql.php'); +require('../sql/installSql.php'); $task = $_POST['task']; if ($task == 'ip-email-bans') { diff --git a/install/mods-for-hesk/ajax/uninstall-database-ajax.php b/install/mods-for-hesk/ajax/uninstall-database-ajax.php new file mode 100644 index 00000000..7c3962da --- /dev/null +++ b/install/mods-for-hesk/ajax/uninstall-database-ajax.php @@ -0,0 +1,16 @@ +INFOStarting task code: ' + task + ''); + $.ajax({ + type: 'POST', + url: 'ajax/install-database-ajax.php', + data: { task: task }, + success: function(data) { + markUninstallAsSuccess(cssclass, formattedVersion); + }, + error: function(data) { + appendToInstallConsole('ERROR'+ data.responseText + ''); + markUninstallAsFailure(cssclass); + } + }); +} + +jQuery(document).ready(loadJquery); \ No newline at end of file diff --git a/install/mods-for-hesk/js/version-scripts.js b/install/mods-for-hesk/js/version-scripts.js index aa88a6a7..8cdd3412 100644 --- a/install/mods-for-hesk/js/version-scripts.js +++ b/install/mods-for-hesk/js/version-scripts.js @@ -39,7 +39,7 @@ function executeUpdate(version, cssclass, formattedVersion) { appendToInstallConsole('INFOStarting updates for ' + formattedVersion + ''); $.ajax({ type: 'POST', - url: 'ajax/database-ajax.php', + url: 'ajax/install-database-ajax.php', data: { version: version }, success: function(data) { markUpdateAsSuccess(cssclass, formattedVersion); diff --git a/install/mods-for-hesk/modsForHeskSql.php b/install/mods-for-hesk/sql/installSql.php similarity index 100% rename from install/mods-for-hesk/modsForHeskSql.php rename to install/mods-for-hesk/sql/installSql.php diff --git a/install/mods-for-hesk/sql/uninstallSql.php b/install/mods-for-hesk/sql/uninstallSql.php new file mode 100644 index 00000000..6c70a5c2 --- /dev/null +++ b/install/mods-for-hesk/sql/uninstallSql.php @@ -0,0 +1,130 @@ +fetch_assoc()) + { + + executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `status_int` = '".intval($currentResult['status'])."' WHERE `id` = ".$currentResult['id']); + } + 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` ENUM('0','1','2','3','4','5') NOT NULL"); + executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses`"); +} + +function removeAutorefresh() { + global $hesk_settings; + + hesk_dbConnect(); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `autorefresh`"); +} + +function removeParentColumn() { + global $hesk_settings; + + hesk_dbConnect(); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` DROP COLUMN `parent`"); +} + +function removeHelpDeskSettingsPermission() { + global $hesk_settings; + + hesk_dbConnect(); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `can_manage_settings`"); +} + +function removeActiveColumn() { + global $hesk_settings; + + hesk_dbConnect(); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `active`"); +} + +function removeNotifyNoteUnassigned() { + global $hesk_settings; + + hesk_dbConnect(); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `notify_note_unassigned`"); +} + +function removeUserManageOwnNotificationSettingsColumn() { + global $hesk_settings; + + hesk_dbConnect(); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `can_change_notification_settings`"); +} + +function removeSettingsTable() { + global $hesk_settings; + + hesk_dbConnect(); + executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."settings`"); +} + +function removeVerifiedEmailsTable() { + global $hesk_settings; + + hesk_dbConnect(); + executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."verified_emails`"); +} + +function removePendingVerificationEmailsTable() { + global $hesk_settings; + + hesk_dbConnect(); + executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."pending_verification_emails`"); +} + +function removeTicketsPendingVerificationTable() { + global $hesk_settings; + + hesk_dbConnect(); + executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets`"); +} \ No newline at end of file diff --git a/install/mods-for-hesk/uninstallModsForHesk.php b/install/mods-for-hesk/uninstallModsForHesk.php index 6fc87e44..46b8dbf5 100644 --- a/install/mods-for-hesk/uninstallModsForHesk.php +++ b/install/mods-for-hesk/uninstallModsForHesk.php @@ -3,6 +3,27 @@ define('IN_SCRIPT',1); define('HESK_PATH','../../'); require(HESK_PATH . 'install/install_functions.inc.php'); require(HESK_PATH . 'hesk_settings.inc.php'); + +function echoTaskRows() { + printUninstallRow('Change status column to default HESK values', 'status-change'); + printUninstallRow('Remove autorefresh feature', 'autorefresh'); + printUninstallRow('Remove parent-child ticket relationships', 'parent-child'); + printUninstallRow('Remove explicit help desk settings permission', 'settings-access'); + printUninstallRow('Remove activate/deactivate users settings', 'activate-user'); + printUninstallRow('Remove Mods for HESK-added notification settings', 'notify-note-unassigned'); + printUninstallRow('Remove "user can manage notification settings" feature', 'user-manage-notification-settings'); + printUninstallRow('Remove settings table', 'settings-table'); + printUninstallRow('Remove verified emails table', 'verified-emails-table'); + printUninstallRow('Remove pending verification emails table', 'pending-verification-emails-table'); + printUninstallRow('Remove tickets pending verification table', 'pending-verification-tickets-table'); +} + +function printUninstallRow($text, $id) { + echo ''; + echo ''.$text.''; + echo ' Waiting...'; + echo ''; +} ?> @@ -16,13 +37,32 @@ require(HESK_PATH . 'hesk_settings.inc.php'); - +
Uninstalling Mods for HESK
- + +
+
+
+
Uninstallation Progress
+
+ + + + +
+
+
+
+
+ \ No newline at end of file