#168 Add SQL scripts, start JavaScript code
parent
2ddfc10933
commit
c3134b459a
@ -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;
|
@ -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);
|
@ -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`");
|
||||||
|
}
|
Loading…
Reference in New Issue