Guest User

Untitled

a guest
Jul 12th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1.  
  2.   // Hardcore: Liste des battles pour lesquels il reste des participations à noter
  3.  
  4.  
  5.   // Battles éligibles à la notation
  6.   $battles_notables = fetchAll($db->query('SELECT id FROM battle WHERE (status > 0 AND officiel = 0 AND status < 3) OR (officiel = 1 AND status = 2)'));
  7.  
  8.   $bn = array();
  9.  
  10.   foreach($battles_notables as $b)
  11.     $bn[] = $b->id;
  12.  
  13.   $bn_list = join(', ', $bn);
  14.  
  15.   // $bn_list contient une liste d'id de battles éligibles sous la forme: 1, 3, 5, 12, 24
  16.  
  17.   // Participations aux battles éligibles
  18.   $participations_notables = fetchAll($db->query('SELECT id, id_battle, id_gratteux FROM participation WHERE id_battle IN ('.$bn_list.')'));
  19.  
  20.   // Participations déja notées parmi les éligibles
  21.   $participations_notees = fetchAll($db->query('SELECT id_participation, id_battle FROM note WHERE id_notant='.$__user->id.' AND id_battle IN ('.$bn_list.')'));
  22.  
  23.   $pnt = array();
  24.  
  25.   foreach($participations_notees as $p)
  26.     $pnt[] = $p->id_participation;
  27.  
  28.   $pn = array();
  29.  
  30.   foreach($participations_notables as $p)
  31.   {
  32.     if (in_array($p->id, $pnt) || $p->id_gratteux == $__user->id) {
  33.       // Déja noté ou participation propre
  34.     } else {
  35.  
  36.       if (array_key_exists($p->id_battle, $pn)) // Si on a déja ajouté le battle comme étant a noter
  37.       {
  38.         $pn[$p->id_battle]->cnt++; // On ajoute une participation
  39.       } else {  // Sinon on ajoute le battle
  40.         $pn[$p->id_battle] = $db->query('SELECT id, titre FROM battle WHERE id='.$p->id_battle)->fetch_object();
  41.         $pn[$p->id_battle]->cnt = 1;
  42.       }  
  43.     }
  44.   }
Add Comment
Please, Sign In to add comment