function og_role_grant_permissions in Organic groups 7.2
Same name and namespace in other branches
- 7 og.module \og_role_grant_permissions()
Grant permissions to a user role.
Parameters
$rid: The ID of a user role to alter.
$permissions: A list of permission names to grant.
See also
user_role_change_permissions()
user_role_revoke_permissions()
6 calls to og_role_grant_permissions()
- OgAccessModeratedGroup::setUp in og_access/
og_access.test - Sets up a Drupal site for running functional and integration tests.
- OgUiAdminPermissionsTestCase::testOgUiAdminPermissionsAccess in og_ui/
og_ui.test - Check access to restricted permissions on the permissions edit page.
- OgUiAdminPermissionsTestCase::testOgUiAdminTabAccess in og_ui/
og_ui.test - Check access permissions to the group admin tab.
- OgUiPrivateGroupStatus::testMemberShipRequestStatus in og_ui/
og_ui.test - The variable "og_ui_deny_subscribe_without_approval" responsible for determine that when the user ask to join to a private group their membership status will be pending. By default his value is true. The test has two parts:
- og_features_permission_features_rebuild in includes/
og_features_permission.features.inc - Implements hook_features_rebuild().
File
- ./
og.module, line 3194 - Enable users to create and manage groups with roles and permissions.
Code
function og_role_grant_permissions($rid, array $permissions = array()) {
$modules = array();
foreach (og_get_permissions() as $name => $value) {
$modules[$name] = $value['module'];
}
// Grant new permissions for the role.
foreach ($permissions as $name) {
// Prevent WSOD, if the permission name is wrong, and we can't find its
// module.
if (!empty($modules[$name])) {
db_merge('og_role_permission')
->key(array(
'rid' => $rid,
'permission' => $name,
'module' => $modules[$name],
))
->execute();
}
}
og_invalidate_cache();
}