From f2ee531a20c901fa04f4e50f0c846eb1531f6ad1 Mon Sep 17 00:00:00 2001 From: x2001corpet Date: Wed, 14 Jun 2006 12:06:33 +0000 Subject: [PATCH] calendrier iCal des anniversaires git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@314 839d8a87-29fc-0310-9880-83ba4fa771e5 --- ChangeLog | 5 ++- htdocs/carnet/calendar.php | 69 ++++++++++++++++++++++++++++++++++++++ htdocs/images/icalicon.gif | Bin 0 -> 460 bytes plugins/function.display_ical.php | 40 ++++++++++++++++++++++ templates/carnet/calendar.tpl | 39 +++++++++++++++++++++ templates/carnet/mescontacts.tpl | 15 ++++++++- 6 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 htdocs/carnet/calendar.php create mode 100644 htdocs/images/icalicon.gif create mode 100644 plugins/function.display_ical.php create mode 100644 templates/carnet/calendar.tpl diff --git a/ChangeLog b/ChangeLog index 4df9c06..043a063 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,8 +10,11 @@ New : - Dynamic maps using geodesix plugin. -Car - Link to local maps for all addresses. -Car + * Notifications : + - iCal calendar for birthdays. -Car + * Profile : - - See fiche send to AX. -Car + - See fiche sent to AX. -Car * Skin : - Common file for header above title. -Car diff --git a/htdocs/carnet/calendar.php b/htdocs/carnet/calendar.php new file mode 100644 index 0000000..3746842 --- /dev/null +++ b/htdocs/carnet/calendar.php @@ -0,0 +1,69 @@ +xdb->query( + 'SELECT a.id + FROM aliases AS a + INNER JOIN auth_user_quick AS q ON ( a.id = q.user_id AND q.core_rss_hash = {?} ) + WHERE a.alias = {?} AND a.type != "homonyme"', $hash, $alias); + $uid = $res->fetchOneCell(); +} + +require_once('notifs.inc.php'); +$notifs = new Notifs($uid, true); + +$annivcat = false; +foreach ($notifs->_cats as $cat) + if (preg_match('/anniv/i', $cat['short'])) + $annivcat = $cat['id']; + +if ($annivcat !== false) { + $annivs = array(); + foreach ($notifs->_data[$annivcat] as $promo) foreach ($promo as $notif) + if ($all || $notif['contact']) { + $annivs[] = array( + 'timestamp' => $notif['known'], + 'date' => strtotime($notif['date']), + 'tomorrow' => strtotime("+1 day", strtotime($notif['date'])), + 'bestalias' => $notif['bestalias'], + 'summary' => 'Anniversaire de '.$notif['prenom'].' '.$notif['nom'].' - x '.$notif['promo'], + ); + } + $page->assign('events', $annivs); +} + +header('Content-Type: text/calendar; charset=utf-8'); + +$page->run(); +?> \ No newline at end of file diff --git a/htdocs/images/icalicon.gif b/htdocs/images/icalicon.gif new file mode 100644 index 0000000000000000000000000000000000000000..01cc8cde5643d5bde115b93b1df9b4ab09bd6c0c GIT binary patch literal 460 zcmV;-0WWu*R zA|To{;`rtuyi9T0hycGS0MQzu;I={CRLA_q((&4%@T!sIqX5nvQNwz1(vT3cMPcM` z5XLhAcnbigJ(1h00Lvc$JOh~eoe!`EEWKn=8rc${kdjxRSVpwT*S# z0Z+_xx=IqNRbnYoQl5pbltCRRC?EqBVi7P+Z-G!>O#~$@G7kwQ0v-<_92y`aB{~cx zF^DCKPmBW+j|c;aFHR5;8zmn*B?l0zqk^SYr>VH4ZY3Bbk2Sx#PNt|Vs*?h`BO?oA zV-3fPb1HT>19~M65*s!WVJs;rEF~!yZyzT(ILTIFV-Eu@6k|R#Il>4JGfEVA@P?W_ zFT5UjSm>b%3>qj5c#r`Cfrmo_V0chvkzqrGT?T*{8B$7z03lMUT* diff --git a/templates/carnet/calendar.tpl b/templates/carnet/calendar.tpl new file mode 100644 index 0000000..0e3b207 --- /dev/null +++ b/templates/carnet/calendar.tpl @@ -0,0 +1,39 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2006 Polytechnique.org *} +{* http://opensource.polytechnique.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 *} +{* *} +{**************************************************************************} +BEGIN:VCALENDAR +{display_ical name="prodid" value="-//Polytechnique.org//Plat-al//FR"} +VERSION:2.0 +CALSCALE:GREGORIAN +METHOD:PUBLISH +{display_ical name="x-wr-calname" value="Anniversaires des X"} +X-WR-TIMEZONE:Europe/Paris +{foreach from=$events item=e} +BEGIN:VEVENT +DTSTAMP:{$e.timestamp|date_format:"%Y%m%dT%H%M%SZ"} +DTSTART;VALUE=DATE:{$e.date|date_format:"%Y%m%d"} +DTEND;VALUE=DATE:{$e.tomorrow|date_format:"%Y%m%d"} +UID:anniv-{$e.date|date_format:"%Y%m%d"}-{$e.bestalias}@polytechnique.org +CLASS:PUBLIC +{display_ical name="summary" value=$e.summary} +END:VEVENT +{/foreach} +END:VCALENDAR \ No newline at end of file diff --git a/templates/carnet/mescontacts.tpl b/templates/carnet/mescontacts.tpl index fd6846e..5fe05e1 100644 --- a/templates/carnet/mescontacts.tpl +++ b/templates/carnet/mescontacts.tpl @@ -54,6 +54,19 @@ Pour r [tri par noms] +{if $smarty.session.core_rss_hash} +

+ Tu peux récupérer un calendrier iCal avec l'anniversaire de tes contacts. +

+
+ fichier ical +
+{else} +

+ Pour récupérer un calendrier iCal avec l'anniversaire de tes contacts, active les flux RSS dans Mes préférences. +

+{/if} + {if $trombi} @@ -76,7 +89,7 @@ Pour afficher la liste d

-Pour afficher le trombi de tes contacts : [vue sous forme de trombi] +[Afficher le trombi de tes contacts]

{include file=carnet/tricontacts.tpl order=$order} -- 2.1.4