Ajustement de la partie ajout/modif/suppression des projets
This commit is contained in:
parent
80dcaee91c
commit
a846fa104f
7 changed files with 31 additions and 29 deletions
|
|
@ -7,17 +7,17 @@ require_once("mother_entity.php");
|
||||||
|
|
||||||
class Project extends Entity{
|
class Project extends Entity{
|
||||||
|
|
||||||
private ?int $_id = null;
|
private ?int $_id = null;
|
||||||
private string $_title = "";
|
private string $_title = "";
|
||||||
private string $_description = "";
|
private string $_description = "";
|
||||||
private ?string $_thumbnail = null;
|
private ?string $_thumbnail = null;
|
||||||
private string $_content = "";
|
private string $_content = "";
|
||||||
private string $_creation_date;
|
private string $_creation_date;
|
||||||
private string $_status = "en_attente";
|
private string $_status = "en_attente";
|
||||||
private int $_user;
|
private int $_user;
|
||||||
private int $_category = 0;
|
private int $_category = 0;
|
||||||
private string $_creatorname;
|
private string $_creatorname;
|
||||||
private ?string $_user_image = null;
|
private ?string $_user_image = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -216,6 +216,4 @@ class Project extends Entity{
|
||||||
public function setUser_image($user_image){
|
public function setUser_image($user_image){
|
||||||
$this->_user_image = $user_image;
|
$this->_user_image = $user_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -140,14 +140,14 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction de changement de status (accepter) d'un projet en BDD
|
* Fonction de changement de status (accepter) d'un projet en BDD
|
||||||
* @author Guillaume
|
|
||||||
* @param int $id l'id du projet
|
* @param int $id l'id du projet
|
||||||
* @return bool Est-ce que la requête s'est bien passée
|
* @return bool Est-ce que la requête s'est bien passée
|
||||||
*/
|
*/
|
||||||
public function accept(int $id){
|
public function accept(int $id){
|
||||||
|
|
||||||
$strRq = "UPDATE project
|
$strRq = "UPDATE project
|
||||||
SET project_status= 'publié'
|
SET project_status = 'publié',
|
||||||
|
project_edit_date = NOW()
|
||||||
WHERE project_id =".$id;
|
WHERE project_id =".$id;
|
||||||
|
|
||||||
return $this->_db->query($strRq);
|
return $this->_db->query($strRq);
|
||||||
|
|
@ -155,14 +155,14 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction de changement de status (refusé) d'un projet en BDD
|
* Fonction de changement de status (refusé) d'un projet en BDD
|
||||||
* @author Guillaume
|
|
||||||
* @param int $id l'id du projet
|
* @param int $id l'id du projet
|
||||||
* @return bool Est-ce que la requête s'est bien passée
|
* @return bool Est-ce que la requête s'est bien passée
|
||||||
*/
|
*/
|
||||||
public function refuse(int $id){
|
public function refuse(int $id){
|
||||||
|
|
||||||
$strRq = "UPDATE project
|
$strRq = "UPDATE project
|
||||||
SET project_status= 'refusé'
|
SET project_status = 'refusé',
|
||||||
|
project_edit_date = NOW()
|
||||||
WHERE project_id =".$id;
|
WHERE project_id =".$id;
|
||||||
|
|
||||||
return $this->_db->query($strRq);
|
return $this->_db->query($strRq);
|
||||||
|
|
@ -170,13 +170,13 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction de suppression d'un projet en BDD
|
* Fonction de suppression d'un projet en BDD
|
||||||
* @author Guillaume
|
|
||||||
* @param int $id l'id du projet
|
* @param int $id l'id du projet
|
||||||
* @return bool Est-ce que la requête s'est bien passée
|
* @return bool Est-ce que la requête s'est bien passée
|
||||||
*/
|
*/
|
||||||
public function delete_soft_project(int $intId): bool {
|
public function delete_soft_project(int $intId): bool {
|
||||||
$strRq = "UPDATE project
|
$strRq = "UPDATE project
|
||||||
SET project_deleted_at = NOW()
|
SET project_deleted_at = NOW(),
|
||||||
|
project_edit_date = NOW()
|
||||||
WHERE project_id = :id";
|
WHERE project_id = :id";
|
||||||
|
|
||||||
$rqPrep = $this->_db->prepare($strRq);
|
$rqPrep = $this->_db->prepare($strRq);
|
||||||
|
|
@ -187,7 +187,6 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction de mise à jour d'un projet en BDD
|
* Fonction de mise à jour d'un projet en BDD
|
||||||
* @author Guillaume
|
|
||||||
* @param object $objProject L'objet utilisateur
|
* @param object $objProject L'objet utilisateur
|
||||||
* @return bool Est-ce que la requête s'est bien passée
|
* @return bool Est-ce que la requête s'est bien passée
|
||||||
*/
|
*/
|
||||||
|
|
@ -197,7 +196,9 @@
|
||||||
SET project_title = :title,
|
SET project_title = :title,
|
||||||
project_description = :description,
|
project_description = :description,
|
||||||
project_content = :content,
|
project_content = :content,
|
||||||
project_thumbnail = :thumbnail
|
project_thumbnail = :thumbnail,
|
||||||
|
project_status = 'en_attente',
|
||||||
|
project_edit_date = NOW()
|
||||||
WHERE project_id = :id";
|
WHERE project_id = :id";
|
||||||
|
|
||||||
$rqPrep = $this->_db->prepare($strRq);
|
$rqPrep = $this->_db->prepare($strRq);
|
||||||
|
|
@ -213,7 +214,6 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction de récupération d'image d'un projet en BDD
|
* Fonction de récupération d'image d'un projet en BDD
|
||||||
* @author Guillaume
|
|
||||||
* @param int $objProject L'Id du projet choisit
|
* @param int $objProject L'Id du projet choisit
|
||||||
* @return array Un tableau avec les informations de la bdd
|
* @return array Un tableau avec les informations de la bdd
|
||||||
*/
|
*/
|
||||||
|
|
@ -231,7 +231,6 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction de récupération d'image d'un projet en BDD
|
* Fonction de récupération d'image d'un projet en BDD
|
||||||
* @author Guillaume
|
|
||||||
* @param int $id L'Id de l'image choisit
|
* @param int $id L'Id de l'image choisit
|
||||||
* @return array Un tableau avec les informations de la bdd
|
* @return array Un tableau avec les informations de la bdd
|
||||||
*/
|
*/
|
||||||
|
|
@ -244,12 +243,13 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction de modifications de status de l'image d'un projet en BDD
|
* Fonction de modifications de status de l'image d'un projet en BDD
|
||||||
* @author Guillaume
|
|
||||||
* @param int $id L'Id de l'image choisit, string $status le status choisit
|
* @param int $id L'Id de l'image choisit, string $status le status choisit
|
||||||
* @return array Un tableau avec les informations de la bdd
|
* @return array Un tableau avec les informations de la bdd
|
||||||
*/
|
*/
|
||||||
public function updateImageStatus(int $id, string $status): bool {
|
public function updateImageStatus(int $id, string $status): bool {
|
||||||
$strRq = "UPDATE image SET image_status = :status WHERE image_id = :id";
|
$strRq = "UPDATE image
|
||||||
|
SET image_status = :status
|
||||||
|
WHERE image_id = :id";
|
||||||
$rqPrep = $this->_db->prepare($strRq);
|
$rqPrep = $this->_db->prepare($strRq);
|
||||||
$rqPrep->bindValue(':status', $status, PDO::PARAM_STR);
|
$rqPrep->bindValue(':status', $status, PDO::PARAM_STR);
|
||||||
$rqPrep->bindValue(':id', $id, PDO::PARAM_INT);
|
$rqPrep->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
|
|
@ -258,12 +258,12 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction de récupération d'image d'un projet en BDD
|
* Fonction de récupération d'image d'un projet en BDD
|
||||||
* @author Guillaume
|
|
||||||
* @param int $id L'Id de l'image choisit
|
* @param int $id L'Id de l'image choisit
|
||||||
* @return array Un tableau avec les informations de la bdd
|
* @return array Un tableau avec les informations de la bdd
|
||||||
*/
|
*/
|
||||||
public function findImage(int $id): array|bool {
|
public function findImage(int $id): array|bool {
|
||||||
$strRq = "SELECT * FROM image WHERE image_id = :id";
|
$strRq = "SELECT * FROM image
|
||||||
|
WHERE image_id = :id";
|
||||||
$rqPrep = $this->_db->prepare($strRq);
|
$rqPrep = $this->_db->prepare($strRq);
|
||||||
$rqPrep->bindValue(':id', $id, PDO::PARAM_INT);
|
$rqPrep->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
$rqPrep->execute();
|
$rqPrep->execute();
|
||||||
|
|
@ -273,7 +273,6 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajoute une image liée à un projet dans la table 'image'
|
* Ajoute une image liée à un projet dans la table 'image'
|
||||||
* @author Guillaume
|
|
||||||
* @param string $fileName Nom du fichier image
|
* @param string $fileName Nom du fichier image
|
||||||
* @param int $projectId ID du projet parent
|
* @param int $projectId ID du projet parent
|
||||||
* @param string $alt Texte alternatif
|
* @param string $alt Texte alternatif
|
||||||
|
|
|
||||||
|
|
@ -80,13 +80,16 @@
|
||||||
date('Y-m-d H:i:s', time() + (15*24*60*60))
|
date('Y-m-d H:i:s', time() + (15*24*60*60))
|
||||||
, PDO::PARAM_STR);
|
, PDO::PARAM_STR);
|
||||||
return $rqPrep->execute();
|
return $rqPrep->execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getTokenUser(string $hash){
|
public function getTokenUser(string $hash){
|
||||||
$strRq = $this->_db->prepare("SELECT token_user_id FROM tokens WHERE token_hash = :hash AND token_expire_at > NOW()");
|
$strRq = $this->_db->prepare("SELECT token_user_id FROM tokens WHERE token_hash = :hash AND token_expire_at > NOW()");
|
||||||
$strRq->execute(['hash' => $hash]);
|
$strRq->execute(['hash' => $hash]);
|
||||||
return $strRq->fetch();
|
return $strRq->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function deleteToken(string $hash){
|
public function deleteToken(string $hash){
|
||||||
$strRq = $this->_db->prepare("DELETE FROM tokens WHERE token_hash = :hash");
|
$strRq = $this->_db->prepare("DELETE FROM tokens WHERE token_hash = :hash");
|
||||||
return $strRq->execute(['hash' => $hash]);
|
return $strRq->execute(['hash' => $hash]);
|
||||||
|
|
|
||||||
BIN
uploads/projects/69a049e86a0f4.webp
Normal file
BIN
uploads/projects/69a049e86a0f4.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
BIN
uploads/projects/69a049e8834a4_gallery.webp
Normal file
BIN
uploads/projects/69a049e8834a4_gallery.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
|
|
@ -33,14 +33,14 @@
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p class="small text-muted mb-0">
|
<p class="small text-muted mb-0">
|
||||||
<i class="bi bi-geo-alt"></i> Colmar
|
<i class="bi bi-geo-alt">Colmar</i>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex justify-content-between align-items-center mt-3">
|
<div class="d-flex justify-content-between align-items-center mt-3">
|
||||||
<small class="text-muted">
|
<small class="text-muted">
|
||||||
<i class="bi bi-clock"></i> <time>{$objProject->getCreation_date()}</time>
|
<i class="bi bi-clock"><time>{$objProject->getCreation_date()}</time></i>
|
||||||
</small>
|
</small>
|
||||||
{if $objProject->getStatus() != "refusé"}
|
{if $objProject->getStatus() != "refusé"}
|
||||||
<a href="index.php?ctrl=project&action=display&id={$objProject->getId()}"
|
<a href="index.php?ctrl=project&action=display&id={$objProject->getId()}"
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,10 @@
|
||||||
<h2 class="visually-hidden">Les 4 derniers articles</h2>
|
<h2 class="visually-hidden">Les 4 derniers articles</h2>
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
|
|
||||||
{foreach from=$arrProjectToDisplay item=objProject}
|
{foreach from=$arrProjectToDisplay item=objProject}
|
||||||
{include file="views/_partial/preview.tpl"}
|
{if $objProject->getStatus() !== "refusé"}
|
||||||
|
{include file="views/_partial/preview.tpl"}
|
||||||
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</section>
|
</section>
|
||||||
{/block}
|
{/block}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue