Accéder au contenu.
Menu Sympa

devel - [Devel] r89 - trunk

Objet : devel-adl

Archives de la liste

[Devel] r89 - trunk


Chronologique Discussions 
  • From: thomas AT lolut.utbm.info
  • To: devel AT agendadulibre.org
  • Subject: [Devel] r89 - trunk
  • Date: Sat, 17 Sep 2005 17:43:14 +0200 (CEST)
  • List-archive: <http://lolut.utbm.info/pipermail/devel>
  • List-id: Developpement de l'Agenda du Libre <devel.agendadulibre.org>

Author: thomas
Date: 2005-09-17 17:43:13 +0200 (Sat, 17 Sep 2005)
New Revision: 89

Added:
trunk/ical.php
Modified:
trunk/funcs.inc.php
Log:

Ajout du support iCal.



Modified: trunk/funcs.inc.php
===================================================================
--- trunk/funcs.inc.php 2005-08-18 21:07:52 UTC (rev 88)
+++ trunk/funcs.inc.php 2005-09-17 15:43:13 UTC (rev 89)
@@ -25,7 +25,7 @@
*
* @param[in] Relative URL in the website
*/
-function calendar_absolute_url($url)
+function calendar_absolute_url($url="")
{
global $root;
$root = rtrim ($root, "/");

Added: trunk/ical.php
===================================================================
--- trunk/ical.php 2005-08-18 21:07:52 UTC (rev 88)
+++ trunk/ical.php 2005-09-17 15:43:13 UTC (rev 89)
@@ -0,0 +1,106 @@
+<?php
+/*
+ * Copyright 2004-2005
+ * - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+include("bd.inc.php");
+include("bd-private.inc.php");
+include("funcs.inc.php");
+
+$db = new db();
+
+header("Content-Type: application/octet-stream");
+
+calendar_setlocale();
+
+$timezone = "Europe/Paris";
+
+function ical_start_calendar ()
+{
+ echo "BEGIN:VCALENDAR\n";
+ echo "VERSION:2.0\n";
+ echo "X-WR-CALNAME:Agenda du Libre\n";
+ echo "X-WR-TIMEZONE:US/Central\n";
+ echo "CALSCALE:GREGORIAN\n";
+ echo "X-WR-CALDESC:Agenda du Libre\n";
+}
+
+function ical_end_calendar()
+{
+ echo "END:VCALENDAR";
+}
+
+function ical_display_event ($city, $start, $end, $title, $url, $description)
+{
+ global $timezone;
+
+ echo "BEGIN:VEVENT\n";
+ echo "DTSTART;" . date ('Ymd\THi\0\0', $start) . "\n";
+ echo "DTEND;" . date ('Ymd\THi\0\0', $end) . "\n";
+ echo "SUMMARY:" . $title . "\n";
+ echo "URL;VALUE=URI:" . $url . "\n";
+ echo "DESCRIPTION:" . $description . "\n";
+ echo "LOCATION:" . $city . "\n";
+ echo "END:VEVENT\n";
+}
+
+function get_events ($db, $region)
+{
+ $start = mktime();
+ $end = mktime() + (30 * 24 * 60 * 60);
+
+ if ($region == "all")
+ {
+ $sql = "select * from events where " .
+ "(start_time <= '" . date_timestamp2mysql($end) . "') AND " .
+ "(end_time >= '" . date_timestamp2mysql($start) . "') AND
(moderated=1)";
+ }
+ else
+ {
+ $sql = "select * from events where " .
+ "(start_time <= '" . date_timestamp2mysql($end) . "') AND " .
+ "(end_time >= '" . date_timestamp2mysql($start) . "') AND " .
+ "((region=" . $region . ") OR (locality=1)) AND (moderated=1)";
+ }
+
+ return $db->query ($sql);
+}
+
+$list = get_events ($db, $_GET['region']);
+if ($list == FALSE)
+{
+ echo "Erreur lors de la r�cup�ration des �v�nements";
+ exit;
+}
+
+ical_start_calendar();
+
+while ($event = mysql_fetch_object($list))
+{
+ ical_display_event (utf8_encode($event->city),
+ date_mysql2timestamp ($event->start_time),
+ date_mysql2timestamp ($event->end_time),
+ utf8_encode($event->title),
+ calendar_absolute_url("showevent.php?id=" . $event->id),
+ utf8_encode("Un �v�nement de l'Agenda du Libre"));
+}
+
+ical_end_calendar();
+
+?>
\ No newline at end of file






Archives gérées par MHonArc 2.6.16.

Haut de le page