Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #7071 - Reply to, Reply to All issue with attachment #7430

Open
wants to merge 3 commits into
base: hotfix-7.10.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
94 changes: 48 additions & 46 deletions modules/Emails/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -3031,57 +3031,59 @@ public function send(

///////////////////////////////////////////////////////////////////////
//// ATTACHMENTS
if (isset($this->saved_attachments)) {
foreach ($this->saved_attachments as $note) {
$mime_type = 'text/plain';
if ($note->object_name == 'Note') {
if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) { // brandy-new file upload/attachment
$file_location = "file://" . $note->file->temp_file_location;
$filename = $note->file->original_file_name;
$mime_type = $note->file->mime_type;
} else { // attachment coming from template/forward
$file_location = "upload://{$note->id}";
// cn: bug 9723 - documents from EmailTemplates sent with Doc Name, not file name.
$filename = !empty($note->filename) ? $note->filename : $note->name;
if ($_REQUEST['refer_action'] != 'ReplyTo' && $_REQUEST['refer_action'] != 'ReplyToAll') {
if (isset($this->saved_attachments)) {
foreach ($this->saved_attachments as $note) {
$mime_type = 'text/plain';
if ($note->object_name == 'Note') {
if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) { // brandy-new file upload/attachment
$file_location = "file://" . $note->file->temp_file_location;
$filename = $note->file->original_file_name;
$mime_type = $note->file->mime_type;
} else { // attachment coming from template/forward
$file_location = "upload://{$note->id}";
// cn: bug 9723 - documents from EmailTemplates sent with Doc Name, not file name.
$filename = !empty($note->filename) ? $note->filename : $note->name;
$mime_type = $note->file_mime_type;
}
} elseif ($note->object_name == 'DocumentRevision') { // from Documents
$filePathName = $note->id;
// cn: bug 9723 - Emails with documents send GUID instead of Doc name
$filename = $note->getDocumentRevisionNameForDisplay();
$file_location = "upload://$note->id";
$mime_type = $note->file_mime_type;
}
} elseif ($note->object_name == 'DocumentRevision') { // from Documents
$filePathName = $note->id;
// cn: bug 9723 - Emails with documents send GUID instead of Doc name
$filename = $note->getDocumentRevisionNameForDisplay();
$file_location = "upload://$note->id";
$mime_type = $note->file_mime_type;
}

// strip out the "Email attachment label if exists
$filename = str_replace($mod_strings['LBL_EMAIL_ATTACHMENT'] . ': ', '', $filename);
$file_ext = pathinfo($filename, PATHINFO_EXTENSION);
//is attachment in our list of bad files extensions? If so, append .txt to file location
//check to see if this is a file with extension located in "badext"
foreach ($sugar_config['upload_badext'] as $badExt) {
if (strtolower($file_ext) == strtolower($badExt)) {
//if found, then append with .txt to filename and break out of lookup
//this will make sure that the file goes out with right extension, but is stored
//as a text in db.
$file_location = $file_location . ".txt";
break; // no need to look for more

// strip out the "Email attachment label if exists
$filename = str_replace($mod_strings['LBL_EMAIL_ATTACHMENT'] . ': ', '', $filename);
$file_ext = pathinfo($filename, PATHINFO_EXTENSION);
//is attachment in our list of bad files extensions? If so, append .txt to file location
//check to see if this is a file with extension located in "badext"
foreach ($sugar_config['upload_badext'] as $badExt) {
if (strtolower($file_ext) == strtolower($badExt)) {
//if found, then append with .txt to filename and break out of lookup
//this will make sure that the file goes out with right extension, but is stored
//as a text in db.
$file_location = $file_location . ".txt";
break; // no need to look for more
}
}
$mail->AddAttachment(
$file_location,
$locale->translateCharsetMIME(trim($filename), 'UTF-8', $OBCharset),
'base64',
$mime_type
);
// embedded Images
if ($note->embed_flag == true) {
$cid = $filename;
$mail->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $mime_type);
}

}
$mail->AddAttachment(
$file_location,
$locale->translateCharsetMIME(trim($filename), 'UTF-8', $OBCharset),
'base64',
$mime_type
);

// embedded Images
if ($note->embed_flag == true) {
$cid = $filename;
$mail->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $mime_type);
}
} else {
LoggerManager::getLogger()->fatal('Attachements not found');
}
} else {
LoggerManager::getLogger()->fatal('Attachements not found');
}
//// END ATTACHMENTS
///////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 3 additions & 1 deletion modules/Emails/include/ComposeView/EmailsComposeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,9 @@
"url": 'index.php?module=Emails&action=GetDraftAttachmentData&id=' + id
}).done(function (jsonResponse) {
var response = JSON.parse(jsonResponse);
if (typeof response.data !== "undefined") {
var urlParams = new URLSearchParams(window.location.search);
var act = urlParams.get('action');
if (typeof response.data !== "undefined" && act !== "ReplyTo" && act !== "ReplyToAll") {
$('.file-attachments').empty();
$.fn.EmailsComposeView.loadAttachmentDataFromAjaxResponse(response);
}
Expand Down