From e1a89dfd944c00d525957f1278609a5e8ab094df Mon Sep 17 00:00:00 2001 From: Edsel Date: Thu, 9 Apr 2015 19:16:55 +0530 Subject: [PATCH] CIVI-28 Added support for individual membership types and pricefield options --- CRM/Contribute/Form/Contribution/Main.php | 3 +++ CRM/Price/BAO/PriceSet.php | 15 +++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index ca53823def..d33a381c1a 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -466,6 +466,9 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;')); } } + if (empty($this->_values['fee'])) { + CRM_Core_Error::fatal(ts('This page does not have any price fields configured or you may not have permission for them. Please contact the site administrator for more details.')); + } //we have to load confirm contribution button in template //when multiple payment processor as the user diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index 616090ad31..a00fe680a2 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -937,13 +937,6 @@ WHERE id = %1"; $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly); $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet); - foreach ($form->_priceSet['fields'] as $key => $value) { - foreach ($value['options'] as $options) { - if (!CRM_Core_Permission::check('add contributions of type ' . CRM_Contribute_PseudoConstant::financialType($options['financial_type_id']))) { - unset($form->_priceSet['fields'][$key]); - } - } - } $validPriceFieldIds = array_keys($form->_priceSet['fields']); $form->_quickConfig = $quickConfig = 0; if (CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) { @@ -970,7 +963,13 @@ WHERE id = %1"; else { $feeBlock = &$form->_priceSet['fields']; } - + foreach ($feeBlock as $key => $value) { + foreach ($value['options'] as $k => $options) { + if (!CRM_Core_Permission::check('add contributions of type ' . CRM_Contribute_PseudoConstant::financialType($options['financial_type_id']))) { + unset($feeBlock[$key]['options'][$k]); + } + } + } // call the hook. CRM_Utils_Hook::buildAmount($component, $form, $feeBlock); -- 2.25.1