Merge commit 'origin/master' into account
[platal.git] / templates / include / minifiche.tpl
index 182a737..f6cdc65 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-<div class="contact {if (!$c.inscrit && $smarty.session.auth ge AUTH_COOKIE) || $c.dcd}grayed{/if}"
-     {if $c.inscrit}{if $smarty.session.auth ge AUTH_COOKIE}title="fiche mise à jour le {$c.date|date_format}"{/if}{/if}>
+{assign var=dead    value=$profile->deathdate}
+{if $smarty.session.auth ge AUTH_COOKIE}
+  {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}
+  {* 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 || $dead }grayed{/if}"
+     {if $registered}title="fiche mise à jour le {$profile->last_change|date_format}"{/if}>
   <div class="identity">
-    {if $smarty.session.auth ge AUTH_COOKIE}
+    {if $withAuth}
     <div class="photo">
-      <img src="photo/{$c.hruid}"
-           alt="{$c.prenom} {$c.nom}" />
+      <img src="photo/{$profile->hrid()}" alt="{$profile->directory_name}" />
     </div>
     {/if}
 
     <div class="nom">
-      {if $c.sexe}&bull;{/if}
-      {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}<a href="profile/{$c.hruid}" class="popup2">{/if}
-      {if $c.nom_usage}{$c.nom_usage} {$c.prenom}<br />({$c.nom}){else}{$c.nom} {$c.prenom}{/if}
-      {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}</a>{/if}
+      {if $profile->isFemale()}&bull;{/if}
+      {if !$dead && $registered}<a href="profile/{$profile->hrid()}" class="popup2">{/if}
+      {$profile->full_name}
+      {if !$dead && $registered}</a>{/if}
     </div>
 
-    <div class="appli">
-      {if $c.iso3166}
-      <img src='images/flags/{$c.iso3166}.gif' alt='{$c.nat}' height='11' title='{$c.nat}' />&nbsp;
+    <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}
-      X {$c.promo}{if $c.app0text}, {applis_fmt type=$c.app0type text=$c.app0text url=$c.app0url}{*
-      *}{/if}{if $c.app1text}, {applis_fmt type=$c.app1type text=$c.app1text url=$c.app1url}{/if}{*
-      *}{if $c.dcd}, décédé{if $c.sexe}e{/if} le {$c.deces|date_format}{/if}
+      {$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":$profile} le {$profile->deathdate|date_format}{/if}
     </div>
   </div>
 
-  {if $smarty.session.auth ge AUTH_COOKIE}
+  {if $withAuth}
   <div class="noprint bits">
     <div>
-      {if !$c.wasinscrit && !$c.dcd}
-        {if $show_action eq ajouter}
-    <a href="carnet/notifs/add_nonins/{$c.user_id}?token={xsrf_token}">{*
+      {if !$registered && !$dead && $hasowner}
+        {if $show_action eq 'ajouter'}
+    <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/{$c.user_id}?token={xsrf_token}">{*
+    <a href="carnet/notifs/del_nonins/{$user->login()}?token={xsrf_token}">{*
     *}{icon name=cross title="Retirer de la liste de mes surveillances"}</a>
         {/if}
-      {elseif $c.wasinscrit}
-    <a href="profile/{$c.hruid}" class="popup2">{*
+      {elseif $registered}
+    <a href="profile/{$profile->hrid()}" class="popup2">{*
     *}{icon name=user_suit title="Afficher la fiche"}</a>
-        {if !$c.dcd}
-    <a href="vcard/{$c.hruid}.vcf">{*
+        {if !$dead}
+    <a href="vcard/{$profile->hrid()}.vcf">{*
     *}{icon name=vcard title="Afficher la carte de visite"}</a>
-    <a href="mailto:{$c.bestemail}">{*
+    <a href="mailto:{$user->bestEmail()}">{*
     *}{icon name=email title="Envoyer un email"}</a>
-          {if $show_action eq ajouter}
-    <a href="carnet/contacts?action={$show_action}&amp;user={$c.hruid}&amp;token={xsrf_token}">{*
+          {if !$smarty.session.user->isContact($user)}
+    <a href="carnet/contacts?action=ajouter&amp;user={$user->login()}&amp;token={xsrf_token}">{*
     *}{icon name=add title="Ajouter à mes contacts"}</a>
           {else}
-    <a href="carnet/contacts?action={$show_action}&amp;user={$c.hruid}&amp;token={xsrf_token}">{*
+    <a href="carnet/contacts?action=retirer&amp;user={$user->login()}&amp;token={xsrf_token}">{*
     *}{icon name=cross title="Retirer de mes contacts"}</a>
           {/if}
         {/if}
       {/if}
     </div>
 
-    {if hasPerm('admin')}
+    {if hasPerm('admin') && $hasowner}
     <div>
-      [{if !$c.wasinscrit && !$c.dcd}
-      <a href="marketing/private/{$c.hruid}">{*
+      [{if $registered && !$dead}
+      <a href="marketing/private/{$user->login()}">{*
         *}{icon name=email title="marketter user"}</a>
       {/if}
-      <a href="admin/user/{$c.hruid}">{*
+      <a href="admin/user/{$user->login()}">{*
       *}{icon name=wrench title="administrer user"}</a>
-      <a href="profile/ax/{$c.hruid}">{*
+      <a href="profile/ax/{$user->login()}">{*
       *}{icon name=user_gray title="fiche AX"}</a>]
     </div>
     {/if}
   {/if}
 
   <div class="long">
-  {if $c.wasinscrit || !$c.dcd}
-    {if $c.web || $c.mobile || $c.countrytxt || $c.city || $c.region || $c.entreprise || $c.freetext || (!$c.dcd && !$c.actif )}
+  {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)}
     <table cellspacing="0" cellpadding="0">
-      {if $c.web}
+      {if $web}
       <tr>
         <td class="lt">Page web&nbsp;:</td>
-        <td class="rt"><a href="{$c.web}">{$c.web}</a></td>
+        <td class="rt"><a href="{$web}">{$web}</a></td>
       </tr>
       {/if}
-      {if ($c.countrytxt || $c.city) && !$c.dcd}
+      {if $address.country && !$c.dcd}
       <tr>
         <td class="lt">Géographie&nbsp;:</td>
-        <td class="rt">{$c.city}{if $c.city && $c.countrytxt}, {/if}{$c.countrytxt}</td>
+        <td class="rt">{if $address.locality}{$address.locality}, {/if}{$address.country}</td>
       </tr>
       {/if}
-      {if $c.mobile && !$c.dcd}
+      {if $profile->mobile && !$dead}
       <tr>
         <td class="lt">Mobile&nbsp;:</td>
-        <td class="rt">{$c.mobile}</td>
+        <td class="rt">{$profile->mobile}</td>
       </tr>
       {/if}
-      {if $c.entreprise}
+      {if $job}
       <tr>
         <td class="lt">Profession&nbsp;:</td>
         <td class="rt">
-          {if $c.job_web}<a href="{$c.job_web}">{$c.entreprise}</a>{else}{$c.entreprise}{/if}
-          {if $c.secteur} ({$c.secteur}){/if}{if $c.fonction}<br />{$c.fonction}{/if}
+          {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}
         </td>
       </tr>
       {/if}
-      {if $c.freetext}
+      {if $withAuth}
+      {if !$registered && $hasowner}
       <tr>
-        <td class="lt">Commentaire&nbsp;:</td>
-        <td class="rt">{$c.freetext|nl2br}</td>
+        <td class="smaller" colspan="2">
+          {"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>
+        </td>
       </tr>
-      {/if}
-      {if !$c.dcd && (!$c.actif || !$c.wasinscrit) && $smarty.session.auth ge AUTH_COOKIE}
+      {elseif $user->state neq 'disabled' && $user->lost}
       <tr>
         <td class="smaller" colspan="2">
-          {if !$c.wasinscrit}
-          Ce{if $c.sexe}tte{/if} camarade n'est pas inscrit{if $c.sexe}e{/if}.
-          <a href="marketing/public/{$c.hruid}" class='popup'>Si tu connais son adresse email,
-          <strong>n'hésite pas à nous la transmettre !</strong></a>
-          {elseif !$c.actif}
-          Ce{if $c.sexe}tte{/if} camarade n'a plus d'adresse de redirection valide.
-          <a href="marketing/broken/{$c.hruid}">
+          {"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>
-          {/if}
         </td>
       </tr>
       {/if}
+      {/if}
     </table>
     {/if}
   {/if}