function profile2_og_access_profile2_access in Profile 2 7.2
Same name and namespace in other branches
- 7 contrib/profile2_og_access.module \profile2_og_access_profile2_access()
Implements hook_profile2_access().
See also
File
- contrib/
profile2_og_access.module, line 33 - Profile2 og access integration module.
Code
function profile2_og_access_profile2_access($op, $profile = NULL, $account = NULL) {
if (isset($profile) && ($type_name = $profile->type) && $profile
->identifier() && $op != 'delete') {
// Check by common user og roles.
$current_user_groups = og_get_entity_groups('user', $account);
$profile_user_groups = og_get_entity_groups('user', $profile->uid);
if (!empty($current_user_groups['node']) && !empty($profile_user_groups['node'])) {
foreach ($profile_user_groups['node'] as $grp_id) {
if (in_array($grp_id, $profile_user_groups['node']) && og_user_access_entity("{$op} any {$type_name} profile", 'node', $grp_id, $account)) {
//common group found
return TRUE;
}
}
}
// Only return TRUE if og grants access. So other modules may still grant
// access in case og does not.
if (og_user_access_entity("{$op} any {$type_name} profile", 'profile2', $profile, $account)) {
return TRUE;
}
}
}