Fix referent display
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Mon, 22 Mar 2010 21:54:11 +0000 (22:54 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Mon, 22 Mar 2010 22:03:01 +0000 (23:03 +0100)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
modules/profile.php
templates/profile/fiche_referent.tpl

index 40bff74..8423d29 100644 (file)
@@ -538,28 +538,19 @@ class ProfileModule extends PLModule
         }
     }
 
-    function handler_referent(&$page, $user)
+    function handler_referent(&$page, $pf)
     {
         $page->changeTpl('profile/fiche_referent.tpl', SIMPLE);
 
-        $user = Profile::get($user);
-        if (!$user) {
+        $pf = Profile::get($pf);
+        if (!$pf) {
             return PL_NOT_FOUND;
         }
 
-        $page->assign_by_ref('user', $user);
-        $page->assign('cv', MiniWiki::WikiToHTML($user->cv, true));
-        //TODO: waiting for job refactoring to be done
-        //$page->assign('adr_pro', get_user_details_pro($user->id()));
+        $page->assign_by_ref('profile', $pf);
 
         /////  recuperations infos referent
 
-        //expertise
-        $res = XDB::query('SELECT  expertise
-                             FROM  profile_mentor
-                            WHERE  pid = {?}', $user->id());
-        $page->assign('expertise', $res->fetchOneCell());
-
         // Sectors
         $sectors = $subSectors = Array();
         $res = XDB::iterRow(
@@ -567,7 +558,7 @@ class ProfileModule extends PLModule
                    FROM  profile_mentor_sector      AS m
               LEFT JOIN  profile_job_sector_enum    AS s  ON(m.sectorid = s.id)
               LEFT JOIN  profile_job_subsector_enum AS ss ON(m.sectorid = ss.sectorid AND m.subsectorid = ss.id)
-                  WHERE  pid = {?}", $user->id());
+                  WHERE  pid = {?}", $pf->id());
         while (list($sector, $subSector) = $res->next()) {
             $sectors[]    = $sector;
             $subSectors[] = $subSector;
@@ -580,7 +571,7 @@ class ProfileModule extends PLModule
                 "SELECT  gc.countryFR
                    FROM  profile_mentor_country AS m
               LEFT JOIN  geoloc_countries       AS gc ON (m.country = gc.iso_3166_1_a2)
-                  WHERE  pid = {?}", $user->id());
+                  WHERE  pid = {?}", $pf->id());
         $page->assign('pays', $res->fetchColumn());
 
         $page->addJsLink('close_on_esc.js');
index bf787ee..4b7bc04 100644 (file)
 {**************************************************************************}
 
 {javascript name=ajax}
+{assign var=sectors value=$profile->getMentoringSectors()}
+{assign var=countries value=$profile->getMentoringCountries()}
 <div id="fiche">
 <div id="fiche_referent">
   <div id="fiche_identite">
     <div class="civilite">
-      <strong>{$user->fullName()}</strong><br />
-      <span>{$user->promo()}&nbsp;-&nbsp;</span> <a href="mailto:{$user->bestEmail()}">{$user->bestEmail()}</a>
+      <strong>{$profile->fullName()}</strong><br />
+      <span>{$profile->promo()}&nbsp;-&nbsp;</span> <a href="mailto:{$profile->displayEmail()}">{$profile->displayEmail()}</a>
     </div>
   </div>
   <div class="spacer"></div>
 
-  {if $expertise != '' || $sectors|count || $pays|count }
+  {if $expertise != '' || $sectors|count || $countries|count }
   <div id="part">
     <h2>Informations de référent&nbsp;:</h2>
     {if $expertise}
       <em>Secteurs&nbsp;:</em><br />
       <ul>
         {foreach from=$sectors item="sector" key="i"}
-        <li>{$sector}{if $subSector.$i != ''} ({$subSector.$i}){/if}</li>
+        <li>{$sector.sector}{if $sector.subsector != ''} ({$sector.subsector}){/if}</li>
         {/foreach}
       </ul>
     </div>
     {/if}
-    {if $pays|count}
+    {if $countries|count}
     <div class="rubrique_referent">
       <em>Pays&nbsp;:</em>
       <ul>
   </div>
   {/if}
 
+  {assign var=jobs value=$profile->getJobs(2)}
   <div class="part">
-    {foreach from=$adr_pro item="address" key="i"}
-    <h2>{$address.entreprise}</h2>
-    {include file="include/emploi.tpl" address=$address}
-    {include file="geoloc/address.tpl" address=$address titre="Adresse&nbsp;: " for=$address.entreprise}
-
-    <div class="spacer">&nbsp;</div>
-  {/foreach}
+    {foreach from=$jobs item="job"}
+      <h2>{$job->company->name}</h2>
+      {include file="include/emploi.tpl" job=$job}
+      {if $job->address()}
+        {include file="geoloc/address.tpl" address=$job->address titre="Adresse&nbsp;: " for=$job->company->name}
+      {/if}
+      <div class="spacer">&nbsp;</div>
+    {/foreach}
   </div>
 
-  {if $cv}
+  {if $profile->cv}
   <div class="part">
     <h2>Curriculum Vitae&nbsp;: </h2>
-    <div style="padding: 0 2ex">{$cv|smarty:nodefaults}</div>
+    <div style="padding: 0 2ex">{$profile->cv|smarty:nodefaults}</div>
   </div>
   {/if}