fixed link to gravatar home page
[e-DoKo.git] / include / functions.php
index 0653ce4ecb9d3d372795a0441907dbbd04434fdb..c6544131045bde1fd6725c6cf099b5ac061d55b1 100644 (file)
@@ -86,6 +86,21 @@ define("GAME_RECOVERY",         8);
 define("GAME_REMINDER",         9);
 define("GAME_NEW",             10);
 
+/* define possible status for showing cards */
+
+define("CARDS_EMPTY",       0); /* show player's hand*/
+define("CARDS_SHOW",        1); /* show player's hand*/
+define("CARDS_MYTURN",      2); /* show radiobuttons for cards that can be played*/
+define("CARDS_EXCHANGE",    3); /* do we need to return cards to our partner in poverty?*/
+define("CARDS_GAMEOVER_ME", 4); /* show all cards from everyone*/
+define("CARDS_GAMEOVER",    5); /* show all cards from everyone (looking at someone else's game)*/
+
+ /*   cards_status: SHOW      show our hand
+ *                 MYTURN    show radiobutton for cards that can be played
+ *                 EXCHANGE  do we need to return cards to our partner in poverty?
+ *                 GAMEOVER  show all cards from everyone
+ */
+
 function mymail($uid,$gameid=0,$type,$message)
 {
   global $EmailName,$WIKI;
@@ -956,7 +971,7 @@ function can_call($what,$hash)
   return 0;
 }
 
-function display_table ()
+function display_table_begin ()
 {
   global $gameid, $GT, $debug,$INDEX,$defaulttimezone,$session;
   global $RULES,$GAME,$gametype;
@@ -976,10 +991,57 @@ function display_table ()
                     "WHERE Hand.game_id='".$gameid."' ".
                     "ORDER BY position ASC");
 
-  echo "<div class=\"table\">\n".
-    "  <img class=\"table\" src=\"pics/table.png\" alt=\"table\" />\n";
-  while($r = DB_fetch_array($result))
-    {
+  $row0 = DB_fetch_array($result);
+  $row1 = DB_fetch_array($result);
+  $row2 = DB_fetch_array($result);
+  $row3 = DB_fetch_array($result);
+
+  echo "<div class=\"table\">\n";
+  display_single_user($row1);
+  echo "\n<div class=\"middle\">\n";
+  display_single_user($row0);
+  echo "  <img class=\"table\" src=\"pics/table.png\" alt=\"table\" />\n";
+  display_single_user($row2);
+
+  return;
+}
+function display_table_end ()
+{
+  global $gameid, $GT, $debug,$INDEX,$defaulttimezone,$session;
+  global $RULES,$GAME,$gametype;
+
+  $result = DB_query("SELECT  User.fullname as name,".
+                    "        Hand.position as position, ".
+                    "        User.id, ".
+                    "        Hand.party as party, ".
+                    "        Hand.sickness as sickness, ".
+                    "        Hand.point_call, ".
+                    "        User.last_login, ".
+                    "        Hand.hash,       ".
+                    "        User.timezone,    ".
+                    "        User.email       ".
+                    "FROM Hand ".
+                    "LEFT JOIN User ON User.id=Hand.user_id ".
+                    "WHERE Hand.game_id='".$gameid."' ".
+                    "ORDER BY position ASC");
+
+  $row0 = DB_fetch_array($result);
+  $row1 = DB_fetch_array($result);
+  $row2 = DB_fetch_array($result);
+  $row3 = DB_fetch_array($result);
+
+  echo "</div>\n";
+  display_single_user($row3);
+  echo "</div>\n";
+
+  return;
+}
+
+function display_single_user($r)
+{
+  global $gameid, $GT, $debug,$INDEX,$defaulttimezone,$session;
+  global $RULES,$GAME,$gametype;
+
       $name  = $r[0];
       $pos   = $r[1];
       $user  = $r[2];
@@ -1124,7 +1186,7 @@ function display_table ()
        "title=\"local time: ".date("Y-m-d H:i:s",$timenow).  " ".
        "last login: ".date("Y-m-d H:i:s",$lastlogin)."\" />";
 
-      echo "   <span class=\"numberoftricks\">";
+      echo "   <br /><span class=\"numberoftricks\">";
       /* show how many tricks the person made */
       switch($wins)
        {
@@ -1141,47 +1203,54 @@ function display_table ()
        }
       echo "</span>\n";
       echo "  </div>\n";
-
-    }
-  echo  "</div>\n"; /* end output table */
-
-
-  return;
 }
 
 
-function display_user_menu($id)
+function display_user_menu($id, $skiphash=NULL)
 {
   global $WIKI,$INDEX;
 
-  $result = DB_query("SELECT Hand.hash,Hand.game_id,Game.player from Hand".
-                    " LEFT JOIN Game On Hand.game_id=Game.id".
-                    " WHERE Hand.user_id='$id'".
-                    " AND ( Game.player='$id' OR ISNULL(Game.player) )".
-                    " AND ( Game.status='pre' OR Game.status='play' )".
-                    " ORDER BY Game.session" );
+  if($skiphash)
+    $result = DB_query("SELECT Hand.hash,Hand.game_id,Game.player from Hand".
+                      " LEFT JOIN Game On Hand.game_id=Game.id".
+                      " WHERE Hand.user_id='$id'".
+                      " AND Hand.hash!='$skiphash'".
+                      " AND ( Game.player='$id' OR ISNULL(Game.player) )".
+                      " AND ( Game.status='pre' OR Game.status='play' )".
+                      " ORDER BY Game.session" );
+  else
+    $result = DB_query("SELECT Hand.hash,Hand.game_id,Game.player from Hand".
+                      " LEFT JOIN Game On Hand.game_id=Game.id".
+                      " WHERE Hand.user_id='$id'".
+                      " AND ( Game.player='$id' OR ISNULL(Game.player) )".
+                      " AND ( Game.status='pre' OR Game.status='play' )".
+                      " ORDER BY Game.session" );
 
   $i=0;
   while( $r = DB_fetch_array($result))
     {
       if($i==0)
        {
-         echo "<div class=\"usermenu\">\n";
-         echo _('It\'s your turn in these games').":<br />\n";
+         echo "\n<div class=\"usermenu\">\n  ";
+         echo _('It\'s your turn in these games').":\n";
+       }
+      else
+       {
+         echo ", ";
        }
 
       $i++;
-      echo "<a href=\"".$INDEX."?action=game&amp;me=".$r[0].
-       "\">game ".DB_format_gameid($r[1])." </a><br />\n";
+      echo "  <a href=\"".$INDEX."?action=game&amp;me=".$r[0].
+       "\"> ".DB_format_gameid($r[1])." </a>\n";
       if($i>4)
        {
-         echo "...<br />\n";
+         echo ",  ...\n";
          break;
        }
     }
 
   if($i)
-    echo  "</div>\n";
+    echo  "</div>\n\n";
   return;
 }