diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 3bf7ac78448d98d0ccf9f3dabda944921ab693c0..3340712c4395db054404cba1425879c79959d749 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -279,14 +279,17 @@ class CRM_Report_Form extends CRM_Core_Form { // Get all custom groups $allGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); - // Get the custom groupIds for which the user have VIEW permission - require_once 'CRM/ACL/API.php'; - $permCustomGroupIds = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_custom_group', $allGroups, NULL); - - // do not allow custom data for reports if user don't have - // permission to access custom data. - if (!empty($this->_customGroupExtends) && !CRM_Core_Permission::check('access all custom data') && empty($permCustomGroupIds)) { - $this->_customGroupExtends = array(); + // Get the custom groupIds for which the user has VIEW permission + // If the user has 'access all custom data' permission, we'll leave $permCustomGroupIds empty + // and addCustomDataToColumns() will allow access to all custom groups. + $permCustomGroupIds = array(); + if (!CRM_Core_Permission::check('access all custom data')) { + $permCustomGroupIds = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_custom_group', $allGroups, NULL); + // do not allow custom data for reports if user doesn't have + // permission to access custom data. + if (!empty($this->_customGroupExtends) && empty($permCustomGroupIds)) { + $this->_customGroupExtends = array(); + } } // merge custom data columns to _columns list, if any