2 /***************************************************************************
3 * Copyright (C) 2003-2011 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 GadgetsModule
extends PLModule
27 'gadgets/ig-events.xml' => $this->make_hook('ig_events_xml', AUTH_PUBLIC
, 'user', NO_HTTPS
),
28 'gadgets/ig-events' => $this->make_hook('ig_events', AUTH_PUBLIC
),
29 'gadgets/ig-search.xml' => $this->make_hook('ig_search_xml', AUTH_PUBLIC
, 'user', NO_HTTPS
),
30 'gadgets/ig-search' => $this->make_hook('ig_search', AUTH_PUBLIC
),
34 function handler_ig_events_xml($page)
36 require_once 'gadgets/gadgets.inc.php';
37 init_igoogle_xml('gadgets/ig-events.xml.tpl');
40 function handler_ig_events($page)
42 require_once 'gadgets/gadgets.inc.php';
43 init_igoogle_html('gadgets/ig-events.tpl', AUTH_COOKIE
);
45 $events = XDB
::iterator("SELECT SQL_CALC_FOUND_ROWS
46 e.id, e.titre, UNIX_TIMESTAMP(e.creation_date) AS creation_date,
47 ev.uid IS NULL AS nonlu, e.uid
49 LEFT JOIN announce_read AS ev ON (e.id = ev.evt_id AND ev.uid = {?})
50 WHERE FIND_IN_SET('valide', e.flags) AND expiration >= NOW()
51 ORDER BY e.creation_date DESC", S
::i('uid'));
52 $page->assign('event_count', XDB
::query("SELECT FOUND_ROWS()")->fetchOneCell());
54 Platal
::load('events', 'feed.inc.php');
57 while ($e = PlFeed
::nextEvent($events, $user)) {
59 if (count($data) == 5) {
63 $page->assign('events', $data);
66 function handler_ig_search_xml($page) {
67 require_once 'gadgets/gadgets.inc.php';
68 init_igoogle_xml('gadgets/ig-search.xml.tpl');
71 function handler_ig_search($page)
73 if (Env
::has('quick') && Env
::s('quick') != '') {
75 require_once 'userset.inc.php';
77 $view = new QuickSearchSet();
78 $view->addMod('gadget', 'Gadget', true
);
79 $view->apply(null
, $page);
81 $nb_tot = $view->count();
82 $page->assign('result_count', $nb_tot);
84 if (!S
::logged() && $nb_tot > $globals->search
->public_max
) {
85 $page->assign('error', 'Votre recherche a généré trop de résultats pour un affichage public.');
86 } elseif ($nb_tot > $globals->search
->private_max
) {
87 $page->assign('error', 'Recherche trop générale.');
88 } elseif (empty($nb_tot)) {
89 $page->assign('error', 'Il n\'existe personne correspondant à ces critères dans la base !');
91 $page->assign('error', false
);
95 require_once 'gadgets/gadgets.inc.php';
96 init_igoogle_html('gadgets/ig-search.tpl', AUTH_PUBLIC
);
100 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: