You are here

function og_ui_access_entity_role in Organic groups 7.2

Menu access; Check permissions for role editing - For a specific entity.

Parameters

$perm: Permission string. E.g. 'administer group'.

$group_type: Group entity type. E.g. 'node'.

$gid: Group ID.

$rid: Role ID.

Return value

True if current user is allowed to edit given role. False otherwise.

1 string reference to 'og_ui_access_entity_role'
og_ui_menu in og_ui/og_ui.module
Implements hook_menu().

File

og_ui/og_ui.module, line 421
Organic groups UI.

Code

function og_ui_access_entity_role($perm, $group_type, $gid, $rid) {
  if (!og_user_access($group_type, $gid, $perm)) {
    return FALSE;
  }
  $group = entity_load_single($group_type, $gid);
  if (!$group || !og_is_group($group_type, $group)) {
    return FALSE;
  }
  $role = og_role_load($rid);
  if (!$role || $role->group_type != $group_type) {

    // Role doesn't exist, or doesn't belong to the group.
    return FALSE;
  }
  if ($role->gid && $role->gid != $gid) {

    // Role isn't a global role (i.e. gid isn't 0), but it doesn't match the
    // given role.
    return FALSE;
  }
  return TRUE;
}