You are here

function opigno_og_access_node_grants in Opigno 7

File

modules/opigno_og_access/opigno_og_access.module, line 28
Enable access control for private and public groups and group content.

Code

function opigno_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;
      }
    }
  }
  if ($account->uid) {
    $realm = OG_ACCESS_REALM . ':only_auth';
    $grants[$realm][] = 1;
  }
  return !empty($grants) ? $grants : array();
}