mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-29 17:51:11 +02:00
Améliorations du code
This commit is contained in:
@ -359,4 +359,33 @@ class User
|
||||
{
|
||||
return $this->inscription_date;
|
||||
}
|
||||
|
||||
public function getAllDocuments($tournament_id)
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
|
||||
. "INNER JOIN (SELECT `user`, `type`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `tournament`, `type`) `t2` "
|
||||
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`tournament` = `t2`.`tournament` "
|
||||
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $tournament_id AND `t1`.`user` = $this->id ORDER BY `t1`.`type`;");
|
||||
|
||||
$docs = [];
|
||||
|
||||
while (($data = $req->fetch()) !== false)
|
||||
$docs[] = Document::fromData($data);
|
||||
|
||||
return $docs;
|
||||
}
|
||||
|
||||
public function getOrganizedTournaments()
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->query("SELECT `tournament` FROM `organizers` JOIN `tournaments` ON `tournaments`.`id` = `tournament` WHERE `organizer` = $this->id ORDER BY `date_start`, `name`;");
|
||||
|
||||
$tournaments = [];
|
||||
|
||||
while (($data = $req->fetch()) !== false)
|
||||
$tournaments[] = Tournament::fromId($data["tournament"]);
|
||||
|
||||
return $tournaments;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user