fix error when language is not set
[e-DoKo.git] / digest.php
index c93117af9d376844f80436aa31b11171a11cf7bd..9bb33d20f0e65da25c19b5dde6929dfd6056c679 100644 (file)
@@ -1,4 +1,23 @@
 <?php
 <?php
+/* Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Arun Persaud <arun@nubati.net>
+ *
+ *   This file is part of e-DoKo.
+ *
+ *   e-DoKo is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   e-DoKo is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with e-DoKo.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
 error_reporting(E_ALL);
 
 include_once("config.php");                /* needs to be first in list, since other includes use this */
 error_reporting(E_ALL);
 
 include_once("config.php");                /* needs to be first in list, since other includes use this */
@@ -20,17 +39,23 @@ if(isset($_SERVER['REMOTE_ADDR']))
 /* get userid for users that have digest set != digest-off */
 $users = DB_get_digest_users();
 
 /* get userid for users that have digest set != digest-off */
 $users = DB_get_digest_users();
 
+global $WIKI;
+
 global $defaulttimezone;
 foreach($users as $uid)
   {
     // get local time
 global $defaulttimezone;
 foreach($users as $uid)
   {
     // get local time
-
     $zone  = DB_get_user_timezone($uid);
     date_default_timezone_set($zone);
     $time = (int)(date("H"));
 
     $zone  = DB_get_user_timezone($uid);
     date_default_timezone_set($zone);
     $time = (int)(date("H"));
 
-    // calculate mod by digest-time
+    // load users preferences
     $PREF = DB_get_PREF($uid);
     $PREF = DB_get_PREF($uid);
+
+    // set users language preference
+    set_language($PREF['language']);
+
+    // calculate mod by digest-time
     switch($PREF['digest'])
       {
       case 'digest-off':
     switch($PREF['digest'])
       {
       case 'digest-off':
@@ -66,6 +91,16 @@ foreach($users as $uid)
        // get messages
        $messages = DB_get_digest_message_by_email($email);
 
        // get messages
        $messages = DB_get_digest_message_by_email($email);
 
+       // check messages for outdated ones and delete those
+       foreach ($messages as $key=>$mess)
+         {
+           if($mess[2] == 'your_turn' && $uid != DB_get_player_by_gameid($mess[3]) )
+             {
+               DB_digest_delete_message($mess[0]);
+               unset($messages[$key]);
+             }
+         }
+
        // add them together
        if(sizeof($messages))
          {
        // add them together
        if(sizeof($messages))
          {
@@ -81,15 +116,14 @@ foreach($users as $uid)
 
            // add header, footer, sent out
            $name    = DB_get_name('userid',$uid);
 
            // add header, footer, sent out
            $name    = DB_get_name('userid',$uid);
-           $header  = "Hello $name\n\nHere is a digest of the latest emails:\n\n";
+           $header  = _("Hello")." $name\n\n"._("Here is a digest of the latest emails:")."\n\n";
 
 
-           $footer  = "\nHave a nice day\n".
-             "   your E-Doko digester\n\n".
+           $footer  = "\n"._('Have a nice day')."\n".
+             "   ".('your E-Doko digester')."\n\n".
              "-- \n".
              "-- \n".
-             "You can change your mail delivery mode in the preference menu.\n".
-             'web: http://doko.nubati.net   '.
-             'help: http://wiki.nubati.net/EmailDoko   '.
-             'bugs: http://wiki.nubati.net/EmailDokoIssues';
+             _('You can change your mail delivery mode in the preference menu.')."\n".
+             _('web').': http://doko.nubati.net   '.
+             _('help, bugs, etc.').": $WIKI";
 
            $subject = "$EmailName Digest";
 
 
            $subject = "$EmailName Digest";