git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-369
Array(
'url' => 'preferences.php?mail_fmt='.$fmt,
'title' => 'Recevoir les mails en format '.$fmt2,
- 'text' => 'Tu recois es mails envoyés par le site (lettre mensuelle, carnet, ...) de préférence <strong>sous forme de '
+ 'text' => 'Tu recois les mails envoyés par le site (lettre mensuelle, carnet, ...) de préférence <strong>sous forme de '
.Session::get('mail_fmt', 'html').'</strong>',
'weight' => 30
+ ),
+ Array(
+ 'url' => 'preferences.php?rss='.(intval(Session::get('core_rss_hash')=='')),
+ 'title' => (Session::get('core_rss_hash') ? 'désactiver' : 'activer').' les fils rss',
+ 'text' => 'Ceci te permet d\'utiliser les fils rss du site. Attention, désactiver puis réactiver les fils en change les URL !',
+ 'weight' => 40
)
);
}
if ($fmt != 'texte') $fmt = 'html';
$globals->xdb->execute("REPLACE INTO auth_user_quick
SET core_mail_fmt = '$fmt'
- WHERE user_id = {?}", Session::get('uid'));
+ WHERE user_id = {?}", Session::getInt('uid'));
$_SESSION['mail_fmt'] = $fmt;
+ header('Location: preferences.php');
+}
+
+if (Env::has('rss')) {
+ if (Env::getBool('rss')) {
+ $_SESSION['core_rss_hash'] = rand_url_id(16);
+ $globals->xdb->execute('UPDATE auth_user_quick SET core_rss_hash={?} WHERE user_id={?}',
+ Session::get('core_rss_hash'), Session::getInt('uid'));
+ } else {
+ $globals->xdb->execute('UPDATE auth_user_quick SET core_rss_hash="" WHERE user_id={?}', Session::getInt('uid'));
+ Session::kill('core_rss_hash');
+ }
+ header('Location: preferences.php');
}
$page->assign('prefs', $globals->hook->prefs());
***************************************************************************/
require_once('xorg.inc.php');
-new_nonhtml_page('rss.tpl', AUTH_PUBLIC);
-
require_once('rss.inc.php');
+list($alias, $hash) = init_rss('rss.tpl');
+
$rss = $globals->xdb->iterator(
'SELECT e.id, e.titre, e.texte, e.creation_date
- FROM evenements AS e
- WHERE FIND_IN_SET(flags, "valide") AND peremption >= NOW()
- AND (e.promo_min = 0 || e.promo_min <= {?})
- AND (e.promo_max = 0 || e.promo_max >= {?})
- ORDER BY (e.promo_min != 0 AND e.promo_max != 0) DESC, e.peremption',
- Env::getInt('promo', 3000), Env::getInt('promo'));
+ FROM evenements AS e
+ INNER JOIN aliases AS a ON ( a.alias = {?} AND a.type != "homonyme" )
+ INNER JOIN auth_user_quick AS q ON ( a.id = q.user_id AND core_rss_hash = {?} )
+ INNER JOIN auth_user_md5 AS u USING(user_id)
+ WHERE FIND_IN_SET(e.flags, "valide") AND peremption >= NOW()
+ AND (e.promo_min = 0 || e.promo_min <= u.promo)
+ AND (e.promo_max = 0 || e.promo_max >= u.promo)',
+ $alias, $hash);
$page->assign('rss', $rss);
-header('Content-Type: text/xml; charset=utf-8');
$page->run();
?>
}
}
-$page->register_modifier('rss_date', '_rss_encode_date');
-$page->default_modifiers = Array('@to_rss');
-header('Content-Type: text/xml; charset=utf-8');
+function init_rss($template)
+{
+ global $page;
+ new_nonhtml_page($template, AUTH_PUBLIC);
+ $page->register_modifier('rss_date', '_rss_encode_date');
+ $page->default_modifiers = Array('@to_rss');
+
+ if (preg_match(',^/([^/]+)/([^/]+)\.xml$,', $_SERVER['PATH_INFO'], $m)) {
+ $alias = $m[1];
+ $hash = $m[2];
+ } else {
+ exit;
+ }
+
+ header('Content-Type: application/rss+xml; charset=utf8');
+ return Array($alias, $hash);
+}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
{
global $globals;
$res = $globals->xdb->query("
- SELECT u.user_id AS uid, prenom, nom, perms, promo, matricule, UNIX_TIMESTAMP(s.start) AS lastlogin, s.host, q.core_mail_fmt AS mail_fmt,
- a.alias AS forlife, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last,
- a2.alias AS bestalias, password, FIND_IN_SET('femme', u.flags) AS femme
+ SELECT u.user_id AS uid, prenom, nom, perms, promo, matricule, password, FIND_IN_SET('femme', u.flags) AS femme,
+ UNIX_TIMESTAMP(s.start) AS lastlogin, s.host, a.alias AS forlife, a2.alias AS bestalias,
+ q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash
FROM auth_user_md5 AS u
INNER JOIN auth_user_quick AS q USING(user_id)
INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie')
<p>
<a href="evenements.php">Proposer une information événementielle</a>
</p>
+ {if $smarty.session.core_rss_hash}
+ <div class="right">
+ <a href='{rel}/rss.php/{$smarty.session.forlife}/{$smarty.session.core_rss_hash}.xml'><img src='{rel}/images/rssicon.gif' alt='fil rss' /></a>
+ </div>
+ {/if}
{/if}
{* vim:set et sw=2 sts=2 sws=2: *}
alter table auth_user_quick add column profile_nick varchar(64) not null;
alter table auth_user_quick add index(profile_nick);
+alter table auth_user_quick add column core_rss_hash char(32) not null default '';