function oa_access_get_group_permissions in Open Atrium Core 7.2
Gets all the permissions that a list of groups have.
Parameters
array $groups: An array of nids of Groups or Teams.
Return value
array An associative array keyed by group nid containing associative arrays keyed by the module and containing an array of permission names, for example:
array(
'27' => array(
'mymodule' => array(
'a permission',
),
),
);
Which signifies that the group with nid 27 has 'a permission' from a module called 'mymodule'.
See also
oa_access_set_group_permissions()
9 calls to oa_access_get_group_permissions()
- oa_access_get_group_permissions_combined in modules/
oa_access/ oa_access.module - Gets a combined list of the permissions that a list of groups can perform.
- OpenAtriumAccessAllTestCase::testAddSpaces in modules/
oa_access/ tests/ oa_access.test - OpenAtriumAccessAllTestCase::testModuleEnableWithTeams in modules/
oa_access/ tests/ oa_access.test - OpenAtriumAccessBaseTestCase::getGroupPermissions in modules/
oa_access/ tests/ oa_access.test - Gets all the permissions that a list of groups have.
- OpenAtriumAccessTestCase::testCleanupPermissions in modules/
oa_access/ tests/ oa_access.test
4 string references to 'oa_access_get_group_permissions'
- oa_access_initialize_permissions in modules/
oa_access/ oa_access.module - Initializes new permissions that were added after module install.
- oa_access_set_group_permissions in modules/
oa_access/ oa_access.module - Changes the permissions for a set of groups.
- OpenAtriumAccessTestCase::testCleanupPermissions in modules/
oa_access/ tests/ oa_access.test - OpenAtriumAccessTestCase::testGetSetGroupPermissions in modules/
oa_access/ tests/ oa_access.test
File
- modules/
oa_access/ oa_access.module, line 439 - Code for the Open Atrium Access module.
Code
function oa_access_get_group_permissions($groups) {
$cache =& drupal_static(__FUNCTION__, array());
// First, go through the static cache and any groups we don't have data
// for to the $missing array.
$missing = array();
foreach ($groups as $gid) {
if (!isset($cache[$gid])) {
$missing[] = $gid;
}
}
// Next, query any of the missing groups from the database and add them to
// the static cache.
if (!empty($missing)) {
$query = db_select('oa_access', 'a')
->fields('a', array(
'nid',
'permission',
'module',
))
->condition('a.nid', $missing, 'IN');
foreach ($query
->execute() as $row) {
$cache[$row->nid][$row->module][] = $row->permission;
}
}
// Finally, add all the necessary permissions from the static cache and
// return it!
$return = array();
foreach ($groups as $gid) {
$return[$gid] = isset($cache[$gid]) ? $cache[$gid] : array();
}
return $return;
}