From ac3ba746f63b393529cd52de80bc49b991005c10 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 16 Jun 2015 22:10:22 -0400 Subject: [PATCH] Update uninstaller --- .../ajax/uninstall-database-ajax.php | 28 +------ install/mods-for-hesk/js/uninstall-scripts.js | 5 +- install/mods-for-hesk/sql/uninstallSql.php | 78 +------------------ .../mods-for-hesk/uninstallModsForHesk.php | 16 +--- 4 files changed, 9 insertions(+), 118 deletions(-) diff --git a/install/mods-for-hesk/ajax/uninstall-database-ajax.php b/install/mods-for-hesk/ajax/uninstall-database-ajax.php index eb975e71..d0ad97e5 100644 --- a/install/mods-for-hesk/ajax/uninstall-database-ajax.php +++ b/install/mods-for-hesk/ajax/uninstall-database-ajax.php @@ -9,32 +9,8 @@ require('../sql/uninstallSql.php'); $task = $_POST['task']; if ($task == 'status-change') { replaceStatusColumn(); -} elseif ($task == 'autorefresh') { - removeAutorefresh(); -} elseif ($task == 'parent-child') { - removeParentColumn(); -} elseif ($task == 'settings-access') { - removeHelpDeskSettingsPermission(); -} elseif ($task == 'activate-user') { - removeActiveColumn(); -} elseif ($task == 'notify-note-unassigned') { - removeNotifyNoteUnassigned(); -} elseif ($task == 'user-manage-notification-settings') { - removeUserManageOwnNotificationSettingsColumn(); -} elseif ($task == 'settings-table') { - removeSettingsTable(); -} elseif ($task == 'verified-emails-table') { - removeVerifiedEmailsTable(); -} elseif ($task == 'pending-verification-emails-table') { - removePendingVerificationEmailsTable(); -} elseif ($task == 'pending-verification-tickets-table') { - removeTicketsPendingVerificationTable(); -} elseif ($task == 'service-message-icon') { - removeServiceMessageCustomIcon(); -} elseif ($task == 'location') { - removeTicketLocation(); -} elseif ($task == 'miscellaneous') { - executeMiscellaneousSql(); +} elseif ($task == 'drop-columns') { + removeOtherColumns(); } else { http_response_code(400); } diff --git a/install/mods-for-hesk/js/uninstall-scripts.js b/install/mods-for-hesk/js/uninstall-scripts.js index cd5ce96c..1ac02d4b 100644 --- a/install/mods-for-hesk/js/uninstall-scripts.js +++ b/install/mods-for-hesk/js/uninstall-scripts.js @@ -1,8 +1,5 @@ function getTasks() { - return ['status-change', 'autorefresh', 'parent-child', 'settings-access', 'activate-user', - 'notify-note-unassigned', 'user-manage-notification-settings', 'settings-table', 'verified-emails-table', - 'pending-verification-emails-table', 'pending-verification-tickets-table', 'service-message-icon', 'location', - 'miscellaneous']; + return ['status-change', 'drop-columns']; } function processUninstallation() { diff --git a/install/mods-for-hesk/sql/uninstallSql.php b/install/mods-for-hesk/sql/uninstallSql.php index 9718ab79..96adb576 100644 --- a/install/mods-for-hesk/sql/uninstallSql.php +++ b/install/mods-for-hesk/sql/uninstallSql.php @@ -59,97 +59,27 @@ function replaceStatusColumn() { executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses`"); } -function removeAutorefresh() { - global $hesk_settings; - - hesk_dbConnect(); +function removeOtherColumns() { 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`"); -} - -function removeServiceMessageCustomIcon() { - global $hesk_settings; - - hesk_dbConnect(); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."service_messages` DROP COLUMN `icon`"); -} - -function removeTicketLocation() { - global $hesk_settings; - - hesk_dbConnect(); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` DROP COLUMN `latitude`"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` DROP COLUMN `longitude`"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` DROP COLUMN `latitude`"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` DROP COLUMN `longitude`"); -} + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` DROP COLUMN `manager`"); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `permission_template`"); + executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates`"); -function executeMiscellaneousSql() { - global $hesk_settings; - hesk_dbConnect(); // These queries are ran in case someone used an unfortunate installation they may have not properly cleaned up tables 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`'); diff --git a/install/mods-for-hesk/uninstallModsForHesk.php b/install/mods-for-hesk/uninstallModsForHesk.php index f06857ce..ad79574c 100644 --- a/install/mods-for-hesk/uninstallModsForHesk.php +++ b/install/mods-for-hesk/uninstallModsForHesk.php @@ -5,20 +5,8 @@ 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'); - printUninstallRow('Remove custom service messages icon', 'service-message-icon'); - printUninstallRow('Remove ticket location', 'location'); - printUninstallRow('Miscellaneous database cleanup changes', 'miscellaneous'); + printUninstallRow('Remove custom statuses', 'status-change'); + printUninstallRow('Reset other tables', 'drop-columns'); } function printUninstallRow($text, $id) {