function og_access_node_grants

7.x-2.x og_access.module og_access_node_grants($account, $op)
7.x-1.x og_access.module og_access_node_grants($account, $op)
6.x og_access.module og_access_node_grants($account, $op)

Implements hook_node_grants().

File

og/og_access/og_access.module, line 43
Enable access control for private and public groups and group content.

Code

function og_access_node_grants($account, $op) {
  if ($op != 'view') {
    return;
  }

  if ($groups = og_get_entity_groups('user', $account)) {
    foreach ($groups as $group_type => $gids) {
      foreach ($gids as $gid) {
        $realm = OG_ACCESS_REALM . ':' . $group_type;
        $grants[$realm][] = $gid;
      }
    }
  }

  return !empty($grants) ? $grants : array();
}