function og_role_override_permission in OG Role Override 7.2
Implements hook_permission().
Defines core permissions based on OG group types and roles, of the form 'act as ROLE in GROUP-TYPE'.
File
- ./
og_role_override.module, line 25 - og_role_override.module Allows Core roles to act as OG roles in specific group types.
Code
function og_role_override_permission() {
$permissions = array();
$entity_info = entity_get_info();
// Iterate over all group types; these all have different roles
$og_group_bundles = og_get_all_group_bundle();
foreach (array_keys($og_group_bundles) as $entity_type) {
foreach ($og_group_bundles[$entity_type] as $bundle_name => $bundle_label) {
$og_roles = og_roles($entity_type, $bundle_name);
// Create a core permission for each OG role in this group type.
foreach ($og_roles as $role_name) {
$permissions["act as {$role_name} in og {$entity_type}:{$bundle_name}"] = array(
'title' => t('Act as role "@role" in OG @entity @bundle groups', array(
'@role' => $role_name,
'@entity' => $entity_info[$entity_type]['label'],
'@bundle' => $bundle_label,
)),
);
}
}
}
return $permissions;
}