plus1.api.php in Plus 1 6.2
Hooks provided by the Plus1 module.
File
plus1.api.phpView source
<?php
/**
* @file
* Hooks provided by the Plus1 module.
*/
/**
* @addtogroup hooks
* @{
*/
/**
* 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.
*
* @param $nid
* The node id on which the vote is to be cast.
* @param $op
* The operation to be performed. Possible values:
* - "create"
* - "view"
* @param $account
* A user object representing the user for who is about to cast the vote.
*
* @return
* 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.
*/
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;
}
Functions
Name![]() |
Description |
---|---|
hook_plus1_access | Control whether voting is allowed. |