diff --git a/include/class.thread.php b/include/class.thread.php index fb180a767b027fa12ee99cfe71e8f441cb2cc92a..ed4f48f2819ee7e7c977094373914d8116e87686 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -532,6 +532,7 @@ Class ThreadEntry { $sql ='INSERT IGNORE INTO '.TICKET_ATTACHMENT_TABLE.' SET created=NOW() ' .' ,file_id='.db_input($fileId) .' ,ticket_id='.db_input($this->getTicketId()) + .' ,inline='.db_input($file['inline'] ? 1 : 0) .' ,ref_id='.db_input($this->getId()); return (db_query($sql) && ($id=db_insert_id()))?$id:0; @@ -552,7 +553,7 @@ Class ThreadEntry { return $this->attachments; //XXX: inner join the file table instead? - $sql='SELECT a.attach_id, f.id as file_id, f.size, lower(f.`key`) as file_hash, f.name ' + $sql='SELECT a.attach_id, f.id as file_id, f.size, lower(f.`key`) as file_hash, f.name, a.inline ' .' FROM '.FILE_TABLE.' f ' .' INNER JOIN '.TICKET_ATTACHMENT_TABLE.' a ON(f.id=a.file_id) ' .' WHERE a.ticket_id='.db_input($this->getTicketId()) @@ -583,6 +584,8 @@ Class ThreadEntry { $str=''; foreach($this->getAttachments() as $attachment ) { + if ($attachment['inline']) + continue; /* The hash can be changed but must match validation in @file */ $hash=md5($attachment['file_id'].session_id().$attachment['file_hash']); $size = ''; @@ -1040,6 +1043,11 @@ Class ThreadEntry { //Emailed or API attachments if (isset($vars['attachments']) && $vars['attachments']) { + foreach ($vars['attachments'] as &$a) + if (isset($a['cid']) && strpos($body, 'cid:'.$a['cid']) !== false) + $a['inline'] = true; + unset($a); + $entry->importAttachments($vars['attachments']); foreach ($vars['attachments'] as $a) { // Change <img src="cid:"> inside the message to point to diff --git a/include/client/view.inc.php b/include/client/view.inc.php index 27f2bd0845f90a09050801e8bb6763a1ef0840e8..f26737719309736c0863e03877e7a9a1c302e60a 100644 --- a/include/client/view.inc.php +++ b/include/client/view.inc.php @@ -118,13 +118,14 @@ if($ticket->getThreadCount() && ($thread=$ticket->getClientThread())) { && ($tentry=$ticket->getThreadEntry($entry['id'])) && ($urls = $tentry->getAttachmentUrls()) && ($links=$tentry->getAttachmentsLinks())) { ?> + <tr><td class="info"><?php echo $links; ?></td></tr> +<?php } + if ($urls) { ?> <script type="text/javascript"> $(function() { showImagesInline(<?php echo JsonDataEncoder::encode($urls); ?>); }); </script> - <tr><td class="info"><?php echo $links; ?></td></tr> - <?php - } ?> +<?php } ?> </table> <?php } diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index c76bf30affd6655e6e46ecda139c4d09003dd7c6..1f05d04a5daf6445e1683d083862ca32937510de 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -368,18 +368,20 @@ $tcount+= $ticket->getNumNotes(); echo Format::viewableImages(Format::display($entry['body'])); ?></div></td></tr> <?php if($entry['attachments'] - && ($tentry=$ticket->getThreadEntry($entry['id'])) + && ($tentry = $ticket->getThreadEntry($entry['id'])) && ($urls = $tentry->getAttachmentUrls()) - && ($links=$tentry->getAttachmentsLinks())) {?> + && ($links = $tentry->getAttachmentsLinks())) {?> <tr> - <td class="info" colspan="4"><?php echo $links; ?></td> + <td class="info" colspan="4"><?php echo $tentry->getAttachmentsLinks(); ?></td> + </tr> <?php + } + if ($urls) { ?> <script type="text/javascript"> $(function() { showImagesInline(<?php echo JsonDataEncoder::encode($urls); ?>); }); </script> - </tr> - <?php - }?> +<?php + } ?> </table> <?php if($entry['thread_type']=='M')