X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=php%2Fclass_participant.php;fp=php%2Fclass_participant.php;h=d5f9c71a013911be918de8556dfcf8cdaa9991a0;hb=27f3004da65f2b5803709b3fa76a791c9b38a0c9;hp=0000000000000000000000000000000000000000;hpb=262be7e249593a2764a7c452f70dc5ac68887d5c;p=cl7.git diff --git a/php/class_participant.php b/php/class_participant.php new file mode 100644 index 0000000..d5f9c71 --- /dev/null +++ b/php/class_participant.php @@ -0,0 +1,80 @@ + ce n'est pas un participant valide + if ($v1 == NULL && $v2 == NULL) + { + $this->valide = 0; + return; + } + + if (is_string($v1) && is_string($v2)) # Aucun des arguments n'est vide alors c'est le pseudo et le password qui ont été transmis + $res = mysql_query("SELECT * FROM participants WHERE pseudo = '" . addslashes($v1) . "' AND password = '" . addslashes($v2) . "'"); + else # Sinon c'est l'id + $res = mysql_query("SELECT * FROM participants WHERE id = " . addslashes($v1)); + + if (mysql_num_rows($res) == 0) + { + $this->valide = FALSE; + } + else + { + $this->info = mysql_fetch_object($res); + $this->valide = TRUE; + } + } + + /** + * Renvoie le nombre de votes restant pour le participant. + */ + function nb_vote_restant() + { + $nombre_de_vote = mysql_fetch_array(mysql_query(" + SELECT COUNT(*) FROM participants RIGHT JOIN jeux_choisis ON participants.id = jeux_choisis.participant_id + WHERE participants.id = " . $this->info->id . " + GROUP BY participants.id + ")); + + return Participant::$NB_VOTES_PAR_PARTICIPANT - $nombre_de_vote[0]; + } + + /** + * Renvois TRUE si le nombre de participant max est atteint. + */ + static function nombre_participant_max_atteint() + { + global $NB_MAX_PARTICIPANT; + $res_SQL = mysql_query("SELECT COUNT(*) FROM participants"); + $nb_participant = mysql_fetch_row($res_SQL); + + return $nb_participant[0] >= $NB_MAX_PARTICIPANT; + } + + /** + * Renvois le nombre de places restantes. + */ + static function nombre_place_restante() + { + global $NB_MAX_PARTICIPANT; + $res_SQL = mysql_query("SELECT COUNT(*) FROM participants"); + $nb_participant = mysql_fetch_row($res_SQL); + + return $NB_MAX_PARTICIPANT - $nb_participant[0]; + } +} + +?> \ No newline at end of file