Skip to content
Snippets Groups Projects
Commit d9ec7886 authored by Apparao G's avatar Apparao G
Browse files

#Fixes::158183087::kaushik::email attachments 500 error fixed

parents dd471dd7 bf25034e
No related branches found
No related tags found
No related merge requests found
...@@ -196,11 +196,8 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { ...@@ -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 * 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 * For Normal documents: rawFileName is not exist in the attachments info. So it fallback to normal filename
*/ */
$rawFileName = $existingAttachInfo['storedname']; $rawFileName = $existingAttachInfo['attachment'];
if (!$rawFileName) { $file_name = $existingAttachInfo['storedname'];
$rawFileName = $existingAttachInfo['attachment'];
}
$file_name = $existingAttachInfo['attachment'];
$path = $existingAttachInfo['path']; $path = $existingAttachInfo['path'];
$fileId = $existingAttachInfo['fileid']; $fileId = $existingAttachInfo['fileid'];
...@@ -210,7 +207,6 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { ...@@ -210,7 +207,6 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View {
$oldFileName = $existingAttachInfo['fileid'].'_'.$file_name; $oldFileName = $existingAttachInfo['fileid'].'_'.$file_name;
} }
$oldFilePath = $path.'/'.$oldFileName; $oldFilePath = $path.'/'.$oldFileName;
$binFile = sanitizeUploadFileName($rawFileName, $upload_badext); $binFile = sanitizeUploadFileName($rawFileName, $upload_badext);
$current_id = $adb->getUniqueID("vtiger_crmentity"); $current_id = $adb->getUniqueID("vtiger_crmentity");
...@@ -221,7 +217,8 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { ...@@ -221,7 +217,8 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View {
//get the file path inwhich folder we want to upload the file //get the file path inwhich folder we want to upload the file
$upload_file_path = decideFilePath(); $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); copy($oldFilePath, $newFilePath);
...@@ -229,9 +226,14 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { ...@@ -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)); $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); $adb->pquery($sql1, $params1);
$sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)"; // Inserting $encrypedFilename into the sql query
$params2 = array($current_id, $filename, $recordModel->get('description'), $filetype, $upload_file_path); $sql2 = "INSERT INTO vtiger_attachments(attachmentsid, name, description, type, path, storedname) values(?, ?, ?, ?, ?, ?)";
$result = $adb->pquery($sql2, $params2); $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(?,?)'; $sql3 = 'insert into vtiger_seattachmentsrel values(?,?)';
$adb->pquery($sql3, array($recordModel->getId(), $current_id)); $adb->pquery($sql3, array($recordModel->getId(), $current_id));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment