You are here

function votingapi_rebuild_form in Voting API 7.2

Rebuild the voting results and clear the voting cache.

1 string reference to 'votingapi_rebuild_form'
votingapi_menu in ./votingapi.module
Implements of hook_menu().

File

./votingapi.admin.inc, line 106
Configuration forms and helper functions for VotingAPI module.

Code

function votingapi_rebuild_form($form, $form_state) {
  $query = db_select('votingapi_vote')
    ->fields('votingapi_vote', array(
    'tag',
  ))
    ->distinct(TRUE);
  $results = $query
    ->execute()
    ->fetchAll(PDO::FETCH_ASSOC);
  $tags = array(
    'All Tags',
  );
  foreach ($results as $tag_type) {
    $tags[] = $tag_type['tag'];
  }
  $form['results'] = array(
    '#type' => 'fieldset',
    '#title' => t('Rebuild voting results'),
  );
  $form['results']['votingapi_rebuild_content_selected_tag'] = array(
    '#type' => 'select',
    '#title' => t('Content tags'),
    '#options' => $tags,
  );
  $form['results']['votingapi_rebuild_content_tags'] = array(
    '#type' => 'hidden',
    '#value' => $tags,
  );
  $form['results']['votingapi_recalculate_all'] = array(
    '#type' => 'submit',
    '#value' => t('Rebuild all Voting Results'),
  );
  $form['results']['help'] = array(
    '#prefix' => '<div class="description">',
    '#markup' => t('This action rebuilds all voting results, and may be a lengthy process.') . '<br>' . t("In regular site confirurations, this process does not re-determine <em>validity</em> of votes, so if you change 'rollover' settings on the General Settings page, this does not mean that e.g. Fivestar votes attached to comments will be re-evaluated."),
    '#suffix' => '</div>',
  );
  return $form;
}