You are here

function votingapi_change_vote in Voting API 5

Alters a user's existing vote, if one exists. In most cases, this should not be called directly by external modules.

Parameters

$vobj: A discrete $vote object, or minimally any object with a valid $vobj->vote_id

$value: The new value for the vote.

Return value

The $new version of the vote object.

1 call to votingapi_change_vote()
votingapi_set_vote in ./votingapi.module
Cast a vote on a particular piece of content. If a vote already exists, its value is changed. In most cases, this is the function that should be used by external modules.

File

./votingapi.module, line 214

Code

function votingapi_change_vote($vobj, $value) {
  db_query("UPDATE {votingapi_vote} SET value=%f, timestamp=%d WHERE vote_id=%d", $value, time(), $vobj->vote_id);

  // Give other modules a chance to respond to the change.
  // Both the existing vote object and the new vote value are handed off to interested
  // modules.
  votingapi_invoke('update', $vobj, $value);

  // update the existing $vobj and return it.
  $vobj->value = $value;
  return $vobj;
}