Fix profile view when not logged in.
[platal.git] / templates / profile / profile.tpl
index 036ae02..91af9a1 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2014 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -24,7 +24,7 @@
 <script type="text/javascript">//<![CDATA[
 function chgMainWinLoc(strPage)
 {
-  strPage = platal_baseurl + strPage;
+  strPage = $.plURL(strPage);
   if (parent.opener) {
     try {
       parent.opener.document.location = strPage;
@@ -36,34 +36,43 @@ function chgMainWinLoc(strPage)
     document.location = strPage;
   }
 }
+
+$($.closeOnEsc);
+
 //]]></script>
 {/literal}
-
 <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()}{if $with_pending_pic}/req{/if}" width="{$photo->width()}"/>{/if}
 
-    {if $logged && $view eq 'private' && ( $profile->section|smarty:nodefaults || $profile->getBinets()|smarty:nodefaults || ($owner && $owner->groups()|smarty:nodefaults))}
+    {if $logged && $view->isVisible(#Visibility::EXPORT_AX#) && ( $profile->section|smarty:nodefaults || $profile->getBinets()|smarty:nodefaults || ($owner && $owner->groups(true,true)|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()}
+      {assign var=binets value=$profile->getFullBinets()}
       {if $binets|@count}<div><em class="intitule">Binet{if count($binets) > 1}s{/if}&nbsp;: </em>
-      <span>{', '|implode:$profile->getBinetsNames()}</span></div>{/if}
+      <span> <br />
+      {foreach from=$binets item=binet name=binets}
+        {if !$smarty.foreach.binets.first}, {/if}
+        <span title="{$binet.text}">{if $binet.url}<a href="{$binet.url}">{/if}{$binet.text}{if $binet.url}</a>{/if}</span>
+      {/foreach}
+      </span></div>{/if}
 
-      {if $owner && $view eq 'private'}
-        {assign var=groups value=$owner->groupNames(true)}
+      {if $owner && $view->isVisible(#Visibility::EXPORT_AX#)}
+        {assign var=groups value=$owner->groups(true,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}
+        {foreach from=$groups item=group name=groups}
+          {if !$smarty.foreach.groups.first}, {/if}
+          <span title="{$group.nom}"><a href="{if $group.site}{$group.site}{else}http://www.polytechnique.net/{$group.diminutif}{/if}">{$group.nom}</a></span>
+        {/foreach}
         </span></div>{/if}
       {/if}
 
     {/if}
 
-    {* 458752 stands for 0x70000 = Profile::NETWORKING_ALL *}
-    {assign var=networking value=$profile->getNetworking(458752)}
+    {assign var=networking value=$profile->getNetworking(#Profile::NETWORKING_ALL#)}
     {if count($networking) > 0}
       <h2>Sur le web...</h2>
       {foreach from=$networking item=network}
@@ -77,6 +86,14 @@ function chgMainWinLoc(strPage)
       {/foreach}
     {/if}
 
+    {assign var=hobbies value=$profile->getHobbies()}
+    {if count($hobbies) > 0}
+      <h2>Hobbies...</h2>
+      {foreach from=$hobbies key=type item=text}
+        <div><em class="intitule">{$type} : </em>{$text}</div>
+      {/foreach}
+    {/if}
+
     {if $profile->freetext}
       <h2>Commentaires&nbsp;:</h2>
       <span>{$profile->freetext|miniwiki|smarty:nodefaults}</span>
@@ -87,7 +104,10 @@ function chgMainWinLoc(strPage)
   <div id="fiche_identite" class="part">
     <div class="civilite">
       {if $profile->isFemale()}&bull;{/if}
-        {if $logged}{$profile->private_name}{else}{$profile->public_name}{/if}
+      {if $view->isVisible(#Visibility::EXPORT_PRIVATE#)}{$profile->private_name}{else}{$profile->public_name}{/if}
+      {if $logged && ( hasPerm('admin') || $smarty.session.user->canEdit($profile)) && $view->isVisible(#Visibility::EXPORT_PRIVATE#)}
+        <span title="Identifiant AX, uniquement visible par les administrateurs du site" style="font-weight:normal;font-style:italic;"> ({$profile->ax_id})</span>
+      {/if}
 
       {if $logged}
         &nbsp;{if !$profile->isDead()}<a href="vcard/{$owner->login()}.vcf">{*
@@ -106,14 +126,17 @@ function chgMainWinLoc(strPage)
           {icon name=wrench title="administrer user"}</a>
         {/if}
 
-        {if $owner->login() eq $smarty.session.hruid}
+        {if $smarty.session.user->isMyProfile($profile)}
         <a href="javascript:chgMainWinLoc('profile/edit')">{icon name="user_edit" title="Modifier ma fiche"}</a>
+        {elseif hasPerm('admin') || $smarty.session.user->canEdit($profile)}
+        <a href="javascript:chgMainWinLoc('profile/edit/{$profile->hrpid}')">
+          {icon name=user_edit title="modifier la fiche"}
+        </a>
         {/if}
-
       {/if}
     </div>
 
-    {if $logged && $view eq 'private'}
+    {if $logged && $view->isVisible(#Visibility::EXPORT_AX#) && $owner && $owner->state eq 'active'}
     <div class='maj'>
       Fiche mise à jour<br />
       le {$profile->last_change|date_format}
@@ -122,9 +145,9 @@ function chgMainWinLoc(strPage)
 
     {* 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}
+    {if ($logged && $view->isVisible(#Visibility::EXPORT_AX#)) || count($phones) > 0}
     <div class="contact">
-      {if $logged && $view eq 'private'}
+      {if $logged && $view->isVisible(#Visibility::EXPORT_AX#)}
       <div class='email'>
         {if $profile->isDead()}
         Décédé{if $profile->isFemale()}e{/if} le {$profile->deathdate|date_format}
@@ -135,7 +158,7 @@ function chgMainWinLoc(strPage)
         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}
-        {if $virtualalias}
+        {if $virtualalias && $view->isVisible(#Visibility::EXPORT_PRIVATE#) && $virtualalias neq $owner->bestEmail()}
         <a href="mailto:{$virtualalias}">{$virtualalias}</a><br />
         {/if}
         <a href="mailto:{$owner->bestEmail()}">{$owner->bestEmail()}</a>
@@ -152,6 +175,8 @@ function chgMainWinLoc(strPage)
       {/if}
       <div class='spacer'></div>
     </div>
+    {else}
+    <div class='spacer'></div>
     {/if}
 
     <div class='formation'>
@@ -159,18 +184,17 @@ function chgMainWinLoc(strPage)
       <img src='images/flags/{$code}.gif' alt='{$code}' height='11' title='{$country}' />&nbsp;
       {/foreach}
 
-      {$profile->promo()}
+      {$profile->promo('details')}
 
-      {if $logged && $profile->mentor_expertise}
+      {if $logged && $view->isVisible(#Visibility::EXPORT_AX#) && $profile->mentor_expertise}
       [<a href="referent/{$profile->hrid()}" class='popup2'>Ma fiche référent</a>]
       {/if}
 
       {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=$profile}</li>
+          <li>{display_education edu=$edu profile=$profile full=true}</li>
         {/foreach}
         </ul>
       {/if}
@@ -210,13 +234,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}
@@ -230,11 +254,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=phones value=$job->phones()}
+      {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" phones=$phones}
-      {elseif $phones}
-        {display_phones tels=$phones}
+        {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}
@@ -249,7 +273,7 @@ function chgMainWinLoc(strPage)
       <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}
+          {$m.text}{if $m.level} ({$m.level}){/if}<br />{$m.grade}
         </div>
       </div>
       {/foreach}
@@ -264,14 +288,14 @@ function chgMainWinLoc(strPage)
   </div>
   {/if}
 
-  {if $view eq 'public'}
+  {if $view->level() eq #Visibility::VIEW_PUBLIC#}
   <div class="part">
     <small>
     Cette fiche est publique et visible par tout internaute,<br />
     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'}
+  {elseif $view->level() eq #Visibility::VIEW_AX#}
   <div class="part">
     <small>
     Cette fiche est privée et ne recense que les informations transmises à l'AX.
@@ -282,4 +306,4 @@ function chgMainWinLoc(strPage)
   <div class="spacer"></div>
 </div>
 
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+{* vim:set et sw=2 sts=2 sws=2 fenc=utf-8: *}