X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=php%2Fcontroller.php;h=a42051af08f3d66655e8369167c9ed32374b53fd;hb=HEAD;hp=cad43528819580bc7ec86ae6e30f54503f5ef242;hpb=c75da06bb039de2a43f21b6e853a72745f753dca;p=cl7.git diff --git a/php/controller.php b/php/controller.php index cad4352..a42051a 100644 --- a/php/controller.php +++ b/php/controller.php @@ -62,7 +62,7 @@ class Controller $this->set_periodes($id); pg_query("COMMIT"); - $this->participant = new participant($_POST['pseudo'], $_POST['pass1']); + $this->participant->chargerInfos($_POST['pseudo'], $_POST['pass1']); setcookie("COOKIE_INFO_PARTICIPANT", $this->participant->info->id, time() + 31104000); $this->nouvel_inscrit = TRUE; } @@ -74,11 +74,12 @@ class Controller return; $this->traiter_donnees_inscription(); - if (!$this->login_deja_pris() && $this->donnees_inscription_valides()) + 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)); - pg_query_params("UPDATE participants SET password = $1 WHERE id = $2", array(sha1($_POST['pass1']), $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)); @@ -96,7 +97,7 @@ class Controller } } # vote pour des jeux (autorisé même lorsque les inscriptions sont terminées) - else if (isset($_POST['set_jeux_joues']) && $this->participant->existe()) + else if (isset($_POST['set_jeux_joues']) && $this->participant->existe() && !$config->get("inscription_terminees")) { $votes = $_POST['votes']; if (!$votes) @@ -108,7 +109,7 @@ class Controller $jeu = trim($_POST['jeu']); if ($jeu !== '') { - if(@pg_query_params("INSERT INTO jeux (nom) VALUES ($1)", array($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]; @@ -121,7 +122,8 @@ class Controller pg_query("BEGIN"); $res = pg_query_params("SELECT id FROM jeux WHERE nom = $1", array($jeu)); if ($id = pg_fetch_object($res)) - array_unshift($votes, $id->id); + if (!in_array($id->id, $votes)) + array_unshift($votes, $id->id); } } @@ -162,14 +164,15 @@ class Controller /** * Renvoie TRUE si les données d'une inscription sont valides (POST). + * $maj : égal 'TRUE' si c'est une mise à jour, dans ce cas le password est traité différement */ - private function donnees_inscription_valides() + private function donnees_inscription_valides($maj = FALSE) { return - $_POST['pseudo'] != "" && - $_POST['pass1'] != "" && + $_POST['pseudo'] != "" && + ($maj || $_POST['pass1'] != "") && $_POST['pass1'] == $_POST['pass2'] && - strlen($_POST['pass1']) >= 3 && + (($maj && $_POST['pass1'] == "") || strlen($_POST['pass1']) >= 3) && $_POST['nom'] != "" && $_POST['prenom'] != "" && $_POST['e_mail'] != "";