From c1585e23cb3ea757674c234c9193889b4f2f2090 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Fri, 30 Jan 2009 21:05:32 -0800 Subject: 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). --- include/functions.php | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to 'include/functions.php') 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 "
\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") @@ -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; +} ?> -- cgit v1.2.3-18-g5258