#168 Add SQL scripts, start JavaScript code
This commit is contained in:
parent
2ddfc10933
commit
c3134b459a
@ -4,7 +4,7 @@ define('HESK_PATH','../../../');
|
|||||||
require(HESK_PATH . 'hesk_settings.inc.php');
|
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
require(HESK_PATH . 'inc/common.inc.php');
|
require(HESK_PATH . 'inc/common.inc.php');
|
||||||
hesk_load_database_functions();
|
hesk_load_database_functions();
|
||||||
require('../modsForHeskSql.php');
|
require('../sql/installSql.php');
|
||||||
|
|
||||||
$version = $_POST['version'];
|
$version = $_POST['version'];
|
||||||
if ($version == 1) {
|
if ($version == 1) {
|
@ -4,7 +4,7 @@ define('HESK_PATH','../../../');
|
|||||||
require(HESK_PATH . 'hesk_settings.inc.php');
|
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
require(HESK_PATH . 'inc/common.inc.php');
|
require(HESK_PATH . 'inc/common.inc.php');
|
||||||
hesk_load_database_functions();
|
hesk_load_database_functions();
|
||||||
require('../modsForHeskSql.php');
|
require('../sql/installSql.php');
|
||||||
|
|
||||||
$task = $_POST['task'];
|
$task = $_POST['task'];
|
||||||
if ($task == 'ip-email-bans') {
|
if ($task == 'ip-email-bans') {
|
||||||
|
16
install/mods-for-hesk/ajax/uninstall-database-ajax.php
Normal file
16
install/mods-for-hesk/ajax/uninstall-database-ajax.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
define('IN_SCRIPT',1);
|
||||||
|
define('HESK_PATH','../../../');
|
||||||
|
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
|
require(HESK_PATH . 'inc/common.inc.php');
|
||||||
|
hesk_load_database_functions();
|
||||||
|
require('../sql/uninstallSql.php');
|
||||||
|
|
||||||
|
$task = $_POST['task'];
|
||||||
|
if ($task == 1) {
|
||||||
|
executePre140Scripts();
|
||||||
|
} else {
|
||||||
|
print 'The task "'.$task.'" was not recognized. Check the value submitted and try again.';
|
||||||
|
http_response_code(400);
|
||||||
|
}
|
||||||
|
return;
|
28
install/mods-for-hesk/js/uninstall-scripts.js
Normal file
28
install/mods-for-hesk/js/uninstall-scripts.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
function processUninstallation() {
|
||||||
|
var tasks = ['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'];
|
||||||
|
//-- Change status column to default HESK values
|
||||||
|
tasks.forEach(function(task) {
|
||||||
|
startUninstallation(task);
|
||||||
|
executeUninstallation(task);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function startUninstallation(task) {
|
||||||
|
appendToInstallConsole('<tr><td><span class="label label-info">INFO</span></td><td>Starting task code: ' + task + '</td></tr>');
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: 'ajax/install-database-ajax.php',
|
||||||
|
data: { task: task },
|
||||||
|
success: function(data) {
|
||||||
|
markUninstallAsSuccess(cssclass, formattedVersion);
|
||||||
|
},
|
||||||
|
error: function(data) {
|
||||||
|
appendToInstallConsole('<tr><td><span class="label label-danger">ERROR</span></td><td>'+ data.responseText + '</td></tr>');
|
||||||
|
markUninstallAsFailure(cssclass);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery(document).ready(loadJquery);
|
@ -39,7 +39,7 @@ function executeUpdate(version, cssclass, formattedVersion) {
|
|||||||
appendToInstallConsole('<tr><td><span class="label label-info">INFO</span></td><td>Starting updates for ' + formattedVersion + '</td></tr>');
|
appendToInstallConsole('<tr><td><span class="label label-info">INFO</span></td><td>Starting updates for ' + formattedVersion + '</td></tr>');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: 'ajax/database-ajax.php',
|
url: 'ajax/install-database-ajax.php',
|
||||||
data: { version: version },
|
data: { version: version },
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
markUpdateAsSuccess(cssclass, formattedVersion);
|
markUpdateAsSuccess(cssclass, formattedVersion);
|
||||||
|
130
install/mods-for-hesk/sql/uninstallSql.php
Normal file
130
install/mods-for-hesk/sql/uninstallSql.php
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
|
|
||||||
|
function executeQuery($sql) {
|
||||||
|
global $hesk_last_query;
|
||||||
|
global $hesk_db_link;
|
||||||
|
if ( function_exists('mysqli_connect') ) {
|
||||||
|
|
||||||
|
if ( ! $hesk_db_link && ! hesk_dbConnect())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$hesk_last_query = $sql;
|
||||||
|
|
||||||
|
if ($res = @mysqli_query($hesk_db_link, $sql))
|
||||||
|
{
|
||||||
|
return $res;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
print "Could not execute query: $sql. MySQL said: ".mysqli_error($hesk_db_link);
|
||||||
|
http_response_code(500);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( ! $hesk_db_link && ! hesk_dbConnect())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$hesk_last_query = $sql;
|
||||||
|
|
||||||
|
if ($res = @mysql_query($sql, $hesk_db_link))
|
||||||
|
{
|
||||||
|
return $res;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
print "Could not execute query: $sql. MySQL said: ".mysql_error();
|
||||||
|
http_response_code(500);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceStatusColumn() {
|
||||||
|
global $hesk_settings;
|
||||||
|
|
||||||
|
hesk_dbConnect();
|
||||||
|
|
||||||
|
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` ADD COLUMN `status_int` ENUM('0','1','2','3','4','5') NOT NULL AFTER `status`;");
|
||||||
|
$ticketsRS = executeQuery("SELECT `id`, `status` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets`;");
|
||||||
|
while ($currentResult = $ticketsRS->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`");
|
||||||
|
}
|
@ -3,6 +3,27 @@ define('IN_SCRIPT',1);
|
|||||||
define('HESK_PATH','../../');
|
define('HESK_PATH','../../');
|
||||||
require(HESK_PATH . 'install/install_functions.inc.php');
|
require(HESK_PATH . 'install/install_functions.inc.php');
|
||||||
require(HESK_PATH . 'hesk_settings.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 '<tr id="'.$id.'">';
|
||||||
|
echo '<td>'.$text.'</td>';
|
||||||
|
echo '<td><i id="spinner-'.$id.'" class="fa fa-spinner"></i> <span id="span-'.$id.'">Waiting...</span></td>';
|
||||||
|
echo '</tr>';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@ -16,13 +37,32 @@ require(HESK_PATH . 'hesk_settings.inc.php');
|
|||||||
<script language="Javascript" type="text/javascript" src="<?php echo HESK_PATH; ?>js/bootstrap.min.js"></script>
|
<script language="Javascript" type="text/javascript" src="<?php echo HESK_PATH; ?>js/bootstrap.min.js"></script>
|
||||||
<script language="Javascript" type="text/javascript" src="<?php echo HESK_PATH; ?>js/modsForHesk-javascript.js"></script>
|
<script language="Javascript" type="text/javascript" src="<?php echo HESK_PATH; ?>js/modsForHesk-javascript.js"></script>
|
||||||
<script language="JavaScript" type="text/javascript" src="<?php echo HESK_PATH; ?>install/mods-for-hesk/js/ui-scripts.js"></script>
|
<script language="JavaScript" type="text/javascript" src="<?php echo HESK_PATH; ?>install/mods-for-hesk/js/ui-scripts.js"></script>
|
||||||
<script language="JavaScript" type="text/javascript" src="<?php echo HESK_PATH; ?>install/mods-for-hesk/js/version-scripts.js"></script>
|
<script language="JavaScript" type="text/javascript" src="<?php echo HESK_PATH; ?>install/mods-for-hesk/js/uninstall-scripts.js"></script>
|
||||||
<script language="JavaScript" type="text/javascript" src="<?php echo HESK_PATH; ?>js/bootstrap-datepicker.js"></script>
|
<script language="JavaScript" type="text/javascript" src="<?php echo HESK_PATH; ?>js/bootstrap-datepicker.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="headersm">Uninstalling Mods for HESK</div>
|
<div class="headersm">Uninstalling Mods for HESK</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<!-- Uninstall stuff here! -->
|
<div class="page-header">
|
||||||
|
<h1>Uninstalling Mods for HESK</h1>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Uninstallation Progress</div>
|
||||||
|
<div class="uninstall-information">
|
||||||
|
<table class="table table-striped" style="table-layout:fixed;">
|
||||||
|
<thead>
|
||||||
|
<?php echoTaskRows(); ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
processUninstallation();
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
x
Reference in New Issue
Block a user