From 756b5b301bb5f8ac2baf2011b174f2180d41964c Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Fri, 4 Mar 2016 23:41:03 +0530 Subject: [PATCH] CRM-16210 fix --- CRM/Case/Form/Activity.php | 6 +++++- CRM/Core/BAO/CustomField.php | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CRM/Case/Form/Activity.php b/CRM/Case/Form/Activity.php index 03feaa4f55..e58471ae02 100644 --- a/CRM/Case/Form/Activity.php +++ b/CRM/Case/Form/Activity.php @@ -413,6 +413,10 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { // format activity custom data if (!empty($params['hidden_custom'])) { if ($this->_activityId) { + // retrieve and include the custom data of old Activity + $oldActivity = civicrm_api3('Activity', 'getsingle', array('id' => $this->_activityId)); + $params = array_merge($params, $oldActivity); + // unset custom fields-id from params since we want custom // fields to be saved for new activity. foreach ($params as $key => $value) { @@ -504,8 +508,8 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { else { $newActParams['original_id'] = $activity->id; } - //is_current_revision will be set to 1 by default. + //is_current_revision will be set to 1 by default. // add attachments if any CRM_Core_BAO_File::formatAttachment($newActParams, $newActParams, diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 5756980c20..4324e12d46 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1619,14 +1619,27 @@ SELECT id $fName = $value['name']; $mimeType = $value['type']; + // If we are already passing the file id as a value then retrieve and set the file data + if (CRM_Utils_Rule::integer($value)) { + $fileDAO = new CRM_Core_DAO_File(); + $fileDAO->id = $value; + $fileDAO->find(TRUE); + if ($fileDAO->N){ + $fileID = $value; + $fName = $fileDAO->uri; + $mimeType = $fileDAO->mime_type; + } + } + $filename = pathinfo($fName, PATHINFO_BASENAME); - // rename this file to go into the secure directory - if (!rename($fName, $config->customFileUploadDir . $filename)) { + // rename this file to go into the secure directory only if + // user has uploaded new file not existing verfied on the basis of $fileID + if (!$fileID && !rename($fName, $config->customFileUploadDir . $filename)) { CRM_Core_Error::statusBounce(ts('Could not move custom file to custom upload directory')); } - if ($customValueId) { + if ($customValueId && !$fileID) { $query = " SELECT $columnName FROM $tableName -- 2.25.1