From c2292dbd1a9fcbc831b0599a91aef7c176fee275 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Mon, 3 Oct 2016 13:09:27 +0530 Subject: [PATCH] additional changes to support onbehalf and honoree profile --- CRM/Contribute/Form/ContributionBase.php | 23 ++++++++++++++++------- templates/CRM/UF/Form/Block.tpl | 6 +++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index e408c5ff19..b0fa99acdf 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -630,20 +630,29 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { CRM_Core_BAO_Address::checkContactSharedAddressFields($fields, $contactID); $addCaptcha = FALSE; // fetch file preview when not submitted yet, like in online contribution Confirm and ThankYou page - $viewOnlyFileValues = array(); + $viewOnlyFileValues = empty($profileContactType) ? array() : array($profileContactType => array()); foreach ($fields as $key => $field) { if ($viewOnly && isset($field['data_type']) && $field['data_type'] == 'File' || ($viewOnly && $field['name'] == 'image_URL') ) { - $viewOnlyFileValues[$key] = ''; - if (!empty($this->_params[$key])) { - $path = CRM_Utils_Array::value('name', $this->_params[$key]); - $fileType = CRM_Utils_Array::value('type', $this->_params[$key]); - $viewOnlyFileValues[$key] = CRM_Utils_File::getFileURL($path, $fileType); + //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); + + if ($fileValue) { + $path = CRM_Utils_Array::value('name', $fileValue); + $fileType = CRM_Utils_Array::value('type', $fileValue); + $fileValue = CRM_Utils_File::getFileURL($path, $fileType); } - } + // format custom file value fetched from submitted value + if ($profileContactType) { + $viewOnlyFileValues[$profileContactType][$key] = $fileValue; + } + else { + $viewOnlyFileValues[$key] = $fileValue; + } + } if ($profileContactType) { //Since we are showing honoree name separately so we are removing it from honoree profile just for display if ($profileContactType == 'honor') { diff --git a/templates/CRM/UF/Form/Block.tpl b/templates/CRM/UF/Form/Block.tpl index c59098b604..7e7b525e23 100644 --- a/templates/CRM/UF/Form/Block.tpl +++ b/templates/CRM/UF/Form/Block.tpl @@ -135,7 +135,11 @@ {if $n eq 'organization_name' && !empty($form.onbehalfof_id)} {$form.onbehalfof_id.html} {/if} - {$form.$prefix.$n.html} + {if $field.html_type eq 'File' && $viewOnlyFileValues.$prefix} + {$viewOnlyFileValues.$prefix.$n} + {else} + {$form.$prefix.$n.html} + {/if} {elseif $field.html_type eq 'File' && $viewOnlyFileValues} {$viewOnlyFileValues.$n} {else} -- 2.25.1