function plus1_get_votes in Plus 1 7
Same name and namespace in other branches
- 6.2 plus1.module \plus1_get_votes()
Return the number of votes for a given content.
Parameters
$entity_type: An entity type, node or comment.
$entity_id: An ID of node or comment.
$uid: A user ID.
$tag: A tag for different voting on the content of same type
Return value
Integer Number of votes the user has cast on this node.
5 calls to plus1_get_votes()
- 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.
- plus1_undo_vote in ./
plus1.module - plus1_vote in ./
plus1.module - Page callback.
File
- ./
plus1.module, line 236
Code
function plus1_get_votes($entity_type, $entity_id, $uid, $tag = 'plus1_node_vote') {
$criteria['entity_type'] = $entity_type;
$criteria['entity_id'] = $entity_id;
$criteria['value_type'] = 'points';
$criteria['vote_source'] = $uid ? $uid : ip_address();
if ($uid) {
$criteria['uid'] = $uid;
}
if (isset($tag) && $tag != "") {
$criteria['tag'] = $tag;
}
//Allow vote source to be altered by other modules
drupal_alter('plus1_source', $criteria['vote_source']);
$results = votingapi_select_votes($criteria);
return count($results);
}