Converts the remaining bits of the Profile module to hruid.
authorVincent Zanotti <vincent.zanotti@polytechnique.org>
Sun, 12 Oct 2008 14:12:34 +0000 (16:12 +0200)
committerVincent Zanotti <vincent.zanotti@polytechnique.org>
Sun, 12 Oct 2008 14:12:34 +0000 (16:12 +0200)
Signed-off-by: Vincent Zanotti <vincent.zanotti@polytechnique.org>
modules/profile.php
templates/profile/base.tpl
templates/profile/fiche_referent.tpl
templates/profile/general.tpl
templates/profile/mentor.tpl
templates/profile/trombino.tpl

index 94ae300..7a52138 100644 (file)
@@ -324,7 +324,7 @@ class ProfileModule extends PLModule
             $page->assign('no_private_key', true);
         }
         if (Env::v('synchro_ax') == 'confirm' && !is_ax_key_missing()) {
-            ax_synchronize(S::v('bestalias'), S::v('uid'));
+            ax_synchronize(S::user()->login(), S::v('uid'));
             $page->trigSuccess('Ton profil a été synchronisé avec celui du site polytechniciens.com');
         }
 
@@ -521,39 +521,24 @@ class ProfileModule extends PLModule
     function handler_referent(&$page, $x = null)
     {
         require_once 'user.func.inc.php';
-
-        if (is_null($x)) {
-            return PL_NOT_FOUND;
-        }
-
         $page->changeTpl('profile/fiche_referent.tpl', SIMPLE);
 
-        $res = XDB::query(
-                "SELECT  prenom, nom, user_id, promo, cv, a.alias AS bestalias
-                  FROM  auth_user_md5 AS u
-            INNER JOIN  aliases       AS a ON (u.user_id=a.id
-                                               AND FIND_IN_SET('bestalias', a.flags))
-            INNER JOIN  aliases       AS a1 ON (u.user_id=a1.id
-                                                AND a1.alias = {?}
-                                                AND a1.type!='homonyme')", $x);
-
-        if ($res->numRows() != 1) {
+        $user = User::get($x);
+        if ($user == null) {
             return PL_NOT_FOUND;
         }
 
-        list($prenom, $nom, $user_id, $promo, $cv, $bestalias) = $res->fetchOneRow();
+        $res = XDB::query("SELECT cv FROM auth_user_md5 WHERE user_id = {?}", $user->id());
+        $cv = $res->fetchOneCell();
 
-        $page->assign('prenom', $prenom);
-        $page->assign('nom',    $nom);
-        $page->assign('promo',  $promo);
-        $page->assign('cv',     MiniWiki::WikiToHTML($cv, true));
-        $page->assign('bestalias', $bestalias);
-        $page->assign('adr_pro', get_user_details_pro($user_id));
+        $page->assign_by_ref('user', $user);
+        $page->assign('cv', MiniWiki::WikiToHTML($cv, true));
+        $page->assign('adr_pro', get_user_details_pro($user->id()));
 
         /////  recuperations infos referent
 
         //expertise
-        $res = XDB::query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id);
+        $res = XDB::query("SELECT expertise FROM mentor WHERE uid = {?}", $user->id());
         $page->assign('expertise', $res->fetchOneCell());
 
         //secteurs
@@ -563,7 +548,7 @@ class ProfileModule extends PLModule
                    FROM  mentor_secteurs AS m
               LEFT JOIN  emploi_secteur AS s ON(m.secteur = s.id)
               LEFT JOIN  emploi_ss_secteur AS ss ON(m.secteur = ss.secteur AND m.ss_secteur = ss.id)
-                  WHERE  uid = {?}", $user_id);
+                  WHERE  uid = {?}", $user->id());
         while (list($sec, $ssec) = $res->next()) {
             $secteurs[]    = $sec;
             $ss_secteurs[] = $ssec;
@@ -576,7 +561,7 @@ class ProfileModule extends PLModule
                 "SELECT  gp.pays
                    FROM  mentor_pays AS m
               LEFT JOIN  geoloc_pays AS gp ON(m.pid = gp.a2)
-                  WHERE  uid = {?}", $user_id);
+                  WHERE  uid = {?}", $user->id());
         $page->assign('pays', $res->fetchColumn());
 
         $page->addJsLink('close_on_esc.js');
index bfd56f1..198ec25 100644 (file)
@@ -24,9 +24,9 @@
   {xsrf_token_field}
   <div>
     {icon name=information title="Voir ma fiche"} Tu peux consulter ta fiche telle que la
-    voient <a class="popup2" href="profile/{$smarty.session.forlife}?view=public">n'importe quel internaute</a>,
-    <a class="popup2" href="profile/{$smarty.session.forlife}?view=ax">l'AX</a> ou
-    <a class="popup2" href="profile/{$smarty.session.forlife}">les X</a>.
+    voient <a class="popup2" href="profile/{$smarty.session.hruid}?view=public">n'importe quel internaute</a>,
+    <a class="popup2" href="profile/{$smarty.session.hruid}?view=ax">l'AX</a> ou
+    <a class="popup2" href="profile/{$smarty.session.hruid}">les X</a>.
   </div>
   <div class="flags">
   {include file="include/flags.radio.tpl" disabled=true withtext=true name="profile_ex_pub"}
index 44e4e16..2be806f 100644 (file)
@@ -25,8 +25,8 @@
 <div id="fiche_referent">
   <div id="fiche_identite">
     <div class="civilite">
-      <strong>{$prenom} {$nom}</strong><br />
-      <span>X{$promo}&nbsp;-&nbsp;</span> <a href="mailto:{$bestalias}@{#globals.mail.domain#}">{$bestalias}@{#globals.mail.domain#}</a>
+      <strong>{$user->fullName()}</strong><br />
+      <span>X{$user->promo()}&nbsp;-&nbsp;</span> <a href="mailto:{$user->bestEmail()}">{$user->bestEmail()}</a>
     </div>
   </div>
   <div class="spacer"></div>
index 0203991..277dab1 100644 (file)
   <tr>
     <td {if !$nouvellephoto}colspan="2"{/if} class="center" style="width: 49%">
       <div class="titre">Ta photo actuelle</div>
-      <img src="photo/{$smarty.session.forlife}" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
+      <img src="photo/{$smarty.session.hruid}" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
     </td>
     {if $nouvellephoto}
     <td class="center" style="width: 49%">
       <div class="titre">Photo en attente de validation</div>
       <div>
-        <a href="profile/{$smarty.session.forlife}?modif=new" class="popup2">
+        <a href="profile/{$smarty.session.hruid}?modif=new" class="popup2">
           Ta fiche avec cette photo
         </a>
       </div>
-      <img src="photo/{$smarty.session.forlife}/req" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
+      <img src="photo/{$smarty.session.hruid}/req" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
     </td>
     {/if}
   </tr>
index 7521a28..587cc57 100644 (file)
@@ -20,7 +20,7 @@
 {*                                                                        *}
 {**************************************************************************}
 
-<p>{icon name=information title="Afficher ma fiche référent"}Tu peux consulter ta <a class="popup2" href="referent/{$smarty.session.forlife}">fiche référent</a> qui n'est accessible que par les X.
+<p>{icon name=information title="Afficher ma fiche référent"}Tu peux consulter ta <a class="popup2" href="referent/{$smarty.session.hruid}">fiche référent</a> qui n'est accessible que par les X.
 </p>
 {if (!$expertise)||(!($secteurs|@count))}
   <p>
index 842cdb8..de41dae 100644 (file)
     </tr>
     <tr>
       <td class="center">
-        <img src="photo/{$smarty.session.forlife}" width="200" alt=" [ PHOTO ] " />
+        <img src="photo/{$smarty.session.hruid}" width="200" alt=" [ PHOTO ] " />
       </td>
       <td class="center half">
         {if $submited}
-        <img src="photo/{$smarty.session.forlife}/req" width="200" alt=" [ PHOTO ] " />
+        <img src="photo/{$smarty.session.hruid}/req" width="200" alt=" [ PHOTO ] " />
         {else}
         Pas d'image soumise
         {/if}