From fbfb06dc9003266bf35814b54cb1caf4eddc7cfa Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Tue, 11 Jul 2006 01:55:57 +0000 Subject: [PATCH] migrate calendar, no more PATH_INFO is needed git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@429 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs/carnet/calendar.php | 69 ---------------------------------------- modules/carnet.php | 51 ++++++++++++++++++++++++++++- templates/carnet/mescontacts.tpl | 2 +- 3 files changed, 51 insertions(+), 71 deletions(-) delete mode 100644 htdocs/carnet/calendar.php diff --git a/htdocs/carnet/calendar.php b/htdocs/carnet/calendar.php deleted file mode 100644 index f443df4..0000000 --- a/htdocs/carnet/calendar.php +++ /dev/null @@ -1,69 +0,0 @@ -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/modules/carnet.php b/modules/carnet.php index 9cbb8d0..b07cd19 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -24,7 +24,8 @@ class CarnetModule extends PLModule function handlers() { return array( - 'carnet/rss' => $this->make_hook('rss', AUTH_PUBLIC), + 'carnet/rss' => $this->make_hook('rss', AUTH_PUBLIC), + 'carnet/ical' => $this->make_hook('ical', AUTH_PUBLIC), ); } @@ -39,6 +40,54 @@ class CarnetModule extends PLModule return PL_OK; } + + function handler_ical(&$page, $user = null, $hash = null, $all = null) + { + global $globals; + + new_nonhtml_page('carnet/calendar.tpl', AUTH_PUBLIC); + + if ($alias && $hash) { + $res = $globals->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 == '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'); + + return PL_OK; + } } ?> diff --git a/templates/carnet/mescontacts.tpl b/templates/carnet/mescontacts.tpl index d2212ff..47986d6 100644 --- a/templates/carnet/mescontacts.tpl +++ b/templates/carnet/mescontacts.tpl @@ -59,7 +59,7 @@ Pour r Tu peux récupérer un calendrier iCal avec l'anniversaire de tes contacts.

- fichier ical + fichier ical
{else}

-- 2.1.4