You are here

function vud_reset in Vote Up/Down 6.2

Same name and namespace in other branches
  1. 6.3 vud.theme.inc \vud_reset()
  2. 7.2 vud.theme.inc \vud_reset()
  3. 7 vud.theme.inc \vud_reset()

Callback to reset votes on an object.

1 string reference to 'vud_reset'
vud_menu in ./vud.module
Implementation of hook_menu().

File

./vud.module, line 167

Code

function vud_reset($type, $content_id, $tag, $token) {
  if (drupal_valid_token($token, "votereset/{$type}/{$content_id}/{$tag}", TRUE)) {
    $uid = votingapi_current_user_identifier();
    $criteria = array(
      'content_type' => $type,
      'content_id' => $content_id,
      'tag' => $tag,
    );
    $fullc = $criteria + $uid;
    votingapi_delete_votes(votingapi_select_votes($fullc));
    votingapi_recalculate_results($type, $content_id);
    drupal_goto($_SERVER['HTTP_REFERER']);
  }
  else {
    watchdog('vud', 'Could not reset votes on @type @content_id, with value @value, tag @tag and token @token', array(
      '@type' => $type,
      '@content_id' => $content_id,
      '@value' => $value,
      '@tag' => $tag,
      '@token' => $token,
    ));
    drupal_set_message(t("Oops! There was an error in resetting your vote!", 'warning'));
  }
}