From 1a828cd480b996f34130551073c5148fd0fe035e Mon Sep 17 00:00:00 2001
From: x2000habouzit
Date: Tue, 11 Jul 2006 19:27:48 +0000
Subject: [PATCH] exit login.php, welcome events/
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@438 839d8a87-29fc-0310-9880-83ba4fa771e5
---
hooks/tmp.inc.php | 2 +-
htdocs/login.php | 116 ------------------------------------------
modules/core.php | 4 +-
modules/events.php | 119 +++++++++++++++++++++++++++++++++++++++++++-
templates/evenements.tpl | 2 +-
templates/index.tpl | 2 +-
templates/login.tpl | 2 +-
templates/rss.tpl | 2 +-
templates/skin/default.tpl | 6 +--
templates/skin/espace.tpl | 6 +--
templates/skin/humlinux.tpl | 4 +-
templates/skin/linux.tpl | 6 +--
templates/skin/liteskin.tpl | 4 +-
templates/skin/nbviolet.tpl | 6 +--
templates/skin/newxorg.tpl | 4 +-
templates/skin/oldtimes.tpl | 6 +--
templates/skin/openweb.tpl | 4 +-
templates/skin/sharky.tpl | 4 +-
templates/skin/spectral.tpl | 6 +--
templates/skin/trapped.tpl | 6 +--
20 files changed, 155 insertions(+), 156 deletions(-)
delete mode 100644 htdocs/login.php
diff --git a/hooks/tmp.inc.php b/hooks/tmp.inc.php
index dcc6681..db8e254 100644
--- a/hooks/tmp.inc.php
+++ b/hooks/tmp.inc.php
@@ -45,7 +45,7 @@ function tmp_menu()
$globals->menu->addPrivateEntry(XOM_ADMIN, 30, 'Trackers', 'http://trackers.polytechnique.org');
$globals->menu->addPrivateEntry(XOM_ADMIN, 40, 'Support', 'http://support.polytechnique.org');
- $globals->menu->addPublicEntry(XOM_US, 00, 'Me connecter !', 'login.php');
+ $globals->menu->addPublicEntry(XOM_US, 00, 'Me connecter !', 'events');
$globals->menu->addPublicEntry(XOM_US, 10, 'M\'inscrire', 'register/');
$globals->menu->addPublicEntry(XOM_US, 20, 'Pourquoi m\'inscrire ?', 'Docs/PourquoiM\'Inscrire');
diff --git a/htdocs/login.php b/htdocs/login.php
deleted file mode 100644
index 6de9a2f..0000000
--- a/htdocs/login.php
+++ /dev/null
@@ -1,116 +0,0 @@
-xdb->query('SELECT date, naissance FROM auth_user_md5 WHERE user_id={?}', Session::getInt('uid'));
-list($date, $naissance) = $res->fetchOneRow();
-
-// incitation à mettre à jour la fiche
-
-$d2 = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4));
-if( (time() - $d2) > 60 * 60 * 24 * 400 ) {
- // si fiche date de + de 400j;
- $page->assign('fiche_incitation', $date);
-}
-
-// Souhaite bon anniversaire
-
-if (substr($naissance, 5) == date("m-d")) {
- $page->assign('birthday', date("Y") - substr($naissance, 0, 4));
-}
-
-// incitation à mettre une photo
-
-$res = $globals->xdb->query('SELECT COUNT(*) FROM photo WHERE uid={?}', Session::getInt('uid'));
-$page->assign('photo_incitation', $res->fetchOneCell() == 0);
-
-// Incitation à se géolocaliser
-require_once('geoloc.inc.php');
-$res = localize_addresses(Session::getInt('uid', -1));
-$page->assign('geoloc_incitation', count($res));
-
-// affichage de la boîte avec quelques liens
-
-require_once('login.conf.php') ;
-$pub_nbElem = $pub_nbLig * $pub_nbCol ;
-if (count($pub_tjs) <= $pub_nbElem)
- $publicite = array_slice ($pub_tjs,0,$pub_nbElem) ;
-else
- $publicite = $pub_tjs ;
-$nbAlea = $pub_nbElem - count($publicite) ;
-if ($nbAlea > 0) {
- $choix = array_rand($pub_rnd,$nbAlea) ;
- foreach ($choix as $url)
- $publicite[$url] = $pub_rnd[$url] ;
- }
-$publicite = array_chunk( $publicite , $pub_nbLig , true ) ;
-$page->assign_by_ref('publicite', $publicite);
-
-// ajout du lien RSS
-
-if (Session::has('core_rss_hash')) {
- $page->assign('xorg_rss',
- array("title" => "Polytechnique.org :: News",
- "href" => "/rss/".Session::get('forlife')."/".Session::get('core_rss_hash')."/rss.xml"));
-}
-
-// cache les evenements lus et raffiche les evenements a relire
-if (Env::has('lu')){
- $globals->xdb->execute('DELETE FROM evenements_vus AS ev INNER JOIN evenements AS e ON e.id = ev.evt_id WHERE peremption < NOW)');
- $globals->xdb->execute('REPLACE INTO evenements_vus VALUES({?},{?})', Env::get('lu'), Session::getInt('uid'));
-}
-if (Env::has('nonlu')){
- $globals->xdb->execute('DELETE FROM evenements_vus WHERE evt_id = {?} AND user_id = {?}', Env::get('nonlu'), Session::getInt('uid'));
-}
-
-// affichage des evenements
-// annonces promos triées par présence d'une limite sur les promos
-// puis par dates croissantes d'expiration
-$promo = Session::getInt('promo');
-$sql = "SELECT e.id,e.titre,e.texte,a.user_id,a.nom,a.prenom,a.promo,l.alias AS forlife
- FROM evenements AS e
- INNER JOIN auth_user_md5 AS a ON e.user_id=a.user_id
- INNER JOIN aliases AS l ON ( a.user_id=l.id AND l.type='a_vie' )
- LEFT JOIN evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?})
- WHERE FIND_IN_SET(e.flags, 'valide') AND peremption >= NOW()
- AND (e.promo_min = 0 || e.promo_min <= {?})
- AND (e.promo_max = 0 || e.promo_max >= {?})
- AND ev.user_id IS NULL
- ORDER BY (e.promo_min != 0 AND e.promo_max != 0) DESC, e.peremption";
-$page->assign('evenement', $globals->xdb->iterator($sql, Session::getInt('uid'), $promo, $promo));
-
-$sql = "SELECT e.id,e.titre, ev.user_id IS NULL AS nonlu
- FROM evenements AS e
- LEFT JOIN evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?})
- WHERE FIND_IN_SET(e.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";
-$page->assign('evenement_summary', $globals->xdb->iterator($sql, Session::getInt('uid'), $promo, $promo));
-
-$page->assign('refe',$_SERVER['PHP_SELF']);
-
-$page->run();
-
-// vim:set et sws=4 sw=4 sts=4:
-?>
diff --git a/modules/core.php b/modules/core.php
index e627078..1998766 100644
--- a/modules/core.php
+++ b/modules/core.php
@@ -50,7 +50,7 @@ class CoreModule extends PLModule
function handler_index(&$page)
{
if (logged()) {
- redirect("login.php");
+ redirect("events");
}
return PL_OK;
@@ -86,7 +86,7 @@ class CoreModule extends PLModule
Session::kill('suid');
redirect($globals->baseurl.'/admin/utilisateurs.php?login='.$a4l);
} else {
- redirect("login.php");
+ redirect("events");
}
}
diff --git a/modules/events.php b/modules/events.php
index 6169b82..b244729 100644
--- a/modules/events.php
+++ b/modules/events.php
@@ -24,7 +24,8 @@ class EventsModule extends PLModule
function handlers()
{
return array(
- 'events/submit' => $this->make_hook('submit', AUTH_MDP),
+ 'events' => $this->make_hook('ev', AUTH_COOKIE),
+ 'events/submit' => $this->make_hook('ev_submit', AUTH_MDP),
'nl' => $this->make_hook('nl', AUTH_COOKIE),
'nl/show' => $this->make_hook('nl_show', AUTH_COOKIE),
@@ -32,7 +33,121 @@ class EventsModule extends PLModule
);
}
- function handler_submit(&$page)
+ function handler_ev(&$page)
+ {
+ global $globals;
+
+ $page->changeTpl('login.tpl');
+
+ $res = $globals->xdb->query('SELECT date, naissance FROM auth_user_md5
+ WHERE user_id={?}', Session::getInt('uid'));
+ list($date, $naissance) = $res->fetchOneRow();
+
+ // incitation à mettre à jour la fiche
+
+ $d2 = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2),
+ substr($date, 0, 4));
+ if( (time() - $d2) > 60 * 60 * 24 * 400 ) {
+ // si fiche date de + de 400j;
+ $page->assign('fiche_incitation', $date);
+ }
+
+ // Souhaite bon anniversaire
+
+ if (substr($naissance, 5) == date('m-d')) {
+ $page->assign('birthday', date('Y') - substr($naissance, 0, 4));
+ }
+
+ // incitation à mettre une photo
+
+ $res = $globals->xdb->query('SELECT COUNT(*) FROM photo
+ WHERE uid={?}', Session::getInt('uid'));
+ $page->assign('photo_incitation', $res->fetchOneCell() == 0);
+
+ // Incitation à se géolocaliser
+ require_once 'geoloc.inc.php';
+ $res = localize_addresses(Session::getInt('uid', -1));
+ $page->assign('geoloc_incitation', count($res));
+
+ // affichage de la boîte avec quelques liens
+ require_once 'login.conf.php';
+ $pub_nbElem = $pub_nbLig * $pub_nbCol ;
+ if (count($pub_tjs) <= $pub_nbElem) {
+ $publicite = array_slice($pub_tjs, 0, $pub_nbElem);
+ } else {
+ $publicite = $pub_tjs ;
+ }
+
+ $nbAlea = $pub_nbElem - count($publicite) ;
+ if ($nbAlea > 0) {
+ $choix = array_rand($pub_rnd,$nbAlea) ;
+ foreach ($choix as $url) {
+ $publicite[$url] = $pub_rnd[$url] ;
+ }
+ }
+ $publicite = array_chunk( $publicite , $pub_nbLig , true ) ;
+ $page->assign_by_ref('publicite', $publicite);
+
+ // ajout du lien RSS
+
+ if (Session::has('core_rss_hash')) {
+ $page->assign('xorg_rss',
+ array('title' => 'Polytechnique.org :: News',
+ 'href' => '/rss/'.Session::get('forlife')
+ .'/'.Session::get('core_rss_hash').'/rss.xml')
+ );
+ }
+
+ // cache les evenements lus et raffiche les evenements a relire
+ if (Env::has('lu')){
+ $globals->xdb->execute('DELETE FROM evenements_vus AS ev
+ INNER JOIN evenements AS e ON e.id = ev.evt_id
+ WHERE peremption < NOW)');
+ $globals->xdb->execute('REPLACE INTO evenements_vus VALUES({?},{?})',
+ Env::get('lu'), Session::getInt('uid'));
+ }
+
+ if (Env::has('nonlu')){
+ $globals->xdb->execute('DELETE FROM evenements_vus
+ WHERE evt_id = {?} AND user_id = {?}',
+ Env::get('nonlu'), Session::getInt('uid'));
+ }
+
+ // affichage des evenements
+ // annonces promos triées par présence d'une limite sur les promos
+ // puis par dates croissantes d'expiration
+ $promo = Session::getInt('promo');
+ $sql = "SELECT e.id,e.titre,e.texte,a.user_id,a.nom,a.prenom,a.promo,l.alias AS forlife
+ FROM evenements AS e
+ INNER JOIN auth_user_md5 AS a ON e.user_id=a.user_id
+ INNER JOIN aliases AS l ON ( a.user_id=l.id AND l.type='a_vie' )
+ LEFT JOIN evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?})
+ WHERE FIND_IN_SET(e.flags, 'valide') AND peremption >= NOW()
+ AND (e.promo_min = 0 || e.promo_min <= {?})
+ AND (e.promo_max = 0 || e.promo_max >= {?})
+ AND ev.user_id IS NULL
+ ORDER BY (e.promo_min != 0 AND e.promo_max != 0) DESC, e.peremption";
+ $page->assign('evenement',
+ $globals->xdb->iterator($sql, Session::getInt('uid'),
+ $promo, $promo)
+ );
+
+ $sql = "SELECT e.id,e.titre, ev.user_id IS NULL AS nonlu
+ FROM evenements AS e
+ LEFT JOIN evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?})
+ WHERE FIND_IN_SET(e.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";
+ $page->assign('evenement_summary',
+ $globals->xdb->iterator($sql, Session::getInt('uid'),
+ $promo, $promo)
+ );
+
+ return PL_OK;
+ }
+
+ function handler_ev_submit(&$page)
{
global $globals;
$page->changeTpl('evenements.tpl');
diff --git a/templates/evenements.tpl b/templates/evenements.tpl
index 6287875..dd9ea0e 100644
--- a/templates/evenements.tpl
+++ b/templates/evenements.tpl
@@ -73,7 +73,7 @@ Ta proposition a bien
Merci pour ta contribution à la vie du site!
-Retour à la page d'accueil
+Retour à la page d'accueil
{else}
diff --git a/templates/index.tpl b/templates/index.tpl
index 666b8c3..903a05b 100644
--- a/templates/index.tpl
+++ b/templates/index.tpl
@@ -39,7 +39,7 @@
Si vous êtes polytechnicien,
Vous pouvez consulter la liste de ce que vous apporte Polytechnique.org si vous hésitez à vous inscrire !
diff --git a/templates/login.tpl b/templates/login.tpl
index c6f552d..3b3800d 100644
--- a/templates/login.tpl
+++ b/templates/login.tpl
@@ -148,7 +148,7 @@ Bienvenue {$smarty.session.prenom}
{else}
-
+
{/if}
{/if}
diff --git a/templates/rss.tpl b/templates/rss.tpl
index 3b98f42..729874c 100644
--- a/templates/rss.tpl
+++ b/templates/rss.tpl
@@ -54,7 +54,7 @@
{iterate item=line from=$rss}
-
{$line.titre|strip_tags}
- {#globals.baseurl#}/login.php#newsid{$line.id}
+ {#globals.baseurl#}/events#newsid{$line.id}
{$line.creation_date|rss_date}
diff --git a/templates/skin/default.tpl b/templates/skin/default.tpl
index 2096d7f..34ee9fd 100644
--- a/templates/skin/default.tpl
+++ b/templates/skin/default.tpl
@@ -53,12 +53,12 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
-
+
diff --git a/templates/skin/espace.tpl b/templates/skin/espace.tpl
index 26154dc..0828526 100644
--- a/templates/skin/espace.tpl
+++ b/templates/skin/espace.tpl
@@ -55,12 +55,12 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
-
+
diff --git a/templates/skin/humlinux.tpl b/templates/skin/humlinux.tpl
index 4d3aa44..9d0fc81 100644
--- a/templates/skin/humlinux.tpl
+++ b/templates/skin/humlinux.tpl
@@ -55,10 +55,10 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
diff --git a/templates/skin/linux.tpl b/templates/skin/linux.tpl
index 92cbbb6..c371c7d 100644
--- a/templates/skin/linux.tpl
+++ b/templates/skin/linux.tpl
@@ -55,12 +55,12 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
-
+
diff --git a/templates/skin/liteskin.tpl b/templates/skin/liteskin.tpl
index 1adc6d9..31cc624 100644
--- a/templates/skin/liteskin.tpl
+++ b/templates/skin/liteskin.tpl
@@ -55,10 +55,10 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
diff --git a/templates/skin/nbviolet.tpl b/templates/skin/nbviolet.tpl
index 2cfca74..56ea229 100644
--- a/templates/skin/nbviolet.tpl
+++ b/templates/skin/nbviolet.tpl
@@ -55,12 +55,12 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
-
+
diff --git a/templates/skin/newxorg.tpl b/templates/skin/newxorg.tpl
index eaf78e5..c3ad976 100644
--- a/templates/skin/newxorg.tpl
+++ b/templates/skin/newxorg.tpl
@@ -55,10 +55,10 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
diff --git a/templates/skin/oldtimes.tpl b/templates/skin/oldtimes.tpl
index 3f6877f..4126833 100644
--- a/templates/skin/oldtimes.tpl
+++ b/templates/skin/oldtimes.tpl
@@ -55,12 +55,12 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
-
+
diff --git a/templates/skin/openweb.tpl b/templates/skin/openweb.tpl
index 3785551..bec2b93 100644
--- a/templates/skin/openweb.tpl
+++ b/templates/skin/openweb.tpl
@@ -54,10 +54,10 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
diff --git a/templates/skin/sharky.tpl b/templates/skin/sharky.tpl
index f54fa82..3fb36e0 100644
--- a/templates/skin/sharky.tpl
+++ b/templates/skin/sharky.tpl
@@ -55,10 +55,10 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
diff --git a/templates/skin/spectral.tpl b/templates/skin/spectral.tpl
index a50dd07..9b6fc9c 100644
--- a/templates/skin/spectral.tpl
+++ b/templates/skin/spectral.tpl
@@ -55,12 +55,12 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
-
+
diff --git a/templates/skin/trapped.tpl b/templates/skin/trapped.tpl
index d0b062f..c1ca1ce 100644
--- a/templates/skin/trapped.tpl
+++ b/templates/skin/trapped.tpl
@@ -55,12 +55,12 @@
-
+
-
+
{include file="skin/common.title.header.tpl"}
-
+
--
2.1.4