From 268dc2bd1399524f5b34523e24ca6a163ded87d2 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 7 Mar 2013 03:55:50 -0500 Subject: [PATCH] CRM-11925 - Extract Drupal::filterPermissions from Drupal::getModulePermissions Permission-enumeration is only being used with Civi ext-modules, so the hook-invocation can be done in another (more portable) spot. However, the string-length-limit appears to be specific to D7's permission-store, so it'll need to stay in this class (as "filterPermissions"). --- CRM/Core/Permission/Drupal.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/CRM/Core/Permission/Drupal.php b/CRM/Core/Permission/Drupal.php index 4511000211..d9dcd6ffb6 100644 --- a/CRM/Core/Permission/Drupal.php +++ b/CRM/Core/Permission/Drupal.php @@ -131,16 +131,23 @@ class CRM_Core_Permission_Drupal extends CRM_Core_Permission_DrupalBase{ if (function_exists($fn_name)) { $module_permissions = array(); $fn_name($module_permissions); - foreach ($module_permissions as $key => $label) { - // Prepend the module name to the key. - $new_key = "$module|$key"; - // Limit key length to maintain compatilibility with Drupal, which - // accepts permission keys no longer than 128 characters. - if (strlen($new_key) > 128) { - $new_key = "$module|". md5($key); - } - $return_permissions[$new_key] = $label; + + $return_permissions = self::filterPermissions($module_permissions, $module); + } + return $return_permissions; + } + + public static function filterPermissions($module_permissions, $module) { + $return_permissions = array(); + foreach ($module_permissions as $key => $label) { + // Prepend the module name to the key. + $new_key = "$module|$key"; + // Limit key length to maintain compatilibility with Drupal, which + // accepts permission keys no longer than 128 characters. + if (strlen($new_key) > 128) { + $new_key = "$module|" . md5($key); } + $return_permissions[$new_key] = $label; } return $return_permissions; } -- 2.25.1