BUGFIX: wrongly displayed "trump back" in pre-trick during poverty
[e-DoKo.git] / include / functions.php
index 7141ec75c86236389a668a33539d870ed0a6fdc8..e57c2e593f8a7bd5fc915423f76f31b19a721f9d 100644 (file)
@@ -72,11 +72,8 @@ function mymail($uid,$subject,$message)
       /* add standard header and footer */
       $subject = "$EmailName".$subject;
 
-      /* standard greeting */
-      $header  = "Hello ...\n\n";
-
-      /* and standard goodbye */
-      $footer  = "\n\nHave a nice day\n".
+      /* standard goodbye */
+      $footer  = "\nHave a nice day\n".
        "   your E-Doko service department\n\n".
        "-- \n".
        "You can change your mail delivery mode in the preference menu.\n".
@@ -84,7 +81,26 @@ function mymail($uid,$subject,$message)
        'help: http://wiki.nubati.net/EmailDoko   '.
        'bugs: http://wiki.nubati.net/EmailDokoIssues';
 
-      $To = DB_get_email('userid',$uid);
+      if(is_array($uid))
+       {
+         /* send email to more than one person */
+
+         $header  = "Hello all\n\n";
+
+         foreach($uid as $user)
+           {
+             $all[] = DB_get_email('userid',$user);
+           }
+         $To = implode(",",$all);
+       }
+      else
+       {
+         /* standard greeting */
+         $name    = DB_get_name('userid',$uid);
+         $header  = "Hello $name\n\n";
+
+         $To = DB_get_email('userid',$uid);
+       }
 
       sendmail($To,$subject,$header.$message.$footer);
     }
@@ -921,7 +937,7 @@ function display_table ()
       echo "    <br />\n";
       echo "    <span title=\"local time: ".date("Y-m-d H:i:s",$timenow).  " ".
                             "last login: ".date("Y-m-d H:i:s",$lastlogin)."\">".
-                            "<img src=\"pics/button/time-info.png\" class=\"button\" alt-\"time info\" />".
+                            "<img src=\"pics/button/time-info.png\" class=\"tinybutton\" alt=\"time info\" />".
                             "</span>\n";
       echo "   </div>\n";
 
@@ -941,7 +957,7 @@ function display_user_menu($id)
                     " 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<>'gameover'".
+                    " AND ( Game.status='pre' OR Game.status='play' )".
                     " ORDER BY Game.session" );
 
   $i=0;
@@ -1252,4 +1268,35 @@ function check_vacation($userid)
     return NULL;
 }
 
+function cancel_game($why,$gameid)
+{
+  $gameid = DB_quote_smart($gameid);
+
+  /* update the game table */
+  switch($why)
+    {
+    case 'timedout':
+      DB_query("UPDATE Game SET status='cancel-timedout' WHERE id=$gameid");
+      break;
+    case 'nines':
+      DB_query("UPDATE Game SET status='cancel-nines' WHERE id=$gameid");
+      break;
+    case 'trump':
+      DB_query("UPDATE Game SET status='cancel-trump' WHERE id=$gameid");
+      break;
+    case 'noplay':
+      DB_query("UPDATE Game SET status='cancel-noplay' WHERE id=$gameid");
+      break;
+    }
+  /* set each player to gameover */
+  $result = DB_query("SELECT id FROM Hand WHERE game_id=".DB_quote_smart($gameid));
+  while($r = DB_fetch_array($result))
+    {
+      $id = $r[0];
+      DB_query("UPDATE Hand SET status='gameover' WHERE id=".DB_quote_smart($id));
+    }
+
+  return;
+}
+
 ?>