1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2024-12-05 02:06:52 +00:00

Divserses corrections, phase 0 terminée

This commit is contained in:
galaxyoyo 2019-09-12 16:01:40 +02:00
parent 416264b53c
commit 61bec11bdb
7 changed files with 17 additions and 16 deletions

View File

@ -35,3 +35,5 @@ RUN echo "sendmail_path=msmtp -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini
ENV CORRES2MATH_LOCAL_PATH /var/www/html
ENV CORRES2MATH_MAIL_DOMAIN correspondances-maths.fr
ENV CORRES2MATH_URL_BASE https://inscription.correspondances-maths.fr
RUN chmod 0777 /var/inscription-corres2math

View File

@ -80,13 +80,13 @@ class Document
public function getAllDocuments($problem)
public static function getAllDocuments($problem, $team_id = -1)
{
global $DB;
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
. "INNER JOIN (SELECT `user`, `type`, `problem`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `problem`, `type`, `user`) `t2` "
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`problem` = `t2`.`problem` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`problem` = $problem ORDER BY `t1`.`type`;");
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`problem` = $problem " . ($team_id >= 0 ? "AND `team` = $team_id" : "") . " ORDER BY `t1`.`type`;");
$docs = [];

View File

@ -134,7 +134,7 @@ class User
{
global $DB;
$this->school = $school;
$DB->prepare("UPDATE `users` SET `school` = ? WHERE `id` = ?;")->execute([SchoolClass::getName($school), $this->getId()]);
$DB->prepare("UPDATE `users` SET `school` = ? WHERE `id` = ?;")->execute([$school, $this->getId()]);
}
public function getClass()

View File

@ -1,7 +1,7 @@
<?php
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
//if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ADMIN)
// require_once "server_files/403.php";
$trigram = htmlspecialchars($_GET["trigram"]);
@ -15,7 +15,7 @@ if (isset($_POST["validate"])) {
}
if (isset($_POST["download_zip"])) {
$file_name = getZipFile(DocumentType::PHOTO_CONSENT, $team->getProblem(), $team->getId());
$file_name = getZipFile($team->getProblem(), $team->getId());
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"Documents de l'équipe " . $team->getTrigram() . ".zip\"");
@ -26,6 +26,6 @@ if (isset($_POST["download_zip"])) {
exit();
}
$documents = Document::getAllDocuments($team->getId());
$documents = Document::getAllDocuments($team->getProblem(), $team->getId());
require_once "server_files/views/equipe.php";

View File

@ -60,6 +60,7 @@ function quitTeam()
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");
}
$DB->exec("DELETE FROM `teams` WHERE `encadrant` IS NULL OR `participant_1` IS NULL;");
$req = $DB->query("SELECT `file_id` FROM `documents` WHERE `user` = $user_id;");
while (($data = $req->fetch()) !== false)
unlink("$URL_BASE/files/" . $data["file_id"]);
@ -151,13 +152,10 @@ function getZipFile($problem, $team_id = -1)
die("Impossible de créer le fichier zip.");
}
// TODO Replace DB query
$resp = $DB->query("SELECT * FROM `documents` WHERE `problem` = $problem" . ($team_id >= 0 ? " AND `team` = $team_id" : "") . ";");
$data = Document::getAllDocuments($problem, $team_id);
/** @var Document $file */
//foreach ($data as $file) {
while (($data = $resp->fetch()) != false) {
$file = Document::fromData($data);
foreach ($data as $file) {
$file_id = $file->getFileId();
$user = User::fromId($file->getUserId());
$name = "Autorisation de droit à l'image de " . $user->getFirstName() . " " . $user->getSurname() . ".pdf";

View File

@ -9,7 +9,7 @@ Bonjour {FIRST_NAME} {SURNAME},<br />
<br />
Vous venez de créer l'équipe « {TEAM_NAME} » ({TRIGRAM}) pour les Correspondances des Jeunes Mathématicien·ne·s pour le problème {PROBLEM} et nous vous en remercions.<br />
Afin de permettre aux autres membres de votre équipe de vous rejoindre, veuillez leur transmettre le code d'accès :
{ACCESS_CODE}<br/>
<strong>{ACCESS_CODE}</strong><br/>
<br />
Le comité d'organisation des Correspondances des Jeunes Mathématicien·ne·s
</body>

View File

@ -80,16 +80,17 @@ for ($i = 1; $i <= 5; ++$i) {
<a href="<?= $URL_BASE ?>/mon_equipe/modifier">Modifier mon équipe</a>
<?php } ?>
<hr/>
<h2>Mes autorisations</h2>
<h2>Autorisation de droit à l'image</h2>
<?php
printDocuments($documents);
if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<hr />
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="type" value="photo_consent" />
<table style="width: 100%;">
<tbody>
<tr>
<?php /* <tr>
<td>
<label for="type">Type de document :</label>
</td>
@ -98,7 +99,7 @@ for ($i = 1; $i <= 5; ++$i) {
<option value="photo_consent">Autorisation de droit à l'image</option>
</select>
</td>
</tr>
</tr> */ ?>
<tr>
<td>
<label for="file">Fichier :</label>