migrate nomusage.php
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 20:38:09 +0000 (20:38 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 20:38:09 +0000 (20:38 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@445 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs/nomusage.php [deleted file]
modules/profile.php
templates/nomusage.tpl
templates/profil/general.tpl

diff --git a/htdocs/nomusage.php b/htdocs/nomusage.php
deleted file mode 100644 (file)
index 02320fe..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-require_once("validations.inc.php");
-require_once("xorg.misc.inc.php");
-
-new_skinned_page('nomusage.tpl', AUTH_MDP);
-
-$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);
-    }
-}
-
-$page->run();
-?>
index 1f22180..a211b13 100644 (file)
@@ -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';
index f966e06..8093f27 100644 (file)
@@ -80,7 +80,7 @@ utiliser une adresse personnalis
 
   <br />
 
-  <form action="{$smarty.server.PHP_SELF}" method="post">
+  <form action="{rel}/profile/usage" method="post">
     <table class="bicol" cellpadding="4" summary="Nom d'usage">
       <tr>
         <th>Nom d'usage</th>
index d9c5e68..1d518ea 100644 (file)
@@ -82,7 +82,7 @@
       </td>
       <td class="cold">
         <span class="nom">{$nom_usage|default:"Aucun"}</span>
-        <span class="lien"><a href="nomusage.php">modifier</a></span>
+        <span class="lien"><a href="{rel}/profile/usage">modifier</a></span>
       </td>
     </tr>
     <tr>