diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php
index d44b4efe..38eaacb7 100644
--- a/admin/admin_ticket.php
+++ b/admin/admin_ticket.php
@@ -1261,7 +1261,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
}
}
/* Attachments */
- hesk_listAttachments($ticket['attachments'], $i);
+ hesk_listAttachments($ticket['attachments']);
// Show suggested KB articles
if ($hesk_settings['kb_enable'] && $hesk_settings['kb_recommendanswers'] && strlen($ticket['articles']) )
@@ -1353,26 +1353,139 @@ function hesk_listAttachments($attachments='', $reply=0, $white=1)
/* List attachments */
echo '
'.$hesklang['attachments'].':
';
$att=explode(',',substr($attachments, 0, -1));
+ $columnNumber = 0;
+ echo '
';
foreach ($att as $myatt)
{
- list($att_id, $att_name) = explode('#', $myatt);
-
- /* Can edit and delete tickets? */
- if ($can_edit && $can_delete)
+ $columnNumber++;
+ if ($columnNumber > 4)
{
- echo '
';
+ echo '
';
+ $columnNumber = 1;
}
+ list($att_id, $att_name) = explode('#', $myatt);
- echo '
-
-
'.$att_name.'
+ echo '
';
+
+ $fileparts = pathinfo($att_name);
+ $fontAwesomeIcon = hesk_getFontAwesomeIconForFileExtension($fileparts['extension']);
+ echo '
+
+
';
+ //-- File is an image
+ if ($fontAwesomeIcon == 'fa fa-file-image-o') {
+
+ //-- Get the actual image location and display a thumbnail. It will be linked to a modal to view a larger size.
+ $path = hesk_getSavedNameUrlForAttachment($att_id);
+ if ($path == '') {
+ echo '
';
+ } else {
+ echo '
';
+ echo '
+
+
+
+
+
+
+
+
+
+
';
+ }
+ } else {
+ //-- Display the FontAwesome icon in the panel's body
+ echo '
';
+ }
+ echo '
+
+
';
+ echo '
';
}
- echo '';
+ echo '
';
return true;
} // End hesk_listAttachments()
+function hesk_getSavedNameUrlForAttachment($att_id)
+{
+ global $hesk_settings;
+
+ //-- Call the DB for the attachment
+ $nameRS = hesk_dbQuery("SELECT `saved_name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."attachments` WHERE `att_id` = ".hesk_dbEscape($att_id));
+ $name = hesk_dbFetchAssoc($nameRS);
+ $realpath = '../'.$hesk_settings['attach_dir'] . '/' . $name['saved_name'];
+
+ return !file_exists($realpath) ? '' : $realpath;
+}
+
+function hesk_getFontAwesomeIconForFileExtension($fileExtension)
+{
+ $imageExtensions = array('jpg','png','bmp','gif');
+
+ //-- Word, Excel, and PPT file extensions: http://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions
+ $wordFileExtensions = array('doc','docx','dotm','dot','docm','docb');
+ $excelFileExtensions = array('xls','xlt','xlm','xlsx','xlsm','xltx','xltm');
+ $pptFileExtensions = array('ppt','pot','pps','pptx','pptm','potx','potm','ppsx','ppsm','sldx','sldm');
+
+ //-- File archive extensions: http://en.wikipedia.org/wiki/List_of_archive_formats
+ $archiveFileExtensions = array('tar','gz','zip','rar','7z','bz2','lz','lzma','tgz','tbz2','zipx');
+
+ //-- Audio file extensions: http://en.wikipedia.org/wiki/Audio_file_format#List_of_formats
+ $audioFileExtensions = array('3gp','act','aiff','aac','amr','au','awb','dct','dss','dvf','flac','gsm','iklax','ivs','m4a','m4p','mmf','mp3','mpc','msv','ogg','oga','opus','ra','rm','raw','tta','vox','wav','wma','wv');
+
+ //-- Video file extensions: http://en.wikipedia.org/wiki/Video_file_format#List_of_video_file_formats
+ $videoFileExtensions = array('webm','mkv','flv','drc','mng','avi','mov','qt','wmv','yuv','rm','rmvb','asf','mp4','m4p','m4v','mpg','mp2','mpeg','mpe','mpv','m2v','svi','3gp','3g2','mxf','roq','nsv');
+
+ //-- The only one I know of :D
+ $pdfFileExtensions = array('pdf');
+
+ $textFileExtensions = array('txt');
+
+ $icon = 'fa fa-file-';
+ if (in_array($fileExtension, $imageExtensions)) {
+ $icon.='image-o';
+ } elseif (in_array($fileExtension, $wordFileExtensions)) {
+ $icon.='word-o';
+ } elseif (in_array($fileExtension, $excelFileExtensions)) {
+ $icon.='excel-o';
+ } elseif (in_array($fileExtension, $pptFileExtensions)) {
+ $icon.='powerpoint-o';
+ } elseif (in_array($fileExtension, $archiveFileExtensions)) {
+ $icon.='archive-o';
+ } elseif (in_array($fileExtension, $audioFileExtensions)) {
+ $icon.='audio-o';
+ } elseif (in_array($fileExtension, $videoFileExtensions)) {
+ $icon.='video-o';
+ } elseif (in_array($fileExtension, $pdfFileExtensions)) {
+ $icon.='pdf-o';
+ } elseif (in_array($fileExtension, $textFileExtensions)) {
+ $icon.='text-o';
+ } else {
+ $icon.='o';
+ }
+ return $icon;
+}
+
function hesk_getAdminButtons($reply=0,$white=1)
{
@@ -1611,7 +1724,7 @@ function hesk_printTicketReplies() {
- i {
+ padding-top: 10px;
+ color: #ddd;
+ text-shadow: 2px 2px #ccc;
+}
+
+.file-attachment > img {
+ margin: -15px;
+ height: 100px;
+ cursor: pointer;
+}
diff --git a/css/hesk_newStyleRTL.php b/css/hesk_newStyleRTL.php
index d5a0e365..42756310 100644
--- a/css/hesk_newStyleRTL.php
+++ b/css/hesk_newStyleRTL.php
@@ -368,4 +368,22 @@ button.btn.dropdown-toggle {
button.dropdown-submit {
background:none!important;
border:none;
+}
+
+.file-attachment {
+min-height: 100px;
+max-height: 100px;
+text-align: center;
+}
+
+.file-attachment > i {
+padding-top: 10px;
+color: #ddd;
+text-shadow: 2px 2px #ccc;
+}
+
+.file-attachment > img {
+margin: -15px;
+height: 100px;
+cursor: pointer;
}
\ No newline at end of file
diff --git a/language/en/text.php b/language/en/text.php
index 8b9e88e0..5e0bd7c1 100644
--- a/language/en/text.php
+++ b/language/en/text.php
@@ -26,6 +26,8 @@ $hesklang['saved_ticket_tpl'] = 'Saved Templates';
$hesklang['new_ticket_tpl']='Add or Edit a Ticket Template';
$hesklang['and_change_status_to'] = 'and change status to'; // Used in combination with $hesklang['submit_reply'] (Reads as "Submit reply and change status to")
$hesklang['closed_title'] = 'Closed';
+$hesklang['image'] = 'Image'; // Used for alt tag
+$hesklang['close_modal'] = 'Close';
// ADDED OR MODIFIED IN Mods For HESK 1.7.0