From c99144ec141d1158b5d24d820cc7365f5452bdcb Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 28 Dec 2015 13:06:18 -0500 Subject: [PATCH] Got one of the KB file drops working --- admin/manage_knowledgebase.php | 41 +++++++++++++++---- .../admin/knowledgebase/upload-attachment.php | 24 +++++++++++ 2 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 internal-api/admin/knowledgebase/upload-attachment.php diff --git a/admin/manage_knowledgebase.php b/admin/manage_knowledgebase.php index 44162e0b..481fddd9 100644 --- a/admin/manage_knowledgebase.php +++ b/admin/manage_knowledgebase.php @@ -37,6 +37,7 @@ define('PAGE_TITLE', 'ADMIN_KB'); 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(); // Check for POST requests larger than what the server can handle @@ -434,10 +435,19 @@ if (!isset($_SESSION['hide']['new_article']))
-
-
- + +
+
+ +
'; + } + ?> +
+
+
@@ -1954,14 +1964,29 @@ function new_article() require_once(HESK_PATH . 'inc/posting_functions.inc.php'); require_once(HESK_PATH . 'inc/attachments.inc.php'); $attachments = array(); - for ($i=1;$i<=3;$i++) - { - $att = hesk_uploadFile($i, false); - if ( ! empty($att)) + + $use_legacy_attachments = hesk_POST('use-legacy-attachments', 0); + + if ($use_legacy_attachments) { + for ($i=1; $i<=3; $i++) { - $attachments[$i] = $att; + $att = hesk_uploadFile($i, false); + if ( ! 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=''; /* Any errors? */ diff --git a/internal-api/admin/knowledgebase/upload-attachment.php b/internal-api/admin/knowledgebase/upload-attachment.php new file mode 100644 index 00000000..99aeca7b --- /dev/null +++ b/internal-api/admin/knowledgebase/upload-attachment.php @@ -0,0 +1,24 @@ +