b07cd19736774bfa04b826d38138fddda09f53d4
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 class CarnetModule
extends PLModule
27 'carnet/rss' => $this->make_hook('rss', AUTH_PUBLIC
),
28 'carnet/ical' => $this->make_hook('ical', AUTH_PUBLIC
),
32 function handler_rss(&$page, $user = null
, $hash = null
)
34 require_once 'rss.inc.php';
35 require_once 'notifs.inc.php';
37 $uid = init_rss('carnet/rss.tpl', $user, $hash);
38 $notifs = new Notifs($uid, false
);
39 $page->assign('notifs', $notifs);
44 function handler_ical(&$page, $user = null
, $hash = null
, $all = null
)
48 new_nonhtml_page('carnet/calendar.tpl', AUTH_PUBLIC
);
50 if ($alias && $hash) {
51 $res = $globals->xdb
->query(
54 INNER JOIN auth_user_quick AS q ON ( a.id = q.user_id AND q.core_rss_hash = {?} )
55 WHERE a.alias = {?} AND a.type != "homonyme"', $hash, $alias);
56 $uid = $res->fetchOneCell();
59 require_once 'notifs.inc.php';
60 $notifs = new Notifs($uid, true
);
63 foreach ($notifs->_cats
as $cat) {
64 if (preg_match('/anniv/i', $cat['short']))
65 $annivcat = $cat['id'];
68 if ($annivcat !== false
) {
70 foreach ($notifs->_data
[$annivcat] as $promo) {
71 foreach ($promo as $notif) {
72 if ($all == 'all' ||
$notif['contact']) {
74 'timestamp' => $notif['known'],
75 'date' => strtotime($notif['date']),
76 'tomorrow' => strtotime("+1 day", strtotime($notif['date'])),
77 'bestalias' => $notif['bestalias'],
78 'summary' => 'Anniversaire de '.$notif['prenom']
79 .' '.$notif['nom'].' - x '.$notif['promo'],
84 $page->assign('events', $annivs);
87 header('Content-Type: text/calendar; charset=utf-8');