You are here

function votingapi_unset_vote in Voting API 5

Deletes all votes cast on a particular content-object by a user. In most cases, this is the function that should be used by external modules.

Parameters

$content_type: A string identifying the type of content being rated. Node, comment, aggregator item, etc.

$content_id: The key ID of the content being rated.

$vote:

$uid: The uid of the user casting the vote. If none is specified, the currently logged in user's uid will be inserted.

File

./votingapi.module, line 131

Code

function votingapi_unset_vote($content_type, $content_id, $uid = NULL) {
  if ($uid == NULL) {
    global $user;
    $uid = $user->uid;
  }
  $votes = votingapi_get_user_votes($content_type, $content_id, $uid);
  foreach ($votes as $vobj) {
    votingapi_delete_vote($vobj);
  }
  if (variable_get('votingapi_calculation_schedule', 'immediate') != 'cron') {
    return votingapi_recalculate_results($content_type, $content_id);
  }
}