You are here

function vud_access_callback in Vote Up/Down 6.3

Same name and namespace in other branches
  1. 7.2 vud.module \vud_access_callback()
  2. 7 vud.module \vud_access_callback()

Access callback for votes.

Parameters

$perm: A string containing the permission required to modify the vote.

$content_type: A string containing the type of content being voted on.

$content_id: An integer containing the unique ID of the content being voted on.

$value: An integer containing the vote value, 1 for an up vote, -1 for a down vote.

$tag: A string containing the voting API tag. $param $account An object containing the user voting on the content, NULL for the current user.

Return value

A boolean flagging whether or not the user has access to the vote.

4 calls to vud_access_callback()
vud_comment_comment in vud_comment/vud_comment.module
Implementation of hook_comment().
vud_node_nodeapi in vud_node/vud_node.module
Implementation of hook_nodeapi().
vud_widget_proxy in ./vud.theme.inc
Proxy widget function that hook_theme() calls.
_vud_term_generate_table in vud_term/vud_term.module
Function to generate the voting table.
1 string reference to 'vud_access_callback'
vud_menu in ./vud.module
Implementation of hook_menu().

File

./vud.module, line 137

Code

function vud_access_callback($perm, $content_type, $content_id, $value, $tag, $account = NULL) {
  if ($account === NULL) {
    global $user;
    $account = $user;
  }

  // If user do not pass system permissions, deny soon.
  if (user_access($perm, $account) !== TRUE) {
    return FALSE;
  }

  // Invokes hook_vud_access(), gives modules ability to allow or disallow access.
  $access_array = module_invoke_all('vud_access', $perm, $content_type, $content_id, $value, $tag, $account);
  foreach ($access_array as $access_result) {

    // If one hook implementation want to deny, end there.
    if ($access_result !== TRUE) {
      return FALSE;
    }
  }

  // If we are here, account should pass.
  return TRUE;
}