You are here

function _user_revision_access in User Revision 7.2

Same name and namespace in other branches
  1. 7 user_revision.module \_user_revision_access()

Access callback.

4 calls to _user_revision_access()
user_revision_list_build in ./user_revision.module
Build the table of older revisions of a user.
user_rev_diff_block_view in diff/user_rev_diff.module
Implements hook_block_view().
user_rev_diff_user_revision_access in diff/user_rev_diff.module
Access callback for the user revisions page. Determines whether a user has access to perform a certain operation on a revision.
user_rev_diff_user_view_alter in diff/user_rev_diff.module
Implementation of hook_user_view_alter().
2 string references to '_user_revision_access'
user_revision_menu in ./user_revision.module
Implements hook_menu().
user_rev_diff_menu in diff/user_rev_diff.module
Implementation of hook_menu().

File

./user_revision.module, line 119
Enables user revision.

Code

function _user_revision_access($u, $perm) {
  global $user;
  if (!is_array($perm)) {
    $perm = array(
      $perm,
    );
  }
  $access = FALSE;
  foreach ($perm as $permission) {
    if ($u->uid == $user->uid) {
      $access = user_access($permission) || $access;
    }
    elseif (strpos($permission, 'own') === FALSE) {
      $access = user_access($permission) || $access;
    }
  }
  $count = db_select('user_revision', 'ur')
    ->condition('ur.uid', $u->uid)
    ->countQuery()
    ->execute()
    ->fetchField();
  return $access && $count > 1;
}