From 942f5bff52e52fdb667fc3559505c3f9f0c86555 Mon Sep 17 00:00:00 2001 From: Hugo Sampaio Date: Mon, 3 Feb 2025 11:55:20 -0300 Subject: [PATCH] ticket tasks moving order --- ajax.php | 19 +++++++++++++++++++ ticket.php | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/ajax.php b/ajax.php index 36b232db..9e13c3a0 100644 --- a/ajax.php +++ b/ajax.php @@ -529,3 +529,22 @@ if (isset($_GET['get_totp_token_via_id'])) { if (isset($_GET['get_readable_pass'])) { echo json_encode(GenerateReadablePassword(4)); } + +if (isset($_POST['update_ticket_tasks_order'])) { + // Update multiple ticket tasks order + enforceUserPermission('module_support', 2); + + $positions = $_POST['positions']; + $ticket_id = intval($_POST['ticket_id']); + + foreach ($positions as $position) { + $id = intval($position['id']); + $order = intval($position['order']); + + mysqli_query($mysqli, "UPDATE tasks SET task_order = $order WHERE task_ticket_id = $ticket_id AND task_id = $id"); + } + + // return a response + echo json_encode(['status' => 'success']); + exit; +} \ No newline at end of file diff --git a/ticket.php b/ticket.php index 674a0add..5311ff51 100644 --- a/ticket.php +++ b/ticket.php @@ -11,7 +11,7 @@ if (isset($_GET['client_id'])) { enforceUserPermission('module_support'); // Initialize the HTML Purifier to prevent XSS -require "plugins/htmlpurifier/HTMLPurifier.standalone.php"; +require_once "plugins/htmlpurifier/HTMLPurifier.standalone.php"; $purifier_config = HTMLPurifier_Config::createDefault(); $purifier_config->set('Cache.DefinitionImpl', null); // Disable cache by setting a non-existent directory or an invalid one @@ -345,6 +345,7 @@ if (isset($_GET['ticket_id'])) { $ticket_collaborators = nullable_htmlentities($row['user_names']); ?> +