summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2012-05-08 21:25:49 -0700
committerArun Persaud <arun@nubati.net>2012-05-08 21:31:26 -0700
commit1e258af4136567ab30ce9b54aee751077f80590e (patch)
treed29a58e77e1ccef6527c32f83f52461569f03103
parentd760c835fcf5444dd1a0b2997e6eb5744e0be952 (diff)
downloade-DoKo-1e258af4136567ab30ce9b54aee751077f80590e.tar.gz
e-DoKo-1e258af4136567ab30ce9b54aee751077f80590e.tar.bz2
e-DoKo-1e258af4136567ab30ce9b54aee751077f80590e.zip
BUGFIX: removed side effect from getting the user's preferences: the language used could be overwritten by another user's choise
the DB_get_Prefs($myid) functions used to set the _SESSION variable for the language, but was also called with ids that belonged to other players overwriting the language settings with that from another user
-rw-r--r--digest.php22
-rw-r--r--include/db.php2
-rw-r--r--include/game.php3
-rw-r--r--include/preferences.php2
-rw-r--r--include/stats.php2
-rw-r--r--include/user.php2
-rw-r--r--index.php11
7 files changed, 35 insertions, 9 deletions
diff --git a/digest.php b/digest.php
index 4426bc2..0762519 100644
--- a/digest.php
+++ b/digest.php
@@ -45,13 +45,31 @@ global $defaulttimezone;
foreach($users as $uid)
{
// get local time
-
$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);
+
+ // set users language preference
+ $language = $PREF['language'];
+
+ switch($language)
+ {
+ case 'de':
+ putenv("LC_ALL=de_DE");
+ setlocale(LC_ALL, "de_DE");
+ // Specify location of translation tables
+ bindtextdomain("edoko", "./locale");
+ // Choose domain
+ textdomain("edoko");
+ break;
+ default:
+ /* do nothing */
+ }
+
+ // calculate mod by digest-time
switch($PREF['digest'])
{
case 'digest-off':
diff --git a/include/db.php b/include/db.php
index cf39d85..0523fea 100644
--- a/include/db.php
+++ b/include/db.php
@@ -863,7 +863,7 @@ function DB_get_PREF($myid)
break;
}
}
- $_SESSION['language'] = $PREF['language'];
+
return $PREF;
}
diff --git a/include/game.php b/include/game.php
index 3890c02..f862fec 100644
--- a/include/game.php
+++ b/include/game.php
@@ -57,6 +57,9 @@ $playid = DB_get_current_playid($gameid); /* might be -1 at beginning of the g
/* get prefs and save them in a variable*/
$PREF = DB_get_PREF(isset($_SESSION['id'])?$_SESSION['id']:$myid);
+/* set language chosen in preferences, will become active on the next reload (see index.php)*/
+$_SESSION['language'] = $PREF['language'];
+
/* get rule set for this game */
$RULES = DB_get_RULES($gameid);
diff --git a/include/preferences.php b/include/preferences.php
index bd58eac..d3cbf92 100644
--- a/include/preferences.php
+++ b/include/preferences.php
@@ -49,6 +49,8 @@ display_user_menu($myid);
/* get old infos */
$PREF = DB_get_PREF($myid);
+/* set language chosen in preferences, will become active on the next reload (see index.php)*/
+$_SESSION['language'] = $PREF['language'];
$timezone = DB_get_user_timezone($myid);
DB_update_user_timestamp($myid);
diff --git a/include/stats.php b/include/stats.php
index 8ab7c6a..f0d436b 100644
--- a/include/stats.php
+++ b/include/stats.php
@@ -35,6 +35,8 @@ if(!$myid)
return;
$PREF = DB_get_PREF($myid);
+/* set language chosen in preferences, will become active on the next reload (see index.php)*/
+$_SESSION['language'] = $PREF['language'];
DB_update_user_timestamp($myid);
diff --git a/include/user.php b/include/user.php
index 3d0b729..1b3d83e 100644
--- a/include/user.php
+++ b/include/user.php
@@ -121,6 +121,8 @@ else
$_SESSION['name'] = $myname;
$PREF = DB_get_PREF($myid);
+ /* set language chosen in preferences, will become active on the next reload (see index.php)*/
+ $_SESSION['language'] = $PREF['language'];
DB_update_user_timestamp($myid);
diff --git a/index.php b/index.php
index 4b716f8..51aa24d 100644
--- a/index.php
+++ b/index.php
@@ -58,13 +58,12 @@ if($DBopen<0)
if(myisset('language') || isset($_SESSION['language']))
{
$language = 'en';
- if(isset($_SESSION['language']))
- $language = $_SESSION['language'];
+
if(myisset('language'))
- {
- $language = $_REQUEST['language'];
- $_SESSION['language'] = $language; /* overrule preferences */
- }
+ $language = $_REQUEST['language'];
+ else if(isset($_SESSION['language']))
+ $language = $_SESSION['language'];
+
switch($language)
{
case 'de':