function advpoll_get_user_votes in Advanced Poll 7
Same name and namespace in other branches
- 7.3 includes/advpoll_voteapi.inc \advpoll_get_user_votes()
- 7.2 includes/advpoll_voteapi.inc \advpoll_get_user_votes()
Return unique choice ids for a given node id and user id.
Parameters
$nid: The node ID of the poll to be examined for the current user.
Return value
Returns an array of unique choice IDs selected by the user.
5 calls to advpoll_get_user_votes()
- advpoll_display_borda_results in advpoll_ranking/advpoll_ranking.module 
- advpoll_display_results in ./advpoll.module 
- advpoll_display_runoff_results in advpoll_ranking/advpoll_ranking.module 
- advpoll_node_view in ./advpoll.module 
- Implements hook_node_view().
- advpoll_ranking_node_view in advpoll_ranking/advpoll_ranking.module 
File
- includes/advpoll_voteapi.inc, line 384 
Code
function advpoll_get_user_votes($nid) {
  global $user;
  $votes = array();
  $criteria = array();
  $criteria['entity_id'] = $nid;
  $criteria['entity_type'] = 'advpoll';
  if ($user->uid) {
    $criteria['uid'] = $user->uid;
  }
  else {
    $criteria['vote_source'] = ip_address();
  }
  $results = votingapi_select_votes($criteria);
  if ($results) {
    foreach ($results as $result) {
      $votes[] = $result['tag'];
    }
  }
  return $votes;
}