diff options
author | Arun Persaud <arun@nubati.net> | 2009-01-15 21:40:35 -0800 |
---|---|---|
committer | Arun Persaud <arun@nubati.net> | 2009-01-15 21:40:35 -0800 |
commit | 4b622dbdb85fbb3512a881ec4786a05f6cd4701c (patch) | |
tree | bc3ee3fc89b39fa29c8c74ca38ff1d9d53d36c3d /include/db.php | |
parent | 8114e8920b56b4f078d2b3ff8d283cdf4d18c679 (diff) | |
download | e-DoKo-4b622dbdb85fbb3512a881ec4786a05f6cd4701c.tar.gz e-DoKo-4b622dbdb85fbb3512a881ec4786a05f6cd4701c.tar.bz2 e-DoKo-4b622dbdb85fbb3512a881ec4786a05f6cd4701c.zip |
NEW FEATURE: new user settings allows people to not be available for new games
Players who set their preference on this setting to 'no' are not considered as players in a new game.
Diffstat (limited to 'include/db.php')
-rw-r--r-- | include/db.php | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/include/db.php b/include/db.php index e5699f6..6d4080c 100644 --- a/include/db.php +++ b/include/db.php @@ -439,6 +439,24 @@ function DB_get_all_names() $names = array(); $result = DB_query("SELECT fullname FROM User"); + + while($r = DB_fetch_array($result)) + $names[] = $r[0]; + + return $names; +} + +function DB_get_all_user_names_open_for_games() +{ + $names = array(); + + DB_query("DROP TEMPORARY TABLE IF EXISTS Usertmp;"); + DB_query("CREATE TEMPORARY TABLE Usertmp SELECT id,fullname FROM User;"); + DB_query("DELETE FROM Usertmp WHERE id IN (SELECT user_id FROM User_Prefs WHERE pref_key='open for games' and value='no')"); + + $result = DB_query("SELECT fullname FROM Usertmp"); + DB_query("DROP TEMPORARY TABLE IF EXISTS Usertmp;"); + while($r = DB_fetch_array($result)) $names[] = $r[0]; @@ -737,6 +755,15 @@ function DB_get_PREF($myid) else $PREF['sorting']='high-low'; + /* Open for new games */ + $r = DB_query_array("SELECT value FROM User_Prefs". + " WHERE user_id='$myid' AND pref_key='open for games'" ); + if($r) + $PREF['open_for_games'] = $r[0]; + else + $PREF['open_for_games']='yes'; + + return $PREF; } @@ -1118,7 +1145,7 @@ function DB_get_exchanged_cards($hash) function DB_played_by_others($gameid) { $gameids = array(); - $result = DB_query("SELECT id FROM Game WHERE randomnumbers=(SELECT randomnumbers from Game where id=$gameid) and status='gameover'"); + $result = DB_query("SELECT id FROM Game WHERE randomnumbers=(SELECT randomnumbers FROM Game WHERE id=$gameid) AND status='gameover'"); while($r = DB_fetch_array($result)) if($r[0]!=$gameid) $gameids[]=$r[0]; |