diff --git a/modules/Emails/views/MassSaveAjax.php b/modules/Emails/views/MassSaveAjax.php index 69c5a485bc35bbe9aeecedb998dc5a55c1b23f60..db74b8a1f015b44c34be00cb2da08464d0eaa8a6 100644 --- a/modules/Emails/views/MassSaveAjax.php +++ b/modules/Emails/views/MassSaveAjax.php @@ -196,11 +196,8 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { * Ex: for PDF: if filename - abc_md5(abc).pdf then raw filename - abc.pdf * For Normal documents: rawFileName is not exist in the attachments info. So it fallback to normal filename */ - $rawFileName = $existingAttachInfo['storedname']; - if (!$rawFileName) { - $rawFileName = $existingAttachInfo['attachment']; - } - $file_name = $existingAttachInfo['attachment']; + $rawFileName = $existingAttachInfo['attachment']; + $file_name = $existingAttachInfo['storedname']; $path = $existingAttachInfo['path']; $fileId = $existingAttachInfo['fileid']; @@ -210,7 +207,6 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { $oldFileName = $existingAttachInfo['fileid'].'_'.$file_name; } $oldFilePath = $path.'/'.$oldFileName; - $binFile = sanitizeUploadFileName($rawFileName, $upload_badext); $current_id = $adb->getUniqueID("vtiger_crmentity"); @@ -221,7 +217,8 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { //get the file path inwhich folder we want to upload the file $upload_file_path = decideFilePath(); - $newFilePath = $upload_file_path . $current_id . "_" . $binFile; + $encryptFileName = Vtiger_Util_Helper::getEncryptedFileName($binFile); + $newFilePath = $upload_file_path . $current_id . "_" . $encryptFileName; copy($oldFilePath, $newFilePath); @@ -229,9 +226,14 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { $params1 = array($current_id, $current_user->getId(), $ownerId, $moduleName . " Attachment", $recordModel->get('description'), $adb->formatDate($date_var, true), $adb->formatDate($date_var, true)); $adb->pquery($sql1, $params1); - $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)"; - $params2 = array($current_id, $filename, $recordModel->get('description'), $filetype, $upload_file_path); - $result = $adb->pquery($sql2, $params2); + // Inserting $encrypedFilename into the sql query + $sql2 = "INSERT INTO vtiger_attachments(attachmentsid, name, description, type, path, storedname) values(?, ?, ?, ?, ?, ?)"; + $params2 = array($current_id, $filename, $this->column_fields['description'], $filetype, $upload_file_path, $encryptFileName); + $adb->pquery($sql2, $params2); + // NOTE: Missing storedname columns in below code + // $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)"; + // $params2 = array($current_id, $filename, $recordModel->get('description'), $filetype, $upload_file_path); + // $result = $adb->pquery($sql2, $params2); $sql3 = 'insert into vtiger_seattachmentsrel values(?,?)'; $adb->pquery($sql3, array($recordModel->getId(), $current_id));