You are here

function plus1_get_votes in Plus 1 6.2

Same name and namespace in other branches
  1. 7 plus1.module \plus1_get_votes()

Return the number of votes for a given node ID/user ID pair.

Parameters

$nid: A node ID.

$uid: A user ID.

Return value

Integer Number of votes the user has cast on this node.

3 calls to plus1_get_votes()
hook_plus1_access in ./plus1.api.php
Control whether voting is allowed.
plus1_jquery_widget in ./plus1.module
Create voting widget to display on the webpage.
plus1_plus1_access in ./plus1.module
Implementation of hook_plus1_access().

File

./plus1.module, line 148
A simple +1 voting widget module.

Code

function plus1_get_votes($nid, $uid) {
  $criteria = array(
    'content_id' => $nid,
    'value_type' => 'points',
    'tag' => PLUS1_VOTE_TAG,
  );
  if ($uid == 0) {
    $criteria['vote_source'] = ip_address();
  }
  else {
    $criteria['uid'] = $uid;
  }
  $results = votingapi_select_votes($criteria);
  return count($results);
}