Skip to content

Commit

Permalink
Allow exported permissions in feature modules even when permission's …
Browse files Browse the repository at this point in the history
…defining module isn't enabled.
  • Loading branch information
adamdicarlo committed Nov 9, 2011
1 parent ec365bd commit 9622ffe
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion os_base.module
Expand Up @@ -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.