function _og_subgroups_check_access in Subgroups for Organic groups 7.2
Check access for this group's parents.
1 call to _og_subgroups_check_access()
- og_subgroups_og_user_access_alter in ./
og_subgroups.module - Implements hook_og_user_access_alter().
File
- ./
og_subgroups.module, line 280 - Provides users the ability to inherit permissions on subgroups.
Code
function _og_subgroups_check_access(&$perms, $context, $group_type, $id, $user_groups, $check_member_access = FALSE) {
// Check only one level at a time due to permission inheritance field.
if ($parent_groups = og_subgroups_intersect_groups(og_subgroups_parents_load($group_type, $id, TRUE, FALSE), $user_groups)) {
foreach ($parent_groups as $parent_group_type => $ids) {
// Find all groups that have inheritance set to child (assume inherit
// [default] otherwise).
$child_inheritence = _og_subgroups_get_field_matching($parent_group_type, $ids, OG_USER_INHERITANCE_PERMISSION_FIELD, OG_USER_INHERITANCE_PERMISSION_CHILD);
foreach ($ids as $parent_group_id) {
// Assumed OG_USER_INHERITANCE_PERMISSION_INHERIT as not _CHILD.
if (!in_array($parent_group_id, $child_inheritence)) {
if (og_user_access($parent_group_type, $parent_group_id, $context['string'], $context['account'], TRUE)) {
$perms[$context['string']] = TRUE;
return;
}
// Check inherited access for the parents.
_og_subgroups_check_access($perms, $context, $parent_group_type, $parent_group_id, $user_groups);
// Skip out if permission has been set.
if (!empty($perms[$context['string']])) {
return;
}
}
elseif ($check_member_access) {
// Checks that user has member access to the currentgroup.
if (og_subgroups_check_member_user_access($group_type, $id, $context['string'])) {
$perms[$context['string']] = TRUE;
return;
}
$check_member_access = FALSE;
}
}
}
}
}