diff --git a/install/mods-for-hesk/ajax/uninstall-database-ajax.php b/install/mods-for-hesk/ajax/uninstall-database-ajax.php index 7c3962da..69357dcc 100644 --- a/install/mods-for-hesk/ajax/uninstall-database-ajax.php +++ b/install/mods-for-hesk/ajax/uninstall-database-ajax.php @@ -7,10 +7,31 @@ hesk_load_database_functions(); require('../sql/uninstallSql.php'); $task = $_POST['task']; -if ($task == 1) { - executePre140Scripts(); +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 == 'miscellaneous') { + executeMiscellaneousSql(); } else { - print 'The task "'.$task.'" was not recognized. Check the value submitted and try again.'; http_response_code(400); } return; \ No newline at end of file diff --git a/install/mods-for-hesk/index.html b/install/mods-for-hesk/index.html new file mode 100644 index 00000000..cf048141 --- /dev/null +++ b/install/mods-for-hesk/index.html @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/install/mods-for-hesk/js/uninstall-scripts.js b/install/mods-for-hesk/js/uninstall-scripts.js index c670460d..d85b6a33 100644 --- a/install/mods-for-hesk/js/uninstall-scripts.js +++ b/install/mods-for-hesk/js/uninstall-scripts.js @@ -1,28 +1,104 @@ -function processUninstallation() { - var tasks = ['status-change', 'autorefresh', 'parent-child', 'settings-access', 'activate-user', +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']; + 'pending-verification-emails-table', 'pending-verification-tickets-table', 'miscellaneous']; +} + +function processUninstallation() { + var tasks = getTasks(); //-- Change status column to default HESK values tasks.forEach(function(task) { startUninstallation(task); executeUninstallation(task); }); } - function startUninstallation(task) { + $('#spinner-'+task) + .removeClass('fa-exclamation-triangle') + .addClass('fa-spinner') + .addClass('fa-pulse'); + changeRowTo('row', task, 'info'); + changeTextTo('span', task, 'In Progress'); +} + +function changeTextTo(prefix, task, text) { + $('#'+prefix+'-'+task).text(text); +} + +function changeRowTo(prefix, task, clazz) { + //-- Remove all classes + $('#'+prefix+'-'+task) + .removeClass('info') + .removeClass('warning') + .removeClass('danger') + .removeClass('success'); + + //-- Re-add the requested class + $('#'+prefix+'-'+task).addClass(clazz); +} + +function executeUninstallation(task) { appendToInstallConsole('INFOStarting task code: ' + task + ''); $.ajax({ type: 'POST', - url: 'ajax/install-database-ajax.php', + url: 'ajax/uninstall-database-ajax.php', data: { task: task }, success: function(data) { - markUninstallAsSuccess(cssclass, formattedVersion); + markUninstallAsSuccess(task); + checkForCompletion(); }, error: function(data) { - appendToInstallConsole('ERROR'+ data.responseText + ''); - markUninstallAsFailure(cssclass); + if (data.status == 400) { + appendToInstallConsole('ERRORThe task '+ task +' was not recognized. Check the value submitted and try again.'); + } else { + appendToInstallConsole('ERROR'+ data.responseText + ''); + } + markUninstallAsFailure(task); } }); } +function checkForCompletion() { + // If all rows have a .success row, installation is finished + var numberOfTasks = getTasks().length; + var numberOfCompletions = $('tr.success').length; + if (numberOfTasks == numberOfCompletions) { + uninstallationFinished(); + } +} + +function uninstallationFinished() { + appendToInstallConsole('SUCCESSUninstallation complete'); + var output = '
' + + '
' + + '

' + + '

Awesome! The automated portion of uninstalling Mods for HESK has completed. ' + + 'Please follow these instructions ' + + 'on the Mods for HESK website to finish uninstallation.

' + + '
' + + '
'; + $('#uninstall-information').html(output); +} + +function markUninstallAsSuccess(task) { + removeSpinner(task); + $('#spinner-'+task).addClass('fa-check-circle'); + changeTextTo('span', task, 'Completed Successfully'); + changeRowTo('row', task, 'success'); + appendToInstallConsole('SUCCESSUninstall for task code: ' + task + ' complete'); +} + +function markUninstallAsFailure(task) { + removeSpinner(task); + $('#spinner-'+task).addClass('fa-times-circle'); + changeRowTo('row', task, 'danger'); + changeTextTo('span', task, 'Uninstall failed! Check the console for more information'); +} + +function removeSpinner(task) { + $('#spinner-'+task) + .removeClass('fa-pulse') + .removeClass('fa-spinner'); +} + jQuery(document).ready(loadJquery); \ 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 f3d0b73c..d2aa291f 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -335,6 +335,10 @@ function execute210Scripts() { 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['db_pfix'])."denied_ips`"); + executeQuery("DROP TABLE IF EXISTS `".hesk_dbEscape($hesk['db_pfix'])."denied_emails`"); } function execute210FileUpdate() { diff --git a/install/mods-for-hesk/sql/uninstallSql.php b/install/mods-for-hesk/sql/uninstallSql.php index 6c70a5c2..d8f2b7b4 100644 --- a/install/mods-for-hesk/sql/uninstallSql.php +++ b/install/mods-for-hesk/sql/uninstallSql.php @@ -127,4 +127,13 @@ function removeTicketsPendingVerificationTable() { hesk_dbConnect(); executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets`"); +} + +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`'); } \ No newline at end of file diff --git a/install/mods-for-hesk/uninstallModsForHesk.php b/install/mods-for-hesk/uninstallModsForHesk.php index 46b8dbf5..34dc18d7 100644 --- a/install/mods-for-hesk/uninstallModsForHesk.php +++ b/install/mods-for-hesk/uninstallModsForHesk.php @@ -16,10 +16,11 @@ function echoTaskRows() { 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('Miscellaneous database cleanup changes', 'miscellaneous'); } function printUninstallRow($text, $id) { - echo ''; + echo ''; echo ''.$text.''; echo ' Waiting...'; echo ''; @@ -50,7 +51,7 @@ function printUninstallRow($text, $id) {
Uninstallation Progress
-
+
@@ -60,6 +61,24 @@ function printUninstallRow($text, $id) { +
+
+
+
Console
+
+
+ + + + + + + +
SeverityMessage
+
+
+
+