From 07acdaccb535bae51cf3220bf58e21bb520844ae Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 27 Dec 2015 22:20:25 -0500 Subject: [PATCH] Add drag and drop for admin ticket, fix URL for other pages --- admin/admin_submit_ticket.php | 21 +++++++++++++++++---- admin/new_ticket.php | 23 +++++++++++++++-------- inc/headerAdmin.inc.php | 4 +++- inc/view_attachment_functions.inc.php | 2 +- index.php | 2 +- ticket.php | 2 +- 6 files changed, 38 insertions(+), 16 deletions(-) diff --git a/admin/admin_submit_ticket.php b/admin/admin_submit_ticket.php index ab8e36d1..05937433 100644 --- a/admin/admin_submit_ticket.php +++ b/admin/admin_submit_ticket.php @@ -171,10 +171,23 @@ if ($hesk_settings['attachments']['use']) { $attachments = array(); $trackingID = $tmpvar['trackid']; - for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) { - $att = hesk_uploadFile($i); - if ($att !== false && !empty($att)) { - $attachments[$i] = $att; + $use_legacy_attachments = hesk_POST('use-legacy-attachments', 0); + + if ($use_legacy_attachments) { + for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) { + $att = hesk_uploadFile($i); + if ($att !== false && !empty($att)) { + $attachments[$i] = $att; + } + } + } else { + // The user used the new drag-and-drop system. + $temp_attachment_ids = hesk_POST_array('attachment-ids'); + foreach ($temp_attachment_ids as $temp_attachment_id) { + // Simply get the temp info and move it to the attachments table + $temp_attachment = mfh_getTemporaryAttachment($temp_attachment_id); + $attachments[] = $temp_attachment; + mfh_deleteTemporaryAttachment($temp_attachment_id); } } } diff --git a/admin/new_ticket.php b/admin/new_ticket.php index 74d23344..d3351af9 100644 --- a/admin/new_ticket.php +++ b/admin/new_ticket.php @@ -40,6 +40,7 @@ define('AUTOFOCUS', true); require(HESK_PATH . 'hesk_settings.inc.php'); require(HESK_PATH . 'inc/common.inc.php'); require(HESK_PATH . 'inc/admin_functions.inc.php'); +require(HESK_PATH . 'inc/view_attachment_functions.inc.php'); hesk_load_database_functions(); hesk_session_start(); @@ -1032,18 +1033,24 @@ if ($hesk_settings['attachments']['use']) {
-
'; - } - ?> - +
+
+ +
'; + } + ?> +
+
+

diff --git a/inc/headerAdmin.inc.php b/inc/headerAdmin.inc.php index f8731efb..65eac2df 100644 --- a/inc/headerAdmin.inc.php +++ b/inc/headerAdmin.inc.php @@ -75,12 +75,14 @@ $modsForHesk_settings = mfh_getSettings(); + + + - diff --git a/inc/view_attachment_functions.inc.php b/inc/view_attachment_functions.inc.php index 431753a4..755ca79e 100644 --- a/inc/view_attachment_functions.inc.php +++ b/inc/view_attachment_functions.inc.php @@ -231,7 +231,7 @@ function display_dropzone_field($url) { }); }, paramName: 'attachment', - url: ".json_encode($url).", + url: '" . $url . "', parallelUploads: 1, uploadMultiple: false, maxFiles: 1, diff --git a/index.php b/index.php index bfa8c53f..8bea070f 100644 --- a/index.php +++ b/index.php @@ -996,7 +996,7 @@ function print_add_ticket()