Merge branch 'xorg/maint' into xorg/master
[platal.git] / templates / survey / index.tpl
index c0ade2f..81c3b73 100644 (file)
 
 <h1>Sondages</h1>
 
-{if $active->total() > 0}
-<table class="bicol" id="surveyList">
+{* Survey::MODE_ALL equals 0. *}
+{assign var=SurveyMODE_ALL value=0}
+{if $survey_current->total() > 0 || $smarty.session.auth}
+<table class="bicol">
   <tr>
-    <th>
+    <th colspan="3">
       Sondages en cours
     </th>
-    {if hasPerm('admin')}
-    <th></th>
-    {/if}
   </tr>
-  {iterate from=$active item=survey}
-  <tr class="{cycle values="impair,pair"}">
+  {iterate item=s from=$survey_current}
+  {if $smarty.session.auth || $s.mode == $SurveyMODE_ALL}
+  <tr class="{cycle name=cs_cycle values="impair,pair"}">
+    <td class="half" style="clear: both">
+      <a href="survey/vote/{$s.id}">{$s.title}</a>
+      {if $s.uid eq $smarty.session.user->id() || hasPerm('admin')}
+      (<a href="survey/result/{$s.id}">résultats partiels</a>)
+      {/if}
+    </td>
     <td>
-      <a href="survey/vote/{$survey->shortname}">{$survey->title}</a>
+      {$s.end|date_format:"%x"}
     </td>
-    {if hasPerm('admin')}
-    <td style="text-align: right">
-      <a href="survey/edit/{$survey->shortname}">{icon name=page_edit}</a>
+    <td>
+      {$survey_modes[$s.mode]}
     </td>
-    {/if}
   </tr>
+    {assign var="has_cs" value="true"}
+  {/if}
   {/iterate}
+  {if hasPerm('user')}
+  <tr class="impair">
+    <td colspan="3" style="text-align: right">
+      {if $smarty.session.auth}<a href="survey/edit/new">{icon name=page_edit} Proposer un sondage</a>{/if}
+    </td>
+  </tr>
+  {/if}
 </table>
 {/if}
 
-<div class="center">
-  <a href="survey/edit">{icon name=page_edit} Proposer un nouveau sondage</a>
-</div>
+<br />
+
+<table class="bicol">
+  <tr>
+    <th colspan="3">
+      Anciens sondages
+    </th>
+  </tr>
+  {iterate item=s from=$survey_old}
+    {if $smarty.session.auth || $s.mode == $SurveyMODE_ALL}
+  <tr class="{cycle name=os_cycle values="impair,pair"}">
+    <td>
+      <a href="survey/result/{$s.id}">
+        {$s.title}
+      </a>
+    </td>
+    <td>
+      {$s.end|date_format:"%x"}
+    </td>
+    <td>
+      {$survey_modes[$s.mode]}
+    </td>
+  </tr>
+      {assign var="has_os" value="true"}
+    {/if}
+  {/iterate}
+  {if !$has_os}
+  <tr>
+    <td class="half">Aucun ancien sondage</td>
+  </tr>
+  {/if}
+</table>
 
 {* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}