From 926f16d7860ec40a239507807d8f7c2392b14121 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Tue, 11 Jul 2006 20:38:09 +0000 Subject: [PATCH] migrate nomusage.php git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@445 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs/nomusage.php | 59 -------------------------------------------- modules/profile.php | 53 ++++++++++++++++++++++++++++++++++++--- templates/nomusage.tpl | 2 +- templates/profil/general.tpl | 2 +- 4 files changed, 51 insertions(+), 65 deletions(-) delete mode 100644 htdocs/nomusage.php diff --git a/htdocs/nomusage.php b/htdocs/nomusage.php deleted file mode 100644 index 02320fe..0000000 --- a/htdocs/nomusage.php +++ /dev/null @@ -1,59 +0,0 @@ -xdb->query( - "SELECT u.nom,u.nom_usage,u.flags,e.alias - FROM auth_user_md5 AS u - LEFT JOIN aliases AS e ON(u.user_id = e.id AND FIND_IN_SET('usage',e.flags)) - WHERE user_id={?}", Session::getInt('uid')); - -list($nom,$usage_old,$flags,$alias_old) = $res->fetchOneRow(); -$flags = new flagset($flags); -$page->assign('usage_old', $usage_old); -$page->assign('alias_old', $alias_old); - -$nom_usage = replace_accent(trim(Env::get('nom_usage'))); -$nom_usage = strtoupper($nom_usage); -$page->assign('usage_req', $nom_usage); - -if (Env::has('submit') && ($nom_usage != $usage_old)) { - // on vient de recevoir une requete, differente de l'ancien nom d'usage - if ($nom_usage == $nom) { - $page->assign('same', true); - } else { // le nom de mariage est distinct du nom à l'X - // on calcule l'alias pour l'afficher - $reason = Env::get('reason'); - if ($reason == 'other') - $reason = Env::get('other_reason'); - $myusage = new UsageReq(Session::getInt('uid'), $nom_usage, $reason); - $myusage->submit(); - $page->assign('myusage', $myusage); - } -} - -$page->run(); -?> diff --git a/modules/profile.php b/modules/profile.php index 1f22180..a211b13 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -24,12 +24,14 @@ class ProfileModule extends PLModule function handlers() { return array( - 'photo' => $this->make_hook('photo', AUTH_PUBLIC), - 'photo/change' => $this->make_hook('photo_change', AUTH_MDP), + 'photo' => $this->make_hook('photo', AUTH_PUBLIC), + 'photo/change' => $this->make_hook('photo_change', AUTH_MDP), - 'trombi' => $this->make_hook('trombi', AUTH_COOKIE), + 'profile/usage' => $this->make_hook('p_usage', AUTH_MDP), - 'vcard' => $this->make_hook('vcard', AUTH_COOKIE), + 'trombi' => $this->make_hook('trombi', AUTH_COOKIE), + + 'vcard' => $this->make_hook('vcard', AUTH_COOKIE), ); } @@ -142,6 +144,49 @@ class ProfileModule extends PLModule return PL_OK; } + function handler_p_usage(&$page) + { + global $globals; + + $page->changeTpl('nomusage.tpl'); + + require_once 'validations.inc.php'; + require_once 'xorg.misc.inc.php'; + + $res = $globals->xdb->query( + "SELECT u.nom,u.nom_usage,u.flags,e.alias + FROM auth_user_md5 AS u + LEFT JOIN aliases AS e ON(u.user_id = e.id AND FIND_IN_SET('usage',e.flags)) + WHERE user_id={?}", Session::getInt('uid')); + + list($nom,$usage_old,$flags,$alias_old) = $res->fetchOneRow(); + $flags = new flagset($flags); + $page->assign('usage_old', $usage_old); + $page->assign('alias_old', $alias_old); + + $nom_usage = replace_accent(trim(Env::get('nom_usage'))); + $nom_usage = strtoupper($nom_usage); + $page->assign('usage_req', $nom_usage); + + if (Env::has('submit') && ($nom_usage != $usage_old)) { + // on vient de recevoir une requete, differente de l'ancien nom d'usage + if ($nom_usage == $nom) { + $page->assign('same', true); + } else { // le nom de mariage est distinct du nom à l'X + // on calcule l'alias pour l'afficher + $reason = Env::get('reason'); + if ($reason == 'other') { + $reason = Env::get('other_reason'); + } + $myusage = new UsageReq(Session::getInt('uid'), $nom_usage, $reason); + $myusage->submit(); + $page->assign('myusage', $myusage); + } + } + + return PL_OK; + } + function handler_trombi(&$page, $promo = null) { require_once 'trombi.inc.php'; diff --git a/templates/nomusage.tpl b/templates/nomusage.tpl index f966e06..8093f27 100644 --- a/templates/nomusage.tpl +++ b/templates/nomusage.tpl @@ -80,7 +80,7 @@ utiliser une adresse personnalis
-
+ diff --git a/templates/profil/general.tpl b/templates/profil/general.tpl index d9c5e68..1d518ea 100644 --- a/templates/profil/general.tpl +++ b/templates/profil/general.tpl @@ -82,7 +82,7 @@ -- 2.1.4
Nom d'usage {$nom_usage|default:"Aucun"} - modifier + modifier