Rename $p/$o to $profile/$owner in profile template
[platal.git] / templates / profile / profile.tpl
index a72fa31..2362564 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -41,19 +41,32 @@ function chgMainWinLoc(strPage)
 
 <div id="fiche">
   <div id="photo" class="part">
-    {if $photo_url}<img alt="Photo de {$x.forlife}" src="{$photo_url}" width="{$x.x}"/>{/if}
-    {if $logged && ( $x.section|smarty:nodefaults || $x.binets_join|smarty:nodefaults || $x.gpxs_join|smarty:nodefaults)}
-      <h2>À l'X...</h2>
-      {if $x.section}<div><em class="intitule">Section&nbsp;: </em><span>{$x.section}</span></div>{/if}
-      {if $x.binets_join}<div><em class="intitule">Binet{if count($x.binets) > 1}s{/if}&nbsp;: </em>
-      <span>{$x.binets_join}</span></div>{/if}
-      {if $x.gpxs_join}<div><em class="intitule">Groupe{if count($x.gpxs) > 1}s{/if} et institution{if count($x.gpxs) > 1}s{/if} X&nbsp;: </em>
-      <span><br/>{$x.gpxs_join|smarty:nodefaults}</span></div>{/if}
+    {assign var=photo value=$profile->getPhoto(false)}
+    {if $photo}<img alt="Photo de {$profile->fullName()}" src="photo/{$profile->hrid()}" width="{$photo->width()}"/>{/if}
+
+    {if $logged && ( $profile->section|smarty:nodefaults || $profile->getBinets()|smarty:nodefaults || ($o && $owner->groups()|smarty:nodefaults))}
+      <h2>À l'X&hellip;</h2>
+      {if $profile->section}<div><em class="intitule">Section&nbsp;: </em><span>{$profile->section}</span></div>{/if}
+
+      {assign var=binets value=$profile->getBinets()}
+      {if $binets|@count}<div><em class="intitule">Binet{if count($binets) > 1}s{/if}&nbsp;: </em>
+      <span>{', '|implode:$profile->getBinetsNames()}</span></div>{/if}
+
+      {if $o}
+        {assign var=groups value=$owner->groupNames(true)}
+        {if $groups|@count}<div><em class="intitule">Groupe{if count($groups) > 1}s{/if} et institution{if count($groups) > 1}s{/if} X&nbsp;: </em>
+        <span><br/>
+        {foreach from=$groups item=group key=gk}{if $gk != 0}, {/if}<span title="{$group.nom}"><a href="{$group.site}">{$group.nom}</a></span>{/foreach}
+        </span></div>{/if}
+      {/if}
+
     {/if}
-    {if $x.networking}
+
+    {assign var=networking value=$profile->getNetworking(0)}
+    {if count($networking) > 0}
       <h2>Sur le web...</h2>
-      {foreach from=$x.networking item=network}
-        <img style="width: auto; padding: 0" src="profile/networking/{$network.type}" alt="{$network.name}" title="{$network.name}"/>
+      {foreach from=$networking item=network}
+        <img style="width: auto; padding: 0" src="profile/networking/{$network.network_type}" alt="{$network.name}" title="{$network.name}"/>
         {if $network.filter == 'web'}
           <a href="{$network.address}">{$network.address}</a>
         {elseif $network.link != ''}
@@ -64,153 +77,193 @@ function chgMainWinLoc(strPage)
         <br/>
       {/foreach}
     {/if}
-    {if $x.freetext}
-    <h2>Commentaires&nbsp;:</h2>
-    <span>{$x.freetext|miniwiki|smarty:nodefaults}</span>
+
+    {if $profile->freetext}
+      <h2>Commentaires&nbsp;:</h2>
+      <span>{$profile->freetext|miniwiki|smarty:nodefaults}</span>
     {/if}
+
   </div>
+
   <div id="fiche_identite" class="part">
     <div class="civilite">
-      {if $x.sexe}&bull;{/if}
-      <span {if $x.name_tooltip neq ""}class="hinted" title="{$x.name_tooltip}"{/if}>{$x.name_display}</span>
+      {if $profile->isFemale()}&bull;{/if}
+        <span {if $profile->name_tooltip neq ""}class="hinted" title="{$profile->name_tooltip}"{/if}>{$profile->shortName()}</span>
       {if $logged}
-      {if $x.nickname} (alias {$x.nickname}){/if}
+        {if $profile->nickname} (alias {$profile->nickname}){/if}
       {/if}
+
       {if $logged}
-      &nbsp;{if !$x.dcd}<a href="vcard/{$x.forlife}.vcf">{*
-        *}{icon name=vcard title="Afficher la carte de visite"}</a>{/if}
-      {if !$x.is_contact}
-      <a href="javascript:chgMainWinLoc('carnet/contacts?action=ajouter&amp;user={$x.forlife}&amp;token={xsrf_token}')">
-        {icon name=add title="Ajouter à mes contacts"}</a>
-      {else}
-      <a href="javascript:chgMainWinLoc('carnet/contacts?action=retirer&amp;user={$x.forlife}&amp;token={xsrf_token}')">
-        {icon name=cross title="Retirer de mes contacts"}</a>
-      {/if}
-      {if hasPerm('admin')}
-      <a href="javascript:chgMainWinLoc('admin/user/{$x.forlife}')">
-        {icon name=wrench title="administrer user"}</a>
-      {/if}
-      {if $x.forlife eq $smarty.session.forlife}
-      <a href="javascript:chgMainWinLoc('profile/edit')">{icon name="user_edit" title="Modifier ma fiche"}</a>
-      {/if}
+        &nbsp;{if !$profile->isDead()}<a href="vcard/{$owner->login()}.vcf">{*
+          *}{icon name=vcard title="Afficher la carte de visite"}</a>{/if}
+
+        {if !$smarty.session.user->isContact($p)}
+        <a href="javascript:chgMainWinLoc('carnet/contacts?action=ajouter&amp;user={$owner->login()}&amp;token={xsrf_token}')">
+          {icon name=add title="Ajouter à mes contacts"}</a>
+        {else}
+        <a href="javascript:chgMainWinLoc('carnet/contacts?action=retirer&amp;user={$owner->login()}&amp;token={xsrf_token}')">
+          {icon name=cross title="Retirer de mes contacts"}</a>
+        {/if}
+
+        {if hasPerm('admin')}
+        <a href="javascript:chgMainWinLoc('admin/user/{$owner->login()}')">
+          {icon name=wrench title="administrer user"}</a>
+        {/if}
+
+        {if $owner->login() eq $smarty.session.hruid}
+        <a href="javascript:chgMainWinLoc('profile/edit')">{icon name="user_edit" title="Modifier ma fiche"}</a>
+        {/if}
+
       {/if}
     </div>
+
     {if $logged}
     <div class='maj'>
       Fiche mise à jour<br />
-      le {$x.date|date_format}
+      le {$profile->last_change|date_format}
     </div>
     {/if}
-    {if $logged || $x.tels}
+
+    {assign var=phones value=$profile->getPhones(0)}
+    {if $logged || count($phones) > 0}
     <div class="contact">
       {if $logged}
       <div class='email'>
-        {if $x.dcd}
-        Décédé{if $x.sexe}e{/if} le {$x.deces|date_format}
-        {elseif !$x.actif}
-        Ce{if $c.sexe}tte{/if} camarade n'a plus d'adresse de redirection valide,<br />
-        <a href="marketing/broken/{$x.forlife}" class="popup">clique ici si tu connais son adresse email !</a>
-        {elseif !$x.inscrit}
+        {if $profile->isDead()}
+        Décédé{if $profile->isFemale()}e{/if} le {$profile->deathdate|date_format}
+        {elseif $o && $owner->lost}
+        Ce{if $profile->isFemale()}tte{/if} camarade n'a plus d'adresse de redirection valide,<br />
+        <a href="marketing/broken/{$owner->login()}" class="popup">clique ici si tu connais son adresse email&nbsp;!</a>
+        {elseif $o && $owner->state != 'active'}
         Cette personne n'est pas inscrite à Polytechnique.org,<br />
-        <a href="marketing/public/{$x.user_id}" class="popup">clique ici si tu connais son adresse email !</a>
+        <a href="marketing/public/{$owner->login()}" class="popup">clique ici si tu connais son adresse email&nbsp;!</a>
         {else}
         {if $virtualalias}
         <a href="mailto:{$virtualalias}">{$virtualalias}</a><br />
         {/if}
-        <a href="mailto:{$x.bestalias}@{#globals.mail.domain#}">{$x.bestalias}@{#globals.mail.domain#}</a>
-        {if $x.bestalias neq $x.forlife}<br />
-        <a href="mailto:{$x.forlife}@{#globals.mail.domain#}">{$x.forlife}@{#globals.mail.domain#}</a>
+        <a href="mailto:{$owner->bestEmail()}">{$owner->bestEmail()}</a>
+        {if $owner->bestEmail() neq $owner->forlifeEmail()}<br />
+        <a href="mailto:{$owner->forlifeEmail()}">{$owner->forlifeEmail()}</a>
         {/if}
         {/if}
       </div>
       {/if}
-      {if $x.tels}
-        {display_phones tels=$x.tels}
+      {if count($phones) > 0}
+        {display_phones tels=$phones dcd=$profile->isDead()}
       {/if}
       <div class='spacer'></div>
     </div>
     {/if}
+
     <div class='formation'>
-      {if $x.iso3166_1}
-      <img src='images/flags/{$x.iso3166_1}.gif' alt='{$x.nationalite}' height='11' title='{$x.nationalite}' />&nbsp;
-      {/if}
-      {if $x.iso3166_2}
-      <img src='images/flags/{$x.iso3166_2}.gif' alt='{$x.nationalite2}' height='11' title='{$x.nationalite2}' />&nbsp;
-      {/if}
-      {if $x.iso3166_3}
-      <img src='images/flags/{$x.iso3166_3}.gif' alt='{$x.nationalite3}' height='11' title='{$x.nationalite3}' />&nbsp;
-      {/if}
-      X {$x.promo}
-      {if ($x.promo_sortie-3 > $x.promo)}
-        - X {math equation="a-b" a=$x.promo_sortie b=3}
+      {foreach from=$profile->nationalities() item=nat}
+        <img src='images/flags/{$nat}.gif' alt='{$nat}' height='11' title='{$nat}' />&nbsp;
+      {/foreach}
+
+      {$profile->promo()}
+
+      {if $logged && $profile->mentor_expertise}
+      [<a href="referent/{$profile->hrid()}" class='popup2'>Ma fiche référent</a>]
       {/if}
-      {if $x.applis_join}
-        &nbsp;-&nbsp;Formation&nbsp;: {$x.applis_join|smarty:nodefaults}
+
+      {assign var=educations value=$profile->getEducations(64)}
+      {if count($educations) > 0}
+        &nbsp;-&nbsp;Formation&nbsp;:
+        <ul>
+        {foreach from=$educations item=edu}
+          <li>{display_education edu=$edu profile=$p}</li>
+        {/foreach}
+        </ul>
       {/if}
-      {if $logged && $x.is_referent}
-      [<a href="referent/{$x.forlife}" class='popup2'>Ma fiche référent</a>]
+
+      {assign var=corps value=$profile->getCorps()}
+      {if $corps && ($corps->current || $corps->original)}
+      <ul>
+        {if $corps->current}
+          <li>{$corps->current_name} {$corps->current_rank}
+        {/if}
+        {if $corps->original}
+          <li>{$corps->original_name}
+        {/if}
+      </ul>
       {/if}
+
     </div>
   </div>
-  {if $x.adr}
+
+  {assign var=addr value=$profile->getAddresses(3)}
+  {if count($addr) > 0}
   <div class="part">
     <h2>Contact&nbsp;: </h2>
-    {foreach from=$x.adr item="address" name=adresses}
-      {if $smarty.foreach.adresses.iteration is even}
+    {if $profile->isDead()}
+      {assign var=address_name value="Dernière adresse"}
+    {else}
+      {assign var=address_name value="Adresse"}
+    {/if}
+    {foreach from=$addr item="address" name=addresses}
+      {if $smarty.foreach.addresses.iteration is even}
         {assign var=pos value="right"}
       {else}
         {assign var=pos value="left"}
       {/if}
-      {if $address.active}
-      {include file="geoloc/address.tpl" address=$address titre_div=true titre="Mon adresse actuelle&nbsp;:"
-               for="`$x.prenom` `$x.nom`" pos=$pos}
-      {elseif $address.secondaire}
-      {include file="geoloc/address.tpl" address=$address titre_div=true titre="Adresse secondaire&nbsp;:"
-               for="`$x.prenom` `$x.nom`" pos=$pos}
+      {if $address->hasFlag('current')}
+      {include file="geoloc/address.tpl" address=$address titre_div=true titre=$address_name|@cat:" actuelle&nbsp;:"
+               for="`$profile->firstname` `$profile->lastname`" pos=$pos}
+      {elseif $address->hasFlag('secondary')}
+      {include file="geoloc/address.tpl" address=$address titre_div=true titre=$address_name|@cat:" secondaire&nbsp;:"
+               for="`$profile->firstname` `$profile->lastname`" pos=$pos}
       {else}
-      {include file="geoloc/address.tpl" address=$address titre_div=true titre="Adresse principale&nbsp;:"
-               for="`$x.prenom` `$x.nom`" pos=$pos}
+      {include file="geoloc/address.tpl" address=$address titre_div=true titre=$address_name|@cat:" principale&nbsp;:"
+               for="`$profile->firstname` `$profile->lastname`" pos=$pos}
       {/if}
-      {if $smarty.foreach.adresses.iteration is even}<div class="spacer"></div>{/if}
+      {if $smarty.foreach.addresses.iteration is even}<div class="spacer"></div>{/if}
     {/foreach}
   </div>
   {/if}
-  {if $x.adr_pro}
+
+  {assign var=jobs value=$profile->getJobs(2)}
+  {if count($jobs) > 0}
   <div class="part">
     <h2>Informations professionnelles&nbsp;:</h2>
-    {foreach from=$x.adr_pro item="address" key="i"}
+    {foreach from=$jobs item="job" key="i"}
       {if $i neq 0}<hr />{/if}
-      {include file="include/emploi.tpl" address=$address}
-      {include file="geoloc/address.tpl" address=$address titre="Adresse&nbsp;: " for=$address.entreprise pos="left"}
+      {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 pos="left"}
+      {/if}
       <div class="spacer">&nbsp;</div>
     {/foreach}
   </div>
   {/if}
-  {if $x.medals}
-  <div class="part">
-    <h2>Distinctions&nbsp;: </h2>
-    {foreach from=$x.medals item=m}
-    <div class="medal_frame">
-      <img src="profile/medal/thumb/{$m.id}" height="50px" alt="{$m.medal}" title="{$m.medal}" style='float: left;' />
-      <div class="medal_text">
-        {$m.medal}<br />{$m.grade}
+
+  {assign var=medals value=$profile->getMedals()}
+  {if count($medals) > 0}
+    <div class="part">
+      <h2>Distinctions&nbsp;: </h2>
+      {foreach from=$medals item=m}
+      <div class="medal_frame">
+        <img src="profile/medal/thumb/{$m.mid}" height="50px" alt="{$m.text}" title="{$m.text}" style='float: left;' />
+        <div class="medal_text">
+          {$m.text}<br />{$m.grade}
+        </div>
       </div>
+      {/foreach}
+      <div class="spacer">&nbsp;</div>
     </div>
-    {/foreach}
-    <div class="spacer">&nbsp;</div>
-  </div>
   {/if}
-  {if $logged && $x.cv}
+
+  {if $logged && $profile->cv}
   <div class="part">
     <h2>Curriculum Vitae&nbsp;:</h2>
-    {$x.cv|miniwiki:title|smarty:nodefaults}
+    {$profile->cv|miniwiki:title|smarty:nodefaults}
   </div>
   {/if}
+
   {if $view eq 'public'}
   <div class="part">
     <small>
     Cette fiche est publique et visible par tout internaute,<br />
-    vous pouvez aussi voir <a href="profile/private/{$x.forlife}?display=light">celle&nbsp;réservée&nbsp;aux&nbsp;X</a>.
+    vous pouvez aussi voir <a href="profile/private/{$profile->hrid()}?display=light">celle&nbsp;réservée&nbsp;aux&nbsp;X</a>.
     </small>
   </div>
   {elseif $view eq 'ax'}
@@ -220,6 +273,7 @@ function chgMainWinLoc(strPage)
     </small>
   </div>
   {/if}
+
   <div class="spacer"></div>
 </div>