<commit_before><?php

/**
 * Participant Class File.
 * @version 1.0
 * @author <NAME>
 * @author <NAME>
 * Date: 04/01/2016
 * Project: OpenBooking
 * @copyright 2015 - 2016 OpenBooking Group
 *
 */
namespace OpenBooking;

use \PDO;
use \PDOException;
use \Exception;
use OpenBooking\Exceptions\LoginException;
use OpenBooking\Exceptions\NullDatasException;
use OpenBooking\Exceptions\ValidDatasException;
use OpenBooking\Exceptions\UnknowErrorException;
use OpenBooking\Exceptions\SQLErrorException;
use OpenBooking\model\ModelParticipant;


include_once dirname(__FILE__) . "/../model/ModelParticipant.php";
include_once dirname(__FILE__) . "/../../_exceptions/LoginException.php";
include_once dirname(__FILE__) . "/../../_exceptions/NullDatasException.php";
include_once dirname(__FILE__) . "/../../_exceptions/SQLErrorException.php";
include_once dirname(__FILE__) . "/../../_exceptions/UnknowErrorException.php";
include_once dirname(__FILE__) . "/../../_exceptions/ValidDatasException.php";

/**
 * Class Participant
 *
 * @package OpenBooking\Participant
 */
class Participant
{
    /**
     * Participant ID
     *
     * @var int
     */
    private $id;

    /**
     * Participant first name
     * @var string
     */
    private $first_name;

    /**
     * Participant last name
     * @var string
     */
    private $last_name;

    /**
     * Participant email
     * @var string
     */
    private $email;

    /**
     * Participant registration timestamp
     * @var int Timestamp required
     */
    private $registration_date;

    /**
     * Comments about participant
     * @var string
     */
    private $comments;

    /**
     * Participant status.
     *
     * If status == ban, user can connect but can't participate to an event. He need to contact an administrator.
     *
     * @var string Possible values  : 'verified', 'unverified', 'ban'
     */
    private $status;

    /**
     * @ignore
     */
    private $pdo;

    /**
     * Participant constructor.
     * @param string $email
     * @param string $password
     * @throws LoginException
     * @throws UnknowErrorException
     */
    public function __construct($email, $password)
    {
        try {
            $password = hash("<PASSWORD>", $password);
            $this->pdo = $GLOBALS['pdo'];
            $sql = "SELECT * FROM ob_participant WHERE email = :email AND password = :password";
            $req = $this->pdo->prepare($sql);
            $req->bindParam(":email", $email);
            $req->bindParam(":password", $password);
            $req->execute();
            $req->setFetchMode(PDO::FETCH_OBJ);
            $res = $req->fetch();
            if (!isset($res->id)) {
                throw new LoginException("Access denied, unknow user");
            }
            $this->id = $res->id;
            $this->first_name = $res->first_name;
            $this->last_name = $res->last_name;
            $this->email = $res->email;
            $this->registration_date = $res->registration_date;
            $this->comments = $res->comments;
            $this->status = $res->status;
        } catch (Exception $e) {
            throw new UnknowErrorException("Unknow error");
        }
    }
<commit_msg>Edit Participant Class<commit_after><?php

/**
 * Participant Class File.
 * @version 1.0
 * @author <NAME>
 * @author <NAME>
 * Date: 04/01/2016
 * Project: OpenBooking
 * @copyright 2015 - 2016 OpenBooking Group
 *
 */
namespace OpenBooking;

use \PDO;
use \PDOException;
use \Exception;
use OpenBooking\Exceptions\LoginException;
use OpenBooking\Exceptions\NullDatasException;
use OpenBooking\Exceptions\ValidDatasException;
use OpenBooking\Exceptions\UnknowErrorException;
use OpenBooking\Exceptions\SQLErrorException;
use OpenBooking\model\ModelParticipant;


include_once dirname(__FILE__) . "/../model/ModelParticipant.php";
include_once dirname(__FILE__) . "/../../_exceptions/LoginException.php";
include_once dirname(__FILE__) . "/../../_exceptions/NullDatasException.php";
include_once dirname(__FILE__) . "/../../_exceptions/SQLErrorException.php";
include_once dirname(__FILE__) . "/../../_exceptions/UnknowErrorException.php";
include_once dirname(__FILE__) . "/../../_exceptions/ValidDatasException.php";

/**
 * Class Participant
 *
 * @package OpenBooking\Participant
 */
class Participant
{
    /**
     * Participant ID
     *
     * @var int
     */
    private $id;

    /**
     * Participant first name
     * @var string
     */
    private $first_name;

    /**
     * Participant last name
     * @var string
     */
    private $last_name;

    /**
     * Participant email
     * @var string
     */
    private $email;

    /**
     * Participant registration timestamp
     * @var int Timestamp required
     */
    private $registration_date;

    /**
     * Comments about participant
     * @var string
     */
    private $comments;

    /**
     * Participant status.
     *
     * If status == ban, user can connect but can't participate to an event. He need to contact an administrator.
     *
     * @var string Possible values  : 'verified', 'unverified', 'ban'
     */
    private $status;

    /**
     * @ignore
     */
    private $pdo;

    /**
     * Participant constructor.
     * @param string $email
     * @param string $password
     * @throws LoginException
     * @throws UnknowErrorException
     */
    public function __construct($email, $password)
    {
        try {
            $password = <PASSWORD>("<PASSWORD>", $password);
            $this->pdo = $GLOBALS['pdo'];
            $sql = "SELECT * FROM ob_participant WHERE email = :email AND password = :password";
            $req = $this->pdo->prepare($sql);
            $req->bindParam(":email", $email);
            $req->bindParam(":password", $password);
            $req->execute();
            $req->setFetchMode(PDO::FETCH_OBJ);
            $res = $req->fetch();
            if (isset($res->id) && $res->id > 0) {
                $this->id = $res->id;
                $this->first_name = $res->first_name;
                $this->last_name = $res->last_name;
                $this->email = $res->email;
                $this->registration_date = $res->registration_date;
                $this->comments = $res->comments;
                $this->status = $res->status;
            }else{
                throw new LoginException("Access denied, bad credentials");
            }
        } catch (LoginException $e) {
            throw new LoginException($e->getMessage());
        } catch (Exception $e) {
            throw new UnknowErrorException("Unknow error");
        }
    }

{'fraction_non_alphanumeric': 0.13899380571083245, 'fraction_numerical': 0.005589968273153044, 'mean_word_length': 2.2968127490039842, 'pattern_counts': {'":': 4, '<': 12, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '216786', 'n_tokens_mistral': 2001, 'n_tokens_neox': 1913, 'n_words': 427}