2019-09-07 16:43:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Document
|
|
|
|
{
|
|
|
|
private $file_id;
|
|
|
|
private $user_id;
|
|
|
|
private $team_id;
|
|
|
|
private $tournament_id;
|
|
|
|
private $type;
|
|
|
|
private $uploaded_at;
|
2019-09-07 23:35:05 +00:00
|
|
|
private $version;
|
2019-09-07 16:43:51 +00:00
|
|
|
|
|
|
|
private function __construct() {}
|
|
|
|
|
|
|
|
public static function fromId($id)
|
|
|
|
{
|
|
|
|
global $DB;
|
|
|
|
$req = $DB->prepare("SELECT * FROM `documents` WHERE `file_id` = ?;");
|
|
|
|
$req->execute([htmlspecialchars($id)]);
|
|
|
|
$data = $req->fetch();
|
|
|
|
|
|
|
|
if ($data === false)
|
|
|
|
return null;
|
|
|
|
|
2019-09-07 23:35:05 +00:00
|
|
|
return self::fromData($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function fromData($data)
|
|
|
|
{
|
|
|
|
$doc = new Document();
|
|
|
|
$doc->fill($data);
|
|
|
|
return $doc;
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private function fill($data)
|
|
|
|
{
|
|
|
|
$this->file_id = $data["file_id"];
|
|
|
|
$this->user_id = $data["user"];
|
|
|
|
$this->team_id = $data["team"];
|
|
|
|
$this->tournament_id = $data["tournament"];
|
|
|
|
$this->type = DocumentType::fromName($data["type"]);
|
|
|
|
$this->uploaded_at = $data["uploaded_at"];
|
2019-09-07 23:35:05 +00:00
|
|
|
$this->version = isset($data["version"]) ? $data["version"] : 1;
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getFileId()
|
|
|
|
{
|
|
|
|
return $this->file_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUserId()
|
|
|
|
{
|
|
|
|
return $this->user_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTeamId()
|
|
|
|
{
|
|
|
|
return $this->team_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTournamentId()
|
|
|
|
{
|
|
|
|
return $this->tournament_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getType()
|
|
|
|
{
|
|
|
|
return $this->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUploadedAt()
|
|
|
|
{
|
|
|
|
return $this->uploaded_at;
|
|
|
|
}
|
2019-09-07 23:35:05 +00:00
|
|
|
|
|
|
|
public function getVersion()
|
|
|
|
{
|
|
|
|
return $this->version;
|
|
|
|
}
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class Solution
|
|
|
|
{
|
|
|
|
private $file_id;
|
|
|
|
private $team_id;
|
|
|
|
private $tournament_id;
|
|
|
|
private $problem;
|
|
|
|
private $uploaded_at;
|
2019-09-07 23:35:05 +00:00
|
|
|
private $version;
|
2019-09-07 16:43:51 +00:00
|
|
|
|
|
|
|
private function __construct() {}
|
|
|
|
|
|
|
|
public static function fromId($id)
|
|
|
|
{
|
|
|
|
global $DB;
|
2019-09-07 17:01:23 +00:00
|
|
|
$req = $DB->prepare("SELECT * FROM `solutions` WHERE `file_id` = ?;");
|
2019-09-07 16:43:51 +00:00
|
|
|
$req->execute([htmlspecialchars($id)]);
|
|
|
|
$data = $req->fetch();
|
|
|
|
|
|
|
|
if ($data === false)
|
|
|
|
return null;
|
|
|
|
|
2019-09-07 23:35:05 +00:00
|
|
|
return self::fromData($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function fromData($data)
|
|
|
|
{
|
|
|
|
$sol = new Solution();
|
|
|
|
$sol->fill($data);
|
|
|
|
return $sol;
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private function fill($data)
|
|
|
|
{
|
|
|
|
$this->file_id = $data["file_id"];
|
2019-09-07 17:01:23 +00:00
|
|
|
$this->team_id = $data["team"];
|
|
|
|
$this->tournament_id = $data["tournament"];
|
2019-09-07 16:43:51 +00:00
|
|
|
$this->problem = $data["problem"];
|
|
|
|
$this->uploaded_at = $data["uploaded_at"];
|
2019-09-07 23:35:05 +00:00
|
|
|
$this->version = isset($data["version"]) ? $data["version"] : 1;
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getFileId()
|
|
|
|
{
|
|
|
|
return $this->file_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTeamId()
|
|
|
|
{
|
|
|
|
return $this->team_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTournamentId()
|
|
|
|
{
|
|
|
|
return $this->tournament_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getProblem()
|
|
|
|
{
|
|
|
|
return $this->problem;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUploadedAt()
|
|
|
|
{
|
|
|
|
return $this->uploaded_at;
|
|
|
|
}
|
2019-09-07 23:35:05 +00:00
|
|
|
|
|
|
|
public function getVersion()
|
|
|
|
{
|
|
|
|
return $this->version;
|
|
|
|
}
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
|
2019-09-07 23:35:05 +00:00
|
|
|
class Synthesis
|
2019-09-07 16:43:51 +00:00
|
|
|
{
|
|
|
|
private $file_id;
|
|
|
|
private $team_id;
|
|
|
|
private $tournament_id;
|
|
|
|
private $dest;
|
2020-05-04 23:06:57 +00:00
|
|
|
private $round;
|
2019-09-07 16:43:51 +00:00
|
|
|
private $uploaded_at;
|
2019-09-07 23:35:05 +00:00
|
|
|
private $version;
|
2019-09-07 16:43:51 +00:00
|
|
|
|
|
|
|
private function __construct() {}
|
|
|
|
|
|
|
|
public static function fromId($id)
|
|
|
|
{
|
|
|
|
global $DB;
|
2019-09-07 17:01:23 +00:00
|
|
|
$req = $DB->prepare("SELECT * FROM `syntheses` WHERE `file_id` = ?;");
|
2019-09-07 16:43:51 +00:00
|
|
|
$req->execute([htmlspecialchars($id)]);
|
|
|
|
$data = $req->fetch();
|
|
|
|
|
|
|
|
if ($data === false)
|
|
|
|
return null;
|
|
|
|
|
2019-09-07 23:35:05 +00:00
|
|
|
return self::fromData($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function fromData($data)
|
|
|
|
{
|
|
|
|
$synthese = new Synthesis();
|
|
|
|
$synthese->fill($data);
|
|
|
|
return $synthese;
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private function fill($data)
|
|
|
|
{
|
|
|
|
$this->file_id = $data["file_id"];
|
|
|
|
$this->team_id = $data["team"];
|
|
|
|
$this->tournament_id = $data["tournament"];
|
2020-05-04 23:06:57 +00:00
|
|
|
$this->dest = $data["dest"];
|
|
|
|
$this->round = $data["round"];
|
2019-09-07 16:43:51 +00:00
|
|
|
$this->uploaded_at = $data["uploaded_at"];
|
2019-09-07 23:35:05 +00:00
|
|
|
$this->version = isset($data["version"]) ? $data["version"] : 1;
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getFileId()
|
|
|
|
{
|
|
|
|
return $this->file_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTeamId()
|
|
|
|
{
|
|
|
|
return $this->team_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTournamentId()
|
|
|
|
{
|
|
|
|
return $this->tournament_id;
|
|
|
|
}
|
|
|
|
|
2020-05-04 23:06:57 +00:00
|
|
|
public function getDest()
|
|
|
|
{
|
|
|
|
return $this->dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRound()
|
|
|
|
{
|
|
|
|
return $this->round;
|
|
|
|
}
|
2019-09-07 16:43:51 +00:00
|
|
|
|
|
|
|
public function getUploadedAt()
|
|
|
|
{
|
|
|
|
return $this->uploaded_at;
|
|
|
|
}
|
2019-09-07 23:35:05 +00:00
|
|
|
|
|
|
|
public function getVersion()
|
|
|
|
{
|
|
|
|
return $this->version;
|
|
|
|
}
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class DestType
|
|
|
|
{
|
|
|
|
const DEFENSEUR = 0;
|
|
|
|
const OPPOSANT = 1;
|
|
|
|
const RAPPORTEUR = 2;
|
|
|
|
|
|
|
|
public static function getTranslatedName($status) {
|
|
|
|
switch ($status) {
|
|
|
|
case self::OPPOSANT:
|
|
|
|
return "Opposant";
|
2019-09-09 23:02:13 +00:00
|
|
|
case self::RAPPORTEUR:
|
2019-09-07 16:43:51 +00:00
|
|
|
return "Rapporteur";
|
2019-09-09 23:02:13 +00:00
|
|
|
default:
|
|
|
|
return "Défenseur";
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getName($status) {
|
|
|
|
switch ($status) {
|
|
|
|
case self::OPPOSANT:
|
|
|
|
return "OPPOSANT";
|
2019-09-09 23:02:13 +00:00
|
|
|
case self::RAPPORTEUR:
|
2019-09-07 16:43:51 +00:00
|
|
|
return "RAPPORTEUR";
|
2019-09-09 23:02:13 +00:00
|
|
|
default:
|
|
|
|
return "DEFENSEUR";
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function fromName($name) {
|
|
|
|
switch ($name) {
|
|
|
|
case "OPPOSANT":
|
|
|
|
return self::OPPOSANT;
|
2019-09-09 23:02:13 +00:00
|
|
|
case "RAPPORTEUR":
|
2019-09-07 16:43:51 +00:00
|
|
|
return self::RAPPORTEUR;
|
2019-09-09 23:02:13 +00:00
|
|
|
default:
|
|
|
|
return self::DEFENSEUR;
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class DocumentType
|
|
|
|
{
|
|
|
|
const PARENTAL_CONSENT = 0;
|
|
|
|
const PHOTO_CONSENT = 1;
|
|
|
|
const SANITARY_PLUG = 2;
|
|
|
|
const SOLUTION = 3;
|
2019-09-07 23:35:05 +00:00
|
|
|
const SYNTHESIS = 4;
|
2020-01-01 23:09:02 +00:00
|
|
|
const SCHOLARSHIP = 5;
|
2020-01-18 13:43:42 +00:00
|
|
|
const MOTIVATION_LETTER = 6;
|
2019-09-07 16:43:51 +00:00
|
|
|
|
|
|
|
public static function getTranslatedName($type) {
|
|
|
|
switch ($type) {
|
|
|
|
case self::PARENTAL_CONSENT:
|
|
|
|
return "Autorisation parentale";
|
|
|
|
case self::PHOTO_CONSENT:
|
|
|
|
return "Autorisation de droit à l'image";
|
|
|
|
case self::SANITARY_PLUG:
|
|
|
|
return "Fiche sanitaire";
|
2020-01-01 23:09:02 +00:00
|
|
|
case self::SCHOLARSHIP:
|
|
|
|
return "Notification de bourse";
|
2020-01-18 13:43:42 +00:00
|
|
|
case self::MOTIVATION_LETTER:
|
|
|
|
return "Lettre de motivation";
|
2019-09-07 16:43:51 +00:00
|
|
|
case self::SOLUTION:
|
|
|
|
return "Solution";
|
|
|
|
default:
|
|
|
|
return "Note de synthèse";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getName($type) {
|
|
|
|
switch ($type) {
|
|
|
|
case self::PARENTAL_CONSENT:
|
|
|
|
return "PARENTAL_CONSENT";
|
|
|
|
case self::PHOTO_CONSENT:
|
|
|
|
return "PHOTO_CONSENT";
|
|
|
|
case self::SANITARY_PLUG:
|
|
|
|
return "SANITARY_PLUG";
|
2020-01-01 23:09:02 +00:00
|
|
|
case self::SCHOLARSHIP:
|
|
|
|
return "SCHOLARSHIP";
|
2020-01-18 13:43:42 +00:00
|
|
|
case self::MOTIVATION_LETTER:
|
|
|
|
return "MOTIVATION_LETTER";
|
2019-09-07 16:43:51 +00:00
|
|
|
case self::SOLUTION:
|
|
|
|
return "SOLUTION";
|
|
|
|
default:
|
2019-09-07 23:35:05 +00:00
|
|
|
return "SYNTHESIS";
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function fromName($name) {
|
|
|
|
switch ($name) {
|
|
|
|
case "PARENTAL_CONSENT":
|
|
|
|
return self::PARENTAL_CONSENT;
|
|
|
|
case "PHOTO_CONSENT":
|
|
|
|
return self::PHOTO_CONSENT;
|
|
|
|
case "SANITARY_PLUG":
|
|
|
|
return self::SANITARY_PLUG;
|
2020-01-01 23:09:02 +00:00
|
|
|
case "SCHOLARSHIP":
|
|
|
|
return self::SCHOLARSHIP;
|
2020-01-18 13:43:42 +00:00
|
|
|
case "MOTIVATION_LETTER":
|
|
|
|
return self::MOTIVATION_LETTER;
|
2019-09-07 16:43:51 +00:00
|
|
|
case "SOLUTION":
|
|
|
|
return self::SOLUTION;
|
|
|
|
default:
|
2019-09-07 23:35:05 +00:00
|
|
|
return self::SYNTHESIS;
|
2019-09-07 16:43:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|