From 42c62cb041a2b2b95c9cda0c20fcf70334fd244c Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 1 Nov 2011 09:32:21 +0000 Subject: Rewl og krat... needs cleaning up - after port to GIT. --- forum/utils/calendar.php | 283 ++++++++++++++++++++++++++--------------------- 1 file changed, 156 insertions(+), 127 deletions(-) (limited to 'forum/utils/calendar.php') 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 @@ 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 .= " \n"; + + } else { + $str .= "
ERROR: Date is not in the correct " . + "format! It was NOT posted. Please try again.
\n"; } + } - notify("calendar", "New calendar entry:\n" . $title . "\n" . date("r", $time) . "\n" . - $description . "\n" . - $FORUM_URL . "/?mode=calendar&date=" . $time); -?> - -delete($GLOBALS['eid']); + $events->write(); + } + + $str .= "

\n"; + $str .= "[<]\n"; + $str .= "  \n"; + $str .= "[<<]\n"; + $str .= "  \n"; + $str .= date("F Y", $date) . "\n"; + $str .= "  \n"; + $str .= "[>>] \n"; + $str .= "  \n"; + $str .= "[>]
\n"; + $str .= "[Today]
\n"; + $str .= "

\n"; + + if($client_is_mobile_device) { + for($day = 0; $day < 7; $day++) { + $str .= "
\n"; + $str .= "
\n"; + $t = $date + $day * 24 * 60 * 60; + $str .= " " . date("l j/n", $t) . "\n"; + $str .= "[+]\n"; + $str .= "
\n"; + $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60)); + $str .= "
4) $str .= " style=\"background: #311;\""; + $str .= ">\n"; + + $str .= $events->show($t, $t + 24 * 60 * 60); + + $str .= "
\n"; + $str .= "
\n"; + + } } else { - echo "
ERROR: Date is not in the correct format! It was NOT posted. Please try again.
\n"; - } -} + $str .= "\n"; + $str .= " \n"; -if($action=="edit") { - /* - $event = $events->getEvent($eid); - $event->duration += 2000; - $events->write(); - */ -} + for($day = 0; $day < 7; $day++) { + $str .= " \n"; + } -?> -

-[<] -   -[<<] -   - -   -[>>] -   -[>]
-[Today]
-

-\n"; - echo "
\n"; - $t = $date + $day * 24 * 60 * 60; - echo " " . date("l j/n", $t) . "\n"; -?> - [+] -\n"; + $str .= "
\n"; + $str .= " \n"; - $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60)); - echo "
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 .= "
\n"; + $t = $date + $day * 24 * 60 * 60; + $str .= " " . date("l j/n", $t) . "\n"; + $str .= "
4) $str .= " style=\"background: #311;\""; + $str .= ">\n"; - echo " \n"; - echo " \n"; + $str .= " Add\n"; - } -} else { -?> - - -\n"; - $t = $date + $day * 24 * 60 * 60; - echo " " . date("l j/n", $t) . "\n"; - echo " \n"; -} -?> - - -show($t, $t + 24 * 60 * 60); + $str .= " \n"; + } - echo " \n"; -} -?> - -
4) echo " style=\"background: #311;\""; - echo ">\n"; -?> - Add -show($t, $t + 24 * 60 * 60); - echo "
-\n"; + $str .= "
\n"; + } + + if($GLOBALS['adddate'] != "") { + $str .= "
\n"; + $str .= "Title:
\n"; + $str .= "Concert:
\n"; + $str .= "Desription:
\n"; + $str .= "Date:
\n"; + $str .= "From-Time:
\n"; + $str .= "To-Time:
\n"; + $str .= "
\n"; + $str .= "\n"; + $str .= "
\n"; + } + + return $str; } ?> - -
-Title:
-Desription:
-Date: ">
-From-Time:
-To-Time:
-
- -
- -- cgit v1.2.3