diff --git a/install/mods-for-hesk/installModsForHesk.php b/install/mods-for-hesk/installModsForHesk.php index 16eba7a0..da3aaf54 100644 --- a/install/mods-for-hesk/installModsForHesk.php +++ b/install/mods-for-hesk/installModsForHesk.php @@ -60,6 +60,8 @@ function printRow($version) { + + diff --git a/install/mods-for-hesk/js/ui-scripts.js b/install/mods-for-hesk/js/ui-scripts.js new file mode 100644 index 00000000..158cd758 --- /dev/null +++ b/install/mods-for-hesk/js/ui-scripts.js @@ -0,0 +1,100 @@ +function disableAllDisablable(exclusion) { + $('.disablable').attr('disabled', 'disabled'); + $('#'+exclusion).removeAttr('disabled'); +} + +function enableAllDisablable() { + $('.disablable').removeAttr('disabled'); + $('#updateText').hide(); +} + +function startVersionUpgrade(version) { + $('#spinner-'+version) + .removeClass('fa-exclamation-triangle') + .addClass('fa-spinner') + .addClass('fa-pulse'); + changeRowTo('row', version, 'info'); + changeTextTo('span', version, 'In Progress'); +} + +function markUpdateAsSuccess(version) { + removeSpinner(version); + $('#spinner-'+version).addClass('fa-check-circle'); + changeTextTo('span', version, 'Completed Successfully'); + changeRowTo('row', version, 'success'); +} + +function removeSpinner(version) { + $('#spinner-'+version) + .removeClass('fa-pulse') + .removeClass('fa-spinner'); +} + +function markUpdateAsAttention(version) { + removeSpinner(version); + $('#spinner-'+version).addClass('fa-exclamation-triangle'); + changeRowTo('row', version, 'warning'); + changeTextTo('span', version, 'Attention! See below for more information'); +} + +function markUpdateAsFailure(version) { + removeSpinner(version); + $('#spinner-'+version).addClass('fa-times-circle'); + changeRowTo('row', version, 'danger'); + changeTextTo('span', version, 'Update failed! Check the console for more information'); +} + +function changeTextTo(prefix, version, text) { + $('#'+prefix+'-'+version).text(text); +} + +function changeRowTo(prefix, version, clazz) { + //-- Remove all classes + $('#'+prefix+'-'+version) + .removeClass('info') + .removeClass('warning') + .removeClass('danger') + .removeClass('success'); + + //-- Re-add the requested class + $('#'+prefix+'-'+version).addClass(clazz); +} + +function appendToInstallConsole(text) { + var currentText = $('#console-text').text(); + $('#console-text').append(text).append('
'); +} + +function installationFinished() { + var output = '
' + + '
' + + '

' + + '

Awesome! The installation / upgrade has completed. Please delete the install directory and then proceed to your helpdesk!

' + + '
' + + '
'; + $('#install-information').html(output); +} + +function getContentForMigratePrompt(users) { + var beginningText = '

Migrating IP / E-mail Bans

Mods for HESK has detected that you have added IP address ' + + 'and/or email bans using Mods for HESK. As part of the upgrade process, Mods for HESK will migrate these bans ' + + 'for you to HESK 2.6.0\'s IP/email ban feature. Select the user below that will be the "creator" of the bans, ' + + 'then click "Submit".

'; + var selectMarkup = '
User:
' + + '

'; + var submitMarkup = '
' + + 'Don\'t Migrate
'; + + return beginningText + selectMarkup + submitMarkup; +} + +function prepareAttentionPanel(content) { + $('#attention-body').html(content); + $('#attention-row').show(); +} + +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 new file mode 100644 index 00000000..6c744f55 --- /dev/null +++ b/install/mods-for-hesk/js/version-scripts.js @@ -0,0 +1,105 @@ +function processUpdates(startingVersion) { + if (startingVersion < 1) { + startVersionUpgrade('p140'); + executeUpdate(1, 'p140'); + } else if (startingVersion < 140) { + startVersionUpgrade('140'); + executeUpdate(140, '140'); + } else if (startingVersion < 141) { + startVersionUpgrade('141'); + executeUpdate(141, '141'); + } else if (startingVersion < 150) { + startVersionUpgrade('150'); + executeUpdate(150, '150'); + } else if (startingVersion < 160) { + startVersionUpgrade('160'); + executeUpdate(160, '160'); + } else if (startingVersion < 161) { + startVersionUpgrade('161'); + executeUpdate(161, '161'); + } else if (startingVersion < 170) { + startVersionUpgrade('170'); + executeUpdate(170, '170'); + } else if (startingVersion < 200) { + startVersionUpgrade('200'); + executeUpdate(200, '200'); + } else if (startingVersion < 201) { + startVersionUpgrade('201'); + executeUpdate(201, '201'); + } else { + installationFinished(); + } +} + + +function executeUpdate(version, cssclass) { + $.ajax({ + type: 'POST', + url: 'ajax/database-ajax.php', + data: { version: version }, + success: function(data) { + + markUpdateAsSuccess(cssclass); + if (version == 200) { + migrateIpEmailBans('banmigrate', cssclass); + } + processUpdates(version); + }, + error: function(data) { + appendToInstallConsole('ERROR: ' + data.responseText); + markUpdateAsFailure(cssclass); + } + }); +} + +function migrateIpEmailBans(version, cssclass) { + startVersionUpgrade(version); + $.ajax({ + type: 'POST', + url: 'ajax/task-ajax.php', + data: { task: 'ip-email-bans' }, + success: function(data) { + var parsedData = $.parseJSON(data); + console.info(parsedData); + if (parsedData.status == 'ATTENTION') { + markUpdateAsAttention(version); + prepareAttentionPanel(getContentForMigratePrompt(parsedData.users)); + } else { + migrateComplete(); + } + }, + error: function(data) { + appendToInstallConsole('ERROR: ' + data.responseText); + markUpdateAsFailure(cssclass); + } + }); +} + + +function runMigration() { + // Get user ID that is selected + var userId = $('#user-dropdown').val(); + // Hide the div, switch back to in progress + $('#attention-row').hide(); + startVersionUpgrade('banmigrate'); + $.ajax({ + type: 'POST', + url: 'ajax/task-ajax.php', + data: { task: 'migrate-bans', user: userId }, + success: function(data) { + migrateComplete(); + }, + error: function(data) { + appendToInstallConsole('ERROR: ' + data.responseText); + markUpdateAsFailure('banmigrate'); + } + }) +} + +function migrateComplete() { + $('#attention-row').hide(); + markUpdateAsSuccess('banmigrate'); + processUpdates(200); +} + +jQuery(document).ready(loadJquery); \ No newline at end of file diff --git a/install/mods-for-hesk/migrateBans.php b/install/mods-for-hesk/migrateBans.php deleted file mode 100644 index 19097874..00000000 --- a/install/mods-for-hesk/migrateBans.php +++ /dev/null @@ -1,15 +0,0 @@ - - -

Installation / Update complete!

-

Please delete the install folder for security reasons, and then proceed back to the Help Desk

- - \ No newline at end of file diff --git a/install/mods-for-hesk/modsForHesk.php b/install/mods-for-hesk/modsForHesk.php index a00afe7c..e72aab0a 100644 --- a/install/mods-for-hesk/modsForHesk.php +++ b/install/mods-for-hesk/modsForHesk.php @@ -17,6 +17,8 @@ hesk_dbConnect(); + + diff --git a/js/modsForHesk-javascript.js b/js/modsForHesk-javascript.js index d48d6b80..cc98d8e9 100644 --- a/js/modsForHesk-javascript.js +++ b/js/modsForHesk-javascript.js @@ -68,205 +68,4 @@ function toggleContainers(showIds, hideIds) { }); } -function disableAllDisablable(exclusion) { - $('.disablable').attr('disabled', 'disabled'); - $('#'+exclusion).removeAttr('disabled'); -} - -function enableAllDisablable() { - $('.disablable').removeAttr('disabled'); - $('#updateText').hide(); -} - -function startVersionUpgrade(version) { - $('#spinner-'+version) - .removeClass('fa-exclamation-triangle') - .addClass('fa-spinner') - .addClass('fa-pulse'); - changeRowTo('row', version, 'info'); - changeTextTo('span', version, 'In Progress'); -} - -function markUpdateAsSuccess(version) { - removeSpinner(version); - $('#spinner-'+version).addClass('fa-check-circle'); - changeTextTo('span', version, 'Completed Successfully'); - changeRowTo('row', version, 'success'); -} - -function removeSpinner(version) { - $('#spinner-'+version) - .removeClass('fa-pulse') - .removeClass('fa-spinner'); -} - -function markUpdateAsAttention(version) { - removeSpinner(version); - $('#spinner-'+version).addClass('fa-exclamation-triangle'); - changeRowTo('row', version, 'warning'); - changeTextTo('span', version, 'Attention! See below for more information'); -} - -function markUpdateAsFailure(version) { - removeSpinner(version); - $('#spinner-'+version).addClass('fa-times-circle'); - changeRowTo('row', version, 'danger'); - changeTextTo('span', version, 'Update failed! Check the console for more information'); -} - -function changeTextTo(prefix, version, text) { - $('#'+prefix+'-'+version).text(text); -} - -function changeRowTo(prefix, version, clazz) { - //-- Remove all classes - $('#'+prefix+'-'+version) - .removeClass('info') - .removeClass('warning') - .removeClass('danger') - .removeClass('success'); - - //-- Re-add the requested class - $('#'+prefix+'-'+version).addClass(clazz); -} - -function appendToInstallConsole(text) { - var currentText = $('#console-text').text(); - $('#console-text').append(text).append('
'); -} - -function processUpdates(startingVersion) { - if (startingVersion < 1) { - startVersionUpgrade('p140'); - executeUpdate(1, 'p140'); - } else if (startingVersion < 140) { - startVersionUpgrade('140'); - executeUpdate(140, '140'); - } else if (startingVersion < 141) { - startVersionUpgrade('141'); - executeUpdate(141, '141'); - } else if (startingVersion < 150) { - startVersionUpgrade('150'); - executeUpdate(150, '150'); - } else if (startingVersion < 160) { - startVersionUpgrade('160'); - executeUpdate(160, '160'); - } else if (startingVersion < 161) { - startVersionUpgrade('161'); - executeUpdate(161, '161'); - } else if (startingVersion < 170) { - startVersionUpgrade('170'); - executeUpdate(170, '170'); - } else if (startingVersion < 200) { - startVersionUpgrade('200'); - executeUpdate(200, '200'); - } else if (startingVersion < 201) { - startVersionUpgrade('201'); - executeUpdate(201, '201'); - } else { - installationFinished(); - } -} - -function executeUpdate(version, cssclass) { - $.ajax({ - type: 'POST', - url: 'ajax/database-ajax.php', - data: { version: version }, - success: function(data) { - - markUpdateAsSuccess(cssclass); - if (version == 200) { - migrateIpEmailBans('banmigrate', cssclass); - } - processUpdates(version); - }, - error: function(data) { - appendToInstallConsole('ERROR: ' + data.responseText); - markUpdateAsFailure(cssclass); - } - }); -} - -function migrateIpEmailBans(version, cssclass) { - startVersionUpgrade(version); - $.ajax({ - type: 'POST', - url: 'ajax/task-ajax.php', - data: { task: 'ip-email-bans' }, - success: function(data) { - var parsedData = $.parseJSON(data); - console.info(parsedData); - if (parsedData.status == 'ATTENTION') { - markUpdateAsAttention(version); - prepareAttentionPanel(getContentForMigratePrompt(parsedData.users)); - } else { - migrateComplete(); - } - }, - error: function(data) { - appendToInstallConsole('ERROR: ' + data.responseText); - markUpdateAsFailure(cssclass); - } - }); -} - -function installationFinished() { - var output = '
' + - '
' + - '

' + - '

Awesome! The installation / upgrade has completed. Please delete the install directory and then proceed to your helpdesk!

' + - '
' + - '
'; - $('#install-information').html(output); -} - -function getContentForMigratePrompt(users) { - var beginningText = '

Migrating IP / E-mail Bans

Mods for HESK has detected that you have added IP address ' + - 'and/or email bans using Mods for HESK. As part of the upgrade process, Mods for HESK will migrate these bans ' + - 'for you to HESK 2.6.0\'s IP/email ban feature. Select the user below that will be the "creator" of the bans, ' + - 'then click "Submit".

'; - var selectMarkup = '
User:
' + - '

'; - var submitMarkup = '
' + - 'Don\'t Migrate
'; - - return beginningText + selectMarkup + submitMarkup; -} - -function prepareAttentionPanel(content) { - $('#attention-body').html(content); - $('#attention-row').show(); -} - -function runMigration() { - // Get user ID that is selected - var userId = $('#user-dropdown').val(); - // Hide the div, switch back to in progress - $('#attention-row').hide(); - startVersionUpgrade('banmigrate'); - $.ajax({ - type: 'POST', - url: 'ajax/task-ajax.php', - data: { task: 'migrate-bans', user: userId }, - success: function(data) { - migrateComplete(); - }, - error: function(data) { - appendToInstallConsole('ERROR: ' + data.responseText); - markUpdateAsFailure('banmigrate'); - } - }) -} - -function migrateComplete() { - $('#attention-row').hide(); - markUpdateAsSuccess('banmigrate'); - processUpdates(200); -} - jQuery(document).ready(loadJquery);