From 27e7373df8293de47328977b0bc8ecabbab08613 Mon Sep 17 00:00:00 2001 From: Edsel Date: Fri, 10 Apr 2015 17:48:35 +0530 Subject: [PATCH] CIVI-28 Added check for financial types on membership search form --- CRM/Financial/BAO/FinancialType.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index 6db839ab57..fe739fe36f 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -219,6 +219,20 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { } return $financialTypes; } + + public static function getAvailableMembershipTypes(&$membershipTypes = NULL, $action = 'view') { + if (empty($membershipTypes)) { + $membershipTypes = CRM_Member_PseudoConstant::membershipType(); + } + foreach ($membershipTypes as $memTypeId => $type) { + $finTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $memTypeId, 'financial_type_id'); + $finType = CRM_Contribute_PseudoConstant::financialType($finTypeId); + if (!CRM_Core_Permission::check($action . ' contributions of type ' . $finType)) { + unset($membershipTypes[$memTypeId]); + } + } + return $membershipTypes; + } public static function buildPermissionedClause(&$whereClauses) { self::getAvailableFinancialTypes($financialType); -- 2.25.1