2 /***************************************************************************
3 * Copyright (C) 2003-2010 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 IF(u.nom_usage = "", u.nom, u.nom_usage) AS nom, u.prenom, u.promo,
48 ev.user_id IS NULL AS nonlu, e.uid
50 LEFT JOIN announce_read AS ev ON (e.id = ev.evt_id AND ev.uid = {?})
51 WHERE FIND_IN_SET("valide", e.flags) AND peremption >= NOW()
52 ORDER BY e.creation_date DESC', S
::i('uid'));
53 $page->assign('event_count', XDB
::query("SELECT FOUND_ROWS()")->fetchOneCell());
55 Platal
::load('events', 'feed.inc.php');
58 while ($e = PlFeed
::nextEvent($events, $user)) {
60 if (count($data) == 5) {
64 $page->assign('events', $data);
67 function handler_ig_search_xml(&$page) {
68 require_once 'gadgets/gadgets.inc.php';
69 init_igoogle_xml('gadgets/ig-search.xml.tpl');
72 function handler_ig_search(&$page)
74 if (Env
::has('quick') && Env
::s('quick') != '') {
75 require_once 'userset.inc.php';
76 $view = new SearchSet(true
);
77 $view->addMod('gadget', 'Gadget', true
);
78 $view->apply(null
, $page);
80 $nb_tot = $view->count();
81 $page->assign('result_count', $nb_tot);
83 if (!S
::logged() && $nb_tot > $globals->search
->public_max
) {
84 $page->assign('error', 'Votre recherche a généré trop de résultats pour un affichage public.');
85 } elseif ($nb_tot > $globals->search
->private_max
) {
86 $page->assign('error', 'Recherche trop générale.');
87 } elseif (empty($nb_tot)) {
88 $page->assign('error', 'Il n\'existe personne correspondant à ces critères dans la base !');
92 require_once 'gadgets/gadgets.inc.php';
93 init_igoogle_html('gadgets/ig-search.tpl', AUTH_PUBLIC
);
97 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: