Some more work on attachments

merge-requests/3/head
Mike Koch 8 years ago
parent 87f6093138
commit 056e85d9ea

@ -224,7 +224,7 @@ function display_dropzone_field($url) {
file['databaseId'] = response;
});
this.on('removedfile', function(file) {
console.log(file);
removeAttachment(file['databaseId']);
});
this.on('queuecomplete', function(progress) {
$('#total-progress').removeClass('active');

@ -716,6 +716,7 @@ function execute260Scripts()
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`file_name` VARCHAR(255) NOT NULL,
`saved_name` VARCHAR(255) NOT NULL,
`size` INT(10) UNSIGNED NOT NULL,
`type` ENUM('0','1') NOT NULL,
`date_uploaded` TIMESTAMP NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");

@ -8,4 +8,15 @@ function upload_temp_attachment($i, $isTicket) {
VALUES ('" . hesk_dbEscape($info['saved_name']) . "','" . hesk_dbEscape($info['size']) . "','" . hesk_dbEscape($isTicket ? 1 : 0) . "', NOW())");
return hesk_dbInsertID();
}
function delete_temp_attachment($id, $isTicket) {
global $hesk_settings;
$attachment_rs = hesk_dbQuery("SELECT `saved_name` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` WHERE `id` = " . intval($id));
$attachment = hesk_dbFetchAssoc($attachment_rs);
if (hesk_removeAttachments(array($attachment), $isTicket)) {
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` WHERE `id` = " . intval($id));
}
}

@ -0,0 +1,24 @@
<?php
define('IN_SCRIPT', 1);
define('HESK_PATH', '../../');
define('INTERNAL_API_PATH', '../');
require_once(HESK_PATH . 'hesk_settings.inc.php');
require_once(HESK_PATH . 'inc/common.inc.php');
require_once(HESK_PATH . 'inc/attachments.inc.php');
require_once(HESK_PATH . 'inc/posting_functions.inc.php');
require_once(INTERNAL_API_PATH . 'core/output.php');
require_once(INTERNAL_API_PATH . 'dao/attachment_dao.php');
hesk_load_internal_api_database_functions();
hesk_dbConnect();
$modsForHesk_settings = mfh_getSettings();
if (isset($_GET['id'])) {
$id = $_GET['id'];
$id = delete_temp_attachment($id, true);
return http_response_code(200);
}
return http_response_code(400);

@ -34,7 +34,6 @@ var loadJquery = function()
todayBtn: "linked",
clearBtn: true,
autoclose: true,
autoclose: true,
todayHighlight: true,
format: "yyyy-mm-dd"
});
@ -210,4 +209,18 @@ function outputAttachmentIdHolder(value) {
$('#attachment-holder').append('<input type="hidden" name="attachment-ids[]" value="' + value + '">');
}
function removeAttachment(id) {
$('input[name="attachment-ids[]"][value="' + id + '"]').remove();
$.ajax({
url: getHelpdeskUrl() + '/internal-api/ticket/delete-attachment.php?id=' + id,
method: 'GET',
success: function() {
console.info('Removed attachment ' + id);
},
error: function() {
console.error('Error removing attachment ' + id);
}
});
}
jQuery(document).ready(loadJquery);

Loading…
Cancel
Save