CLEANUP: all email now uses the standard header and footer
authorArun Persaud <arun@nubati.net>
Thu, 30 Apr 2009 04:34:16 +0000 (21:34 -0700)
committerArun Persaud <arun@nubati.net>
Thu, 30 Apr 2009 04:34:16 +0000 (21:34 -0700)
some email functions didn't use myemail, but used sendmail directly. This is now fixed and all emails should have the same header and footer.

include/functions.php
include/game.php
include/newgame.php
include/user.php

index 7bdfd31d8121868d4a81c081a6a58347ad2c50c0..e57c2e593f8a7bd5fc915423f76f31b19a721f9d 100644 (file)
@@ -72,11 +72,7 @@ function mymail($uid,$subject,$message)
       /* add standard header and footer */
       $subject = "$EmailName".$subject;
 
-      /* standard greeting */
-      $name    = DB_get_name('userid',$uid);
-      $header  = "Hello $name\n\n";
-
-      /* and standard goodbye */
+      /* standard goodbye */
       $footer  = "\nHave a nice day\n".
        "   your E-Doko service department\n\n".
        "-- \n".
@@ -85,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);
     }
index 1dc4802b3ee7155a16b6aed098b73e97df10e1c1..9c8c427a1caac49b48ee2ac652f245d1fbab36bc 100644 (file)
@@ -1798,12 +1798,8 @@ switch($mystatus)
                  $message .= "\nUse these links to have a look at game ".DB_format_gameid($gameid).": \n";
 
                  /* send out final email */
-                 $all = array();
-
                  foreach($userids as $user)
                    {
-                     $all[] = DB_get_email('userid',$user);
-
                      /* add links for all players */
                      $hash = DB_get_hash_from_gameid_and_userid($gameid,$user);
                      $name = DB_get_name('userid',$user);
@@ -1811,11 +1807,9 @@ switch($mystatus)
                      $link = "$name: ".$HOST.$INDEX."?action=game&me=".$hash."\n" ;
                      $message .= $link;
                    }
-                 $To = implode(",",$all);
-
                  $message .= "\n\n (you can use reply all on this email to reach all the players.)\n";
-                 $subject = $EmailName.' Game over (game '.DB_format_gameid($gameid).') ';
-                 sendmail($To,$subject,$message);
+                 $subject = ' Game over (game '.DB_format_gameid($gameid).') ';
+                 mymail($userids,$subject,$message);
              }
          }
        else
index 4ce13cb771e07e80c9663ed300a6bd40487b289b..7d776122b907ec39745287a020b922da65c48896 100644 (file)
@@ -170,8 +170,7 @@ else
          DB_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idD', '".$randomNR[$i]."', 'false')");
 
        /* send out email, TODO: check for error with email */
-       $message = "\n".
-         "you are invited to play a game of DoKo.\n".
+       $message = "You are invited to play a game of DoKo.\n".
          "Please, place comments and bug reports here:\n".
          "http://wiki.nubati.net/index.php?title=EmailDoko\n\n".
          "The whole round would consist of the following players:\n".
@@ -183,10 +182,10 @@ else
          "".$HOST.$INDEX."?action=game&me=";
 
        $subject = 'You are invited to a game of DoKo (game '.DB_format_gameid($gameid).')';
-       sendmail($EmailA,$subject, "Hello $PlayerA,\n".$message.$hashA);
-       sendmail($EmailB,$subject, "Hello $PlayerB,\n".$message.$hashB);
-       sendmail($EmailC,$subject, "Hello $PlayerC,\n".$message.$hashC);
-       sendmail($EmailD,$subject, "Hello $PlayerD,\n".$message.$hashD);
+       mymail($useridA,$subject, $message.$hashA);
+       mymail($useridB,$subject, $message.$hashB);
+       mymail($useridC,$subject, $message.$hashC);
+       mymail($useridD,$subject, $message.$hashD);
 
        echo "<div class=\"message\">You started a new game. The emails have been sent out!</div>\n";
         display_user_menu($myid);
index 0273183d0ba5a99b909f8319362ac91c82881527..bac439895098d170ba6c86f12fdb93e4631b27ff 100644 (file)
@@ -54,8 +54,8 @@ 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 = $EmailName.' Recovery';
-           sendmail($email,$subject,$message);
+           $subject = 'Recovery';
+           mymail($myid,$subject,$message);
 
            /* we save these in the database */
            DB_set_recovery_password($myid,md5($newpw));