Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Hardcore: Liste des battles pour lesquels il reste des participations à noter
- // Battles éligibles à la notation
- $battles_notables = fetchAll($db->query('SELECT id FROM battle WHERE (status > 0 AND officiel = 0 AND status < 3) OR (officiel = 1 AND status = 2)'));
- $bn = array();
- foreach($battles_notables as $b)
- $bn[] = $b->id;
- $bn_list = join(', ', $bn);
- // $bn_list contient une liste d'id de battles éligibles sous la forme: 1, 3, 5, 12, 24
- // Participations aux battles éligibles
- $participations_notables = fetchAll($db->query('SELECT id, id_battle, id_gratteux FROM participation WHERE id_battle IN ('.$bn_list.')'));
- // Participations déja notées parmi les éligibles
- $participations_notees = fetchAll($db->query('SELECT id_participation, id_battle FROM note WHERE id_notant='.$__user->id.' AND id_battle IN ('.$bn_list.')'));
- $pnt = array();
- foreach($participations_notees as $p)
- $pnt[] = $p->id_participation;
- $pn = array();
- foreach($participations_notables as $p)
- {
- if (in_array($p->id, $pnt) || $p->id_gratteux == $__user->id) {
- // Déja noté ou participation propre
- } else {
- if (array_key_exists($p->id_battle, $pn)) // Si on a déja ajouté le battle comme étant a noter
- {
- $pn[$p->id_battle]->cnt++; // On ajoute une participation
- } else { // Sinon on ajoute le battle
- $pn[$p->id_battle] = $db->query('SELECT id, titre FROM battle WHERE id='.$p->id_battle)->fetch_object();
- $pn[$p->id_battle]->cnt = 1;
- }
- }
- }
Add Comment
Please, Sign In to add comment