From 978e0a31d709e252da29df1c900ee9caf97acb69 Mon Sep 17 00:00:00 2001 From: TheMrNomis Date: Thu, 12 Nov 2015 10:24:26 +0100 Subject: [PATCH 1/6] started ical export --- export.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 export.php diff --git a/export.php b/export.php new file mode 100644 index 0000000..e55f2b9 --- /dev/null +++ b/export.php @@ -0,0 +1,32 @@ + From 506143038a164f7c767b352cffe40d26f26f636c Mon Sep 17 00:00:00 2001 From: TheMrNomis Date: Thu, 12 Nov 2015 10:45:52 +0100 Subject: [PATCH 2/6] updated DB queries functions --- getEvents.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/getEvents.php b/getEvents.php index fd023b3..1da6069 100755 --- a/getEvents.php +++ b/getEvents.php @@ -35,7 +35,31 @@ function getEventsByDate($db, $date) { try { - $request = $db->prepare('SELECT * FROM events, categorie WHERE events.categorie = categorie.id AND dtstart <= :date AND dtend >= :date'); + $request = $db->prepare('SELECT * FROM events, categorie WHERE events.categorie = categorie.id AND (dtstart <= :date AND dtend >= :date)'); + $request->execute(array('date'=>date("Y-m-d",$date))); + $result = $request->fetchAll(); + $request->closeCursor(); + return $result; + } + catch(PDOException $e) + { + //NOTE: change $e->getMessage() by an error message before going to production + echo($e->getMessage()); + die(); + } +} + +/** + * @brief queries the database for the events after a certain date + * @param $db: the PDO connection to the database + * @param $date: the date to search for + * @return a list of all the events future to $date + */ +function getEventsSince($db,$date) +{ + try + { + $request = $db->prepare('SELECT events.id, events.titre, events.localisation, events.dtstart, events.dtend, events.description FROM events, categorie WHERE events.categorie = categorie.id AND (events.dtstart >= :date OR events.dtend >= :date)'); $request->execute(array('date'=>date("Y-m-d",$date))); $result = $request->fetchAll(); $request->closeCursor(); From 873123dbd856300807fde1436a8211efae7307c6 Mon Sep 17 00:00:00 2001 From: TheMrNomis Date: Thu, 12 Nov 2015 10:46:19 +0100 Subject: [PATCH 3/6] first draft at exporting ical --- export.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/export.php b/export.php index e55f2b9..266bfa9 100644 --- a/export.php +++ b/export.php @@ -1,16 +1,16 @@ Date: Thu, 12 Nov 2015 10:49:04 +0100 Subject: [PATCH 4/6] updated ical PRODID --- export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/export.php b/export.php index 266bfa9..46a1263 100644 --- a/export.php +++ b/export.php @@ -15,7 +15,7 @@ $events = getEventsSince($db, time()); $eol = "\r\n"; echo('BEGIN:VCALENDAR'.$eol); echo('VERSION:2.0'.$eol); -echo('PRODID:-//hacksw/handcal//NONSGML v1.0//EN'.$eol); +echo('PRODID:-//KiWi-Calendar//NONSGML v1.0//EN'.$eol); foreach($events as $event) { echo('BEGIN:VEVENT'.$eol); From 4b44961ed3d298180b768a06ceb9b4b9c6d33ff2 Mon Sep 17 00:00:00 2001 From: TheMrNomis Date: Thu, 12 Nov 2015 10:54:00 +0100 Subject: [PATCH 5/6] export can be parameterized relative to a week offset --- export.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/export.php b/export.php index 46a1263..4732f7a 100644 --- a/export.php +++ b/export.php @@ -2,6 +2,11 @@ header('Content-type: text/calendar; charset=utf-8'); header('Content-Disposition: inline; filename=calendar.ics'); +if(isset($_GET['w'])&&is_numeric($_GET['w'])) + $weekOffset = $_GET['w']; +else + $weekOffset = 0; + function icaldate($date) { $dt = strtotime($date); @@ -10,7 +15,7 @@ function icaldate($date) include_once('getEvents.php'); $db = connect(); -$events = getEventsSince($db, time()); +$events = getEventsSince($db, strtotime('last monday +'.$weekOffset.' weeks')); $eol = "\r\n"; echo('BEGIN:VCALENDAR'.$eol); From 9c36bbe99a0f8a7d33bca12beeab59c6cb788465 Mon Sep 17 00:00:00 2001 From: TheMrNomis Date: Thu, 12 Nov 2015 10:54:13 +0100 Subject: [PATCH 6/6] link to export in iCal --- index.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 60f0213..7d519db 100644 --- a/index.php +++ b/index.php @@ -27,6 +27,11 @@ $months = array( 12 => "Decembre" ); +if(isset($_GET['w'])&&is_numeric($_GET['w'])) + $weekOffset = $_GET['w']; +else + $weekOffset = 0; + ?> @@ -105,11 +110,6 @@ $months = array(
expand more -
Exporter en RSS, iCal, WebCal
+