You are here

function votingapi_add_results in Voting API 6.2

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

Save a bundle of vote results to the database.

This function is called by votingapi_recalculate_results() after tallying the values of all cast votes on a piece of content. This function will be of little use for most third-party modules, unless they manually insert their own result data.

Parameters

vote_results: An array of vote results, each with the following properties: $vote_result['content_type'] $vote_result['content_id'] $vote_result['value_type'] $vote_result['value'] $vote_result['tag'] $vote_result['function'] $vote_result['timestamp'] (Optional, defaults to time())

1 call to votingapi_add_results()
votingapi_recalculate_results in ./votingapi.module
Recalculates the aggregate results of all votes for a piece of content.

File

./votingapi.module, line 271
A generalized voting API for Drupal.

Code

function votingapi_add_results($vote_results = array()) {
  if (!empty($vote_results['content_id'])) {
    $vote_results = array(
      $vote_results,
    );
  }
  foreach ($vote_results as $vote_result) {
    $vote_result['timestamp'] = time();
    drupal_write_record('votingapi_cache', $vote_result);
  }
}