You are here

function votingapi_add_results in Voting API 7.2

Same name and namespace in other branches
  1. 6.2 votingapi.module \votingapi_add_results()
  2. 6 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

array vote_results: An array of vote results, each with the following properties: $vote_result['entity_type'] $vote_result['entity_id'] $vote_result['value_type'] $vote_result['value'] $vote_result['tag'] $vote_result['function'] $vote_result['timestamp'] (Optional, defaults to REQUEST_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 345
A generalized voting API for Drupal.

Code

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