? anonymous-voting.patch
? votingapi-sessionid-vote_source-798790.patch
Index: votingapi.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/votingapi/votingapi.module,v
retrieving revision 1.46.2.24
diff -u -p -r1.46.2.24 votingapi.module
--- votingapi.module	8 Jul 2009 16:09:45 -0000	1.46.2.24
+++ votingapi.module	2 Nov 2010 16:41:07 -0000
@@ -151,6 +151,15 @@ function votingapi_set_votes(&$votes, $c
     _votingapi_prep_vote($vote);
     $votes[$key] = $vote; // Is this needed? Check to see how PHP4 handles refs.
   }
+  
+  // Fetch the last vote of current user 
+  $last_vote = db_fetch_array(db_query_range("SELECT * FROM {votingapi_vote} v WHERE v.vote_source = '%s' ORDER BY v.timestamp DESC", $votes[0]['vote_source'], 0, 1));
+  // Verify time limit for vote rollover
+  $anon_window = variable_get('votingapi_anonymous_window', 3600);
+  if(isset($last_vote['timestamp']) && $vote['timestamp'] < $last_vote['timestamp'] + $anon_window) {
+    // Abort execution and return an empty touched array if the time limit has not been passed
+    return $touched;
+  }
 
   // Cast the actual votes, inserting them into the table.
   votingapi_add_votes($votes);
@@ -177,7 +186,7 @@ function votingapi_current_user_identifi
   global $user;
   $criteria = array('uid' => $user->uid);
   if (!$user->uid) {
-    $criteria['vote_source'] = ip_address();
+    $criteria['vote_source'] = variable_get('votingapi_anonymous_validation_method', 'ip') == 'session' ? session_id() : ip_address();
   }
   return $criteria;
 }
@@ -466,7 +475,7 @@ function votingapi_metadata($reset = FAL
 
     drupal_alter('votingapi_metadata', $data);
   }
-  
+
   return $data;
 }
 
@@ -539,7 +548,7 @@ function _votingapi_prep_vote(&$vote) {
       'tag' => 'vote',
       'uid' => $user->uid,
       'timestamp' => time(),
-      'vote_source' => ip_address(),
+      'vote_source' => (variable_get('votingapi_anonymous_validation_method', 'ip') == 'session' ? session_id() : ip_address()),
       'prepped' => TRUE
     );
   }
