LAYOUT: fixed some typos, changed CSS a bit
[e-DoKo.git] / db.php
diff --git a/db.php b/db.php
index db1910f13e6b613c486b32ba1fd27f828e97d017..54f57066f2981b4b907c5fdc5b769defc68f9c00 100644 (file)
--- a/db.php
+++ b/db.php
@@ -723,7 +723,8 @@ function DB_get_hashes_by_session($session,$user)
   $result = mysql_query("SELECT Hand.hash FROM Hand".
                        " LEFT JOIN Game ON Game.id=Hand.game_id ".
                        " WHERE Game.session=".DB_quote_smart($session).
-                       " AND Hand.user_id=".DB_quote_smart($user));
+                       " AND Hand.user_id=".DB_quote_smart($user).
+                       " ORDER BY Game.create_date ASC");
   while($t = mysql_fetch_array($result,MYSQL_NUM))
     $r[] = $t[0];
 
@@ -792,20 +793,68 @@ function DB_get_PREF($myid)
 {
   global $PREF;
 
-    $result = mysql_query("SELECT value from User_Prefs".
-                         " WHERE user_id='$myid' AND pref_key='cardset'" );
-    $r = mysql_fetch_array($result,MYSQL_NUM);
-    if($r)
-      {
-       if($r[0]=="germancards" && (time()-strtotime( "2009-12-31 23:59:59")<0) ) /* licence only valid until then */
-         $PREF["cardset"]="altenburg";
-       else
-         $PREF["cardset"]="english";
-      }
-    else
-      $PREF["cardset"]="english";
+  /* Cardset */
+  $result = mysql_query("SELECT value from User_Prefs".
+                       " WHERE user_id='$myid' AND pref_key='cardset'" );
+  $r = mysql_fetch_array($result,MYSQL_NUM);
+  if($r)
+    {
+      if($r[0]=="germancards" && (time()-strtotime( "2009-12-31 23:59:59")<0) ) /* licence only valid until then */
+       $PREF["cardset"]="altenburg";
+      else
+       $PREF["cardset"]="english";
+    }
+  else
+    $PREF["cardset"]="english";
 
-    return;
+  /* Email */
+  $result = mysql_query("SELECT value FROM User_Prefs".
+                       " WHERE user_id='$myid' AND pref_key='email'" );
+  $r = mysql_fetch_array($result,MYSQL_NUM);
+  if($r)
+    {
+      if($r[0]=="emailaddict")
+       $PREF["email"]="emailaddict";
+      else
+       $PREF["email"]="emailnonaddict";
+    }
+  else
+    $PREF["email"]="emailnonaddict";
+
+  return;
+}
+
+function DB_get_email_pref_by_hash($hash)
+{
+  $result = mysql_query("SELECT value FROM Hand".
+                       " LEFT JOIN User_Prefs ON Hand.user_id=User_Prefs.user_id".
+                       " WHERE hash='$hash' AND pref_key='email'" );
+  $r = mysql_fetch_array($result,MYSQL_NUM);
+  if($r)
+    {
+      if($r[0]=="emailaddict")
+       return "emailaddict";
+      else
+       return "emailnonaddict";
+    }
+  else
+    return "emailnonaddict";
+}
+
+function DB_get_email_pref_by_uid($uid)
+{
+  $result = mysql_query("SELECT value FROM User_Prefs ".
+                       " WHERE user_id='$uid' AND pref_key='email'" );
+  $r = mysql_fetch_array($result,MYSQL_NUM);
+  if($r)
+    {
+      if($r[0]=="emailaddict")
+       return "emailaddict";
+      else
+       return "emailnonaddict";
+    }
+  else
+    return "emailnonaddict";
 }
 
 function DB_get_unused_randomnumbers($userstr)