From 9b7bedc5ed48f3d98bf872e7b42df4e44fe245cf Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Wed, 12 Oct 2016 12:24:02 +0530 Subject: [PATCH] CRM-19460 - Fix brackets in file uploads --- CRM/Contribute/Form/ContributionBase.php | 5 ++++- CRM/Core/QuickForm/Action/Upload.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 80d3f2a15c..51ab36a334 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -640,7 +640,10 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { $field['data_type'] == 'File' || ($viewOnly && $field['name'] == 'image_URL') ) { //retrieve file value from submitted values on basis of $profileContactType - $fileValue = empty($profileContactType) ? CRM_Utils_Array::value($key, $this->_params) : CRM_Utils_Array::value(sprintf('%s[%s]', $profileContactType, $key), $this->_params); + $fileValue = CRM_Utils_Array::value($key, $this->_params); + if (!empty($profileContactType) && !empty($this->_params[$profileContactType])) { + $fileValue = CRM_Utils_Array::value($key, $this->_params[$profileContactType]); + } if ($fileValue) { $path = CRM_Utils_Array::value('name', $fileValue); diff --git a/CRM/Core/QuickForm/Action/Upload.php b/CRM/Core/QuickForm/Action/Upload.php index f4fe6105bd..4276924ecf 100644 --- a/CRM/Core/QuickForm/Action/Upload.php +++ b/CRM/Core/QuickForm/Action/Upload.php @@ -105,10 +105,13 @@ class CRM_Core_QuickForm_Action_Upload extends CRM_Core_QuickForm_Action { @unlink($this->_uploadDir . $data['values'][$pageName][$uploadName]); } - $data['values'][$pageName][$uploadName] = array( + $value = array( 'name' => $this->_uploadDir . $newName, 'type' => $value['type'], ); + //CRM-19460 handle brackets if present in $uploadName, similar things we do it for all other inputs. + $value = $element->_prepareValue($value, TRUE); + $data['values'][$pageName] = HTML_QuickForm::arrayMerge($data['values'][$pageName], $value); } } } -- 2.25.1