summaryrefslogtreecommitdiff
path: root/forum/utils/calendar.php
diff options
context:
space:
mode:
Diffstat (limited to 'forum/utils/calendar.php')
-rw-r--r--forum/utils/calendar.php283
1 files changed, 156 insertions, 127 deletions
diff --git a/forum/utils/calendar.php b/forum/utils/calendar.php
index 318f458..0e7dba5 100644
--- a/forum/utils/calendar.php
+++ b/forum/utils/calendar.php
@@ -1,144 +1,173 @@
<?php
-include_once($UTIL_DIR . "/events.php");
-include_once($UTIL_DIR . "/notify.php");
-if($ZEND_DIR != "") include_once($UTIL_DIR . "/googlecalendar.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") {
- $title = stripslashes($title);
- $description = stripslashes($description);
-
- $time = strtotime($txtdate . " " . $txttimefrom . ":00");
- if($time !== FALSE) {
- $duration = strtotime($txtdate . " " . $txttimeto . ":00") - $time;
- $eid = time();
- $event = new Event($eid, $title, $time, $duration, $description, $current_user->uid);
- $events->add($event);
- $events->write();
-
- if($ZEND_DIR != "") googleCalendarEvent($event);
-
- if($DOKUWIKI_CALENDAR != "") {
- $file = $DOKUWIKI_CALENDAR;
- $fp = fopen($file, "w");
+function calendar()
+{
+ global $UTIL_DIR, $ZEND_DIR, $DOKUWIKI_CALENDAR, $GLOBALS,
+ $current_user, $DATA_DIR;
+
+ include_once($UTIL_DIR . "/events.php");
+ include_once($UTIL_DIR . "/notify.php");
+ if($ZEND_DIR != "") include_once($UTIL_DIR . "/googlecalendar.php");
+
+ $str = "";
+
+ $events = new Events($DATA_DIR . "/calendar.xml");
+
+ foreach($events->events as $e) {
+ if($e->concert == "true") $str .= $e->show_simple();
+ }
+
+ if(!isset($GLOBALS['date']))
+ $date = time() - (date("N", time()) - 1) * 24 * 60 * 60;
+ else
+ $date = $GLOBALS['date'] - (date("N", $GLOBALS['date'])-1) * 24 * 60 * 60;
+
+ if($GLOBALS['action'] =="addentry") {
+ $title = stripslashes($GLOBALS['title']);
+ $description = stripslashes($GLOBALS['description']);
+ if($GLOBALS['concert'] == "on") $concert = "true";
+ else $concert = "false";
+
+ $time = strtotime($GLOBALS['txtdate'] . " " .
+ $GLOBALS['txttimefrom'] . ":00");
+ if($time !== FALSE) {
+ $duration = strtotime($GLOBALS['txtdate'] . " " .
+ $GLOBALS['txttimeto'] . ":00") - $time;
+ $eid = time();
+ $event = new Event($eid, $title, $concert, $time, $duration, $description,
+ $current_user->uid);
+ $events->add($event);
+ $events->write();
+
+ if($ZEND_DIR != "") googleCalendarEvent($event);
- fprintf($fp, "=====DIEs calendar=====\n");
- fprintf($fp, "Do not edit this file - it is automatically generated by the ExecutionRoom CMS.\n\n");
- fprintf($fp, "====Events====\n");
- foreach($events->events as $event) {
- fprintf($fp, " * %s - %s %s: %s\n",
- date("j.n.Y G:i", $event->starttime),
- date("j.n.Y G:i", $event->starttime + $event->duration),
- $event->title, $event->description);
+ if($DOKUWIKI_CALENDAR != "") {
+ $file = $DOKUWIKI_CALENDAR;
+ $fp = fopen($file, "w");
+
+ fprintf($fp, "=====DIEs calendar=====\n");
+ fprintf($fp, "Do not edit this file - it is automatically generated " .
+ "by the ExecutionRoom CMS.\n\n");
+ fprintf($fp, "====Events====\n");
+ foreach($events->events as $event) {
+ fprintf($fp, " * %s - %s %s: %s\n",
+ date("j.n.Y G:i", $event->starttime),
+ date("j.n.Y G:i", $event->starttime + $event->duration),
+ $event->title, $event->description);
+ }
+ fclose($fp);
}
- fclose($fp);
+
+ notify("calendar", "New calendar entry:\n" . $GLOBALS['title'] . "\n" .
+ date("r", $time) . "\n" . $GLOBALS['description'] . "\n" .
+ $FORUM_URL . "/?mode=calendar&date=" . $time);
+
+ $str .= " <meta http-equiv=\"refresh\" content=\"0; " .
+ "URL=?mode=calendar&amp;date=" . $time . "\"/>\n";
+
+ } else {
+ $str .= "<div class=\"error\">ERROR: Date is not in the correct " .
+ "format! It was NOT posted. Please try again.</div>\n";
}
+ }
- notify("calendar", "New calendar entry:\n" . $title . "\n" . date("r", $time) . "\n" .
- $description . "\n" .
- $FORUM_URL . "/?mode=calendar&date=" . $time);
-?>
- <meta http-equiv="refresh" content="0; URL=?mode=calendar&amp;date=<?php echo $time; ?>" />
-<?php
+ if($GLOBALS['action'] =="delete") {
+ $events->delete($GLOBALS['eid']);
+ $events->write();
+ }
+
+ $str .= "<p style=\"text-align: center;\">\n";
+ $str .= "<a href=\"?mode=calendar&amp;date=" .
+ sprintf("%d", $date - 7 * 24 * 60 * 60) . "\">[&lt;]</a>\n";
+ $str .= "&nbsp;&nbsp;\n";
+ $str .= "<a href=\"?mode=calendar&amp;date=" .
+ sprintf("%d", $date - 31 * 24 * 60 * 60) . "\">[&lt;&lt;]</a>\n";
+ $str .= "&nbsp;&nbsp;\n";
+ $str .= date("F Y", $date) . "\n";
+ $str .= "&nbsp;&nbsp;\n";
+ $str .= "<a href=\"?mode=calendar&amp;date=" .
+ sprintf("%d", $date + 31 * 24 * 60 * 60) . "\">[&gt;&gt;]</a> \n";
+ $str .= "&nbsp;&nbsp;\n";
+ $str .= "<a href=\"?mode=calendar&amp;date=" .
+ sprintf("%d", $date + 7 * 24 * 60 * 60) . "\">[&gt;]</a><br/>\n";
+ $str .= "<a href=\"?mode=calendar\">[Today]</a><br/>\n";
+ $str .= "</p>\n";
+
+ if($client_is_mobile_device) {
+ for($day = 0; $day < 7; $day++) {
+ $str .= " <div class=\"mobilecalentry\">\n";
+ $str .= " <div class=\"mobilecalheader\">\n";
+ $t = $date + $day * 24 * 60 * 60;
+ $str .= " " . date("l j/n", $t) . "\n";
+ $str .= "<a style=\"text-decoration: none;\" " .
+ "href=\"?mode=calendar&amp;date=".
+ sprintf("%d", $date) . "&amp;adddate=". $t .
+ "&amp;action=add\">[+]</a>\n";
+ $str .= " </div>\n";
+ $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60));
+ $str .= " <div class=\"mobilecalcontent\"";
+ if($t == strtotime(date("F j Y", time())))
+ $str .= " style=\"background: #113;\"";
+ elseif($day > 4) $str .= " style=\"background: #311;\"";
+ $str .= ">\n";
+
+ $str .= $events->show($t, $t + 24 * 60 * 60);
+
+ $str .= " </div>\n";
+ $str .= " </div>\n";
+
+ }
} else {
- echo "<div class=\"error\">ERROR: Date is not in the correct format! It was NOT posted. Please try again.</div>\n";
- }
-}
+ $str .= "<table class=\"week\">\n";
+ $str .= " <tr class=\"day\">\n";
-if($action=="edit") {
- /*
- $event = $events->getEvent($eid);
- $event->duration += 2000;
- $events->write();
- */
-}
+ for($day = 0; $day < 7; $day++) {
+ $str .= " <td class=\"header\">\n";
+ $t = $date + $day * 24 * 60 * 60;
+ $str .= " " . date("l j/n", $t) . "\n";
+ $str .= " </td>\n";
+ }
-?>
-<p style="text-align: center;">
-<a href="?mode=calendar&amp;date=<?php echo $date - 7 * 24 * 60 * 60 ?>">[&lt;]</a>
-&nbsp;&nbsp;
-<a href="?mode=calendar&amp;date=<?php echo $date - 31 * 24 * 60 * 60 ?>">[&lt;&lt;]</a>
-&nbsp;&nbsp;
-<?php echo date("F Y", $date); ?>
-&nbsp;&nbsp;
-<a href="?mode=calendar&amp;date=<?php echo $date + 31 * 24 * 60 * 60 ?>">[&gt;&gt;]</a>
-&nbsp;&nbsp;
-<a href="?mode=calendar&amp;date=<?php echo $date + 7 * 24 * 60 * 60 ?>">[&gt;]</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&amp;date=<?php echo $date; ?>&amp;adddate=<?php echo $t; ?>&amp;action=add">[+]</a>
-<?php
- echo " </div>\n";
+ $str .= " </tr>\n";
+ $str .= " <tr class=\"day\">\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";
+ for($day = 0; $day < 7; $day++) {
+ $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60));
- $events->show($t, $t + 24 * 60 * 60);
+ $str .= " <td class=\"content\"";
+ if($t == strtotime(date("F j Y", time())))
+ $str .= " style=\"background: #113;\"";
+ elseif($day > 4) $str .= " style=\"background: #311;\"";
+ $str .= ">\n";
- echo " </div>\n";
- echo " </div>\n";
+ $str .= " <a class=\"button\" href=\"?mode=calendar&amp;date=" .
+ sprintf("%d", $date) . "&amp;adddate=". $t .
+ "&amp;action=add\">Add</a>\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));
+ $str .= $events->show($t, $t + 24 * 60 * 60);
+ $str .= " </td>\n";
+ }
- 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&amp;date=<?php echo $date; ?>&amp;adddate=<?php echo $t; ?>&amp;action=add">Add</a>
-<?php
- $events->show($t, $t + 24 * 60 * 60);
- echo " </td>\n";
-}
-?>
- </tr>
-</table>
-<?php
+ $str .= " </tr>\n";
+ $str .= "</table>\n";
+ }
+
+ if($GLOBALS['adddate'] != "") {
+ $str .= "<form method=\"post\" action=\"?mode=calendar&amp;action=" .
+ "addentry\">\n";
+ $str .= "Title: <input name=\"title\" value=\"\"><br/>\n";
+ $str .= "Concert: <input type=\"checkbox\" name=\"concert\"/><br/>\n";
+ $str .= "Desription: <textarea name=\"description\"></textarea><br/>\n";
+ $str .= "Date: <input name=\"txtdate\" value=\"".
+ date("F j Y", $GLOBALS['adddate']) . "\"><br/>\n";
+ $str .= "From-Time: <input name=\"txttimefrom\" value=\"19:00\"><br/>\n";
+ $str .= "To-Time: <input name=\"txttimeto\" value=\"22:00\"><br/>\n";
+ $str .= "<br/>\n";
+ $str .= "<button type=\"submit\">Add</button>\n";
+ $str .= "</form>\n";
+ }
+
+ return $str;
}
?>
-<?php if($adddate != "") { ?>
-<form method="post" action="?mode=calendar&amp;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 } ?>