function votingapi_rebuild_form_submit in Voting API 7.2
Submit handler for votingapi_rebuild_form.
Recalculates voting results for all content, using the batch API.
File
- ./
votingapi.admin.inc, line 152 - Configuration forms and helper functions for VotingAPI module.
Code
function votingapi_rebuild_form_submit($form, &$form_state) {
$tags = $form_state['values']['votingapi_rebuild_content_tags'];
$selected_tag_index = $form_state['values']['votingapi_rebuild_content_selected_tag'];
// Change the list of tags to remove accordingly.
if ($selected_tag_index > 0) {
$tags = array(
$tags[$selected_tag_index],
);
}
else {
unset($tags[0]);
}
$operations = array();
foreach ($tags as $tag) {
$operations[] = array(
'_votingapi_results_rebuild',
array(
$tag,
),
);
}
$batch = array(
'title' => t('Recalculating votes'),
'operations' => $operations,
'init_message' => 'Preparing to recalculate',
'finished' => '_votingapi_results_rebuild_finished',
'file' => drupal_get_path('module', 'votingapi') . '/votingapi.admin.inc',
);
// Set the recalculation batch so it can be processed.
batch_set($batch);
// Redirect the user to the votingapi rebuild page.
$form_state['redirect'] = 'admin/config/search/votingapi/rebuild';
}