function drush_votingapi_flush in Voting API 7.3
Same name and namespace in other branches
- 8.3 votingapi.drush.inc \drush_votingapi_flush()
- 7.2 votingapi.drush.inc \drush_votingapi_flush()
Command callback. Flush votes and results.
File
- ./
votingapi.drush.inc, line 180 - Generate votingapi votes, recalculate results for existing votes, or flush VotingAPI data entirely.
Code
function drush_votingapi_flush($entity_type = NULL, $entity_id = NULL) {
if (drush_confirm(dt("Delete @type voting data?", array(
'@type' => empty($entity_type) ? dt('all') : $entity_type,
)))) {
$cache = db_delete('votingapi_cache');
$votes = db_delete('votingapi_vote');
if (!empty($entity_type)) {
$cache
->condition('entity_type', $entity_type);
$votes
->condition('entity_type', $entity_type);
}
if (!empty($entity_id)) {
$cache
->condition('entity_id', $entity_id);
$votes
->condition('entity_id', $entity_id);
}
$cache
->execute();
$votes
->execute();
drush_log(t('Flushed vote data for @type entities.', array(
'@type' => empty($entity_type) ? t('all') : $entity_type,
)), 'success');
}
}