Skip to content
Browse files

Allow exported permissions in feature modules even when permission's …

…defining module isn't enabled.
  • Loading branch information...
1 parent ec365bd commit 9622ffec5ac66562e8d6cedafec87b09201c0d39 @adamdicarlo adamdicarlo committed Nov 9, 2011
Showing with 17 additions and 1 deletion.
  1. +17 −1 os_base.module
View
18 os_base.module
@@ -120,4 +120,20 @@ function os_base_preprocess_views_view(&$vars) {
}
$vars['empty'] = !empty($output) ? $output : t('There is currently no content to view in this section.');
}
-}
+}
+
+/**
+ * Implements hook_user_default_permissions_alter(). (Features hook.)
+ */
+function os_base_user_default_permissions_alter(&$permissions) {
+ // This is a workaround that allows us to export permissions for modules
+ // without making them a hard dependency. This simply removes permissions
+ // whose modules are not currently enabled.
+ $modules_enabled = module_list();
+ foreach ($permissions as $key => $perm) {
+ if (!isset($modules_enabled[$perm['module']])) {
+ // Module isn't enabled; simply remove the permission.
+ unset($permissions[$key]);
+ }
+ }
+}

0 comments on commit 9622ffe

Please sign in to comment.
Something went wrong with that request. Please try again.