276c8f5630cd3fd1d66977b10f5f65d0788baeb9
3 include_once("php/traitement_pre_affichage.php");
5 if (!$participant->existe())
7 echo '<p><em>Remarque : </em>Il faut être inscrit pour pouvoir voter.</p>';
9 else if ($config->get("inscription_terminees"))
11 echo '<p><em>Remarque : </em>Les inscriptions sont terminées, il n\'est plus possible de voter.</p>';
14 $vote_possible = !$config->get("inscription_terminees") && $participant->existe();
17 <form id="formulaireJeuxJoues" method="post" action="index.php?page=jeux_joues">
18 <p><input type="hidden" name="set_jeux_joues" value="1" /></p>
20 <tr>', ($vote_possible ? '<th></th>' : ''), '<th>Votes</th><th>Nom</th><th>Type</th><th></th></tr>';
22 # /!\ Attention, requête un poil tricky :
23 # On souhait avoir une liste des jeux joués avec pour chaque tuple :
24 # - l'id du jeu et son nom
25 # - Un tableau des participants ayant voté pour ce jeu
26 # De plus il faut que le résultat soit trié par le nombre de vote
27 $jeux_query = pg_query("
33 array_agg(jeux_choisis.participant_id) AS participants,
34 (COUNT(*) + (CASE WHEN bool_and(jeux_choisis.participant_id is null) THEN -1 ELSE 0 END)) as nb_vote
37 LEFT JOIN jeux_choisis ON jeux.id = jeux_choisis.jeu_id
38 GROUP BY jeux.id, jeux.nom, jeux.type, jeux.url
39 ORDER BY nb_vote DESC, jeux.nom
42 while ($jeu = pg_fetch_object($jeux_query))
46 # est-ce que le participant courant à voté pour ce jeu ?
49 $participants = split(",", ereg_replace("[{-}]", "", $jeu->participants
));
50 for($i = 0; $i < count($participants); $i++
)
51 $participants[$i] = (int)$participants[$i];
53 $a_vote = in_array($participant->info
->id
, $participants);
56 $a_url = preg_match('/^https?:\/\/.+$/', $jeu->url
);
59 $vote_possible ? '<td><input type="checkbox" name="votes[]" '. ($a_vote ? 'checked="checked"' : '') .' value="'.$jeu->id
.'" /></td>' : '',
60 '<td>' . $jeu->nb_vote
. '</td>',
61 '<td ' . ($a_vote ? 'class="aVote" ': '').'>' . ($a_url ? '<a href="'. htmlentities($jeu->url
) .'">' : '') . traitement_pre_affichage($jeu->nom
) . ($a_url ? '</a>' : '') . '</td>',
62 '<td ' . ($a_vote ? 'class="aVote" ': '').'>' . traitement_pre_affichage($jeu->type
) . '</td>',
72 <input class="info" type="text" size="20" maxlength="50" name="jeu" value="<nom>" >
73 <input class="info" type="text" size="10" maxlength="100" name="type" value="<type>" />
74 <input class="info" type="text" size="20" maxlength="200" name="url" value="<URL>" />
76 <p><input type="submit" value="Voter" /></p>';
80 # affichage du nombre de vote restant
82 echo '<p>Nombre de votes restant : ' . $participant->nb_vote_restant() . '</p>';