summaryrefslogtreecommitdiffstats
path: root/include/functions.php
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2009-01-30 21:05:32 -0800
committerArun Persaud <arun@nubati.net>2009-01-30 21:05:32 -0800
commitc1585e23cb3ea757674c234c9193889b4f2f2090 (patch)
tree3f87836cef1a81e400e4a660c0433ad4080acc97 /include/functions.php
parentee08bf05ddb0bb5722b0f8b1569d7ab4473a798d (diff)
downloade-DoKo-c1585e23cb3ea757674c234c9193889b4f2f2090.tar.gz
e-DoKo-c1585e23cb3ea757674c234c9193889b4f2f2090.tar.bz2
e-DoKo-c1585e23cb3ea757674c234c9193889b4f2f2090.zip
NEW FEATURE: vacation support
users can specify a vacation start and end date and a message. Once they are on vacation their name will be shown in a different color at the table and on the user page (in case it is their turn).
Diffstat (limited to 'include/functions.php')
-rw-r--r--include/functions.php51
1 files changed, 48 insertions, 3 deletions
diff --git a/include/functions.php b/include/functions.php
index 044c6c7..b4c344d 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -767,10 +767,22 @@ function display_table ()
$timenow = strtotime(date("Y-m-d H:i:s"));
echo " <div class=\"table".($pos-1)."\">\n";
- if(!$debug)
- echo " $name \n";
+
+ if($debug)
+ echo " <a href=\"".$INDEX."?action=game&amp;me=".$hash."\">";
+ if($vacation = check_vacation($user))
+ {
+ $start = $vacation[0];
+ $stop = substr($vacation[1],0,10);
+ $comment = $vacation[2];
+
+ $title = "begin: $start end: $stop $comment";
+ echo " <span class=\"vacation\" title=\"$title\">$name (on vacation until $stop)</span> \n";
+ }
else
- echo " <a href=\"".$INDEX."?action=game&amp;me=".$hash."\">$name</a>\n";
+ echo " $name \n";
+ if($debug)
+ echo"</a>\n";
/* add hints for poverty, wedding, solo, etc */
if( $gametype != "solo")
@@ -1162,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;
+}
?>