You are here

function fivestar_fivestar_access in Fivestar 6.2

Same name and namespace in other branches
  1. 8 fivestar.module \fivestar_fivestar_access()
  2. 5 fivestar.module \fivestar_fivestar_access()
  3. 6 fivestar.module \fivestar_fivestar_access()
  4. 7.2 fivestar.module \fivestar_fivestar_access()

Implementation of hook_fivestar_access().

This hook is called before every vote is cast through Fivestar. It allows modules to allow voting on any type of content, such as nodes, users, or comments, even though only nodes are supported by Fivestar directly.

Parameters

$type: Type of target (currently only node is supported).

$id: Identifier within the type (in this case nid).

$tag: The VotingAPI tag string.

$uid: The user ID trying to cast the vote.

Return value

boolean or NULL Returns TRUE if voting is supported on this object. Returns NULL if voting is not supported on this object by this module. If needing to absolutely deny all voting on this object, regardless of permissions defined in other modules, return FALSE. Note if all modules return NULL, stating no preference, then access will be denied.

File

./fivestar.module, line 449
A simple n-star voting widget, usable in other forms.

Code

function fivestar_fivestar_access($type, $id, $tag, $uid) {
  if ($type == 'node' && ($node = node_load($id))) {
    if (variable_get('fivestar_' . fivestar_get_suffix($node->type, $tag), 0)) {
      return TRUE;
    }
  }
}