From 789565bf64867799e0d1a9e1fff16cafe9d8ef97 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 7 Mar 2013 05:12:05 -0500 Subject: [PATCH] CRM-11925 - Allow permission-enumeration on all platforms. (This facilitates error-reporting when a module is installed on an incompatible CMS.) --- CRM/Core/Permission/Base.php | 12 +++++++++++- CRM/Core/Permission/Drupal.php | 20 ++++---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/CRM/Core/Permission/Base.php b/CRM/Core/Permission/Base.php index 68bef77ce9..8293a5b7e5 100644 --- a/CRM/Core/Permission/Base.php +++ b/CRM/Core/Permission/Base.php @@ -188,10 +188,20 @@ class CRM_Core_Permission_Base { * Get the permissions defined in the hook_civicrm_permission implementation * of the given module. * + * Note: At time of writing, this is only used with native extension-modules, so + * there's one, predictable calling convention (regardless of CMS). + * * @return Array of permissions, in the same format as CRM_Core_Permission::getCorePermissions(). */ static function getModulePermissions($module) { - return array(); + $return_permissions = array(); + $fn_name = "{$module}_civicrm_permission"; + if (function_exists($fn_name)) { + $module_permissions = array(); + $fn_name($module_permissions); + $return_permissions = $module_permissions; + } + return $return_permissions; } /** diff --git a/CRM/Core/Permission/Drupal.php b/CRM/Core/Permission/Drupal.php index 19750a8e1c..10e0aa1c4e 100644 --- a/CRM/Core/Permission/Drupal.php +++ b/CRM/Core/Permission/Drupal.php @@ -122,24 +122,12 @@ class CRM_Core_Permission_Drupal extends CRM_Core_Permission_DrupalBase{ } /** - * Get the permissions defined in the hook_civicrm_permission implementation - * of the given module. Permission keys are prepended with the module name - * to facilitate cleanup of permissions later, and may be hashed to provide - * a unique value that fits storage limitations within Drupal 7. - * + * Permission keys are prepended with the module name to facilitate cleanup + * of permissions later, and may be hashed to provide a unique value that + * fits storage limitations within Drupal 7. + * * @return Array of permissions, in the same format as CRM_Core_Permission::getCorePermissions(). */ - static function getModulePermissions($module) { - $return_permissions = array(); - $fn_name = "{$module}_civicrm_permission"; - if (function_exists($fn_name)) { - $module_permissions = array(); - $fn_name($module_permissions); - $return_permissions = $module_permissions; - } - return $return_permissions; - } - public static function filterPermissions($module_permissions, $module) { $return_permissions = array(); foreach ($module_permissions as $key => $label) { -- 2.25.1