function _profile2_revision_access in Profile 2 7.2
Access callback.
5 calls to _profile2_revision_access()
- profile2_diff_block_view in contrib/
profile2_diff.module - Implements hook_block_view().
- profile2_diff_entity_view_alter in contrib/
profile2_diff.module - Implementation of hook_entity_view_alter().
- profile2_revision_list_build in ./
profile2.module - Build the table of older revisions of a profile.
- _profile2_any_revision_access in ./
profile2.module - Determine if any profile revision sub-tab is allowed access.
- _profile2_revision_tab_access in ./
profile2.module
2 string references to '_profile2_revision_access'
- profile2_diff_menu in contrib/
profile2_diff.module - Implements hook_menu().
- profile2_page_menu in contrib/
profile2_page.module - Implements hook_menu().
File
- ./
profile2.module, line 1684 - Support for configurable user profiles.
Code
function _profile2_revision_access($profile, $perm) {
if (empty($profile)) {
return FALSE;
}
global $user;
if (!is_array($perm)) {
$perm = array(
$perm,
);
}
$access = FALSE;
foreach ($perm as $permission) {
if ($profile->uid == $user->uid) {
$access = user_access($permission) || $access;
}
elseif (strpos($permission, 'own') === FALSE) {
$access = user_access($permission) || $access;
}
}
$count =& drupal_static(__FUNCTION__, array());
if (!isset($count[$profile->pid])) {
$count[$profile->pid] = db_select('profile_revision', 'pr')
->condition('pr.pid', $profile->pid)
->countQuery()
->execute()
->fetchField();
}
return $access && $count[$profile->pid] > 1;
}