From 9242026295eb3b602297acbb70a2f4fa263cfce0 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Tue, 14 Jul 2015 17:47:57 +0530 Subject: [PATCH] --ICM-20, fixed notice error --- CRM/Financial/BAO/FinancialType.php | 47 +++++++++++++++++++---------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index 34a367f720..6a8a9cffe8 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -181,12 +181,13 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { ); foreach ($financialType as $key => $financialTypeName) { - if (!in_array($key, $revenueFinancialType) + if (!in_array($key, $revenueFinancialType) || (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('add contributions of type ' . $financialTypeName)) ) { unset($financialType[$key]); } + } return $financialType; } @@ -195,22 +196,37 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { * adding permissions for financial types * * - * @param array $permissions + * @param array $permissions * an array of permissions */ public static function permissionedFinancialTypes(&$permissions) { if (!self::isACLFinancialTypeStatus()) { - return $membershipTypes; + return FALSE; } $financialTypes = CRM_Contribute_PseudoConstant::financialType(); $prefix = ts('CiviCRM') . ': '; foreach ($financialTypes as $id => $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); + $permissions['add contributions of type ' . $type] = array( + $prefix . ts('add contributions of type ') . $type, + ts('add contributions of type ') . $type, + ); + $permissions['view contributions of type ' . $type] = array( + $prefix . ts('view contributions of type ') . $type, + ts('View contributions of type ') . $type, + ); + $permissions['edit contributions of type ' . $type] = array( + $prefix . ts('edit contributions of type ') . $type, + ts('Edit contributions of type ') . $type, + ); + $permissions['delete contributions of type ' . $type] = array( + $prefix . ts('delete contributions of type ') . $type, + ts('Delete contributions of type ') . $type, + ); } - $permissions['administer CiviCRM Financial Types'] = $prefix . ts('administer CiviCRM Financial Types'); + $permissions['administer CiviCRM Financial Types'] = array( + $prefix . ts('administer CiviCRM Financial Types'), + ts('Administer access to Financial Types'), + ); } public static function getAvailableFinancialTypes(&$financialTypes = NULL, $action = 'view') { @@ -227,7 +243,7 @@ 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(); @@ -252,10 +268,10 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { if (is_array($whereClauses)) { self::getAvailableFinancialTypes($types); if (empty($types)) { - $whereClauses[] = ' ' . $alias . '.financial_type_id IN (0)'; + $whereClauses[] = ' '.$alias.'.financial_type_id IN (0)'; } else { - $whereClauses[] = ' ' . $alias . '.financial_type_id IN (' . implode(',', array_keys($types)) . ')'; + $whereClauses[] = ' '.$alias.'.financial_type_id IN (' . implode(',' , array_keys($types)) .')'; } } else { @@ -271,14 +287,14 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { $whereClauses .= " AND civicrm_{$component}.{$column} IN (0)"; return; } - $whereClauses .= " AND civicrm_{$component}.{$column} IN (" . implode(',', array_keys($types)) . ")"; + $whereClauses .= " AND civicrm_{$component}.{$column} IN (". implode(',' , array_keys($types)) .")"; } } public static function checkPermissionedLineItems($id, $op, $force = TRUE) { $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($id); $flag = FALSE; - foreach ($lineItems as $items) { + foreach ($lineItems as $items) { if (!CRM_Core_Permission::check($op . ' contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) { if ($force) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); @@ -293,11 +309,11 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { } return $flag; } - + /** * Check if FT-ACL is turned on or off * - * @return bool + * @return boolean */ public static function isACLFinancialTypeStatus() { $contributeSettings = CRM_Core_BAO_Setting::getItem( @@ -308,5 +324,4 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { } return FALSE; } - } -- 2.25.1