BUGFIX: timestamp was not always updated when user made a move
authorArun Persaud <arun@nubati.net>
Fri, 5 Feb 2010 04:19:18 +0000 (20:19 -0800)
committerArun Persaud <arun@nubati.net>
Fri, 5 Feb 2010 04:26:51 +0000 (20:26 -0800)
this happend when the user wasn't logged in, but made a move by using an email link for example. Should be fixed now.

include/game.php

index de19cabb8b0c20b7a36bb4b3bedc5abdc9d20d3f..0a40bab00032266c0782db4f63c09923367cadaf 100644 (file)
@@ -24,10 +24,6 @@ if(!$myid)
 
 global $GAME,$RULES,$CARDS;
 
-/* the user has done something, update the timestamp */
-if(isset($_SESSION['id']))
-  DB_update_user_timestamp($_SESSION['id']);
-
 /* get some information from the DB */
 $gameid   = DB_get_gameid_by_hash($me);
 $myname   = DB_get_name('hash',$me);
@@ -288,6 +284,16 @@ display_table();
  * play:     game in progress
  * gameover: are we revisiting a game
  */
+
+/* the user has done something, update the timestamp. Use $myid in
+ * active games and check for session-id in old games (myid might be wrong in that case)
+ */
+if($mystatus!='gameover')
+  DB_update_user_timestamp($myid);
+ else
+   if(isset($_SESSION['id']))
+     DB_update_user_timestamp($_SESSION['id']);
+
 switch($mystatus)
   {
   case 'start':