You are here

function simple_access_groups_from_roles in Simple Access 6.2

Same name and namespace in other branches
  1. 8.3 simple_access.module \simple_access_groups_from_roles()
  2. 5.2 simple_access.module \simple_access_groups_from_roles()
  3. 5 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

3 calls to simple_access_groups_from_roles()
simple_access_groups_check_user in ./simple_access.module
simple_access_node_grants in ./simple_access.module
Implementation of hook_node_grants().
simple_access_views_plugin_group::access in views/simple_access_views_plugin_group.inc

File

./simple_access.module, line 577
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();
  $result = db_query('SELECT DISTINCT(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;
}