From: Tim Otten Date: Thu, 7 Mar 2013 10:12:05 +0000 (-0500) Subject: CRM-11925 - Allow permission-enumeration on all platforms. (This facilitates error... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=789565bf64867799e0d1a9e1fff16cafe9d8ef97;p=civicrm-core.git CRM-11925 - Allow permission-enumeration on all platforms. (This facilitates error-reporting when a module is installed on an incompatible CMS.) --- 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) {