FIX #97
[cl7.git] / php / class_participant.php
index a402402..ea27ffa 100644 (file)
@@ -1,79 +1,79 @@
-<?php\r
-\r
-/**\r
-  * Représente un participant.\r
+<?php
+
+/**
+  * Représente un participant.
   */
 class Participant
 {
    public $info; # Toute les infos du membre sous la forme d'un objet
-       public $valide; # Savoir si le participant existe\r
-   \r
+       public $valide; # Savoir si le participant existe
+   
    static private $NB_VOTES_PAR_PARTICIPANT = 3;
        
    /**
-     * Constructeur, peut être appelé sous trois formes différentes.\r
+     * Constructeur, peut être appelé sous trois formes différentes.
      */
-       function Participant($v1=NULL, $v2=NULL)
-       {          \r
-      # aucunes valeurs transmise => ce n'est pas un participant valide
+   function Participant($v1=NULL, $v2=NULL)
+   {      
+# aucunes valeurs transmise => ce n'est pas un participant valide
           if ($v1 == NULL && $v2 == NULL) 
-      {\r
-         $this->valide = 0;\r
-         return;\r
-      }\r
+      {
+         $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
+               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));\r
+                       $res = mysql_query("SELECT * FROM participants WHERE id = " . addslashes($v1));
       
-               if (mysql_error() || mysql_num_rows($res) == 0)\r
-      {\r
-         $this->valide = FALSE;\r
-      }\r
-      else\r
+               if (mysql_error() || mysql_num_rows($res) == 0)
+      {
+         $this->valide = FALSE;
+      }
+      else
       {
          $this->info = mysql_fetch_object($res);
-         $this->valide = TRUE; \r
+         $this->valide = TRUE; 
       }
-       }\r
-   \r
-   /**\r
-     * Renvoie le nombre de votes restant pour le participant.\r
-     */\r
-   function nb_vote_restant()\r
-   {\r
-      $nombre_de_vote = mysql_fetch_array(mysql_query("\r
-         SELECT COUNT(*) FROM participants RIGHT JOIN jeux_choisis ON participants.id = jeux_choisis.participant_id\r
-         WHERE participants.id = " . $this->info->id . "\r
-         GROUP BY participants.id\r
-      "));\r
-      \r
-      return Participant::$NB_VOTES_PAR_PARTICIPANT - $nombre_de_vote[0];\r
-   }\r
-\r
-   /**\r
-     * Renvois TRUE si le nombre de participant max est atteint.\r
-     */\r
-   static function nombre_participant_max_atteint()\r
-   {\r
-      global $config;\r
-      $res_SQL = mysql_query("SELECT COUNT(*) FROM participants");\r
-      $nb_participant = mysql_fetch_row($res_SQL);\r
-\r
-      return $nb_participant[0] >= $config->get('nb_max_participant');\r
-   }\r
-   \r
-   /**\r
-     * Renvois le nombre de places restantes.\r
-     */\r
-   static function nombre_place_restante()\r
-   {\r
-      global $config;\r
-      $res_SQL = mysql_query("SELECT COUNT(*) FROM participants");\r
-      $nb_participant = mysql_fetch_row($res_SQL);\r
-      \r
-      return $config->get('nb_max_participant') - $nb_participant[0];\r
+       }
+   
+   /**
+     * 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 $config;
+      $res_SQL = mysql_query("SELECT COUNT(*) FROM participants");
+      $nb_participant = mysql_fetch_row($res_SQL);
+
+      return $nb_participant[0] >= $config->get('nb_max_participant');
+   }
+   
+   /**
+     * Renvois le nombre de places restantes.
+     */
+   static function nombre_place_restante()
+   {
+      global $config;
+      $res_SQL = mysql_query("SELECT COUNT(*) FROM participants");
+      $nb_participant = mysql_fetch_row($res_SQL);
+      
+      return $config->get('nb_max_participant') - $nb_participant[0];
    }
 }