Since user can have their profile filled with data from the AX, show a
[platal.git] / templates / include / minifiche.tpl
index 735b25e..683c5b7 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2009 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*                                                                        *}
 {**************************************************************************}
 
-{assign var=profile value=$user->profile()}
 {assign var=dead    value=$profile->deathdate}
-{if $user->state neq 'pending'}
-{assign var=registered value=true}
-{else}
-{assign var=registered value=false}
-{/if}
 {if $smarty.session.auth ge AUTH_COOKIE}
-{assign var=withAuth value=true}
+  {assign var=withAuth value=true}
+  {assign var=user value=$profile->owner()}
+  {if $user == null}
+    {assign var=hasowner value=false}
+    {assign var=registered value=false}
+  {else}
+    {assign var=hasowner value=true}
+    {if $user->state neq 'pending'}
+      {assign var=registered value=true}
+    {else}
+      {assign var=registered value=false}
+    {/if}
+  {/if}
 {else}
-{assign var=withAuth value=false}
+  {* Without auth, all profiles appear as registered and with owner *}
+  {assign var=hasowner value=true}
+  {assign var=registered value=true}
+  {assign var=withAuth value=false}
 {/if}
 
 
-<div class="contact {if (!$registered && $withAuth) || $dead }grayed{/if}"
-     {if $registered && $withAuth}title="fiche mise à jour le {$profile->last_change|date_format}"{/if}>
+<div class="contact {if !$registered || $dead }grayed{/if}"
+     {if $profile->last_change}title="fiche mise à jour le {$profile->last_change|date_format}"{/if}>
   <div class="identity">
     {if $withAuth}
     <div class="photo">
 
     <div class="nom">
       {if $profile->isFemale()}&bull;{/if}
-      {if !$dead && (!$registered || $withAuth)}<a href="profile/{$profile->hrid}" class="popup2">{/if}
-      {$profile->full_name}
-      {if !$dead && (!$registered || $withAuth)}</a>{/if}
+      {if !$dead && ($withAuth || $registered)}<a href="profile/{$profile->hrid()}" class="popup2">{/if}
+      {$profile->directory_name}
+      {if !$dead && ($withAuth || $registered)}</a>{/if}
     </div>
 
     <div class="edu">
-      {if $profile->nationality1}
-      <img src='images/flags/{$profile->nationality1}.gif' alt='{$profile->nationality1}' height='11' title='{$profile->nationality1}' />&nbsp;
-      {/if}
-      {if $profile->nationality2}
-      <img src='images/flags/{$profile->nationality2}.gif' alt='{$profile->nationality2}' height='11' title='{$profile->nationality2}' />&nbsp;
-      {/if}
-      {if $profile->nationality3}
-      <img src='images/flags/{$profile->nationality3}.gif' alt='{$profile->nationality3}' height='11' title='{$profile->nationality3}' />&nbsp;
-      {/if}
+      {foreach from=$profile->nationalities() item=country key=code}
+      <img src='images/flags/{$code}.gif' alt='{$code}' height='11' title='{$country}' />&nbsp;
+      {/foreach}
       {$profile->promo()}{*
-      *}{iterate from=$profile->getExtraEducations(4) item=edu}, {education_fmt edu=$edu profile=$profile}{/iterate}{*
-      *}{if $dead}, {"décédé"|sex:"décédée":$user} le {$orfile->deathdate|date_format}{/if}
+      *}{foreach from=$profile->getExtraEducations(4) item=edu}, {display_education edu=$edu profile=$profile full=false}{/foreach}{*
+      *}{if $dead}, {"décédé"|sex:"décédée":$profile} le {$profile->deathdate|date_format}{/if}
     </div>
   </div>
 
   {if $withAuth}
   <div class="noprint bits">
+    {if $registered || (!$dead && $hasowner)}
     <div>
-      {if !$registered && !$dead}
-        {if $show_action eq 'ajouter'}
+      {if !$registered && !$dead && $hasowner}
+        {if hasPerm('directory_private')}
+        {if !$smarty.session.user->isWatchedUser($profile)}
     <a href="carnet/notifs/add_nonins/{$user->login()}?token={xsrf_token}">{*
     *}{icon name=add title="Ajouter à la liste de mes surveillances"}</a>
         {else}
     <a href="carnet/notifs/del_nonins/{$user->login()}?token={xsrf_token}">{*
     *}{icon name=cross title="Retirer de la liste de mes surveillances"}</a>
         {/if}
+        {/if}
       {elseif $registered}
     <a href="profile/{$profile->hrid()}" class="popup2">{*
     *}{icon name=user_suit title="Afficher la fiche"}</a>
     *}{icon name=vcard title="Afficher la carte de visite"}</a>
     <a href="mailto:{$user->bestEmail()}">{*
     *}{icon name=email title="Envoyer un email"}</a>
-          {if !$smarty.session.user->isContact($user)}
-    <a href="carnet/contacts?action=ajouter&amp;user={$user->login()}&amp;token={xsrf_token}">{*
+          {if hasPerm('directory_private')}
+          {if !$smarty.session.user->isContact($profile)}
+    <a href="carnet/contacts?action=ajouter&amp;user={$profile->hrid()}&amp;token={xsrf_token}">{*
     *}{icon name=add title="Ajouter à mes contacts"}</a>
           {else}
-    <a href="carnet/contacts?action=retirer&amp;user={$user->login()}&amp;token={xsrf_token}">{*
+    <a href="carnet/contacts?action=retirer&amp;user={$profile->hrid()}&amp;token={xsrf_token}">{*
     *}{icon name=cross title="Retirer de mes contacts"}</a>
           {/if}
+          {/if}
         {/if}
       {/if}
     </div>
+    {/if}
 
-    {if hasPerm('admin')}
+    {if hasPerm('admin') || $smarty.session.user->canEdit($profile)}
     <div>
-      [{if $registered && !$dead}
+      [{if hasPerm('admin') && $hasowner}{if !$registered && !$dead}
       <a href="marketing/private/{$user->login()}">{*
         *}{icon name=email title="marketter user"}</a>
       {/if}
       <a href="admin/user/{$user->login()}">{*
-      *}{icon name=wrench title="administrer user"}</a>
-      <a href="http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&amp;anc_id={$profile->ax_id}">{*
-      *}{icon name=user_gray title="fiche AX"}</a>]
+      *}{icon name=wrench title="administrer user"}</a>{/if}{*
+      *}{if hasPerm('admin') || $smarty.session.user->canEdit($profile)}{*
+      *}<a href="profile/edit/{$user->login()}">{*
+      *}{icon name=user_edit title="modifier la fiche"}</a>{*
+      *}<a href="profile/ax/{$user->login()}">{*
+      *}{icon name=user_gray title="fiche AX"}</a>{/if}]
     </div>
     {/if}
   </div>
   {if !$dead}
     {assign var=address value=$profile->getMainAddress()}
     {assign var=web     value=$profile->getWebSite()}
-    {assign var=job     value=$profile->getMailJob()}
-    {if $web || $profile->mobile || $address.country || $job || (!$dead && !$registered)}
+    {assign var=job     value=$profile->getMainJob()}
+    {if $web || $profile->mobile || ($address && $address->country) || $job || !$registered || $user->lost}
     <table cellspacing="0" cellpadding="0">
       {if $web}
       <tr>
-        <td class="lt">Page web&nbsp;:</td>
-        <td class="rt"><a href="{$web}">{$web}</a></td>
+        <td class="lt">{$web.name}&nbsp;:</td>
+        <td class="rt"><a href="{$web.address}">{$web.address}</a></td>
       </tr>
       {/if}
-      {if $address.country}
+      {if $address && $address->country}
       <tr>
         <td class="lt">Géographie&nbsp;:</td>
-        <td class="rt">{if $address.locality}{$address.locality}, {/if}{$address.country}</td>
+        <td class="rt">{if $address->locality}{$address->locality}, {/if}{$address->country}</td>
       </tr>
       {/if}
       {if $profile->mobile && !$dead}
       <tr>
         <td class="lt">Profession&nbsp;:</td>
         <td class="rt">
-          {if $job.url|default:$job.user_site}<a href="{$job.url|default:$job.user_site}">{$job.name}</a>{else}{$job.name}{/if}
-          {if $job.subsubsector}&nbsp;({$job.subsubsector}){/if}{if $job.description}<br />{$job.description}{/if}
+          {if $job->company->url|default:$job->user_site}<a href="{$job->company->url|default:$job->user_site}">{$job->company->name}</a>{else}{$job->company->name}{/if}
+          {if $job->description}<br />{$job->description}{/if}
         </td>
       </tr>
       {/if}
       {if $withAuth}
-      {if !$registered}
+      {if !$registered && $hasowner}
       <tr>
         <td class="smaller" colspan="2">
-          {"Ce"|sex:"Cette":$user} camarade n'est pas {"inscrit"|sex:"inscrite":$user}.
+          {"Ce"|sex:"Cette":$profile} camarade n'est pas {"inscrit"|sex:"inscrite":$profile}.
           <a href="marketing/public/{$user->login()}" class='popup'>Si tu connais son adresse email,
-          <strong>n'hésite pas à nous la transmettre !</a>
+          <strong>n'hésite pas à nous la transmettre !</strong></a>
         </td>
       </tr>
       {elseif $user->state neq 'disabled' && $user->lost}
       <tr>
         <td class="smaller" colspan="2">
-          {"Ce"|sex:"Cette":$user} camarade n'a plus d'adresse de redirection valide.
+          {"Ce"|sex:"Cette":$profile} camarade n'a plus d'adresse de redirection valide.
           <a href="marketing/broken/{$user->login()}">
             Si tu en connais une, <strong>n'hésite pas à nous la transmettre</strong>.
           </a>