New attachment uploader working for customer ticket create
This commit is contained in:
parent
1bdd658a7d
commit
07b82c4d93
@ -143,3 +143,29 @@ function hesk_removeAttachments($attachments, $isTicket)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // End hesk_removeAttachments()
|
} // End hesk_removeAttachments()
|
||||||
|
|
||||||
|
|
||||||
|
function mfh_getTemporaryAttachment($id) {
|
||||||
|
global $hesk_settings;
|
||||||
|
|
||||||
|
$rs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` WHERE `id` = " . intval($id));
|
||||||
|
if (hesk_dbNumRows($rs) == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
$row = hesk_dbFetchAssoc($rs);
|
||||||
|
|
||||||
|
$info = array(
|
||||||
|
'saved_name' => $row['saved_name'],
|
||||||
|
'real_name' => $row['file_name'],
|
||||||
|
'size' => $row['size']
|
||||||
|
);
|
||||||
|
|
||||||
|
return $info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function mfh_deleteTemporaryAttachment($id) {
|
||||||
|
global $hesk_settings;
|
||||||
|
|
||||||
|
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` WHERE `id` = ".intval($id));
|
||||||
|
}
|
@ -4,8 +4,10 @@ function upload_temp_attachment($i, $isTicket) {
|
|||||||
global $hesk_settings;
|
global $hesk_settings;
|
||||||
|
|
||||||
$info = hesk_uploadFile($i, $isTicket);
|
$info = hesk_uploadFile($i, $isTicket);
|
||||||
|
|
||||||
|
// `type`: 0: ticket, 1: note
|
||||||
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` (`file_name`,`size`, `type`, `date_uploaded`, `saved_name`)
|
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` (`file_name`,`size`, `type`, `date_uploaded`, `saved_name`)
|
||||||
VALUES ('" . hesk_dbEscape($info['real_name']) . "','" . hesk_dbEscape($info['size']) . "','" . hesk_dbEscape($isTicket ? 1 : 0) . "',
|
VALUES ('" . hesk_dbEscape($info['real_name']) . "','" . hesk_dbEscape($info['size']) . "','0',
|
||||||
NOW(), '" . hesk_dbEscape($info['saved_name']) . "')");
|
NOW(), '" . hesk_dbEscape($info['saved_name']) . "')");
|
||||||
|
|
||||||
return hesk_dbInsertID();
|
return hesk_dbInsertID();
|
||||||
|
@ -292,10 +292,24 @@ if ($below_limit) {
|
|||||||
$attachments = array();
|
$attachments = array();
|
||||||
$trackingID = $tmpvar['trackid'];
|
$trackingID = $tmpvar['trackid'];
|
||||||
|
|
||||||
for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) {
|
$use_legacy_attachments = hesk_POST('use-legacy-attachments', 0);
|
||||||
$att = hesk_uploadFile($i);
|
|
||||||
if ($att !== false && !empty($att)) {
|
if ($use_legacy_attachments) {
|
||||||
$attachments[$i] = $att;
|
// The user went to the fallback file upload system.
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user