function simple_access_get_groups in Simple Access 7.2
Same name and namespace in other branches
- 8.3 simple_access.module \simple_access_get_groups()
- 5.2 simple_access.module \simple_access_get_groups()
- 5 simple_access.module \simple_access_get_groups()
- 6.2 simple_access.module \simple_access_get_groups()
Return list of groups.
5 calls to simple_access_get_groups()
- simple_access_group_load in ./
simple_access.module - Load a group.
- simple_access_node_access_explain in ./
simple_access.module - Implements hook_node_access_explain().
- simple_access_page_overview in ./
simple_access.admin.inc - Simple Access Overview form.
- simple_access_views_plugin_group::options_form in views/
simple_access_views_plugin_group.inc - Provide the default form for setting options.
- simple_access_views_plugin_group::summary_title in views/
simple_access_views_plugin_group.inc - Return a string to display as the clickable title for the access control.
File
- ./
simple_access.module, line 652 - 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_get_groups($gid = NULL) {
$groups = array();
$query = db_select('simple_access_groups', 'g')
->fields('g', array(
'gid',
'name',
'weight',
))
->orderBy('weight', 'ASC')
->orderBy('name', 'ASC')
->distinct(TRUE);
if ($gid) {
$query
->condition('gid', $gid);
}
$result = $query
->execute();
foreach ($result
->fetchAllAssoc('gid', PDO::FETCH_ASSOC) as $g) {
$groups[$g['gid']]['name'] = $g['name'];
$groups[$g['gid']]['gid'] = $g['gid'];
$groups[$g['gid']]['weight'] = $g['weight'];
$groups[$g['gid']]['roles'] = simple_access_get_roles($g['gid']);
}
return $gid ? $groups[$gid] : $groups;
}