2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once("xorg.inc.php");
23 new_nonhtml_page('carnet/calendar.tpl', AUTH_PUBLIC
);
25 if (preg_match(',^/([^/]+)/([^/_]+)(_all)?\.ics$,', $_SERVER['PATH_INFO'], $m)) {
30 $alias = Env
::get('alias');
31 $hash = Env
::get('hash');
32 $all = Env
::has('all');
34 if ($alias && $hash) {
35 $res = $globals->xdb
->query(
38 INNER JOIN auth_user_quick AS q ON ( a.id = q.user_id AND q.core_rss_hash = {?} )
39 WHERE a.alias = {?} AND a.type != "homonyme"', $hash, $alias);
40 $uid = $res->fetchOneCell();
43 require_once('notifs.inc.php');
44 $notifs = new Notifs($uid, true
);
47 foreach ($notifs->_cats
as $cat)
48 if (preg_match('/anniv/i', $cat['short']))
49 $annivcat = $cat['id'];
51 if ($annivcat !== false
) {
53 foreach ($notifs->_data
[$annivcat] as $promo) foreach ($promo as $notif)
54 if ($all ||
$notif['contact']) {
56 'timestamp' => $notif['known'],
57 'date' => strtotime($notif['date']),
58 'tomorrow' => strtotime("+1 day", strtotime($notif['date'])),
59 'bestalias' => $notif['bestalias'],
60 'summary' => 'Anniversaire de '.$notif['prenom'].' '.$notif['nom'].' - x '.$notif['promo'],
63 $page->assign('events', $annivs);
66 header('Content-Type: text/calendar; charset=utf-8');