From bce2f8ebbaa025a5b3425648c679a70b2092016c Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sun, 9 Jul 2006 21:32:22 +0000 Subject: [PATCH] merge webredirect also git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@409 839d8a87-29fc-0310-9880-83ba4fa771e5 --- hooks/webredirect.inc.php | 2 +- htdocs/webredirect.php | 54 ----------------------------------------------- modules/platal.php | 38 +++++++++++++++++++++++++++++++++ templates/webredirect.tpl | 14 ++++-------- 4 files changed, 43 insertions(+), 65 deletions(-) delete mode 100644 htdocs/webredirect.php diff --git a/hooks/webredirect.inc.php b/hooks/webredirect.inc.php index d074618..47c46b6 100644 --- a/hooks/webredirect.inc.php +++ b/hooks/webredirect.inc.php @@ -48,7 +48,7 @@ function webredirect_prefs() return Array( Array( - 'url' => 'webredirect.php', + 'url' => 'prefs/webredirect', 'title' => 'Ma redirection de page WEB', 'text' => $text, 'weight' => 60 diff --git a/htdocs/webredirect.php b/htdocs/webredirect.php deleted file mode 100644 index 1643d00..0000000 --- a/htdocs/webredirect.php +++ /dev/null @@ -1,54 +0,0 @@ -assign('xorg_title','Polytechnique.org - Redirection de page WEB'); - -$log =& Session::getMixed('log'); -$url = Env::get('url'); - -if ((Env::get('submit') == 'Valider' or Env::get('submit') == 'Modifier') and Env::has('url')) { - if ($globals->xdb->execute('UPDATE auth_user_quick SET redirecturl = {?} WHERE user_id = {?}', - $url, Session::getInt('uid'))) - { - $log->log('carva_add', 'http://'.Env::get('url')); - $page->trig("Redirection activée vers $url"); - } else { - $page->trig('Erreur de mise à jour'); - } -} elseif (Env::get('submit') == "Supprimer") { - if ($globals->xdb->execute("UPDATE auth_user_quick SET redirecturl = '' WHERE user_id = {?}", Session::getInt('uid'))) - { - $log->log("carva_del", $url); - Post::kill('url'); - $page->trig('Redirection supprimée'); - } else { - $page->trig('Erreur de suppression'); - } -} - - -$res = $globals->xdb->query('SELECT redirecturl FROM auth_user_quick WHERE user_id = {?}', Session::getInt('uid')); -$page->assign('carva', $res->fetchOneCell()); - -$page->run(); -?> diff --git a/modules/platal.php b/modules/platal.php index fe02ded..d6057b0 100644 --- a/modules/platal.php +++ b/modules/platal.php @@ -27,6 +27,8 @@ class PlatalModule extends PLModule // Preferences thingies 'prefs' => $this->make_hook('prefs', AUTH_COOKIE), 'prefs/rss' => $this->make_hook('prefs_rss', AUTH_COOKIE), + 'prefs/webredirect' + => $this->make_hook('webredir', AUTH_MDP), 'skin' => $this->make_hook('skin', AUTH_COOKIE), // password related thingies @@ -85,6 +87,42 @@ class PlatalModule extends PLModule return PL_OK; } + function handler_webredir(&$page) + { + global $globals; + + $page->changeTpl('webredirect.tpl'); + + $page->assign('xorg_title','Polytechnique.org - Redirection de page WEB'); + + $log =& Session::getMixed('log'); + $url = Env::get('url'); + + if (Env::get('submit') == 'Valider' and Env::has('url')) { + $globals->xdb->execute('UPDATE auth_user_quick + SET redirecturl = {?} WHERE user_id = {?}', + $url, Session::getInt('uid'))) + $log->log('carva_add', 'http://'.Env::get('url')); + $page->trig("Redirection activée vers $url"); + } elseif (Env::get('submit') == "Supprimer") { + $globals->xdb->execute("UPDATE auth_user_quick + SET redirecturl = '' + WHERE user_id = {?}", + Session::getInt('uid'))) + $log->log("carva_del", $url); + Post::kill('url'); + $page->trig('Redirection supprimée'); + } + + $res = $globals->xdb->query('SELECT redirecturl + FROM auth_user_quick + WHERE user_id = {?}', + Session::getInt('uid')); + $page->assign('carva', $res->fetchOneCell()); + + return PL_OK; + } + function handler_prefs_rss(&$page) { global $globals; diff --git a/templates/webredirect.tpl b/templates/webredirect.tpl index ec8ff14..9b00a09 100644 --- a/templates/webredirect.tpl +++ b/templates/webredirect.tpl @@ -58,7 +58,7 @@

- Pour modifier cette redirection remplis le champ suivant et clique sur Modifier. + Pour modifier cette redirection remplis le champ suivant et clique sur Valider. {if $carva} Si tu veux annuler ta redirection, clique sur Supprimer. {/if} @@ -80,18 +80,12 @@ -{if $carva} - - - - - - -{else} - +{if $carva} + {/if} + -- 2.1.4