mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-01-07 12:22:19 +00:00
L'autorisation de droit à l'image est désormais sur la page "Mon compte"
This commit is contained in:
parent
a73b0889b4
commit
dc3f81b6d3
@ -258,13 +258,13 @@ class User
|
|||||||
$DB->prepare("UPDATE `users` SET `receive_animath_mails` = ? WHERE `id` = ?;")->execute([$receive_animath_mails ? 1 : 0, $this->getId()]);
|
$DB->prepare("UPDATE `users` SET `receive_animath_mails` = ? WHERE `id` = ?;")->execute([$receive_animath_mails ? 1 : 0, $this->getId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllDocuments($problem)
|
public function getAllDocuments()
|
||||||
{
|
{
|
||||||
global $DB;
|
global $DB;
|
||||||
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
|
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
|
||||||
. "INNER JOIN (SELECT `user`, `problem`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `problem`, `user`) `t2` "
|
. "INNER JOIN (SELECT `user`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `problem`, `user`) `t2` "
|
||||||
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`problem` = `t2`.`problem` "
|
. "ON `t1`.`user` = `t2`.`user` "
|
||||||
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`problem` = $problem AND `t1`.`user` = $this->id;");
|
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`user` = $this->id;");
|
||||||
|
|
||||||
$docs = [];
|
$docs = [];
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ if (!isset($_SESSION["user_id"]))
|
|||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = $_SESSION["user"];
|
$user = $_SESSION["user"];
|
||||||
|
$documents = $user->getAllDocuments();
|
||||||
|
|
||||||
$has_error = false;
|
$has_error = false;
|
||||||
$error_message = null;
|
$error_message = null;
|
||||||
@ -33,6 +34,18 @@ if (isset($_POST["update_password"])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_POST["send_document"])) {
|
||||||
|
$send_document = new SendDocument();
|
||||||
|
try {
|
||||||
|
$send_document->makeVerifications();
|
||||||
|
$send_document->sendDocument();
|
||||||
|
}
|
||||||
|
catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class MyAccount
|
class MyAccount
|
||||||
{
|
{
|
||||||
public $email;
|
public $email;
|
||||||
@ -119,4 +132,40 @@ class NewPassword
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SendDocument
|
||||||
|
{
|
||||||
|
private $file;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->file = $_FILES["document"];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
global $LOCAL_PATH;
|
||||||
|
|
||||||
|
ensure($this->file["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo.");
|
||||||
|
ensure(!$this->file["error"], "Une erreur est survenue.");
|
||||||
|
ensure(finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]) == "application/pdf", "Le fichier doit être au format PDF.");
|
||||||
|
ensure(is_dir("$LOCAL_PATH/files") || mkdir("$LOCAL_PATH/files"), "Un problème est survenue dans l'envoi du fichier. Veuillez contacter l'administrateur du serveur.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendDocument()
|
||||||
|
{
|
||||||
|
global $LOCAL_PATH, $DB;
|
||||||
|
|
||||||
|
do
|
||||||
|
$id = genRandomPhrase(64);
|
||||||
|
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||||
|
|
||||||
|
if (!rename($this->file["tmp_name"], "$LOCAL_PATH/files/$id"))
|
||||||
|
throw new AssertionError("Une erreur est survenue lors de l'envoi du fichier.");
|
||||||
|
|
||||||
|
$req = $DB->prepare("INSERT INTO `documents`(`file_id`, `user`, `team`, `problem`)
|
||||||
|
VALUES (?, ?, ?, ?);");
|
||||||
|
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team"]->getId(), $_SESSION["team"]->getProblem()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
require_once "server_files/views/mon_compte.php";
|
require_once "server_files/views/mon_compte.php";
|
||||||
|
@ -8,18 +8,6 @@ if (isset($_POST["leave_team"])) {
|
|||||||
$has_error = false;
|
$has_error = false;
|
||||||
$error_message = null;
|
$error_message = null;
|
||||||
|
|
||||||
if (isset($_POST["send_document"])) {
|
|
||||||
$send_document = new SendDocument();
|
|
||||||
try {
|
|
||||||
$send_document->makeVerifications();
|
|
||||||
$send_document->sendDocument();
|
|
||||||
}
|
|
||||||
catch (AssertionError $e) {
|
|
||||||
$has_error = true;
|
|
||||||
$error_message = $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_POST["team_edit"])) {
|
if (isset($_POST["team_edit"])) {
|
||||||
$my_team = new MyTeam($_POST);
|
$my_team = new MyTeam($_POST);
|
||||||
try {
|
try {
|
||||||
@ -45,7 +33,6 @@ if (isset($_POST["request_validation"])) {
|
|||||||
$_SESSION["team"]->setValidationStatus(ValidationStatus::WAITING);
|
$_SESSION["team"]->setValidationStatus(ValidationStatus::WAITING);
|
||||||
}
|
}
|
||||||
|
|
||||||
$documents = [];
|
|
||||||
/** @var Question[][] $questions_received */
|
/** @var Question[][] $questions_received */
|
||||||
$questions_received = [];
|
$questions_received = [];
|
||||||
|
|
||||||
@ -57,7 +44,7 @@ if (isset($_SESSION["user_id"]) && isset($_SESSION["team"]) && $_SESSION["team"]
|
|||||||
$user = $_SESSION["user"];
|
$user = $_SESSION["user"];
|
||||||
$team = $_SESSION["team"];
|
$team = $_SESSION["team"];
|
||||||
|
|
||||||
$documents = $user->getAllDocuments($team->getProblem());
|
$documents = $user->getAllDocuments();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
require_once "server_files/403.php";
|
require_once "server_files/403.php";
|
||||||
@ -68,42 +55,6 @@ if (isset($_GET["publish_videos"])) {
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
class SendDocument
|
|
||||||
{
|
|
||||||
private $file;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->file = $_FILES["document"];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function makeVerifications()
|
|
||||||
{
|
|
||||||
global $LOCAL_PATH;
|
|
||||||
|
|
||||||
ensure($this->file["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo.");
|
|
||||||
ensure(!$this->file["error"], "Une erreur est survenue.");
|
|
||||||
ensure(finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]) == "application/pdf", "Le fichier doit être au format PDF.");
|
|
||||||
ensure(is_dir("$LOCAL_PATH/files") || mkdir("$LOCAL_PATH/files"), "Un problème est survenue dans l'envoi du fichier. Veuillez contacter l'administrateur du serveur.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function sendDocument()
|
|
||||||
{
|
|
||||||
global $LOCAL_PATH, $DB;
|
|
||||||
|
|
||||||
do
|
|
||||||
$id = genRandomPhrase(64);
|
|
||||||
while (file_exists("$LOCAL_PATH/files/$id"));
|
|
||||||
|
|
||||||
if (!rename($this->file["tmp_name"], "$LOCAL_PATH/files/$id"))
|
|
||||||
throw new AssertionError("Une erreur est survenue lors de l'envoi du fichier.");
|
|
||||||
|
|
||||||
$req = $DB->prepare("INSERT INTO `documents`(`file_id`, `user`, `team`, `problem`)
|
|
||||||
VALUES (?, ?, ?, ?);");
|
|
||||||
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team"]->getId(), $_SESSION["team"]->getProblem()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyTeam
|
class MyTeam
|
||||||
{
|
{
|
||||||
public $name;
|
public $name;
|
||||||
|
@ -8,17 +8,17 @@ require_once "header.php";
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (!$has_error && (isset($my_account) || isset($new_password))) {
|
if (!$has_error && (isset($my_account) || isset($new_password))) {
|
||||||
?>
|
?>
|
||||||
<div class="alert alert-success">
|
<div class="alert alert-success">
|
||||||
Votre compte a bien été mis à jour !
|
Votre compte a bien été mis à jour !
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
if (isset($my_account) && $user->getEmail() != $my_account->email) { ?>
|
if (isset($my_account) && $user->getEmail() != $my_account->email) { ?>
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
Votre adresse mail a bien été changée. Veuillez vérifier votre boîte mail pour valider votre nouvelle
|
Votre adresse mail a bien été changée. Veuillez vérifier votre boîte mail pour valider votre nouvelle
|
||||||
adresse, vous en aurez besoin pour vous reconnecter.
|
adresse, vous en aurez besoin pour vous reconnecter.
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
@ -47,9 +47,9 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
|
|||||||
|
|
||||||
<label for="receive_animath_mails">J'accepte de recevoir des mails de la part d'Animath (<em>facultatif</em>) :</label>
|
<label for="receive_animath_mails">J'accepte de recevoir des mails de la part d'Animath (<em>facultatif</em>) :</label>
|
||||||
<input type="checkbox" id="receive_animath_mails" name="receive_animath_mails"
|
<input type="checkbox" id="receive_animath_mails" name="receive_animath_mails"
|
||||||
<?= $user->doReceiveAnimathMails() ? "checked" : "" ?> />
|
<?= $user->doReceiveAnimathMails() ? "checked" : "" ?> />
|
||||||
|
|
||||||
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
|
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label id="school_label" for="school">Établissement dans lequel l'élève étudie :</label>
|
<label id="school_label" for="school">Établissement dans lequel l'élève étudie :</label>
|
||||||
@ -70,7 +70,7 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label id="description_label" for="description">Description :</label>
|
<label id="description_label" for="description">Description :</label>
|
||||||
@ -78,7 +78,7 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
|
|||||||
name="description"><?= $user->getDescription() ?></textarea>
|
name="description"><?= $user->getDescription() ?></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<input class="btn btn-primary btn-lg btn-block" name="update_account" type="submit"
|
<input class="btn btn-primary btn-lg btn-block" name="update_account" type="submit"
|
||||||
@ -86,7 +86,7 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<hr />
|
<hr/>
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
|
|
||||||
@ -108,8 +108,35 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<input class="btn btn-secondary btn-lg btn-block" type="submit" name="update_password" value="Mettre à jour mon mot de passe"/>
|
<input class="btn btn-secondary btn-lg btn-block" type="submit" name="update_password"
|
||||||
|
value="Mettre à jour mon mot de passe"/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<div class="mt-4 mb-4">
|
||||||
|
<h1 class="display-5">Autorisation de droit à l'image</h1>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
if (isset($_SESSION["team"])) {
|
||||||
|
printDocuments($documents);
|
||||||
|
|
||||||
|
if ($_SESSION["team"]->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
|
||||||
|
<form method="POST" enctype="multipart/form-data">
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="document">Fichier :</label>
|
||||||
|
<input class="form-control" type="file" id="document" name="document" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<input class="btn btn-primary btn-lg btn-block" type="submit" name="send_document"
|
||||||
|
value="Envoyer le document"/>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<?php }
|
||||||
|
} ?>
|
||||||
|
|
||||||
<?php require_once "footer.php" ?>
|
<?php require_once "footer.php" ?>
|
@ -101,28 +101,7 @@ require_once "header.php";
|
|||||||
<button class="btn btn-secondary btn-lg btn-block">Modifier mon équipe</button>
|
<button class="btn btn-secondary btn-lg btn-block">Modifier mon équipe</button>
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<hr/><div class="mt-4 mb-4">
|
<?php if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
|
||||||
<h1 class="display-5">Autorisation de droit à l'image</h1>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
printDocuments($documents);
|
|
||||||
|
|
||||||
if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
|
|
||||||
<form method="POST" enctype="multipart/form-data">
|
|
||||||
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md-12">
|
|
||||||
<label for="document">Fichier :</label>
|
|
||||||
<input class="form-control" type="file" id="document" name="document" required/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group row">
|
|
||||||
<input class="btn btn-primary btn-lg btn-block" type="submit" name="send_document"
|
|
||||||
value="Envoyer le document"/>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
|
Loading…
Reference in New Issue
Block a user