You are here

function advpoll_votingapi_results_alter in Advanced Poll 6.3

Same name and namespace in other branches
  1. 6 advpoll.module \advpoll_votingapi_results_alter()
  2. 6.2 advpoll.module \advpoll_votingapi_results_alter()

Implementation of VotingAPI's hook_calculate.

Recalculate results whenever a vote is added or removed.

File

./advpoll.module, line 948
Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.

Code

function advpoll_votingapi_results_alter(&$cache, $content_type, $content_id) {

  // Make sure it's an Advanced Poll content type.
  if ($content_type == 'advpoll') {

    // Don't load the node from cache in case the mode or algorithm changed.
    $node = node_load($content_id, NULL, TRUE);
    $mode = _advpoll_get_mode($node->type);
    $function = 'advpoll_calculate_results_' . $mode;
    if (function_exists($function)) {
      $function($cache, $node);
    }
    cache_clear_all();
  }
}