1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-01-05 23:42:21 +00:00

Nombreux changements mineurs

This commit is contained in:
Yohann 2019-10-04 22:36:23 +02:00
parent 7eba8b542b
commit 57b8f7bdfe
13 changed files with 142 additions and 43 deletions

View File

@ -8,6 +8,8 @@ class User
public $surname;
public $first_name;
public $school;
public $city;
public $country;
public $class;
public $description;
private $role;
@ -88,6 +90,8 @@ class User
$this->surname = $data["surname"];
$this->first_name = $data["first_name"];
$this->school = $data["school"];
$this->city = $data["city"];
$this->country = $data["country"];
$this->class = SchoolClass::fromName($data["class"]);
$this->description = $data["description"];
$this->role = Role::fromName($data["role"]);
@ -157,17 +161,41 @@ class User
$DB->prepare("UPDATE `users` SET `first_name` = ? WHERE `id` = ?;")->execute([$first_name, $this->getId()]);
}
public function getSchool()
{
return $this->school;
}
public function getSchool()
{
return $this->school;
}
public function setSchool($school)
{
global $DB;
$this->school = $school;
$DB->prepare("UPDATE `users` SET `school` = ? WHERE `id` = ?;")->execute([$school, $this->getId()]);
}
public function setSchool($school)
{
global $DB;
$this->school = $school;
$DB->prepare("UPDATE `users` SET `school` = ? WHERE `id` = ?;")->execute([$school, $this->getId()]);
}
public function getCity()
{
return $this->city;
}
public function setCity($city)
{
global $DB;
$this->city = $city;
$DB->prepare("UPDATE `users` SET `city` = ? WHERE `id` = ?;")->execute([$city, $this->getId()]);
}
public function getCountry()
{
return $this->country;
}
public function setCountry($country)
{
global $DB;
$this->country = $country;
$DB->prepare("UPDATE `users` SET `country` = ? WHERE `id` = ?;")->execute([$country, $this->getId()]);
}
public function getClass()
{

View File

@ -22,6 +22,7 @@ class NewTeam {
public $name;
public $trigram;
public $problem;
public $allow_other_teams;
public $allow_publish;
public $access_code;
@ -32,6 +33,7 @@ class NewTeam {
$this->trigram = strtoupper($this->trigram);
$this->allow_other_teams = $this->allow_other_teams == "on" ? 1 : 0;
$this->allow_publish = $this->allow_publish == "on" ? 1 : 0;
}
@ -41,11 +43,12 @@ class NewTeam {
ensure(date("Y-m-d H:i:s") < $CONFIG->getInscriptionDate(), "La date limite d'inscription est dépassée.");
ensure($_SESSION["team"] == null, "Vous êtes déjà dans une équipe.");
ensure($this->name != null && $this->name != "", "Vous devez spécifier un nom d'équipe.");
ensure(preg_match("#^[\p{L} ]+$#ui", $this->name), "Le nom de l'équipe ne doit pas comporter de caractères spéciaux.");
ensure(preg_match("#^[\p{L} \d]+$#ui", $this->name), "Le nom de l'équipe ne doit pas comporter de caractères spéciaux.");
ensure(preg_match("#^[A-Z]{3}$#", $this->trigram), "Le trigramme entré n'est pas valide.");
ensure(!teamExists($this->name), "Une équipe existe déjà avec ce nom.");
ensure(!trigramExists($this->trigram), "Une équipe a déjà choisi ce trigramme.");
ensure(preg_match("#[0-4]#", $this->problem), "Le problème choisi n'a pas été reconnu.");
ensure($this->allow_other_teams, "Vous devez autoriser de diffuser vos vidéos aux autres équipes participantes pour pouvoir participer.");
}
public function register() {

View File

@ -22,6 +22,8 @@ class NewUser
public $surname;
public $role;
public $school;
public $city;
public $country;
public $class;
public $receive_animath_mails;
@ -66,10 +68,12 @@ class NewUser
if (!$DB->query("SELECT `id` FROM `users` WHERE `year` = $YEAR;")->fetch())
$this->role = Role::ADMIN;
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `school`, `class`, `role`, `description`, `receive_animath_mails`, `year`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->confirm_email_token, $this->surname, $this->first_name,
$this->school, SchoolClass::getName($this->class), Role::getName($this->role), $this->description, $this->receive_animath_mails, $YEAR]);
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`,
`school`, `city`, `country`, `class`, `role`, `description`, `receive_animath_mails`, `year`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->confirm_email_token,
$this->surname, $this->first_name, $this->school, $this->city, $this->country, SchoolClass::getName($this->class),
Role::getName($this->role), $this->description, $this->receive_animath_mails, $YEAR]);
Mailer::sendRegisterMail($this);
}

View File

@ -52,6 +52,8 @@ class MyAccount
public $surname;
public $first_name;
public $school;
public $city;
public $country;
public $class;
public $description;
public $receive_animath_mails;
@ -89,6 +91,8 @@ class MyAccount
$this->user->setSurname($this->surname);
$this->user->setFirstName($this->first_name);
$this->user->setSchool($this->school);
$this->user->setCity($this->city);
$this->user->setCountry($this->country);
$this->user->setClass($this->class);
$this->user->setDescription($this->description);
$this->user->setReceiveAnimathMails($this->receive_animath_mails);

View File

@ -78,7 +78,7 @@ class MyTeam
ensure($this->name != "" && $this->name != null, "Veuillez spécifier un nom d'équipe.");
ensure($this->name == $this->team->getName() || !teamExists($this->name), "Une équipe existe déjà avec ce nom.");
ensure(preg_match("#^[\p{L} ]+$#ui", $this->name), "Le nom de l'équipe ne doit pas comporter de caractères spéciaux.");
ensure(preg_match("#^[\p{L} \d]+$#ui", $this->name), "Le nom de l'équipe ne doit pas comporter de caractères spéciaux.");
ensure(preg_match("#^[A-Z]{3}$#", $this->trigram), "Le trigramme n'est pas valide.");
ensure($this->trigram == $this->team->getTrigram() || !trigramExists($this->trigram), "Une équipe a déjà choisi ce trigramme.");
ensure(preg_match("#^[0-4]$#", $this->problem), "Le problème indiqué n'existe pas.");

View File

@ -29,7 +29,7 @@ require_once "header.php";
</div>
<div class="form-group col-md-6">
<label for="trigram">Trigramme :</label>
<label for="trigram">Trigramme (<em>identifiant unique à trois lettres de l'équipe</em>) :</label>
<input class="form-control" type="text" id="trigram" name="trigram"
value="<?php if (isset($new_team)) echo $new_team->trigram ?>" pattern="[A-Z]{3}" maxlength="3" required/>
</div>
@ -46,9 +46,17 @@ require_once "header.php";
</select>
</div>
<label for="allow_other_teams">J'accepte que mes vidéos soient diffusées aux équipes avec lesquelles je vais concourir :</label>
<input type="checkbox" id="allow_other_teams" name="allow_other_teams"
<?= isset($new_team) && $new_team->allow_other_teams ? "checked" : "" ?> required/><br />
<label for="allow_publish">J'accepte qu'Animath diffuse mes vidéos à la fin du tournoi (<em>facultatif</em>) :</label>
<input type="checkbox" id="allow_publish" name="allow_publish"
<?= isset($new_team) && $new_team->allow_publish ? "checked" : "" ?> />
<?= isset($new_team) && $new_team->allow_publish ? "checked" : "" ?> />
<div class="alert alert-info">
Cette dernière option est modifiable à tout moment, et permet à <em>Animath</em> de diffuser les vidéos primées.
</div>
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="add_team" type="submit" value="Ajouter une équipe"/>

View File

@ -90,40 +90,49 @@
<?php } else { ?>
<div class="alert alert-<?= Phase::getCurrentPhase() == Phase::INSCRIPTION ? "warning" : "success" ?>">
<?= Phase::getTranslatedName(Phase::INSCRIPTION) ?> :
<?= Phase::getTranslatedName(Phase::INSCRIPTION) ?> :
<strong><?= formatDate($CONFIG->getInscriptionDate(), true) ?></strong>
</div>
<div class="alert alert-<?= Phase::getCurrentPhase() < Phase::PHASE1 ? "danger" : (Phase::getCurrentPhase() == Phase::PHASE1 ? "warning" : "success") ?>">
<?= Phase::getTranslatedName(Phase::PHASE1) ?> :
<?= Phase::getTranslatedName(Phase::PHASE1) ?> :
Du <strong><?= formatDate($CONFIG->getStartPhase1Date(), true) ?></strong> au
<strong><?= formatDate($CONFIG->getEndPhase1Date(), true) ?></strong>
</div>
<div class="alert alert-<?= Phase::getCurrentPhase() < Phase::PHASE2 ? "danger" : (Phase::getCurrentPhase() == Phase::PHASE2 ? "warning" : "success") ?>">
<?= Phase::getTranslatedName(Phase::PHASE2) ?> :
<?= Phase::getTranslatedName(Phase::PHASE2) ?> :
Du <strong><?= formatDate($CONFIG->getStartPhase2Date(), true) ?></strong> au
<strong><?= formatDate($CONFIG->getEndPhase2Date(), true) ?></strong>
</div>
<div class="alert alert-<?= Phase::getCurrentPhase() < Phase::PHASE3 ? "danger" : (Phase::getCurrentPhase() == Phase::PHASE3 ? "warning" : "success") ?>">
<?= Phase::getTranslatedName(Phase::PHASE3) ?> :
<?= Phase::getTranslatedName(Phase::PHASE3) ?> :
Du <strong><?= formatDate($CONFIG->getStartPhase3Date(), true) ?></strong> au
<strong><?= formatDate($CONFIG->getEndPhase3Date(), true) ?></strong>
</div>
<div class="alert alert-<?= Phase::getCurrentPhase() < Phase::PHASE4 ? "danger" : (Phase::getCurrentPhase() == Phase::PHASE4 ? "warning" : "success") ?>">
<?= Phase::getTranslatedName(Phase::PHASE4) ?> :
<?= Phase::getTranslatedName(Phase::PHASE4) ?> :
Du <strong><?= formatDate($CONFIG->getStartPhase4Date(), true) ?></strong> au
<strong><?= formatDate($CONFIG->getEndPhase4Date(), true) ?></strong>
</div>
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
<!--suppress HtmlUnknownTarget -->
<a href="/calendrier/modifier">
<button class="btn btn-primary btn-block">Modifier le calendrier</button>
<button class="btn btn-primary btn-lg btn-block">Modifier le calendrier</button>
</a>
<?php }
}
<?php } ?>
<hr/>
<a href="https://correspondances-maths.fr/participer/">
<button class="btn btn-primary btn-lg btn-block">
Comment participer aux Correspondances ?
</button>
</a>
<?php }
require_once "footer.php";

View File

@ -78,6 +78,7 @@
<li class="nav-item active"><a class="nav-link" href="/probleme/2">Problème 2</a></li>
<li class="nav-item active"><a class="nav-link" href="/probleme/3">Problème 3</a></li>
<li class="nav-item active"><a class="nav-link" href="/probleme/4">Problème 4</a></li>
<li class="nav-item active"><a class="nav-link" href="/probleme/0">Équipes sans problème</a></li>
<li class="nav-item active"><a class="nav-link" href="/profils-orphelins">Profils orphelins</a></li>
</ul>
</li>

View File

@ -66,11 +66,13 @@ if (!$has_error) {
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
<div class="alert alert-info">
<strong>Lycée :</strong> <?= $user->getSchool() ?><br/>
<strong>Ville :</strong> <?= $user->getCity() ?><br/>
<strong>Payer :</strong> <?= $user->getCountry() ?><br/>
<strong>Classe :</strong> <?= SchoolClass::getTranslatedName($user->getClass()) ?>
</div>
<?php } elseif ($user->getDescription() != "") { ?>
<div class="alert alert-info">
<strong>Description :</strong> <?= $user->getDescription() ?>
<strong>Activité professionnelle :</strong> <?= $user->getDescription() ?>
</div>
<?php } ?>

View File

@ -11,7 +11,7 @@ require_once "header.php";
if (isset($user) && !$has_error) {
?>
<div class="alert alert-success">
Votre inscription est validée ! Merci désormais de confirmer votre boîte mail pour valider votre adresse.
Vous êtes bien inscrit ! Merci désormais de confirmer votre boîte mail pour valider votre adresse.
</div>
<?php } else if (isset($_SESSION["user_id"])) { ?>
<div class="alert alert-danger">
@ -46,16 +46,18 @@ if (isset($user) && !$has_error) {
</div>
</div>
<div class="alert alert-info">
L'adresse mail sert uniquement à recevoir les informations de déroulement des Correspondances.
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="email">E-mail :</label>
<input class="form-control" type="email" id="email" name="email"
value="<?php if (isset($user)) echo $user->email ?>"
required/>
value="<?php if (isset($user)) echo $user->email ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="password">Mot de passe :</label>
@ -73,6 +75,18 @@ if (isset($user) && !$has_error) {
<input class="form-control" type="text" id="school" name="school"
value="<?php if (isset($user)) echo $user->school ?>"/>
</div>
<div class="form-group col-md-6">
<label id="city_label" for="city">Ville de l'établissement :</label>
<input class="form-control" type="text" id="city" name="city"
value="<?php if (isset($user)) echo $user->city ?>"/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label id="country_label" for="country">Pays :</label>
<input class="form-control" type="text" id="country" name="country"
value="<?php if (isset($user)) echo $user->country; else echo "France" ?>"/>
</div>
<div class="form-group col-md-6">
<label id="class_label" for="class">Classe :</label>
<select id="class" name="class" class="custom-select">
@ -84,13 +98,14 @@ if (isset($user) && !$has_error) {
</div>
<div class="form-group row">
<label id="description_label" for="description">Description :</label>
<label id="description_label" for="description">Activité professionnelle :</label>
<textarea class="form-control" id="description"
name="description"><?php if (isset($user)) echo $user->description ?></textarea>
</div>
<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 dêtre recontacté par l'association <em>Animath</em> au sujet
d'autres activités (<em>facultatif</em>) :</label>
<input type="checkbox" id="receive_animath_mails" name="receive_animath_mails"
<?= isset($user) && $user->receive_animath_mails ? "checked" : "" ?> /><br /><br />
@ -107,6 +122,10 @@ if (isset($user) && !$has_error) {
document.getElementById("school").style.display = "block";
document.getElementById("class_label").style.display = "block";
document.getElementById("class").style.display = "block";
document.getElementById("city_label").style.display = "block";
document.getElementById("city").style.display = "block";
document.getElementById("country_label").style.display = "block";
document.getElementById("country").style.display = "block";
document.getElementById("description_label").style.display = "none";
document.getElementById("description").style.display = "none";
break;
@ -115,6 +134,10 @@ if (isset($user) && !$has_error) {
document.getElementById("school").style.display = "none";
document.getElementById("class_label").style.display = "none";
document.getElementById("class").style.display = "none";
document.getElementById("city_label").style.display = "none";
document.getElementById("city").style.display = "none";
document.getElementById("country_label").style.display = "none";
document.getElementById("country").style.display = "none";
document.getElementById("description_label").style.display = "block";
document.getElementById("description").style.display = "block";
break;

View File

@ -45,9 +45,12 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
</div>
</div>
<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"
<?= $user->doReceiveAnimathMails() ? "checked" : "" ?> />
<?php if ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?>
<label for="receive_animath_mails">J'accepte d'être recontacté par l'association <em>Animath</em> au sujet
d'autres activités (<em>facultatif</em>) :</label>
<input type="checkbox" id="receive_animath_mails" name="receive_animath_mails"
<?= $user->doReceiveAnimathMails() ? "checked" : "" ?> />
<?php } ?>
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
<div class="form-row">
@ -56,7 +59,19 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
<input class="form-control" type="text" id="school" name="school"
value="<?= $user->getSchool() ?>"/>
</div>
<div class="form-group col-md-6">
<label id="city_label" for="city">Ville de l'établissement :</label>
<input class="form-control" type="text" id="city" name="city"
value="<?php if (isset($user)) echo $user->getCity() ?>"/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label id="country_label" for="country">Pays :</label>
<input class="form-control" type="text" id="country" name="country"
value="<?php if (isset($user)) echo $user->getCountry(); else echo "France" ?>"/>
</div>
<div class="form-group col-md-6">
<label id="class_label" for="class">Classe :</label>
<select id="class" name="class" class="custom-select">
@ -73,7 +88,7 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
<?php } else { ?>
<div class="form-group row">
<label id="description_label" for="description">Description :</label>
<label id="description_label" for="description">Activité professionnelle :</label>
<textarea class="form-control" id="description"
name="description"><?= $user->getDescription() ?></textarea>
</div>
@ -113,7 +128,7 @@ if (!$has_error && (isset($my_account) || isset($new_password))) {
</div>
</form>
<?php if ($_SESSION["team"]->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<?php if (isset($_SESSION["team"]) && $_SESSION["team"]->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<hr/>
<div class="mt-4 mb-4">
<h1 class="display-5">Autorisation de droit à l'image</h1>

View File

@ -52,8 +52,8 @@ require_once "header.php";
</div>
<div class="alert alert-info">
<!--suppress HtmlUnknownTarget -->
Autorise Animath à diffuser mes vidéos : <?= $team->allowPublish() ? "oui" : "non" ?> (<a
href="/mon-equipe/diffusion-videos">changer</a>)
<strong>Autorise Animath à diffuser mes vidéos à la fin du tournoi :</strong>
<?= $team->allowPublish() ? "oui" : "non" ?> (<a href="/mon-equipe/diffusion-videos">changer</a>)
</div>
<?php if (date("Y-m-d H:i:s") >= $CONFIG->getInscriptionDate() && $team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>

View File

@ -1,12 +1,14 @@
<?php require_once "header.php" ?>
<div class="mt-4 mb-4">
<h2 class="display-3">Problème <?= $problem ?></h2>
<h2 class="display-3">
<?= $problem == 0 ? "Équipes sans problème" : "Problème " . $problem ?>
</h2>
</div>
<hr/>
<h2>Équipes inscrites pour ce problème :</h2>
<h2>Équipes inscrites <?= $problem > 0 ? "pour ce problème" : "sans problème choisi" ?> :</h2>
<table class="table table-striped table-bordered table-hover">
<thead>