You are here

function _votingapi_prep_vote in Voting API 6

Same name and namespace in other branches
  1. 6.2 votingapi.module \_votingapi_prep_vote()
  2. 7.2 votingapi.module \_votingapi_prep_vote()

Populate the value of any unset vote properties.

Parameters

$vobj: A single vote object.

Return value

A vote object with all required properties filled in with their default values.

2 calls to _votingapi_prep_vote()
votingapi_add_votes in ./votingapi.module
Save a single vote to the database.
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 443

Code

function _votingapi_prep_vote($vobj) {
  global $user;
  if (empty($vobj->prepped)) {
    $varray = (array) $vobj;
    $vote = array();
    $vote['content_type'] = 'node';
    $vote['value_type'] = 'percent';
    $vote['tag'] = 'vote';
    $vote['uid'] = $user->uid;
    $vote['timestamp'] = time();
    $vote['vote_source'] = ip_address();
    $vote['prepped'] = TRUE;
    $varray += $vote;
    return (object) $varray;
  }
  return $vobj;
}