Implement hidden permission in profile editor
[platal.git] / templates / profile / deco.tpl
index b4eb62b..e12b5ad 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2007 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2014 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*                                                                        *}
 {**************************************************************************}
 
-
-<script type="text/javascript">//<![CDATA[
-{literal}
-var subgrades = new array();
-var names     = new array();
-
-function update()
-{
-  var val = document.forms.prof_annu['medal_sel'].value;
-  if (val == '' || document.getElementById('medal_' + val) != null) {
-    document.getElementById('medal_add').style.display = 'none';
-  } else {
-    document.getElementById('medal_add').style.display = '';
-  }
-}
-
-function getMedalName(id)
-{
-  document.getElementById('medal_name_' + id).innerHTML = names[id];
-}
-
-function buildGrade(id, current)
-{
-  var grade;
-  var subg = subgrades[id];
-  var obj  = $('#medal_grade_' + id);
-  if (!subg) {
-    obj.prepend('<input type="hidden" name="medals[' + id + '][grade]" value="0" />');
-  } else {
-    var html = 'Agrafe : <select name="medals[' + id + '][grade]">';
-    html += '<option value="0">Non précisée</option>';
-    for (grade = 0 ; grade < subg.length ; grade++) {
-      html += '<option value="' + subg[grade][0] + '">' + subg[grade][1] + '</option>';
-    }
-
-    html += '</select>';
-    obj.prepend(html);
-  }
-}
-
-function makeAddProcess(id)
-{
-  return function(data)
-         {
-           $('#medals').after(data);
-           update();
-           getMedalName(id);
-           buildGrade(id, 0);
-         };
-}
-
-function add()
-{
-  var id = document.forms.prof_annu['medal_sel'].value;
-  $.get(platal_baseurl + 'profile/ajax/medal/' + id, makeAddProcess(id));
-}
-
-function remove(id)
-{
-  $("#medal_" + id).remove();
-  update();
-}
-
-{/literal}
-{foreach from=$medal_list key=type item=list}
-  {foreach from=$list item=m}
-  names[{$m.id}] = "{$m.text}";
-  {if $grades[$m.id]|@count}
-    names[{$m.id}] = "{$m.text}";
-    subgrades[{$m.id}] = new array({$grades[$m.id]|@count});
-    {foreach from=$grades[$m.id] item=g}
-      subgrades[{$m.id}][{$g.gid-1}] = [{$g.gid},"{$g.text}"];
-    {/foreach}
-  {/if}{/foreach}
-{/foreach}
-//]]></script>
-
+{if $isMe || hasPerm('admin') || ($medals|@count eq 0)}
+  {assign var=hidden_medal value=false}
+{elseif hasPerm('directory_hidden') || (($medals_pub neq 'hidden') && ($medals_pub neq 'private'))}
+  {assign var=hidden_medal value=false}
+{elseif hasPerm('directory_private') && ($medals_pub neq 'hidden')}
+  {assign var=hidden_medal value=false}
+{else}
+  {assign var=hidden_medal value=true}
+{/if}
 <table class="bicol">
   <tr>
     <th>
-      Médailles, Décorations, Prix, ...
+      <div class="flags" style="float: left">
+        <label><input type="checkbox" name="medals_pub"{if $medals_pub eq 'public'} checked="checked"{/if}{if $hidden_medal} disabled="disabled"{/if} />
+        {icon name="flag_green" title="site public"}</label>
+      </div>
+      Médailles, Décorations, Prix&hellip;{if $hidden_medal} (masqué){/if}
     </th>
   </tr>
+{if !$hidden_medal}
   <tr>
     <td>
-      <div class="flags">
-        <div class="vert" style="float: left">
-          <input type="checkbox" name="medals_pub"{if $medals_pub eq 'public'} checked="checked"{/if} />
-        </div>
-        <div class="texte">
-          ces informations sont normalement publiques (JO, ...) mais tu peux choisir de les associer a ta fiche publique
-        </div>
-      </div>
       <div style="clear: both; margin-top: 0.2em" id="medals">
-        <select name="medal_sel" onchange="update()">
-          <option value=''></option>
+        <select name="medal_sel" onchange="updateMedal()">
+          <option value=''>&nbsp;</option>
           {foreach from=$medal_list key=type item=list}
-          <optgroup label="{$trad[$type]}...">
+          <optgroup label="{$fullType[$type]}&hellip;">
             {foreach from=$list item=m}
             <option value="{$m.id}">{$m.text}</option>
             {/foreach}
           </optgroup>
           {/foreach}
         </select>
-        <span id="medal_add">
-          <a href="javascript:add();">{icon name=add title="Ajouter cette médaille"}</a>
+        <span id="medal_add" style="display: none">
+          <a href="javascript:addMedal();">{icon name=add title="Ajouter cette médaille"}</a>
         </span>
       </div>
       {foreach from=$medals item=medal key=id}
       {include file="profile/deco.medal.tpl" medal=$medal id=$id}
       {/foreach}
+      <p class="center" style="clear: both">
+        <small>
+          Si {if $isMe}ta{else}la{/if} décoration
+          ou {if $isMe}ta{else}la{/if} médaille ne figure pas dans la liste,
+          <a href="mailto:support@{#globals.mail.domain#}">contacte-nous</a>.
+        </small>
+      </p>
     </td>
   </tr>
+{/if}
 </table>
 
-<script type="text/javascript">
-update();
-</script>
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+{* vim:set et sw=2 sts=2 sws=2 fenc=utf-8: *}