You are here

function fivestar_validate_target in Fivestar 6

Same name and namespace in other branches
  1. 5 fivestar.module \fivestar_validate_target()
  2. 6.2 fivestar.module \fivestar_validate_target()
  3. 7.2 fivestar.module \fivestar_validate_target()

Check that an item being voted upon is a valid vote.

Parameters

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

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

$uid: The user trying to cast the vote.

Return value

boolean

3 calls to fivestar_validate_target()
fivestar_block in ./fivestar.module
fivestar_nodeapi in ./fivestar.module
Implementation of hook_nodeapi().
_fivestar_cast_vote in ./fivestar.module
Internal function to handle vote casting, flood control, XSS, IP based voting, etc...

File

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

Code

function fivestar_validate_target($type, $id, $uid = NULL) {
  if (!isset($uid)) {
    $uid = $GLOBALS['user']->uid;
  }
  $access = module_invoke_all('fivestar_access', $type, $id, $uid);
  foreach ($access as $result) {
    if ($result == TRUE) {
      return TRUE;
    }
    if ($result === FALSE) {
      return FALSE;
    }
  }
}