You are here

function hook_plus1_access in Plus 1 6.2

Control whether voting is allowed.

Modules may implement this hook if they want to have a say in whether or not a given user is allowed to vote on a given node.

The administrative account (user ID #1) does not bypass this access check.

Note that not all modules will want to influence access. If your module does not want to actively grant or block access, return PLUS1_ACCESS_IGNORE or simply return nothing. Blindly returning FALSE will break other Plus1 access modules.

Parameters

$nid: The node id on which the vote is to be cast.

$op: The operation to be performed. Possible values:

  • "create"
  • "view"

$account: A user object representing the user for who is about to cast the vote.

Return value

PLUS1_ACCESS_ALLOW if voting is to be allowed; PLUS1_ACCESS_DENY if voting is to be denied; PLUS1_ACCESS_IGNORE to not affect voting at all.

2 functions implement hook_plus1_access()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

plus1_forums_plus1_access in ./plus1_forums.module
Implementation of hook_plus1_access().
plus1_plus1_access in ./plus1.module
Implementation of hook_plus1_access().
1 invocation of hook_plus1_access()
plus1_vote_access in ./plus1.module
Check that an item being voted upon is a valid vote.

File

./plus1.api.php, line 40
Hooks provided by the Plus1 module.

Code

function hook_plus1_access($node, $op, $account) {

  // Only show widget on selected node types
  if (!in_array($node->type, variable_get('plus1_nodetypes', array()))) {
    return PLUS1_ACCESS_DENY;
  }

  // If the node voting is disabled, deny.
  if ($node->plus1_disable_vote) {
    return PLUS1_ACCESS_DENY;
  }

  // If the user has already voted - don't let another vote be registered
  if ($op == 'vote' && plus1_get_votes($node->nid, $account->uid)) {
    return PLUS1_ACCESS_DENY;
  }
  return PLUS1_ACCESS_IGNORE;
}