From cb2f7dd1be626caf6560b068526173696eb5d9af Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Sat, 8 Aug 2015 02:10:13 +0530 Subject: [PATCH] --CRM-16526, fixed notice error on reports --- CRM/Core/Permission.php | 2 +- CRM/Financial/BAO/FinancialType.php | 41 +++++++++++++++-------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index 1c3723a5c3..1aacfef53f 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -632,7 +632,7 @@ class CRM_Core_Permission { // Add any permissions defined in hook_civicrm_permission implementations. $module_permissions = $config->userPermissionClass->getAllModulePermissions($descriptions); $permissions = array_merge($permissions, $module_permissions); - CRM_Financial_BAO_FinancialType::permissionedFinancialTypes($permissions); + CRM_Financial_BAO_FinancialType::permissionedFinancialTypes($permissions, $descriptions); return $permissions; } diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index 3eab56f137..653550f60a 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -215,34 +215,35 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { * @param array $permissions * an array of permissions */ - public static function permissionedFinancialTypes(&$permissions) { + public static function permissionedFinancialTypes(&$permissions, $descriptions) { if (!self::isACLFinancialTypeStatus()) { return FALSE; } $financialTypes = CRM_Contribute_PseudoConstant::financialType(); $prefix = ts('CiviCRM') . ': '; + $actions = array('add', 'view', 'edit', 'delete'); foreach ($financialTypes as $id => $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, + foreach ($actions as $action) { + if ($descriptions) { + $permissions[$action . ' contributions of type ' . $type] = array( + $prefix . ts($action . ' contributions of type ') . $type, + ts(ucfirst($action) . ' contributions of type ') . $type, + ); + } + else { + $permissions[$action . ' contributions of type ' . $type] = $prefix . ts($action . ' contributions of type ') . $type; + } + } + } + if (!$descriptions) { + $permissions['administer CiviCRM Financial Types'] = $prefix . ts('administer CiviCRM Financial Types'); + } + else { + $permissions['administer CiviCRM Financial Types'] = array( + $prefix . ts('administer CiviCRM Financial Types'), + ts('Administer access to 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', $resetCache = FALSE) { -- 2.25.1