Desgn "Mon compte" & mini-corrections

This commit is contained in:
galaxyoyo 2019-09-24 23:44:38 +02:00
parent b6434cafb8
commit 90952ecb7c
13 changed files with 158 additions and 125 deletions

View File

@ -240,7 +240,7 @@ class User
{
global $DB;
$this->receive_animath_mails = $receive_animath_mails;
$DB->prepare("UPDATE `users` SET `receive_animath_mails` = ? WHERE `id` = ?;")->execute([$receive_animath_mails, $this->getId()]);
$DB->prepare("UPDATE `users` SET `receive_animath_mails` = ? WHERE `id` = ?;")->execute([$receive_animath_mails ? 1 : 0, $this->getId()]);
}
public function getAllDocuments($problem)

View File

@ -9,7 +9,7 @@ $user = $_SESSION["user"];
$has_error = false;
$error_message = null;
if (isset($_POST["update_team"])) {
if (isset($_POST["update_account"])) {
$my_account = new MyAccount($_POST);
try {
$my_account->makeVerifications();
@ -21,7 +21,7 @@ if (isset($_POST["update_team"])) {
}
}
if (isset($_POST["submitted_password"])) {
if (isset($_POST["update_password"])) {
$new_password = new NewPassword($_POST);
try {
$new_password->makeVerifications();
@ -59,6 +59,8 @@ class MyAccount
foreach ($keys as $key)
$this->$key = $this->$key != null && $this->$key != "" ? $this->$key : $this->user->$key;
$this->receive_animath_mails = $this->receive_animath_mails == "on";
}
public function makeVerifications()

View File

@ -1,7 +1,12 @@
<?php
require_once "header.php";
?>
if (isset($admin) && !$has_error) { ?>
<div class="mt-4 mb-4">
<h1 class="display-4">Ajouter un administrateur</h1>
</div>
<?php if (isset($admin) && !$has_error) { ?>
<div class="alert alert-success">
Organisateur ajouté avec succès ! Ses identifiants ont été transmis par mail.
</div>

View File

@ -10,14 +10,14 @@ if (isset($new_team) && !$has_error) { ?>
<?php } else { ?>
<form method="POST">
<table style="width: 100%;">
<table >
<tbody>
<tr>
<td style="width: 30%;">
<label for="name">Nom :</label>
</td>
<td style="width: 70%;">
<input style="width: 100%;" type="text" id="name" name="name" />
<input type="text" id="name" name="name" />
</td>
</tr>
<tr>
@ -25,7 +25,7 @@ if (isset($new_team) && !$has_error) { ?>
<label for="trigram">Trigramme :</label>
</td>
<td>
<input style="width: 100%;" type="text" id="trigram" name="trigram" />
<input type="text" id="trigram" name="trigram" />
</td>
</tr>
<tr>
@ -33,7 +33,7 @@ if (isset($new_team) && !$has_error) { ?>
<label for="problem">Problème :</label>
</td>
<td>
<select style="width: 100%;" id="problem" name="problem">
<select id="problem" name="problem">
<?php
for ($i = 1; $i <= 4; ++$i)
echo "<option value='$i'>$i</option>";
@ -49,7 +49,7 @@ if (isset($new_team) && !$has_error) { ?>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="add_team" value="Ajouter une équipe" />
<input type="submit" name="add_team" value="Ajouter une équipe" />
</td>
</tr>
</tbody>

View File

@ -18,7 +18,7 @@ for ($i = 0; $i < 2; ++$i) {
<?php displayVideo($sol->getLink()) ?>
<h5>Questions échangées :</h5>
<table style="width: 100%;">
<table >
<tbody>
<?php
for ($j = 0; $j < 6; ++$j) {
@ -97,14 +97,14 @@ for ($i = 0; $i < 2; ++$i) {
<form method="POST">
<input type="hidden" name="team" value="<?= $i + 1 ?>" />
<table style="width: 100%;">
<table >
<tbody>
<tr>
<td style="width: 30%;">
<label for="link">Lien de la vidéo à soumettre :</label>
</td>
<td style="width: 70%;">
<input style="width: 100%;" type="url" id="link" name="link" />
<input type="url" id="link" name="link" />
</td>
</tr>
<tr>
@ -119,7 +119,7 @@ for ($i = 0; $i < 2; ++$i) {
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="upload_answer" value="Envoyer la vidéo" />
<input type="submit" name="upload_answer" value="Envoyer la vidéo" />
</td>
</tr>
</tbody>

View File

@ -21,7 +21,7 @@ if (isset($_GET["mdp_oublie"])) { ?>
<form method="POST" class="jumbotron mt-5">
<h1 class="display-4">Réinitialisation du mot de passe</h1>
<label for="email">E-mail associée au compte :</label>
<input type="email" class="form-control" id="email" name="email"/>
<input type="email" class="form-control" id="email" name="email" required/>
<input class="btn btn-lg btn-primary btn-block" type="submit" name="forgotten_password"
value="Envoyer l'e-mail de récupération"/>
</form>
@ -31,11 +31,11 @@ if (isset($_GET["mdp_oublie"])) { ?>
<input type="hidden" name="token" value="<?= $_GET["token"] ?>"/>
<div class="form-group">
<label for="password">Nouveau mot de passe :</label>
<input type="password" id="password" name="password" class="form-control"/>
<input type="password" id="password" name="password" class="form-control" required/>
</div>
<div class="form-group">
<label for="confirm_password">Confirmer le mot de passe :</label>
<input type="password" id="confirm_password" name="confirm_password" class="form-control"/>
<input type="password" id="confirm_password" name="confirm_password" class="form-control" required/>
</div>
<input type="submit" name="reset_password" class="btn btn-block btn-primary"
value="Changer le mot de passe"/>
@ -48,11 +48,11 @@ if (isset($_GET["mdp_oublie"])) { ?>
<div class="form-group">
<label for="email">E-mail :</label>
<input class="form-control" type="email" id="email" name="email"
value="<?php if (isset($email)) echo $email ?>"/>
value="<?php if (isset($email)) echo $email ?>" required/>
</div>
<div class="form-group">
<label for="password">Mot de passe :</label>
<input class="form-control" type="password" id="password" name="password"/>
<input class="form-control" type="password" id="password" name="password" required/>
</div>
<input class="btn btn-primary btn-block" name="login" type="submit" value="Se connecter"/>
</form>

View File

@ -31,14 +31,14 @@ if ($video_validated != null && $video_validated->getId() != $video->getId()) {
?>
<form method="POST">
<table style="width: 100%;">
<table >
<tbody>
<tr>
<td style="width: 30%;">
<label for="link">Lien de la vidéo à soumettre :</label>
</td>
<td style="width: 70%;">
<input style="width: 100%;" type="url" id="link" name="link" />
<input type="url" id="link" name="link" />
</td>
</tr>
<tr>
@ -53,7 +53,7 @@ if ($video_validated != null && $video_validated->getId() != $video->getId()) {
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="upload" value="Envoyer la vidéo" />
<input type="submit" name="upload" value="Envoyer la vidéo" />
</td>
</tr>
</tbody>

View File

@ -26,7 +26,7 @@ if ($_SESSION["role"] == Role::ADMIN) { ?>
<hr />
<form method="POST">
<label for="other_teams">L'équipe va recevoir les questions des équipes suivantes (merci d'en sélectionner exactement 2) :</label>
<select style="width: 100%;" id="other_teams" name="other_teams[]" multiple>
<select id="other_teams" name="other_teams[]" multiple>
<?php
/** @var Team $other_team */
foreach ($other_teams as $other_team) {
@ -39,7 +39,7 @@ if ($_SESSION["role"] == Role::ADMIN) { ?>
}
?>
</select>
<input style="width: 100%;" type="submit" name="update_video_teams" value="Mettre à jour" />
<input type="submit" name="update_video_teams" value="Mettre à jour" />
</form>
<?php } ?>
@ -50,13 +50,13 @@ if ($_SESSION["role"] == Role::ADMIN) { ?>
<?php printDocuments($documents) ?>
<form method="POST">
<input style="width: 100%;" type="submit" name="download_zip" value="Télécharger l'archive"/>
<input type="submit" name="download_zip" value="Télécharger l'archive"/>
</form>
<?php if ($team->getValidationStatus() == ValidationStatus::WAITING && $_SESSION["role"] == Role::ADMIN) { ?>
<hr />
<form method="POST">
<input style="width: 100%;" type="submit" name="validate" value="Valider l'équipe"/>
<input type="submit" name="validate" value="Valider l'équipe"/>
</form>
<?php
}

View File

@ -1,91 +1,117 @@
<?php
require_once "header.php";
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Mon compte</h1>
</div>
<?php
if (!$has_error && (isset($my_account) || isset($new_password))) {
?>
<h2>Votre compte a bien été mis à jour !</h2>
<div class="alert alert-success">
Votre compte a bien été mis à jour !
</div>
<?php
if (isset($my_account) && $user->getEmail() != $my_account->email) {
echo "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.";
}
?>
if (isset($my_account) && $user->getEmail() != $my_account->email) { ?>
<div class="alert alert-info">
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.
</div>
<?php } ?>
<?php } ?>
<form method="POST">
<table style="width: 100%">
<tr>
<td style="width: 30%"><label for="email">E-mail :</label></td>
<td style="width: 70%"><?= $user->getEmail() ?></td>
</tr>
<tr>
<td colspan="2"><input style="width: 100%" type="email" id="email" name="email"/></td>
</tr>
<tr>
<td><label for="surname">Nom :</label></td>
<td><?= $user->getSurname() ?></td>
</tr>
<tr>
<td colspan="2"><input style="width: 100%" type="text" id="surname" name="surname"/></td>
</tr>
<tr>
<td><label for="firstname">Prénom :</label></td>
<td><?= $user->getFirstName() ?></td>
</tr>
<tr>
<td colspan="2"><input style="width: 100%" type="text" id="firstname" name="firstname"/></td>
</tr>
<form method="POST">
<div class="form-row">
<div class="form-group col-md-6">
<label for="surname">Nom :</label>
<input class="form-control" type="text" id="surname" name="surname"
value="<?= $user->getSurname() ?>" required/>
</div>
<div class="form-group col-md-6">
<label for="first_name">Prénom :</label>
<input class="form-control" type="text" id="first_name" name="first_name"
value="<?= $user->getFirstName() ?>" required/>
</div>
</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="<?= $user->getEmail() ?>" required/>
</div>
</div>
<div class="form-row">
<label for="receive_animath_mails">J'accepte de recevoir des mails de la part d'Animath :</label>
<input class="form-control" type="checkbox" id="receive_animath_mails" name="receive_animath_mails"
<?= $user->doReceiveAnimathMails() ? "checked" : "" ?> />
</div>
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
<tr>
<td><label for="school">Établissement dans lequel l'élève étudie :</label></td>
<td><?= $user->getSchool() ?></td>
</tr>
<tr>
<td colspan="2"><input style="width: 100%" type="text" id="school" name="school"/></td>
</tr>
<tr>
<td><label for="class">Classe :</label></td>
<td><select style="width: 100%" id="class" name="class">
<option value="terminale" <?php if ($user->getClass() == SchoolClass::TERMINALE) echo "selected" ?>><?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?></option>
<option value="premiere" <?php if ($user->getClass() == SchoolClass::PREMIERE) echo "selected" ?>><?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?></option>
<option value="seconde" <?php if ($user->getClass() == SchoolClass::SECONDE) echo "selected" ?>><?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?></option>
</select></td>
</tr>
<div class="form-row">
<div class="form-group col-md-6">
<label id="school_label" for="school">Établissement dans lequel l'élève étudie :</label>
<input class="form-control" type="text" id="school" name="school"
value="<?= $user->getSchool() ?>"/>
</div>
<div class="form-group col-md-6">
<label id="class_label" for="class">Classe :</label>
<select id="class" name="class" class="custom-select">
<option value="terminale"><?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?>
<?= $user->getClass() == SchoolClass::TERMINALE ? "selected" : "" ?></option>
<option value="premiere"><?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?>
<?= $user->getClass() == SchoolClass::PREMIERE ? "selected" : "" ?></option>
<option value="seconde"><?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?>
<?= $user->getClass() == SchoolClass::SECONDE ? "selected" : "" ?></option>
</select>
</div>
</div>
<?php } else { ?>
<tr>
<td><label for="description">Description :</label></td>
<td><textarea style="width: 100%" id="description" name="description"><?= $user->getDescription() ?></textarea></td>
</tr>
<div class="form-group row">
<label id="description_label" for="description">Description :</label>
<textarea class="form-control" id="description"
name="description"><?= $user->getDescription() ?></textarea>
</div>
<?php } ?>
<tr>
<td style="text-align: center;" colspan="2"><input type="checkbox" id="receive_animath_mails" name="receive_animath_mails" <?= $user->doReceiveAnimathMails() ? "checked" : "" ?> /> <label for="receive_animath_mails">J'accepte de recevoir des mails de la part d'Animath</label></td>
</tr>
<tr>
<td colspan="2"><input type="submit" style="width: 100%" name="update_team" value="Mettre à jour mes données"/></td>
</tr>
</table>
</form>
<div style="padding: 20px"></div>
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="update_account" type="submit"
value="Enregistrer les modifications"/>
</div>
</form>
<form method="POST">
<input type="hidden" name="submitted_password" value="true"/>
<table style="width: 100%">
<tr>
<td style="width: 30%"><label for="old_password">Ancien mot de passe :</label></td>
<td style="width: 70%"><input style="width: 100%" type="password" id="old_password" name="old_password"/></td>
</tr>
<tr>
<td><label for="new_password">Nouveau mot de passe :</label></td>
<td><input style="width: 100%" type="password" id="new_password" name="new_password"/></td>
</tr>
<tr>
<td><label for="confirm_password">Confirmer le mot de passe :</label></td>
<td><input style="width: 100%" type="password" id="confirm_password" name="confirm_password"/></td>
</tr>
<tr>
<td colspan="2"><input type="submit" style="width: 100%" value="Mettre à jour mon mot de passe"/></td>
</tr>
</table>
</form>
<hr />
<form method="POST">
<div class="form-row">
<div class="form-group col-md-4">
<label for="old_password">Ancien mot de passe :</label>
<input class="form-control" type="password" id="old_password" name="old_password" required/>
</div>
<div class="form-group col-md-4">
<label for="new_password">Nouveau mot de passe :</label>
<input class="form-control" type="password" id="new_password" name="new_password" required/>
</div>
<div class="form-group col-md-4">
<label for="confirm_password">Confirmer le mot de passe :</label>
<input class="form-control" type="password" id="confirm_password" name="confirm_password" required/>
</div>
</div>
<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"/>
</div>
</form>
<?php require_once "footer.php" ?>

View File

@ -38,14 +38,14 @@ for ($i = 1; $i <= 5; ++$i) {
<form method="POST">
<input type="hidden" name="team_edit" value="true"/>
<table style="width: 100%;">
<table >
<tbody>
<tr>
<td style="width: 30%;">
<label for="name">Nom :</label>
</td>
<td style="width: 70%;">
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $team->getName() ?>"/>
<input type="text" id="name" name="name" value="<?= $team->getName() ?>"/>
</td>
</tr>
<tr>
@ -53,7 +53,7 @@ for ($i = 1; $i <= 5; ++$i) {
<label for="trigram">Trigramme :</label>
</td>
<td>
<input style="width: 100%;" type="text" id="trigram" name="trigram"
<input type="text" id="trigram" name="trigram"
value="<?= $team->getTrigram() ?>"/>
</td>
</tr>
@ -62,7 +62,7 @@ for ($i = 1; $i <= 5; ++$i) {
<label for="problem">Problème :</label>
</td>
<td>
<select style="width: 100%;" id="problem" name="problem">
<select id="problem" name="problem">
<?php
for ($i = 1; $i <= 4; ++$i)
echo "<option value=\"$i\" " . ($team->getProblem() == $i ? "selected" : "") . ">$i</option>\n";
@ -72,7 +72,7 @@ for ($i = 1; $i <= 5; ++$i) {
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" value="Modifier l'équipe"/>
<input type="submit" value="Modifier l'équipe"/>
</td>
</tr>
</tbody>
@ -94,30 +94,30 @@ for ($i = 1; $i <= 5; ++$i) {
<hr/>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="type" value="photo_consent"/>
<table style="width: 100%;">
<table >
<tbody>
<tr>
<td>
<label for="file">Fichier :</label>
</td>
<td>
<input style="width: 100%;" type="file" id="file" name="document"/>
<input type="file" id="file" name="document"/>
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="send_document" value="Envoyer le document"/>
<input type="submit" name="send_document" value="Envoyer le document"/>
</td>
</tr>
</tbody>
</table>
</form>
<hr/>
<table style="width: 100%;">
<table >
<tr>
<td style="width: 50%;">
<form method="post">
<input style="width: 100%;" type="submit" name="leave_team" value="Quitter l'équipe"/>
<input type="submit" name="leave_team" value="Quitter l'équipe"/>
</form>
</td>
<?php
@ -127,7 +127,7 @@ for ($i = 1; $i <= 5; ++$i) {
<form method="post">
<input type="checkbox" name="engage" id="engage"/> <label for="engage">Je m'engage à
participer à l'intégralité des Correspondances</label><br/>
<input style="width: 100%;" type="submit" name="request_validation"
<input type="submit" name="request_validation"
value="Demander la validation"/>
</form>
</td>
@ -152,7 +152,7 @@ for ($i = 1; $i <= 5; ++$i) {
$answer = Video::getVideo($asker->getVideoTeamIds()[0] == $team->getId() ? Reason::ANSWER1 : Reason::ANSWER2, $asker);
?>
<h5>Questions de l'équipe <?= $asker->getName() ?> (<?= $asker->getTrigram() ?>) :</h5>
<table style="width: 100%;">
<table >
<tbody>
<?php
for ($j = 0; $j < 6; ++$j) {
@ -231,7 +231,7 @@ for ($i = 1; $i <= 5; ++$i) {
<br/>
<h5>Vos questions :</h5>
<br/>
<table style="width: 100%;">
<table >
<tbody>
<?php
for ($j = 0; $j < 6; ++$j) {

View File

@ -15,7 +15,7 @@ for ($i = 0; $i < 2; ++$i) {
<br/>
<form method="POST" enctype="multipart/form-data">
<input type="hidden" name="to" value="<?= $receiver->getTrigram() ?>"/>
<table style="width: 100%;">
<table >
<tbody>
<?php
for ($j = 0; $j < 6; ++$j) {
@ -25,7 +25,7 @@ for ($i = 0; $i < 2; ++$i) {
<label for="question_<?= $j + 1 ?>">Question <?= $j + 1 ?> <?= $j >= 3 ? "(<em>facultatif</em>)" : "" ?> :</label>
</td>
<td style="width: 70%;">
<textarea style="width: 100%;" id="question_<?= $j + 1 ?>" name="question_<?= $j + 1 ?>"><?= $question->getQuestion() ?></textarea>
<textarea id="question_<?= $j + 1 ?>" name="question_<?= $j + 1 ?>"><?= $question->getQuestion() ?></textarea>
</td>
</tr>
<?php
@ -44,7 +44,7 @@ for ($i = 0; $i < 2; ++$i) {
<label for="file_<?= $j + 1 ?>">Ajouter une pièce jointe (<em>facultatif</em>) :</label>
</td>
<td>
<input style="width: 100%;" type="file" name="file_<?= $j + 1 ?>" id="file_<?= $j + 1 ?>" />
<input type="file" name="file_<?= $j + 1 ?>" id="file_<?= $j + 1 ?>" />
</td>
</tr>
<?php } ?>
@ -55,7 +55,7 @@ for ($i = 0; $i < 2; ++$i) {
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="give_questions" value="Poser les questions" />
<input type="submit" name="give_questions" value="Poser les questions" />
</td>
</tr>
</tbody>

View File

@ -10,19 +10,19 @@ if (isset($join_team) && !$has_error) { ?>
<?php if ($has_error) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
<form method="POST">
<table style="width: 100%;">
<table >
<tbody>
<tr>
<td style="width: 30%;">
<label for="access_code">Code d'accès :</label>
</td>
<td style="width: 70%;">
<input style="width: 100%;" type="text" id="access_code" name="access_code" />
<input type="text" id="access_code" name="access_code" />
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" name="join_team" type="submit" value="Rejoindre l'équipe" />
<input name="join_team" type="submit" value="Rejoindre l'équipe" />
</td>
</tr>
</tbody>

View File

@ -13,7 +13,7 @@ foreach ($questions as $questions_team) {
?>
<form method="POST" enctype="multipart/form-data">
<input type="hidden" name="from" value="<?= $from->getTrigram() ?>" />
<table style="width: 100%;">
<table >
<tbody>
<?php
for ($i = 0; $i < sizeof($questions_team); ++$i) {
@ -45,7 +45,7 @@ foreach ($questions as $questions_team) {
<label for="answer_<?= $i + 1 ?>">Réponse :</label>
</td>
<td>
<textarea style="width: 100%;" id="answer_<?= $i + 1 ?>" name="answer_<?= $i + 1 ?>"><?= $question->getAnswer() ?></textarea>
<textarea id="answer_<?= $i + 1 ?>" name="answer_<?= $i + 1 ?>"><?= $question->getAnswer() ?></textarea>
</td>
</tr>
<?php
@ -64,7 +64,7 @@ foreach ($questions as $questions_team) {
<label for="file_<?= $i + 1 ?>">Ajouter une pièce jointe (<em>facultatif</em>) :</label>
</td>
<td>
<input style="width: 100%;" type="file" name="file_<?= $i + 1 ?>" id="file_<?= $i + 1 ?>" />
<input type="file" name="file_<?= $i + 1 ?>" id="file_<?= $i + 1 ?>" />
</td>
</tr>
<?php } ?>
@ -75,7 +75,7 @@ foreach ($questions as $questions_team) {
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="answer" value="Répondre aux questions posées" />
<input type="submit" name="answer" value="Répondre aux questions posées" />
</td>
</tr>
</tbody>