now we can see medals in the fiche
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Sat, 15 Jan 2005 23:08:16 +0000 (23:08 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:40 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-349

include/profil/get_deco.inc.php
include/user.func.inc.php
templates/fiche.tpl

index 01853a2..0368f9f 100644 (file)
@@ -28,11 +28,11 @@ if (Env::has('medal_op')) {
         $globals->xdb->execute("INSERT INTO profile_medals_sub (uid,mid) VALUES ({?}, {?})", Session::getInt('uid', -1), Env::getInt('medal_id'));
     }
 }
-
-foreach (Post::getMixed('grade') as $mid=>$gid) {
-    $globals->xdb->execute('UPDATE profile_medals_sub SET gid={?} WHERE uid={?} AND mid={?}', $gid, Session::getInt('uid'), $mid);
-}
+if (Post::has('grade')) {
+    foreach (Post::getMixed('grade') as $mid=>$gid) {
+        $globals->xdb->execute('UPDATE profile_medals_sub SET gid={?} WHERE uid={?} AND mid={?}', $gid, Session::getInt('uid'), $mid);
+    }
+} 
 
 $res    = $globals->xdb->query(
        "SELECT  m.id, m.text AS medal, m.type, m.img, s.gid
index 9829700..974d3bd 100644 (file)
@@ -235,6 +235,16 @@ function &get_user_details($login, $from_uid = '')
     }
     $user['applis_join'] = join(', ', $user['applis_fmt']);
 
+    $res = $globals->xdb->iterator("SELECT  m.id, m.text AS medal, m.type, m.img, s.gid, g.text AS grade
+                                      FROM  profile_medals_sub    AS s
+                                INNER JOIN  profile_medals        AS m ON ( s.mid = m.id )
+                                LEFT  JOIN  profile_medals_grades AS g ON ( s.mid = g.mid AND s.gid = g.gid )
+                                     WHERE  s.uid = {?}", $uid);
+    $user['medals'] = Array();
+    while ($tmp = $res->next()) {
+        $user['medals'][] = $tmp;
+    }
+
     return $user;
 }
 
index 6d47aa4..acdba44 100644 (file)
@@ -101,13 +101,12 @@ function chgMainWinLoc( strPage ) {
       <h2>Contact : </h2>
       {foreach from=$x.adr item="address" key="i"}
         {if $address.active}
-          {assign var="address_titre" value="Mon adresse actuelle :"}
+        {include file="geoloc/address.tpl" address=$address titre_div=true titre="Mon adresse actuelle :"}
         {elseif $address.secondaire}
-          {assign var="address_titre" value="Adresse secondaire :"}
+        {include file="geoloc/address.tpl" address=$address titre_div=true titre="Adresse secondaire :"}
         {else}
-          {assign var="address_titre" value="Adresse principale :"}
+        {include file="geoloc/address.tpl" address=$address titre_div=true titre="Adresse principale :"}
         {/if}
-        {include file="geoloc/address.tpl" address=$address titre_div=true titre=$address_titre}
       {/foreach}
       <div class="spacer">&nbsp;</div>
     </td>
@@ -149,6 +148,27 @@ function chgMainWinLoc( strPage ) {
     </td>
   </tr>
   {/if}
+  {if $x.medals}
+  <tr>
+    <td>
+      <h2>Distinctions : </h2>
+      {foreach from=$x.medals item=m}
+      <table style="float: left; width: 33%;">
+        <tr>
+          <td>
+            <img src="{rel}/images/medals/{$m.img}" width="24" alt="{$m.medal}" title="{$m.medal}" style='float: left;' />
+          </td>
+          <td>
+            <strong>{$m.medal}</strong>
+            <br />{$m.grade}
+          </td>
+        </tr>
+      </table>
+      {/foreach}
+      <div class="spacer">&nbsp;</div>
+    </td>
+  </tr>
+  {/if}
   {if $x.cv}
   <tr>
     <td>