From a4ef4eac2c650ffa7cc5d9f02d37fbed8ff802ae Mon Sep 17 00:00:00 2001 From: Edsel Date: Tue, 17 Mar 2015 15:49:54 +0530 Subject: [PATCH] CIVI-28 Bug fixes and modifications --- CRM/Contribute/BAO/Query.php | 3 ++- CRM/Contribute/Form/Contribution.php | 2 +- CRM/Contribute/Form/ContributionPage/Settings.php | 10 +++------- CRM/Event/Form/EventFees.php | 5 ++++- CRM/Event/Form/ManageEvent/Fee.php | 8 +++++++- CRM/Financial/BAO/FinancialType.php | 6 +++--- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index 4ff886c356..d2e4e95705 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -888,8 +888,9 @@ class CRM_Contribute_BAO_Query { ); // CRM-13848 + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, 'view'); $form->addSelect('financial_type_id', - array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search') + array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => $financialTypes) ); $form->add('select', 'contribution_page_id', diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index f35bc6e2bd..e6eb2a11c4 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -616,7 +616,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution'); // Check permissions for financial type first - CRM_Financial_BAO_FinancialType::addFinancialTypes($financialTypes); + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, 'add'); $financialType = $this->add('select', 'financial_type_id', ts('Financial Type'), diff --git a/CRM/Contribute/Form/ContributionPage/Settings.php b/CRM/Contribute/Form/ContributionPage/Settings.php index 0dc2616795..efcbd983a4 100644 --- a/CRM/Contribute/Form/ContributionPage/Settings.php +++ b/CRM/Contribute/Form/ContributionPage/Settings.php @@ -119,16 +119,12 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ // financial Type if (CRM_Core_Permission::check('administer CiviCRM Financial Types')) { - $this->addSelect('financial_type_id', array(), TRUE); + $this->addSelect('financial_type_id', array('context' => 'search'), TRUE); } else { - CRM_Financial_BAO_FinancialType::addFinancialTypes($financialTypes); + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, 'add'); - $financialType = $this->add('select', 'financial_type_id', - ts('Financial Type'), - array('' => ts('- select -')) + $financialTypes, - TRUE - ); + $this->addSelect('financial_type_id', array('context' => 'search', 'options' => $financialTypes), TRUE); } // name diff --git a/CRM/Event/Form/EventFees.php b/CRM/Event/Form/EventFees.php index 4f9a9280d0..9fa165118f 100644 --- a/CRM/Event/Form/EventFees.php +++ b/CRM/Event/Form/EventFees.php @@ -417,10 +417,13 @@ SELECT id, html_type $form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), NULL, array('onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);") ); + + // Check permissions for financial type first + CRM_Financial_BAO_FinancialType::addFinancialTypes($financialTypes); $form->add('select', 'financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType() + array('' => ts('- select -')) + $financialTypes ); $form->addDateTime('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime')); diff --git a/CRM/Event/Form/ManageEvent/Fee.php b/CRM/Event/Form/ManageEvent/Fee.php index de7574d456..4b7370b633 100644 --- a/CRM/Event/Form/ManageEvent/Fee.php +++ b/CRM/Event/Form/ManageEvent/Fee.php @@ -273,7 +273,13 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { )); // financial type - $this->addSelect('financial_type_id'); + if (CRM_Core_Permission::check('administer CiviCRM Financial Types')) { + $this->addSelect('financial_type_id'); + } + else { + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, 'add'); + $this->addSelect('financial_type_id', array('context' => 'search', 'options' => $financialTypes)); + } // add pay later options $this->addElement('checkbox', 'is_pay_later', ts('Enable Pay Later option?'), NULL, array('onclick' => "return showHideByValue('is_pay_later','','payLaterOptions','block','radio',false);") diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index 49ac55512a..dff2aa0630 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -198,7 +198,7 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { $financialTypes = CRM_Contribute_PseudoConstant::financialType(); $prefix = ts('CiviCRM') . ': '; foreach ($financialTypes as $id => $type) { - $permissions['add new contributions of type ' . $type] = $prefix . ts('add new contributions of type ' . $type); + $permissions['add contributions of type ' . $type] = $prefix . ts('add contributions of type ' . $type); $permissions['view contributions of type ' . $type] = $prefix . ts('view contributions of type ' . $type); $permissions['edit contributions of type ' . $type] = $prefix . ts('edit contributions of type ' . $type); $permissions['delete contributions of type ' . $type] = $prefix . ts('delete contributions of type ' . $type); @@ -206,11 +206,11 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { $permissions['administer CiviCRM Financial Types'] = $prefix . ts('administer CiviCRM Financial Types'); } - public static function addFinancialTypes(&$financialTypes) { + public static function getAvailableFinancialTypes(&$financialTypes, $action) { $financialTypes = CRM_Contribute_PseudoConstant::financialType(); foreach ($financialTypes as $finTypeId => $type) { - if (!CRM_Core_Permission::check('add new contributions of type ' . $type)) { + if (!CRM_Core_Permission::check($action . ' contributions of type ' . $type)) { unset($financialTypes[$finTypeId]); } } -- 2.25.1