Take directory_* permissions into account when accessing a profile.
[platal.git] / templates / profile / profile.tpl
index 2362564..ed73b0b 100644 (file)
@@ -42,9 +42,9 @@ function chgMainWinLoc(strPage)
 <div id="fiche">
   <div id="photo" class="part">
     {assign var=photo value=$profile->getPhoto(false)}
-    {if $photo}<img alt="Photo de {$profile->fullName()}" src="photo/{$profile->hrid()}" width="{$photo->width()}"/>{/if}
+    {if $photo}<img alt="Photo de {$profile->fullName()}" src="photo/{$profile->hrid()}{if $with_pending_pic}/req{/if}" width="{$photo->width()}"/>{/if}
 
-    {if $logged && ( $profile->section|smarty:nodefaults || $profile->getBinets()|smarty:nodefaults || ($o && $owner->groups()|smarty:nodefaults))}
+    {if $logged && $view eq 'private' && ( $profile->section|smarty:nodefaults || $profile->getBinets()|smarty:nodefaults || ($owner && $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}
 
@@ -52,7 +52,7 @@ function chgMainWinLoc(strPage)
       {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}
+      {if $owner && $view eq 'private'}
         {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/>
@@ -62,15 +62,14 @@ function chgMainWinLoc(strPage)
 
     {/if}
 
-    {assign var=networking value=$profile->getNetworking(0)}
+    {* 458752 stands for 0x70000 = Profile::NETWORKING_ALL *}
+    {assign var=networking value=$profile->getNetworking(458752)}
     {if count($networking) > 0}
       <h2>Sur le web...</h2>
       {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 != ''}
-          <a href="{$network.link}">{$network.address}</a>
+        <img style="width: auto; padding: 0" src="profile/networking/{$network.nwid}" alt="{$network.name}" title="{$network.name}"/>
+        {if $network.link}
+          <a href="{$network.link|replace:'%s':$network.address}">{$network.address}</a>
         {else}
           {$network.address}
         {/if}
@@ -88,16 +87,13 @@ function chgMainWinLoc(strPage)
   <div id="fiche_identite" class="part">
     <div class="civilite">
       {if $profile->isFemale()}&bull;{/if}
-        <span {if $profile->name_tooltip neq ""}class="hinted" title="{$profile->name_tooltip}"{/if}>{$profile->shortName()}</span>
-      {if $logged}
-        {if $profile->nickname} (alias {$profile->nickname}){/if}
-      {/if}
+        {if $view eq 'private'}{$profile->private_name}{else}{$profile->public_name}{/if}
 
       {if $logged}
         &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)}
+        {if !$smarty.session.user->isContact($profile)}
         <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}
@@ -117,24 +113,25 @@ function chgMainWinLoc(strPage)
       {/if}
     </div>
 
-    {if $logged}
+    {if $logged && $view eq 'private'}
     <div class='maj'>
       Fiche mise à jour<br />
       le {$profile->last_change|date_format}
     </div>
     {/if}
 
-    {assign var=phones value=$profile->getPhones(0)}
-    {if $logged || count($phones) > 0}
+    {* 121634816 is Profile::PHONE_LINK_PROFILE | Profile::PHONE_TYPE_ANY = 0x7400000 *}
+    {assign var=phones value=$profile->getPhones(121634816)}
+    {if ($logged && $view eq 'private') || count($phones) > 0}
     <div class="contact">
-      {if $logged}
+      {if $logged && $view eq 'private'}
       <div class='email'>
         {if $profile->isDead()}
         Décédé{if $profile->isFemale()}e{/if} le {$profile->deathdate|date_format}
-        {elseif $o && $owner->lost}
+        {elseif $owner && $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'}
+        {elseif $owner && $owner->state != 'active'}
         Cette personne n'est pas inscrite à Polytechnique.org,<br />
         <a href="marketing/public/{$owner->login()}" class="popup">clique ici si tu connais son adresse email&nbsp;!</a>
         {else}
@@ -149,15 +146,19 @@ function chgMainWinLoc(strPage)
       </div>
       {/if}
       {if count($phones) > 0}
+      <div style="float: right">
         {display_phones tels=$phones dcd=$profile->isDead()}
+      </div>
       {/if}
       <div class='spacer'></div>
     </div>
+    {else}
+    <div class='spacer'></div>
     {/if}
 
     <div class='formation'>
-      {foreach from=$profile->nationalities() item=nat}
-        <img src='images/flags/{$nat}.gif' alt='{$nat}' height='11' title='{$nat}' />&nbsp;
+      {foreach from=$profile->nationalities() item=country key=code}
+      <img src='images/flags/{$code}.gif' alt='{$code}' height='11' title='{$country}' />&nbsp;
       {/foreach}
 
       {$profile->promo()}
@@ -166,26 +167,29 @@ function chgMainWinLoc(strPage)
       [<a href="referent/{$profile->hrid()}" class='popup2'>Ma fiche référent</a>]
       {/if}
 
-      {assign var=educations value=$profile->getEducations(64)}
+      {assign var=educations value=$profile->getEducations(32)}
       {if count($educations) > 0}
         &nbsp;-&nbsp;Formation&nbsp;:
         <ul>
         {foreach from=$educations item=edu}
-          <li>{display_education edu=$edu profile=$p}</li>
+          <li>{display_education edu=$edu profile=$profile}</li>
         {/foreach}
         </ul>
       {/if}
 
       {assign var=corps value=$profile->getCorps()}
       {if $corps && ($corps->current || $corps->original)}
-      <ul>
+        <ul>
         {if $corps->current}
-          <li>{$corps->current_name} {$corps->current_rank}
+          <li>
+            Corps actuel&nbsp;: {$corps->current_name}
+            {if $corps->current_rank}({$corps->current_rank}){/if}
+          </li>
         {/if}
-        {if $corps->original}
-          <li>{$corps->original_name}
+        {if $corps->current != $corps->original && $corps->original}
+          <li>Corps d'origine&nbsp;: {$corps->original_name}</li>
         {/if}
-      </ul>
+        </ul>
       {/if}
 
     </div>
@@ -208,13 +212,13 @@ function chgMainWinLoc(strPage)
       {/if}
       {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}
+               for="`$profile->firstname` `$profile->lastname`" pos=$pos phones=null}
       {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}
+               for="`$profile->firstname` `$profile->lastname`" pos=$pos phones=null}
       {else}
       {include file="geoloc/address.tpl" address=$address titre_div=true titre=$address_name|@cat:" principale&nbsp;:"
-               for="`$profile->firstname` `$profile->lastname`" pos=$pos}
+               for="`$profile->firstname` `$profile->lastname`" pos=$pos phones=null}
       {/if}
       {if $smarty.foreach.addresses.iteration is even}<div class="spacer"></div>{/if}
     {/foreach}
@@ -228,8 +232,11 @@ function chgMainWinLoc(strPage)
     {foreach from=$jobs item="job" key="i"}
       {if $i neq 0}<hr />{/if}
       {include file="include/emploi.tpl" job=$job}
+      {assign var=jobPhones value=$job->phones()}
       {if $job->address()}
-        {include file="geoloc/address.tpl" address=$job->address titre="Adresse&nbsp;: " for=$job->company->name pos="left"}
+        {include file="geoloc/address.tpl" address=$job->address() titre="Adresse&nbsp;: " for=$job->company->name pos="left" phones=$jobPhones}
+      {elseif $jobPhones|@count neq 0}
+        {display_phones tels=$jobPhones}
       {/if}
       <div class="spacer">&nbsp;</div>
     {/foreach}