You are here

function group_non_member_gids in Group 7

Get the ids of the groups someone isn't a member of.

Note: seeing as anonymous users cannot become a member of a group, this function returns all group ids when provided with the anonymous account (UID: 0), though still optionally filtered by group type.

Parameters

int $uid: The id of the user to retrieve group ids for.

string $type: (optional) Filters the results for a given group type.

Return value

array An array of group ids (gids).

2 calls to group_non_member_gids()
gnode_group_node_create_access in modules/gnode/gnode.module
Determines whether a user could create a node in a Group context.
gnode_group_node_create_gids in modules/gnode/gnode.module
Retrieve all group ids a user can create a node of a given type in.

File

helpers/group.inc, line 132
Group related helper functions.

Code

function group_non_member_gids($uid, $type = '') {
  $query = db_select('groups', 'g');
  $query
    ->addField('g', 'gid');
  $query
    ->where('g.gid NOT IN (SELECT gid FROM {group_membership} WHERE uid = :uid)', array(
    ':uid' => $uid,
  ));
  if ($type) {
    $query
      ->condition('g.type', $type);
  }
  return $query
    ->execute()
    ->fetchCol();
}