+ $this->traiter_donnees_inscription();
+ if (!$this->login_deja_pris() && $this->donnees_inscription_valides(true))
+ {
+ pg_query("BEGIN");
+ pg_query_params("UPDATE participants SET pseudo = $1 WHERE id = $2", array($_POST['pseudo'], $this->participant->info->id));
+ if ($_POST['pass1'] != '') // Uniquement si un nouveau password est donné.
+ pg_query_params("UPDATE participants SET password = $1 WHERE id = $2", array(sha1($_POST['pass1']), $this->participant->info->id));
+ pg_query_params("UPDATE participants SET clan_nom = $1 WHERE id = $2", array($_POST['clan_nom'], $this->participant->info->id));
+ pg_query_params("UPDATE participants SET clan_tag = $1 WHERE id = $2", array($_POST['clan_tag'], $this->participant->info->id));
+ pg_query_params("UPDATE participants SET nom = $1 WHERE id = $2", array($_POST['nom'], $this->participant->info->id));
+ pg_query_params("UPDATE participants SET prenom = $1 WHERE id = $2", array($_POST['prenom'], $this->participant->info->id));
+ pg_query_params("UPDATE participants SET age = $1 WHERE id = $2", array($_POST['age'], $this->participant->info->id));
+ pg_query_params("UPDATE participants SET e_mail = $1 WHERE id = $2", array($_POST['e_mail'], $this->participant->info->id));
+ pg_query_params("UPDATE participants SET remarques = $1 WHERE id = $2", array($_POST['remarques'], $this->participant->info->id));
+ $this->set_periodes($this->participant->info->id);
+ pg_query("COMMIT");
+ //header("Location: /inscrits.html");
+ $this->message_utilisateur = "Les modifications ont été enregistrées";
+
+ // Puisque les données du participant ont changés il faut les re-charger.
+ $this->participant->chargerInfos();
+ }
+ }
+ # vote pour des jeux (autorisé même lorsque les inscriptions sont terminées)
+ else if (isset($_POST['set_jeux_joues']) && $this->participant->existe() && !$config->get("inscription_terminees"))
+ {
+ $votes = $_POST['votes'];
+ if (!$votes)
+ $votes = array();
+
+ pg_query("BEGIN");
+
+ # l'utilisateur peut proposer le nom d'un jeu qui ne se trouve pas dans la liste
+ $jeu = trim($_POST['jeu']);
+ if ($jeu !== '')
+ {
+ if(@pg_query_params("INSERT INTO jeux (participant_id, nom, type, url) VALUES ($1, $2, $3, $4)", array($this->participant->info->id, $jeu, $_POST['type'], $_POST['url'])))
+ {
+ $row = pg_fetch_row(pg_query("SELECT LASTVAL()"));
+ $id = $row[0];
+ if ($id != 0) # si le jeu se trouve déjà dans la liste alors $id == 0
+ array_unshift($votes, $id);
+ }
+ else # Puisque le jeu existe déjà, on le recherche
+ {
+ pg_query("ROLLBACK");
+ pg_query("BEGIN");
+ $res = pg_query_params("SELECT id FROM jeux WHERE nom = $1", array($jeu));
+ if ($id = pg_fetch_object($res))
+ if (!in_array($id->id, $votes))
+ array_unshift($votes, $id->id);
+ }
+ }
+
+ # suppression des anciens votes (remplacement par les nouveaux)
+ pg_query_params("DELETE FROM jeux_choisis WHERE participant_id = $1", array($this->participant->info->id));
+
+ # traite les trois premiers votes
+ for ($i = 0; $i < count($votes) && $i < $this->config->get('nb_votes_jeux'); $i++)
+ {
+ pg_query_params("INSERT INTO jeux_choisis (participant_id, jeu_id) VALUES ($1, $2)", array($this->participant->info->id, (int)$votes[$i]));
+ }
+
+ pg_query("COMMIT");
+ }
+ }