@@ -48,7 +48,7 @@ protected function createAttachmentsFrom($html, $ticket, $comment = false, $coun
4848 // Create filename
4949 $ original_filename = 'embedded_image_ ' .($ i +$ count ).'.png ' ;
5050
51- $ file_name = $ this ->makeFilename ($ original_filename .date ('YmdHis ' , time ()), ' embedded ' , '' );
51+ $ file_name = $ this ->makeFilename ($ original_filename .date ('YmdHis ' , time ()), $ ticket -> id . ' _embedded ' , '' );
5252
5353 // Attach real file to storage folder
5454 $ file_path = storage_path (Setting::grab ('attachments_path ' )) .DIRECTORY_SEPARATOR . $ file_name ;
@@ -373,6 +373,9 @@ protected function updateAttachments($request, $a_result_errors, $attachments)
373373 // Update related Ticket or comment Html field
374374 $ model = $ att ->comment_id == "" ? $ att ->ticket : $ att ->comment ;
375375 $ model ->html = str_replace ($ original_filename , basename ($ att ->file_path ), $ model ->html );
376+ if ($ att ->comment_id == "" ){
377+ $ model ->intervention_html = str_replace ($ original_filename , basename ($ att ->file_path ), $ model ->intervention_html );
378+ }
376379 $ model ->save ();
377380 }
378381 }
@@ -485,21 +488,31 @@ protected function destroyAttachmentsLoop($attachments)
485488 /**
486489 * Destroy a single attachment files and model instance
487490 */
488- protected function destroyAttachedElement ($ attachment )
491+ protected function destroyAttachedElement ($ att )
489492 {
490493 // Delete attachment file
491- $ error = $ this ->deleteAttachmentFile ($ attachment ->file_path , $ attachment ->original_filename );
494+ $ error = $ this ->deleteAttachmentFile ($ att ->file_path , $ att ->original_filename );
492495 if ($ error ) return $ error ;
493496
494497 // Delete original file (if exists)
495- if ($ attachment ->original_attachment != basename ($ attachment ->file_path )){
496- $ original_path = pathinfo ($ attachment ->file_path , PATHINFO_DIRNAME ).DIRECTORY_SEPARATOR .$ attachment ->original_attachment ;
497- $ error = $ this ->deleteAttachmentFile ($ original_path , $ attachment ->original_filename );
498+ if ($ att ->original_attachment != basename ($ att ->file_path )){
499+ $ original_path = pathinfo ($ att ->file_path , PATHINFO_DIRNAME ).DIRECTORY_SEPARATOR .$ att ->original_attachment ;
500+ $ error = $ this ->deleteAttachmentFile ($ original_path , $ att ->original_filename );
498501 if ($ error ) return $ error ;
499502 }
500503
501504 // Delete thumbnail
502- $ this ->deleteThumbnail (basename ($ attachment ->file_path ));
505+ $ this ->deleteThumbnail (basename ($ att ->file_path ));
506+
507+ // Remove thumbnail link from any html field
508+ $ model = $ att ->comment_id == "" ? $ att ->ticket : $ att ->comment ;
509+ $ model ->html = preg_replace ('/<a[^>]*summernote_thumbnail_link[^>]*?><img[^>]* ' .basename ($ att ->file_path ).'[^>]*><\/a>/ ' , '' , $ model ->html );
510+
511+ if ($ att ->comment_id == "" ){
512+ $ model ->intervention_html = preg_replace ('/<a[^>]*summernote_thumbnail_link[^>]*?><img[^>]* ' .basename ($ att ->file_path ).'[^>]*><\/a>/ ' , '' , $ model ->intervention_html );
513+ }
514+ $ model ->save ();
515+
503516 return false ;
504517 }
505518
0 commit comments