From 7927d719895927e369649d71e64c21a49e8c1ff3 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sun, 9 Jul 2006 12:53:39 +0000 Subject: [PATCH] factorize filsrss into platal module git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@403 839d8a87-29fc-0310-9880-83ba4fa771e5 --- hooks/tmp.inc.php | 6 +++--- htdocs/filrss.php | 47 ------------------------------------------ modules/platal.php | 51 +++++++++++++++++++++++++++++++++------------- templates/carnet/index.tpl | 2 +- templates/filrss.tpl | 10 ++++----- templates/login.tpl | 2 +- 6 files changed, 47 insertions(+), 71 deletions(-) delete mode 100644 htdocs/filrss.php diff --git a/hooks/tmp.inc.php b/hooks/tmp.inc.php index dcca4ef..07f16c8 100644 --- a/hooks/tmp.inc.php +++ b/hooks/tmp.inc.php @@ -27,7 +27,7 @@ function tmp_menu() $globals->menu->addPrivateEntry(XOM_CUSTOM, 20, 'Mes contacts', 'carnet/mescontacts.php'); $globals->menu->addPrivateEntry(XOM_CUSTOM, 30, 'Mon carnet', 'carnet/'); $globals->menu->addPrivateEntry(XOM_CUSTOM, 40, 'Mon mot de passe', 'password'); - $globals->menu->addPrivateEntry(XOM_CUSTOM, 50, 'Mes préférences', 'preferences'); + $globals->menu->addPrivateEntry(XOM_CUSTOM, 50, 'Mes préférences', 'prefs'); $globals->menu->addPrivateEntry(XOM_GROUPS, 10, 'Trombi/Site promo', 'trombipromo.php'); $globals->menu->addPrivateEntry(XOM_GROUPS, 20, 'Conseil Pro.', 'referent.php'); @@ -76,14 +76,14 @@ function tmp_prefs() $fmt2 = Session::get('mail_fmt', 'html') == 'html' ? 'texte' : 'HTML'; return Array( Array( - 'url' => 'preferences?mail_fmt='.$fmt, + 'url' => 'prefs?mail_fmt='.$fmt, 'title' => 'Recevoir les mails en format '.$fmt2, 'text' => 'Tu recois les mails envoyés par le site (lettre mensuelle, carnet, ...) de préférence sous forme de ' .Session::get('mail_fmt', 'html').'', 'weight' => 80 ), Array( - 'url' => 'preferences?rss='.(intval(Session::get('core_rss_hash')=='')), + 'url' => 'prefs?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' => 90 diff --git a/htdocs/filrss.php b/htdocs/filrss.php deleted file mode 100644 index 85ea594..0000000 --- a/htdocs/filrss.php +++ /dev/null @@ -1,47 +0,0 @@ -assign('goback',$param); -} - -if (Env::has('referer')) { - $act = Env::get('act_rss'); - if ($act == 'Activer') { - $page->trig("Ton Fil RSS est activé."); - $_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')); - } -} - -if (Session::get('core_rss_hash')) { - $page->assign('rsshash','oui'); -} - -$page->run(); - -// vim:set et sws=4 sw=4 sts=4: -?> diff --git a/modules/platal.php b/modules/platal.php index 488743d..c68f8dc 100644 --- a/modules/platal.php +++ b/modules/platal.php @@ -24,13 +24,32 @@ class PlatalModule extends PLModule function handlers() { return array( - 'preferences' => $this->make_hook('prefs', AUTH_COOKIE), + 'prefs' => $this->make_hook('prefs', AUTH_COOKIE), + 'prefs/rss' => $this->make_hook('rss', AUTH_COOKIE), 'password' => $this->make_hook('password', AUTH_MDP), 'tmpPWD' => $this->make_hook('tmpPWD', AUTH_PUBLIC), 'skin' => $this->make_hook('skin', AUTH_COOKIE), ); } + function __set_rss_state($state) + { + global $globals; + + if ($state) { + $_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'); + } + } + function handler_prefs(&$page) { global $globals; @@ -50,19 +69,7 @@ class PlatalModule extends PLModule } 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'); - } - redirect('preferences'); + $this->__set_rss_state(Env::getBool('rss')); } $page->assign('prefs', $globals->hook->prefs()); @@ -70,6 +77,22 @@ class PlatalModule extends PLModule return PL_OK; } + function handler_rss(&$page) + { + global $globals; + + $page->changeTpl('filrss.tpl'); + + $page->assign('goback', Env::get('referer', 'login')); + + if (Env::get('act_rss') == 'Activer') { + $this->__set_rss_state(true); + $page->trig("Ton Fil RSS est activé."); + } + + return PL_OK; + } + function handler_password(&$page) { global $globals; diff --git a/templates/carnet/index.tpl b/templates/carnet/index.tpl index 4a8c3ff..031d49f 100644 --- a/templates/carnet/index.tpl +++ b/templates/carnet/index.tpl @@ -69,7 +69,7 @@ {else}
- fil rss + fil rss
{/if} diff --git a/templates/filrss.tpl b/templates/filrss.tpl index dd32c20..9d3f250 100644 --- a/templates/filrss.tpl +++ b/templates/filrss.tpl @@ -22,7 +22,7 @@

Fil RSS

-{if !$rsshash } +{if !$smarty.session.core_rss_hash} Tu viens de cliquer sur le lien d'activation des fils RSS. Les fils RSS du site
ne sont pas activés dans tes préférences. -
+
- - + +
@@ -63,6 +63,6 @@ Tu peux le d

Attention: désactiver, puis réactiver le fil RSS en change l'adresse.

-

[retour à la page dont tu venais]

+

[retour à la page dont tu venais]

{/if} {* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/login.tpl b/templates/login.tpl index d574cee..533a425 100644 --- a/templates/login.tpl +++ b/templates/login.tpl @@ -148,7 +148,7 @@ Bienvenue {$smarty.session.prenom} {else}
- fil rss + fil rss
{/if} {/if} -- 2.1.4