You are here

function og_get_node_groups_result in Organic groups 6.2

Same name and namespace in other branches
  1. 5.8 og.module \og_get_node_groups_result()
  2. 5 og.module \og_get_node_groups_result()
  3. 5.2 og.module \og_get_node_groups_result()
  4. 5.3 og.module \og_get_node_groups_result()
  5. 5.7 og.module \og_get_node_groups_result()
  6. 6 og.module \og_get_node_groups_result()

Get all groups associated with the given Node ID.

This function is also used in og.views.inc.

Parameters

$nid: Node ID.

$bypass: (optional) Bypass user access checks to resulting groups. Defaults to FALSE.

See also

og_get_node_groups()

2 calls to og_get_node_groups_result()
og_get_node_groups in ./og.module
Returns all the group affiliations for a given node.
og_views_handler_field_og_group_nids::pre_render in modules/og_views/includes/og_views_handler_field_og_group_nids.inc

File

./og.module, line 1418
Code for the Organic Groups module.

Code

function og_get_node_groups_result($nid, $bypass = FALSE) {
  $sql = "SELECT oga.group_nid, n.title FROM {node} n INNER JOIN {og_ancestry} oga ON n.nid = oga.group_nid WHERE oga.nid = %d";
  if ($bypass) {

    // We do not run db_rewrite_sql() here since we need to know about groups that the user cannot access as well (i.e. node edit).
    return db_query($sql, $nid);
  }
  return db_query(db_rewrite_sql($sql), $nid);
}