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