From ecf0d1a7dc34c106673614026721fc5768a2488e Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 28 Dec 2015 12:47:51 -0500 Subject: [PATCH] Drag and drop attachments now working for admin notes and admin replies --- admin/admin_reply_ticket.php | 22 +++++-- admin/admin_ticket.php | 82 +++++++++++++++++++-------- inc/view_attachment_functions.inc.php | 12 ++-- internal-api/dao/attachment_dao.php | 5 +- js/modsForHesk-javascript.js | 4 +- 5 files changed, 86 insertions(+), 39 deletions(-) diff --git a/admin/admin_reply_ticket.php b/admin/admin_reply_ticket.php index a2b5ba22..0601eacd 100644 --- a/admin/admin_reply_ticket.php +++ b/admin/admin_reply_ticket.php @@ -145,10 +145,24 @@ if (strlen($message)) { if ($hesk_settings['attachments']['use']) { require(HESK_PATH . 'inc/attachments.inc.php'); $attachments = array(); - 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/admin_ticket.php b/admin/admin_ticket.php index 941121e2..5975a028 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -314,12 +314,27 @@ if (isset($_POST['notemsg']) && hesk_token_check('POST')) { require(HESK_PATH . 'inc/htmLawed.php'); require(HESK_PATH . 'inc/attachments.inc.php'); $attachments = array(); - 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); } } + } $myattachments = ''; @@ -1238,23 +1253,32 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); ?>
-
-
- -
+
+
+
+ +
+
+
+
+
+
+ +
'; + } + ?> +
+
+ +
- '; - for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) { - echo '
'; - } - echo '
'; - } - ?> + @@ -1806,15 +1830,23 @@ function hesk_printReplyForm()
-
'; - } - - echo '' . $hesklang['ful'] . ''; - ?> +
+
+ +
'; + } + ?> +
+
+
diff --git a/inc/view_attachment_functions.inc.php b/inc/view_attachment_functions.inc.php index 755ca79e..16731f4f 100644 --- a/inc/view_attachment_functions.inc.php +++ b/inc/view_attachment_functions.inc.php @@ -200,25 +200,25 @@ function output_dropzone_window() {
'; } -function output_attachment_id_holder_container() { - echo '
'; +function output_attachment_id_holder_container($id) { + echo '
'; } -function display_dropzone_field($url) { +function display_dropzone_field($url, $id = 'filedrop') { global $hesk_settings, $hesklang; output_dropzone_window(); - output_attachment_id_holder_container(); + output_attachment_id_holder_container($id); $acceptedFiles = implode(',', $hesk_settings['attachments']['allowed_types']); echo "