You are here

function simple_access_groups_from_roles in Simple Access 7.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. 6.2 simple_access.module \simple_access_groups_from_roles()

Get a list of group/grant ids based on a list of user roles.

$roles string A linear list a role ids.

3 calls to simple_access_groups_from_roles()
simple_access_groups_check_user in ./simple_access.module
Check if a user's role is in a group.
simple_access_node_grants in ./simple_access.module
Implements hook_node_grants().
simple_access_views_plugin_group::access in views/simple_access_views_plugin_group.inc
Determine if the current user has access or not.

File

./simple_access.module, line 719
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_select('simple_access_roles', 'r')
    ->fields('r', array(
    'gid',
  ))
    ->condition('rid', $roles, 'IN')
    ->execute();
  $gids = $result
    ->fetchAllAssoc('gid', PDO::FETCH_ASSOC);
  return $gids;
}