Merge branch 'master' of /home/arun/nubati.net/git/e-DoKo
[e-DoKo.git] / include / db.php
index 5503a4a160e2ea9baf83eb8bbc245f5a0b159437..bd50189d69f8435784144621a9d5ccbe4b5e3cd1 100644 (file)
@@ -30,7 +30,7 @@ if(!isset($HOST))
 
 function DB_open()
 {
-  $version_needed = 1;
+  $version_needed = 2;
 
   global $DB,$DB_user,$DB_host,$DB_database,$DB_password;
   $DB = @mysql_connect($DB_host,$DB_user, $DB_password);
@@ -703,14 +703,15 @@ function DB_get_hashes_by_session($session,$user)
   return $r;
 }
 
-function DB_get_ruleset($dullen,$schweinchen,$call)
+function DB_get_ruleset($dullen,$schweinchen,$call,$lowtrump)
 {
   $r = array();
 
   $result = DB_query("SELECT id FROM Rulesets WHERE".
                     " dullen=".DB_quote_smart($dullen)." AND ".
                     " Rulesets.call=".DB_quote_smart($call)." AND ".
-                    " schweinchen=".DB_quote_smart($schweinchen));
+                    " schweinchen=".DB_quote_smart($schweinchen)." AND ".
+                    " lowtrump=".DB_quote_smart($lowtrump));
   if($result)
     $r    = DB_fetch_array($result);
 
@@ -722,6 +723,7 @@ function DB_get_ruleset($dullen,$schweinchen,$call)
       $result = DB_query("INSERT INTO Rulesets VALUES (NULL, NULL, ".
                         DB_quote_smart($dullen).",".
                         DB_quote_smart($schweinchen).",".
+                        DB_quote_smart($lowtrump).",".
                         DB_quote_smart($call).
                         ", NULL)");
       if($result)
@@ -770,6 +772,7 @@ function DB_get_PREF($myid)
   $PREF['vacation_start']      =  NULL;
   $PREF['vacation_stop']       =  NULL;
   $PREF['vacation_comment']    =  '';
+  $PREF['language']            =  'en';
 
   /* get all preferences */
   $r = DB_query('SELECT pref_key, value FROM User_Prefs'.
@@ -780,7 +783,7 @@ function DB_get_PREF($myid)
        {
        case 'cardset':
          /* licence only valid until then */
-         if($pref[1]=='altenburg' && (time()-strtotime( '2009-12-31 23:59:59')<0) )
+         if($pref[1]=='altenburg' && (time()-strtotime( '2012-12-31 23:59:59')<0) )
            $PREF['cardset']='altenburg';
          break;
 
@@ -823,8 +826,14 @@ function DB_get_PREF($myid)
          if($pref[1])
            $PREF['vacation_comment'] = $pref[1];
          break;
+
+       case 'language':
+         if($pref[1])
+           $PREF['language'] = $pref[1];
+         break;
        }
     }
+  $_SESSION['language'] =  $PREF['language'];
   return $PREF;
 }
 
@@ -834,9 +843,10 @@ function DB_get_RULES($gameid)
                      " LEFT JOIN Game ON Game.ruleset=Rulesets.id ".
                      " WHERE Game.id='$gameid'" );
 
-  $RULES["dullen"]      = $r[2];
-  $RULES["schweinchen"] = $r[3];
-  $RULES["call"]        = $r[4];
+  $RULES['dullen']      = $r[2];
+  $RULES['schweinchen'] = $r[3];
+  $RULES['lowtrump']    = $r[4];
+  $RULES['call']        = $r[5];
 
   return $RULES;
 }