X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Ffunctions.php;h=b4c344d244e436946d830bdc95c722491a7d15f4;hp=cb09d6c6ad33a55b83283ea11eb96238b15c9a0d;hb=c1585e23cb3ea757674c234c9193889b4f2f2090;hpb=617c9d49a2445bd39f2d18274462a29d8e533353
diff --git a/include/functions.php b/include/functions.php
index cb09d6c..b4c344d 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -329,17 +329,22 @@ function check_wedding($cards)
return 0;
}
-function count_trump($cards)
+function count_trump($cards,$status='pregame')
{
global $RULES;
$trump = 0;
- /* count each trump, including the foxes */
+ /* count each trump, including the foxes, since this is used to determine poverty status */
foreach($cards as $c)
if( (int)($c) <27)
$trump++;
+ /* In case we really want to know the amount of trump, we can use the status variable.
+ * This is needed for example to figure out what icon to display on the table in case of
+ * trump given back in poverty */
+ if($status=='all') return $trump;
+
/* normally foxes don't count as trump, so we substract them here
* in case someone has schweinchen, one or two of them should count as trump
* though, so we need to add one trump for those cases */
@@ -727,7 +732,7 @@ function can_call($what,$hash)
function display_table ()
{
- global $gameid, $GT, $debug,$INDEX,$defaulttimezone;
+ global $gameid, $GT, $debug,$INDEX,$defaulttimezone,$session;
global $RULES,$GAME,$gametype;
$result = DB_query("SELECT User.fullname as name,".
@@ -762,10 +767,22 @@ function display_table ()
$timenow = strtotime(date("Y-m-d H:i:s"));
echo "
\n";
- if(!$debug)
- echo " $name \n";
+
+ if($debug)
+ echo "
";
+ if($vacation = check_vacation($user))
+ {
+ $start = $vacation[0];
+ $stop = substr($vacation[1],0,10);
+ $comment = $vacation[2];
+
+ $title = "begin: $start end: $stop $comment";
+ echo " $name (on vacation until $stop) \n";
+ }
else
- echo " $name\n";
+ echo " $name \n";
+ if($debug)
+ echo"\n";
/* add hints for poverty, wedding, solo, etc */
if( $gametype != "solo")
@@ -777,7 +794,7 @@ function display_table ()
{
$userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
$cards = DB_get_all_hand($userhash);
- $trumpNR = count_trump($cards);
+ $trumpNR = count_trump($cards,'all');
if($trumpNR)
echo "
";
else
@@ -792,7 +809,7 @@ function display_table ()
{
$userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
$cards = DB_get_all_hand($userhash);
- $trumpNR = count_trump($cards);
+ $trumpNR = count_trump($cards,'all');
if($trumpNR)
echo "
";
else
@@ -805,7 +822,7 @@ function display_table ()
{
$userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
$cards = DB_get_all_hand($userhash);
- $trumpNR = count_trump($cards);
+ $trumpNR = count_trump($cards,'all');
if($trumpNR)
echo "
";
else
@@ -863,8 +880,8 @@ function display_table ()
}
echo "
\n";
- echo "
local time\n";
- echo "
last login\n";
+ echo "
time info\n";
echo "
\n";
}
@@ -1157,5 +1174,38 @@ function getCache($cacheFile, $expireTime)
return false;
}
+function check_vacation($userid)
+{
+ /* get start date */
+ $result = DB_query_array("SELECT value FROM User_Prefs".
+ " WHERE user_id='$userid' AND pref_key='vacation start'" );
+ if($result)
+ $start = $result[0];
+ else
+ return NULL;
+
+ /* get end date */
+ $result = DB_query_array("SELECT value FROM User_Prefs".
+ " WHERE user_id='$userid' AND pref_key='vacation stop'" );
+ if($result)
+ $stop = $result[0];
+ else
+ return NULL;
+
+ /* get comment */
+ $result = DB_query_array("SELECT value FROM User_Prefs".
+ " WHERE user_id='$userid' AND pref_key='vacation comment'" );
+ if($result)
+ $comment = $result[0];
+ else
+ $comment = '';
+
+ /* check if user is on vacation. TODO: use user's timezone */
+ if( (time() - strtotime($start) >0) &&
+ (strtotime($stop) - time() >0))
+ return array ($start,$stop,$comment);
+ else
+ return NULL;
+}
?>