You are here

function plus1_get_score in Plus 1 7

Same name and namespace in other branches
  1. 6.2 plus1.module \plus1_get_score()
  2. 6 plus1.module \plus1_get_score()

Return the total score for a given content.

Parameters

$entity_type: Node or comment

$entity_id: A node or comment ID.

$tag: A tag to identify different votes on the same content type

Return value

Integer The score.

3 calls to plus1_get_score()
plus1_build_comment_jquery_widget in ./plus1.module
Create voting widget to display on the webpage.
plus1_build_node_jquery_widget in ./plus1.module
Create voting widget to display on the webpage.
plus1_build_taxonomy_term_jquery_widget in ./plus1.module
Create voting widget to display on the webpage.

File

./plus1.module, line 268

Code

function plus1_get_score($entity_type, $entity_id, $tag = 'plus1_node_vote') {
  $criteria['entity_type'] = $entity_type;
  $criteria['entity_id'] = $entity_id;
  $criteria['value_type'] = 'points';
  $criteria['function'] = 'sum';
  if (isset($tag) && $tag != "") {
    $criteria['tag'] = $tag;
  }
  $results = votingapi_select_results($criteria);
  if (empty($results)) {
    return 0;
  }
  else {
    return $results[0]['value'];
  }
}