summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/cancelgame.php3
-rw-r--r--include/functions.php60
-rw-r--r--include/game.php35
-rw-r--r--include/newgame.php9
-rw-r--r--include/reminder.php3
-rw-r--r--include/user.php3
6 files changed, 77 insertions, 36 deletions
diff --git a/include/cancelgame.php b/include/cancelgame.php
index 98cbca2..4128126 100644
--- a/include/cancelgame.php
+++ b/include/cancelgame.php
@@ -62,8 +62,7 @@ if(time()-strtotime($r[0]) > 60*60*24*30) /* = 1 month */
$userids = DB_get_all_userid_by_gameid($gameid);
foreach($userids as $user)
{
- $subject = "Game ".DB_format_gameid($gameid)." canceled (timed out)";
- mymail($user,$subject,$message);
+ mymail($user,$gameid, GAME_CANCELED_TIMEOUT, $message);
}
/* set gamestatus to canceled */
diff --git a/include/functions.php b/include/functions.php
index 5343d36..2504506 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -73,7 +73,20 @@ function config_check()
return;
}
-function mymail($uid,$subject,$message)
+/* define possible status for email subsjects */
+define("GAME_CANCELED", 0);
+define("GAME_CANCELED_POVERTY", 1);
+define("GAME_CANCELED_TIMEOUT", 2);
+define("GAME_YOUR_TURN", 3);
+define("GAME_READY", 4);
+define("GAME_POVERTY", 5);
+define("GAME_DPOVERTY", 6);
+define("GAME_OVER", 7);
+define("GAME_RECOVERY", 8);
+define("GAME_REMINDER", 9);
+define("GAME_NEW", 10);
+
+function mymail($uid,$gameid=0,$type,$message)
{
global $EmailName,$WIKI;
@@ -81,7 +94,50 @@ function mymail($uid,$subject,$message)
$send_now = 1;
/* add standard header and footer */
- $subject = "$EmailName".$subject;
+ $subject = "$EmailName ";
+ if($gameid)
+ $game = DB_format_gameid($gameid);
+ else
+ $game = '';
+
+ switch($type)
+ {
+ case GAME_CANCELED:
+ $subject.="Game $game canceled";
+ break;
+ case GAME_CANCELED_POVERTY:
+ $subject.="Game $game canceled (poverty not resolved)";
+ break;
+ case GAME_CANCELED_TIMEOUT:
+ $subject.="Game $game canceled (timed out)";
+ break;
+ case GAME_YOUR_TURN:
+ $subject.="A card has been played in game $game";
+ break;
+ case GAME_READY:
+ $subject.="Ready, set, go... (game $game)";
+ break;
+ case GAME_POVERTY:
+ $subject.="Poverty (game $game)";
+ break;
+ case GAME_DPOVERTY:
+ $subject.="Double poverty (game $game)";
+ break;
+ case GAME_OVER:
+ $subject.="Game over (game $game)";
+ break;
+ case GAME_RECOVERY:
+ $subject.="Recovery";
+ break;
+ case GAME_REMINDER:
+ $subject.="Reminder: game $game it's your turn";
+ break;
+ case GAME_NEW:
+ $subject.="You are invited to a game of DoKo (game $game)";
+ break;
+ default:
+ $subject.="Problem with email, contact admin (errorcode $gameid)";
+ }
/* standard goodbye */
$footer = "\nHave a nice day\n".
diff --git a/include/game.php b/include/game.php
index d691c7f..0ef5a3e 100644
--- a/include/game.php
+++ b/include/game.php
@@ -344,8 +344,7 @@ switch($mystatus)
$userids = DB_get_all_userid_by_gameid($gameid);
foreach($userids as $user)
{
- $subject = 'Game '.DB_format_gameid($gameid).' canceled';
- mymail($user,$subject,$message);
+ mymail($user,$gameid,GAME_CANCELED,$message);
}
/* update game status */
@@ -394,7 +393,7 @@ switch($mystatus)
$message = "It's your turn now in game ".DB_format_gameid($gameid).".\n".
"Use this link to go the game: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ;
- mymail($who,"Ready, set, go... (game ".DB_format_gameid($gameid).") ",$message);
+ mymail($who, $gameid, GAME_READY,$message);
*/
}
}
@@ -669,8 +668,7 @@ switch($mystatus)
$userids = DB_get_all_userid_by_gameid($gameid);
foreach($userids as $user)
{
- $subject = 'Game '.DB_format_gameid($gameid).' canceled';
- mymail($user,$subject,$message);
+ mymail($user,$gameid, GAME_CANCELED, $message);
}
echo "</div>\n"; /* end div message */
@@ -807,8 +805,7 @@ switch($mystatus)
/* email startplayer */
$message = "It's your turn now in game ".DB_format_gameid($gameid).".\n".
"Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ;
- $subject = 'Ready, set, go... (game '.DB_format_gameid($gameid).')';
- mymail($who,$subject,$message);
+ mymail($who,$gameid,GAME_READY,$message);
}
}
else
@@ -833,8 +830,7 @@ switch($mystatus)
/* email player for poverty */
$message = "Poverty: It's your turn now in game ".DB_format_gameid($gameid).".\n".
"Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$whohash."\n\n" ;
- $subject = 'Poverty (game '.DB_format_gameid($gameid).') ';
- mymail($whoid,$subject,$message);
+ mymail($whoid,$gameid,GAME_POVERTY,$message);
}
}
}
@@ -939,8 +935,7 @@ switch($mystatus)
/* email startplayer */
$message = "It's your turn now in game ".DB_format_gameid($gameid).".\n".
"Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ;
- $subject = 'Ready, set, go... (game '.DB_format_gameid($gameid).') ';
- mymail($who,$subject,$message);
+ mymail($who,$gameid,GAME_READY,$message);
}
}
else
@@ -1023,8 +1018,7 @@ switch($mystatus)
$userids = DB_get_all_userid_by_gameid($gameid);
foreach($userids as $user)
{
- $subject = 'Game '.DB_format_gameid($gameid).' canceled (poverty not resolved)';
- mymail($user,$subject,$message);
+ mymail($user, $gameid, GAME_CANCELED_POVERTY, $message);
}
/* update game status */
@@ -1044,8 +1038,7 @@ switch($mystatus)
$message = "Someone has poverty, it's your turn to decide, if you want to take the trump. Please visit:".
" ".$HOST.$INDEX."?action=game&me=".$userhash."\n\n" ;
- $subject = 'Poverty (game '.DB_format_gameid($gameid).')';
- mymail($userid,$subject,$message);
+ mymail($userid,$gameid, GAME_POVERTY, $message);
}
}
else
@@ -1136,8 +1129,7 @@ switch($mystatus)
$message = "Two people have poverty, it's your turn to decide, if you want to take the trump. Please visit:".
" ".$HOST.$INDEX."?action=game&me=".$userhash."\n\n" ;
- $subject = 'Double poverty (game '.DB_format_gameid($gameid).')';
- mymail($userid,$subject,$message);
+ mymail($userid,$gameid, GAME_DPOVERTY, $message);
}
}
echo "<div class=\"message\">Please, <a href=\"$INDEX?action=game&amp;me=$me\">continue</a> here.</div>\n";
@@ -1210,8 +1202,7 @@ switch($mystatus)
/* email startplayer) */
$message = "It's your turn now in game ".DB_format_gameid($gameid).".\n".
"Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ;
- $subject = 'Ready, set, go... (game '.DB_format_gameid($gameid).')';
- mymail($who,$subject,$message);
+ mymail($who,$gameid, GAME_READY, $message);
}
}
}
@@ -1664,8 +1655,7 @@ switch($mystatus)
"Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$next_hash."\n\n" ;
if( DB_get_email_pref_by_uid($who)!='emailaddict' )
{
- $subject = 'A card has been played in game '.DB_format_gameid($gameid);
- mymail($who,$subject,$message);
+ mymail($who,$gameid, GAME_YOUR_TURN, $message);
}
}
else /* send out final email */
@@ -1907,8 +1897,7 @@ switch($mystatus)
$message .= $link;
}
$message .= "\n\n (you can use reply all on this email to reach all the players.)\n\n";
- $subject = ' Game over (game '.DB_format_gameid($gameid).') ';
- mymail($userids,$subject,$message);
+ mymail($userids,$gameid, GAME_OVER, $message);
}
}
else
diff --git a/include/newgame.php b/include/newgame.php
index 4e9deaf..68e0d15 100644
--- a/include/newgame.php
+++ b/include/newgame.php
@@ -200,11 +200,10 @@ else
"If you want to join this game, please follow this link:\n".
"".$HOST.$INDEX."?action=game&me=";
- $subject = 'You are invited to a game of DoKo (game '.DB_format_gameid($gameid).')';
- mymail($useridA,$subject, $message.$hashA."\n\n");
- mymail($useridB,$subject, $message.$hashB."\n\n");
- mymail($useridC,$subject, $message.$hashC."\n\n");
- mymail($useridD,$subject, $message.$hashD."\n\n");
+ mymail($useridA, $gameid, GAME_NEW, $message.$hashA."\n\n");
+ mymail($useridB, $gameid, GAME_NEW, $message.$hashB."\n\n");
+ mymail($useridC, $gameid, GAME_NEW, $message.$hashC."\n\n");
+ mymail($useridD, $gameid, GAME_NEW, $message.$hashD."\n\n");
echo "<div class=\"message\">You started a new game. The emails have been sent out!</div>\n";
display_user_menu($myid);
diff --git a/include/reminder.php b/include/reminder.php
index 1031dec..502c408 100644
--- a/include/reminder.php
+++ b/include/reminder.php
@@ -67,8 +67,7 @@ if( (time()-strtotime($r[0]) > 60*60*24*7) && ($r[2]!='gameover') ) /* = 1 week
else
{
DB_set_reminder($r[1],$gameid);
- $subject ='Reminder: game '.DB_format_gameid($gameid)." it's your turn";
- mymail($r[1],$subject,$message);
+ mymail($r[1],$gameid, GAME_REMINDER, $message);
echo "<p style=\"background-color:red\";>Game ".DB_format_gameid($gameid).
": an email has been sent out.<br /><br /></p>";
diff --git a/include/user.php b/include/user.php
index e8d38f7..2c3afeb 100644
--- a/include/user.php
+++ b/include/user.php
@@ -75,8 +75,7 @@ if(myisset('forgot'))
"to log into the server. The new password is valid for 24h, so make\n".
"sure you reset your password to something new. Your old password will\n".
"also still be valid until you set a new one.\n";
- $subject = 'Recovery';
- mymail($myid,$subject,$message);
+ mymail($myid,0, GAME_RECOVERY, $message);
/* we save these in the database */
DB_set_recovery_password($myid,md5($newpw));