// 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