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 PlatalModule
extends PLModule
27 'preferences' => $this->make_hook('prefs', AUTH_COOKIE
),
28 'skin' => $this->make_hook('skin', AUTH_COOKIE
),
32 function handler_prefs(&$page)
36 $page->changeTpl('preferences.tpl');
37 $page->assign('xorg_title','Polytechnique.org - Mes préférences');
39 if (Env
::has('mail_fmt')) {
40 $fmt = Env
::get('mail_fmt');
41 if ($fmt != 'texte') $fmt = 'html';
42 $globals->xdb
->execute("UPDATE auth_user_quick
43 SET core_mail_fmt = '$fmt'
45 Session
::getInt('uid'));
46 $_SESSION['mail_fmt'] = $fmt;
47 redirect('preferences');
50 if (Env
::has('rss')) {
51 if (Env
::getBool('rss')) {
52 $_SESSION['core_rss_hash'] = rand_url_id(16);
53 $globals->xdb
->execute('UPDATE auth_user_quick
54 SET core_rss_hash={?} WHERE user_id={?}',
55 Session
::get('core_rss_hash'),
56 Session
::getInt('uid'));
58 $globals->xdb
->execute('UPDATE auth_user_quick
59 SET core_rss_hash="" WHERE user_id={?}',
60 Session
::getInt('uid'));
61 Session
::kill('core_rss_hash');
63 redirect('preferences');
66 $page->assign('prefs', $globals->hook
->prefs());
71 function handler_skin(&$page)
75 if (!$globals->skin
->enable
) {
79 $page->changeTpl('skins.tpl');
80 $page->assign('xorg_title','Polytechnique.org - Skins');
82 if (Env
::has('newskin')) { // formulaire soumis, traitons les données envoyées
83 $globals->xdb
->execute('UPDATE auth_user_quick
84 SET skin={?} WHERE user_id={?}',
85 Env
::getInt('newskin'),
86 Session
::getInt('uid'));
90 $sql = "SELECT s.*,auteur,count(*) AS nb
92 LEFT JOIN auth_user_quick AS a ON s.id=a.skin
93 WHERE skin_tpl != '' AND ext != ''
94 GROUP BY id ORDER BY s.date DESC";
95 $page->assign_by_ref('skins', $globals->xdb
->iterator($sql));