function plus1_vote doesn`t pass arg vote_source to voteAPI.
Problem: If anonymous user do "vote undo" and ip address of anonymous and registred user are equals then votes of this node will reset.

you should pass vote_source to voteAPI:

 'vote_source' => $user->uid ? $user->uid : ip_address(),

all code:

function plus1_vote($entity_type, $entity_id, $tag = 'plus1_node_vote') {
  global $user;
  if (!drupal_valid_token($_GET['token'], $entity_id, $skip_anonymous = TRUE)) {
    watchdog('plus1', 'Voting form error: Invalid token.');
    return drupal_access_denied();
  }
  $voted = plus1_get_votes($entity_type, $entity_id, $user->uid, $tag);
  //print_r( $voted );
  // If the voter has not already voted.
  if (!$voted) {
    $votes[] = array(
      'entity_type' => $entity_type,
      'entity_id' => $entity_id,
      'value_type' => 'points',
      'value' => 1,
      'tag' => $tag ? $tag : 'plus1_' . $entity_type . '_vote',
      'vote_source' => $user->uid ? $user->uid : ip_address(),
    );
CommentFileSizeAuthor
#1 1246254-0.patch452 bytesrogical
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rogical’s picture

Status: Active » Needs review
FileSize
452 bytes

I created a patch for this

shopobdii’s picture

It is very useful, thanks for your sharing! I am looking forward to your update.

rogical’s picture

Status: Needs review » Closed (fixed)

Committed.

NancyDru’s picture

Status: Closed (fixed) » Fixed

Shaun, when you fix an issue, mark it "fixed" so that it stays visible for another two weeks.

rogical’s picture

Okay, got it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.