existe()) { echo '

Remarque : Il faut être inscrit pour pouvoir voter.

'; } else if ($config->get("inscription_terminees")) { echo '

Remarque : Les inscriptions sont terminées, il n\'est plus possible de voter.

'; } $vote_possible = !$config->get("inscription_terminees") && $participant->existe(); echo '

', ($vote_possible ? '' : ''), ''; # /!\ Attention, requête un poil tricky : # On souhait avoir une liste des jeux joués avec pour chaque tuple : # - l'id du jeu et son nom # - Un tableau des participants ayant voté pour ce jeu # De plus il faut que le résultat soit trié par le nombre de vote $jeux_query = pg_query(" SELECT jeux.id, jeux.nom, array_agg(jeux_choisis.participant_id) AS participants, (COUNT(*) + (CASE WHEN bool_and(jeux_choisis.participant_id is null) THEN -1 ELSE 0 END)) as nb_vote FROM jeux LEFT JOIN jeux_choisis ON jeux.id = jeux_choisis.jeu_id GROUP BY jeux.id, jeux.nom ORDER BY nb_vote DESC, jeux.nom "); while ($jeu = pg_fetch_object($jeux_query)) { $a_vote = FALSE; # est-ce que le participant courant à voté pour ce jeu ? if ($vote_possible) { $participants = split(",", ereg_replace("[{-}]", "", $jeu->participants)); for($i = 0; $i < count($participants); $i++) $participants[$i] = (int)$participants[$i]; $a_vote = in_array($participant->info->id, $participants); } echo '', $vote_possible ? '' : '', '', ''; } echo '
VotesJeux
' . $jeu->nb_vote . '' . traitement_pre_affichage($jeu->nom) . '
'; if ($vote_possible) echo '

Autre :

'; echo '
'; # affichage du nombre de vote restant if ($vote_possible) echo '

Nombre de votes restant : ' . $participant->nb_vote_restant() . '

'; ?>