function simple_access_group_select in Simple Access 6.2
Same name and namespace in other branches
- 8.3 simple_access.module \simple_access_group_select()
- 5.2 simple_access.module \simple_access_group_select()
- 5 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.admin.inc - _simple_access_filter_access in ./
simple_access.module - Filter the access records for the current user
File
- ./
simple_access.module, line 547 - 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 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')) . ') GROUP BY g.gid', $roles);
while ($group = db_fetch_array($result)) {
$groups[$group['gid']]['access'] = TRUE;
}
}
}
return $groups;
}