Implement hidden permission in profile editor
[platal.git] / templates / profile / deco.tpl
index 1dd1f24..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  *}
 {*                                                                        *}
 {**************************************************************************}
 
-
-{literal}
-<script type="text/javascript">//<![CDATA[
-function update()
-{
-  var val = document.forms.prof_annu['medal_sel'].value;
-  if (val == '' || document.getElementById('medal_' + val) != null) {
-    document.getElementById('medal_add').display.style = 'none';
-  } else {
-    document.getElementById('medal_add').display.style = '';
-  }
-}
-
-  var valid = new array();
-  function medal_add()
-  {
-    var selid = document.forms.prof_annu.medal_sel.selectedIndex;
-    document.forms.prof_annu.medal_id.value = document.forms.prof_annu.medal_sel.options[selid].value;
-    document.forms.prof_annu.grade_id.value = document.forms.prof_annu.grade_sel.value;
-    document.forms.prof_annu.medal_op.value = "ajouter";
-    document.forms.prof_annu.submit();
-  }
-
-  function medal_del( id )
-  {
-    document.forms.prof_annu.medal_id.value = id;
-    document.forms.prof_annu.medal_op.value = "retirer";
-    document.forms.prof_annu.submit();
-  }
-
-  function medal_cancel(stamp)
-  {
-    document.forms.prof_annu.medal_id.value = stamp;
-    document.forms.prof_annu.medal_op.value = "annuler";
-    document.forms.prof_annu.submit();
-  }
-  var subgrades = new array();
-  function getoption( select_input, j)
-  {
-    if (!document.all)
-    {
-      return select_input.options[j];
-    }
-    else
-    {
-      return j;
-    }
-  }
-  function medal_grades( sel_medal )
-  {
-    var subg = subgrades[sel_medal.selectedIndex];
-    document.getElementById("grade_sel_div").style.display = subg?"inline":"none";
-    if (!subg) return;
-    var select = document.getElementById("grade_sel");
-    while (select.length > 1)
-    {
-      select.remove(1);
-    }
-
-    for (i=0; i < subg.length; i++)
-    {
-      var dmc = document.createElement("option");
-      dmc.text= subg[i][1];
-      dmc.value = subg[i][0];
-      select.add(dmc,getoption(select,i));
-    }
-    var vide = document.createElement("option");
-    vide.text = "";
-    vide.value = 0;
-    select.add(vide,getoption(select,0));
-    select.remove(subg.length+1);
-  }
-  //]]>
-{/literal}
-{foreach from=$medal_list key=type item=list}
-  {foreach from=$list item=m}{if $grades[$m.id]|@count}
-    subgrades[{$m.id}] = new array({$grades[$m.id]|@count});
-    i = 0;
-    {foreach from=$grades[$m.id] item=g}
-      subgrades[{$m.id}][i] = [{$g.gid},"{$g.text}"];
-      i++;
-    {/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">
-        <select name="medal_sel" onchange="update()">
-          <option value=''></option>
+      <div style="clear: both; margin-top: 0.2em" id="medals">
+        <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: *}