function simple_access_get_profiles in Simple Access 7.2
Same name and namespace in other branches
- 8.3 simple_access.module \simple_access_get_profiles()
- 5.2 simple_access.module \simple_access_get_profiles()
- 6.2 simple_access.module \simple_access_get_profiles()
Get simple access profiles.
3 calls to simple_access_get_profiles()
- simple_access_get_profiles_select in ./
simple_access.module - Get all profiles as options for a select list.
- simple_access_node_access_explain in ./
simple_access.module - Implements hook_node_access_explain().
- simple_access_profile_load in ./
simple_access.module - Load a profile.
File
- ./
simple_access.module, line 618 - 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_profiles($pid = NULL) {
$profiles = array();
$query = db_select('simple_access_profiles', 'p')
->fields('p', array(
'pid',
'name',
))
->orderBy('weight', 'ASC')
->orderBy('name');
if ($pid) {
$query
->condition('pid', $pid);
}
$profiles = $query
->execute()
->fetchAllAssoc('pid', PDO::FETCH_ASSOC);
$query = db_select('simple_access_profiles_access', 'a')
->fields('a', array(
'pid',
'gid',
'sa_view',
'sa_update',
'sa_delete',
))
->orderBy('pid');
if ($pid) {
$query
->condition('pid', $pid);
}
$result = $query
->execute();
while ($a = $result
->fetchAssoc(PDO::FETCH_ASSOC)) {
if (isset($profiles[$a['pid']])) {
$profiles[$a['pid']]['access'][$a['gid']] = $a;
}
}
return isset($pid) ? $profiles[$pid] : $profiles;
}