You are here

function og_subgroups_check_member_user_access in Subgroups for Organic groups 7.2

Checks what access a 'member' of a given group has.

1 call to og_subgroups_check_member_user_access()
_og_subgroups_check_access in ./og_subgroups.module
Check access for this group's parents.

File

./og_subgroups.module, line 317
Provides users the ability to inherit permissions on subgroups.

Code

function og_subgroups_check_member_user_access($group_type, $gid, $string) {
  global $user;
  $perm =& drupal_static(__FUNCTION__, array());
  $identifier = $group_type . ':' . $gid;
  if (!isset($perm[$identifier])) {
    $group = entity_load_single($group_type, $gid);
    $query_gid = og_is_group_default_access($group_type, $gid) ? 0 : $gid;

    // Get the bundle of the group.
    list($id, $vid, $bundle) = entity_extract_ids($group_type, $group);

    // Grab the default rid for authenticate role for this group.
    $rids = db_select('og_role', 'ogr')
      ->fields('ogr', array(
      'rid',
      'name',
    ))
      ->condition('group_type', $group_type, '=')
      ->condition('group_bundle', $bundle, '=')
      ->condition('gid', $query_gid, '=')
      ->condition('name', OG_AUTHENTICATED_ROLE, '=')
      ->execute()
      ->fetchAllkeyed();
    $perm[$identifier] = current(og_role_permissions($rids));
  }
  return !empty($perm[$identifier][$string]) || !empty($perm[$identifier]['administer group']);
}