Correction image changeante

pull/22/head^2
Leni BEAULATON 5 months ago
parent bcb2413cbd
commit 844fb56883

@ -1,7 +1,11 @@
<?php
namespace Controleur;
use Gateway\CharacterGateway;
use Gateway\SourceGateway;
use Model\CharacterModel;
use Model\CommentaryModel;
use Gateway\CommentaryGateway;
use Model\SourceModel;
use Model\UserModel;
use Gateway\UserGateway;
use Model\QuoteModel;
@ -22,6 +26,7 @@ use Twig\Error\SyntaxError;
use Twig\Loader\FilesystemLoader;
use Verification\Verification;
use Enum\TypeSourceEnum;
class UserControler {
@ -112,7 +117,7 @@ class UserControler {
$score = $_SESSION['score'];
$_SESSION['no_question'] = Verification::verifChar( isset($_SESSION['no_question']) ? ($_SESSION['no_question'] + 1) : 1);
if ($_SESSION['no_question'] >= $total_questions) {
session_destroy();
$_SESSION['no_question'] = 0;
$this->endQuiz($id_quiz, $score);
}
else header("Location: ".$racine."/quiz/$id_quiz"); ///~kekentin/WF/WF-Website
@ -180,7 +185,7 @@ class UserControler {
*/
public function showQuestion(int $id, int $num) : void
{
global $vues;
global $vues,$twig;
$q = $this->GetQuestion($id);
$question = $q[$num] ?? $q[0];
$idquestion = $question->getIdQuestion();
@ -232,9 +237,11 @@ class UserControler {
$_SESSION['user'] = $newPseudo;
}
}
else if($newEmail){
$user = $this-> uMod->setEmail($_SESSION['user'], $newEmail);
}
else if($newMdpFirst && $newMdpSecond){
if($newMdpFirst == $newMdpSecond){
@ -242,12 +249,111 @@ class UserControler {
$option = ['cost' => 12];
$newPassWd = password_hash($newMdpFirst, PASSWORD_BCRYPT, $option);
$user = $this-> uMod->setPassWd($_SESSION['user'], $newPassWd);
}
}
}
else if($newImage){
$user = $this->uMod->setImage($_SESSION['user']);
}
}
header("Location: /~lebeaulato/WF-Website/profil");
header("Location: ". $racine."/profil");
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function submit() : void
{
global $twig;
echo $twig -> render("submitQuote.html.twig");
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function toSubmit() : ?array
{
global $co;
if ($_POST)
{
$content = $_POST['content'] ?? null;
$character = $_POST['character'] ?? null;
$source = $_POST['source'] ?? null;
//$img = $_POST['img'] ?? null;
$errors = [null, null];
$gw = new CharacterGateway($co);
$mdl = new CharacterModel($gw);
$character = $mdl -> getCharacterByName($character);
$gw = new SourceGateway($co);
$mdl = new SourceModel($gw);
$source = $mdl -> getSourceByTitle($source);
if (!$character)
$errors[0] = "Personnage inexistant";
if (!$source)
$errors[1] = "Source inexistante";
if ($errors[0] || $errors[1])
{
global $twig;
echo $twig->render("submitQuote.html.twig", ['errors' => $errors]);
exit();
}
$gw = new QuoteGateway($co);
$mdl = new QuoteModel($gw);
$mdl -> insert4User($content, '/imgPath', 'fr', $this -> getIdOfUser(), $source->getIdSource(), $character->getIdCharacter());
return [$content, $_POST['character'], $_POST['source']];
}
return null;
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function validsubmit() : void
{
$recap = $this -> toSubmit();
if ($recap)
{
$this -> recapSubmitQuote($recap);
}
}
/**
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*/
public function recapSubmitQuote(?array $recap) : void
{
global $twig;
echo $twig -> render("recapSubmitQuote.html.twig", ['content' => $recap[0], 'character' => $recap[1], 'source' => $recap[2]]);
}
public function getIdOfUser() : ?int
{
if (isset($_SESSION['user']))
{
global $co;
$gw = new UserGateway($co);
$mdl = new UserModel($gw);
return $mdl -> getUsername($_SESSION['user']) -> getId();
}
return null;
}
}

@ -3,9 +3,8 @@
<h1>▶ Profil ◀</h1>
<form method="post" action="{{ racine }}/changedata">
<img name="image" src="{{ srcImg }}" class="imageProfil" onmousedown="return false"/>
<input type="hidden" name="image" value="1"/>
<button class="saveButtonPasswd" type="Submit">Changer l'image de profil</button>
<img src="{{ srcImg }}" class="imageProfil" onmousedown="return false"/>
<button name="image" class="saveButtonPasswd" value="1" type="Submit">Changer l'image de profil</button>
<p class="infoProfil" name="pseudo" id="username"> <strong>{{ srcUsername }}</strong><img class='imgModify' src='{{ racine }}/images/modify.svg' onclick="editFieldUsername('username')"/></p>

Loading…
Cancel
Save