diff options
author | deva <deva> | 2008-10-04 10:38:03 +0000 |
---|---|---|
committer | deva <deva> | 2008-10-04 10:38:03 +0000 |
commit | cce5e7710295021b41d9aaecc503a60fb99256be (patch) | |
tree | 660235be91fb821e976c7ae62347eb368ce87524 /forum/utils/calendar.php |
Initial revision
Diffstat (limited to 'forum/utils/calendar.php')
-rw-r--r-- | forum/utils/calendar.php | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/forum/utils/calendar.php b/forum/utils/calendar.php new file mode 100644 index 0000000..1592195 --- /dev/null +++ b/forum/utils/calendar.php @@ -0,0 +1,112 @@ +<?php +include_once($UTIL_DIR . "/events.php"); +include_once($UTIL_DIR . "/notify.php"); + +$events = new Events($DATA_DIR . "/calendar.xml"); + +if(!$date) $date = time() - (date("N", time()) - 1) * 24 * 60 * 60; +else $date = $date - (date("N", $date) - 1) * 24 * 60 * 60; +//echo $date; + +if($action=="addentry") { + $time = strtotime($txtdate . " " . $txttimefrom . ":00"); + $duration = strtotime($txtdate . " " . $txttimeto . ":00") - $time; + $eid = time(); + $event = new Event($eid, $title, $time, $duration, $description, $current_user->uid); + $events->add($event); + $events->write(); + notify("calendar", "New calendar entry:\n" . $title . "\n" . date("r", $time) . "\n" . + $description . "\n" . + "http://www.executionroom.com/forum/?mode=calendar&date=" . $time); +} + +if($action=="edit") { + /* + $event = $events->getEvent($eid); + $event->duration += 2000; + $events->write(); + */ +} + +?> +<p style="text-align: center;"> +<a href="?mode=calendar&date=<?php echo $date - 7 * 24 * 60 * 60 ?>">[<]</a> + +<a href="?mode=calendar&date=<?php echo $date - 31 * 24 * 60 * 60 ?>">[<<]</a> + +<?php echo date("F Y", $date); ?> + +<a href="?mode=calendar&date=<?php echo $date + 31 * 24 * 60 * 60 ?>">[>>]</a> + +<a href="?mode=calendar&date=<?php echo $date + 7 * 24 * 60 * 60 ?>">[>]</a><br/> +<a href="?mode=calendar">[Today]</a><br/> +</p> +<?php +if($client_is_mobile_device) { + for($day = 0; $day < 7; $day++) { + echo " <div class=\"mobilecalentry\">\n"; + echo " <div class=\"mobilecalheader\">\n"; + $t = $date + $day * 24 * 60 * 60; + echo " " . date("l j/n", $t) . "\n"; +?> + <a style="text-decoration: none;" href="?mode=calendar&date=<?php echo $date; ?>&adddate=<?php echo $t; ?>&action=add">[+]</a> +<?php + echo " </div>\n"; + + $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60)); + echo " <div class=\"mobilecalcontent\""; + if($t == strtotime(date("F j Y", time()))) echo " style=\"background: #113;\""; + elseif($day > 4) echo " style=\"background: #311;\""; + echo ">\n"; + + $events->show($t, $t + 24 * 60 * 60); + + echo " </div>\n"; + echo " </div>\n"; + + } +} else { +?> +<table class="week"> + <tr class="day"> +<?php +for($day = 0; $day < 7; $day++) { + echo " <td class=\"header\">\n"; + $t = $date + $day * 24 * 60 * 60; + echo " " . date("l j/n", $t) . "\n"; + echo " </td>\n"; +} +?> + </tr> + <tr class="day"> +<?php +for($day = 0; $day < 7; $day++) { + $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60)); + + echo " <td class=\"content\""; + if($t == strtotime(date("F j Y", time()))) echo " style=\"background: #113;\""; + elseif($day > 4) echo " style=\"background: #311;\""; + echo ">\n"; +?> + <a class="button" href="?mode=calendar&date=<?php echo $date; ?>&adddate=<?php echo $t; ?>&action=add">Add</a> +<?php + $events->show($t, $t + 24 * 60 * 60); + echo " </td>\n"; +} +?> + </tr> +</table> +<?php +} +?> +<?php if($adddate != "") { ?> +<form method="post" action="?mode=calendar&action=addentry"> +Title: <input name="title" value=""><br/> +Desription: <textarea name="description"></textarea><br/> +Date: <input name="txtdate" value="<?php echo date("F j Y", $adddate); ?>"><br/> +From-Time: <input name="txttimefrom" value="17:00"><br/> +To-Time: <input name="txttimeto" value="20:00"><br/> +<br/> +<button type="submit">Add</button> +</form> +<?php } ?> |