You are here

function simple_access_groups_from_roles in Simple Access 5.2

Same name and namespace in other branches
  1. 8.3 simple_access.module \simple_access_groups_from_roles()
  2. 5 simple_access.module \simple_access_groups_from_roles()
  3. 6.2 simple_access.module \simple_access_groups_from_roles()
  4. 7.2 simple_access.module \simple_access_groups_from_roles()

Get a list of group/grant ids based on a list of user roles $roles should be a linear list a role ids

1 call to simple_access_groups_from_roles()
simple_access_node_grants in ./simple_access.module
Implementation of hook_node_grants().

File

./simple_access.module, line 882
This module allows administrators to make nodes viewable by specific 'access groups'. Each access group can contain any number of roles. If a node is not assigned to any access groups, it will remain viewable by all users.

Code

function simple_access_groups_from_roles($roles) {

  // there probably should be some 'static' stuff going on here
  // always return gid 0 just to be safe.
  $gids = array(
    0,
  );
  $result = db_query('SELECT gid FROM {simple_access_roles} WHERE rid IN (' . implode(',', array_fill(0, count($roles), '%d')) . ')', $roles);
  while ($g = db_fetch_object($result)) {
    $gids[] = $g->gid;
  }
  return $gids;
}