function simple_access_group_select in Simple Access 5.2
Same name and namespace in other branches
- 8.3 simple_access.module \simple_access_group_select()
- 5 simple_access.module \simple_access_group_select()
- 6.2 simple_access.module \simple_access_group_select()
- 7.2 simple_access.module \simple_access_group_select()
3 calls to simple_access_group_select()
- simple_access_form in ./
simple_access.module - simple_access_profile_form in ./
simple_access.module - _simple_access_filter_access in ./
simple_access.module - Filter the access records for the corrent user
File
- ./
simple_access.module, line 852 - 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_group_select() {
static $groups;
if (empty($groups)) {
global $user;
$default_access = user_access('administer nodes');
$groups = array();
$result = db_query('SELECT gid, name FROM {simple_access_groups} ORDER BY weight, name');
while ($group = db_fetch_array($result)) {
$groups[$group['gid']] = $group;
$groups[$group['gid']]['access'] = $default_access;
}
if (!$default_access) {
// return just groups for which user is a member
$roles = array_keys($user->roles);
$result = db_query('SELECT DISTINCT g.gid FROM {simple_access_groups} g INNER JOIN {simple_access_roles} r ON g.gid = r.gid WHERE r.rid IN (' . implode(',', array_fill(0, count($roles), '%d')) . ') ORDER BY weight, name', $roles);
while ($group = db_fetch_array($result)) {
$groups[$group['gid']]['access'] = TRUE;
}
}
}
return $groups;
}