From f1db52b97a003f1882394abe172e4e28b4959f8a Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Fri, 3 Apr 2015 17:37:10 -0400 Subject: [PATCH] CRM-16230 - Permissions: handle extensions with and without descriptions ---------------------------------------- * CRM-16230: Extensions providing permissions will choke https://issues.civicrm.org/jira/browse/CRM-16230 --- CRM/Core/Permission.php | 2 +- CRM/Core/Permission/Base.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index b56d805b3d..9fb1bd1551 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -616,7 +616,7 @@ class CRM_Core_Permission { } // Add any permissions defined in hook_civicrm_permission implementations. - $module_permissions = $config->userPermissionClass->getAllModulePermissions(); + $module_permissions = $config->userPermissionClass->getAllModulePermissions($descriptions); $permissions = array_merge($permissions, $module_permissions); return $permissions; } diff --git a/CRM/Core/Permission/Base.php b/CRM/Core/Permission/Base.php index 3b47e271b8..e3e9f4d520 100644 --- a/CRM/Core/Permission/Base.php +++ b/CRM/Core/Permission/Base.php @@ -256,9 +256,20 @@ class CRM_Core_Permission_Base { * @return array * Array of permissions, in the same format as CRM_Core_Permission::getCorePermissions(). */ - public function getAllModulePermissions() { + public function getAllModulePermissions($descriptions = FALSE) { $permissions = array(); CRM_Utils_Hook::permission($permissions); + + if ($descriptions) { + foreach ($permissions as $permission => $label) { + $permissions[$permission] = (is_array($label)) ? $label : array($label); + } + } + else { + foreach ($permissions as $permission => $label) { + $permissions[$permission] = (is_array($label)) ? array_shift($label) : $label; + } + } return $permissions; } -- 2.25.1