X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fevents.php;h=dfe3fd591fc12f3abe10b82582b8551a086b0d9d;hb=8b1f8e12d444062ef63a0db3a8fa94582a9778c3;hp=36451f4357cbe4a0346017b735822539e4632c49;hpb=dc767839c54aa6d6d2910da5b818b43c5306cfc3;p=platal.git diff --git a/modules/events.php b/modules/events.php index 36451f4..dfe3fd5 100644 --- a/modules/events.php +++ b/modules/events.php @@ -25,7 +25,7 @@ class EventsModule extends PLModule { return array( 'events' => $this->make_hook('ev', AUTH_COOKIE), - 'send_bug' => $this->make_hook('bug', AUTH_COOKIE), + 'rss' => $this->make_hook('rss', AUTH_PUBLIC), 'events/submit' => $this->make_hook('ev_submit', AUTH_MDP), 'admin/events' => $this->make_hook('admin_events', AUTH_MDP, 'admin'), @@ -34,7 +34,7 @@ class EventsModule extends PLModule 'nl' => $this->make_hook('nl', AUTH_COOKIE), 'nl/show' => $this->make_hook('nl_show', AUTH_COOKIE), - 'nl/submit' => $this->make_hook('nl_submit', AUTH_COOKIE), + 'nl/submit' => $this->make_hook('nl_submit', AUTH_MDP), 'admin/newsletter' => $this->make_hook('admin_nl', AUTH_MDP, 'admin'), 'admin/newsletter/categories' => $this->make_hook('admin_nl_cat', AUTH_MDP, 'admin'), 'admin/newsletter/edit' => $this->make_hook('admin_nl_edit', AUTH_MDP, 'admin'), @@ -59,6 +59,7 @@ class EventsModule extends PLModule AND (promo_min = 0 OR promo_min <= {?}) AND (promo_max = 0 OR promo_max >= {?}) AND (priorite >= {?}) + AND (state = 'active') $exclude ORDER BY RAND() LIMIT 1", @@ -70,21 +71,12 @@ class EventsModule extends PLModule return $res->fetchOneAssoc(); } - function handler_bug(&$page) - { - $this->handler_ev($page); - $page->assign('bug', 1); - } - function handler_ev(&$page, $action = 'list', $eid = null, $pound = null) { - $page->changeTpl('login.tpl'); + $page->changeTpl('events/index.tpl'); $page->addJsLink('ajax.js'); $page->assign('tips', $this->get_tips()); - // donne la derniere date de session - $page->assign('lastlogin', strftime("%Y%m%d%H%M%S",S::i('lastlogin'))); - $res = XDB::query('SELECT date, naissance FROM auth_user_md5 WHERE user_id={?}', S::v('uid')); list($date, $naissance) = $res->fetchOneRow(); @@ -171,9 +163,27 @@ class EventsModule extends PLModule ); } + function handler_rss(&$page, $user = null, $hash = null) + { + require_once 'rss.inc.php'; + + $uid = init_rss('events/rss.tpl', $user, $hash); + + $rss = XDB::iterator( + 'SELECT e.id, e.titre, e.texte, e.creation_date, + IF(u2.nom_usage = "", u2.nom, u2.nom_usage) AS nom, u2.prenom, u2.promo + FROM auth_user_md5 AS u + INNER JOIN evenements AS e ON ( (e.promo_min = 0 || e.promo_min <= u.promo) + AND (e.promo_max = 0 || e.promo_max >= u.promo) ) + INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = e.user_id) + WHERE u.user_id = {?} AND FIND_IN_SET(e.flags, "valide") + AND peremption >= NOW()', $uid); + $page->assign('rss', $rss); + } + function handler_ev_submit(&$page) { - $page->changeTpl('evenements.tpl'); + $page->changeTpl('events/submit.tpl'); $titre = Post::v('titre'); $texte = Post::v('texte'); @@ -183,7 +193,7 @@ class EventsModule extends PLModule $valid_mesg = Post::v('valid_mesg'); $action = Post::v('action'); - if ($promo_min > $promo_max || + if (($promo_min > $promo_max && $promo_max != 0)|| ($promo_min != 0 && ($promo_min <= 1900 || $promo_min >= 2020)) || ($promo_max != 0 && ($promo_max <= 1900 || $promo_max >= 2020))) { @@ -244,6 +254,7 @@ class EventsModule extends PLModule $table_editor->describe('promo_min', 'promo. min (0 aucune)', false); $table_editor->describe('promo_max', 'promo. max (0 aucune)', false); $table_editor->describe('titre', 'titre', true); + $table_editor->describe('state', 'actif', true); $table_editor->describe('text', 'texte (html) de l\'astuce', false); $table_editor->describe('priorite', 'priorité (0=min, 256=max)', false); $table_editor->apply($page, $action, $id); @@ -302,7 +313,7 @@ class EventsModule extends PLModule function handler_admin_events(&$page, $action = 'list', $eid = null) { - $page->changeTpl('admin/evenements.tpl'); + $page->changeTpl('events/admin_events.tpl'); $page->assign('xorg_title','Polytechnique.org - Administration - Evenements'); $page->register_modifier('hde', 'html_entity_decode');