diff --git a/entities/project_entity.php b/entities/project_entity.php index 6e7e944..b77c134 100644 --- a/entities/project_entity.php +++ b/entities/project_entity.php @@ -7,17 +7,17 @@ require_once("mother_entity.php"); class Project extends Entity{ - private ?int $_id = null; - private string $_title = ""; - private string $_description = ""; - private ?string $_thumbnail = null; - private string $_content = ""; + private ?int $_id = null; + private string $_title = ""; + private string $_description = ""; + private ?string $_thumbnail = null; + private string $_content = ""; private string $_creation_date; - private string $_status = "en_attente"; + private string $_status = "en_attente"; private int $_user; private int $_category = 0; 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){ $this->_user_image = $user_image; } - - } \ No newline at end of file diff --git a/models/project_model.php b/models/project_model.php index 0a72059..d960674 100644 --- a/models/project_model.php +++ b/models/project_model.php @@ -140,14 +140,14 @@ /** * Fonction de changement de status (accepter) d'un projet en BDD - * @author Guillaume * @param int $id l'id du projet * @return bool Est-ce que la requête s'est bien passée */ public function accept(int $id){ $strRq = "UPDATE project - SET project_status= 'publié' + SET project_status = 'publié', + project_edit_date = NOW() WHERE project_id =".$id; return $this->_db->query($strRq); @@ -155,14 +155,14 @@ /** * Fonction de changement de status (refusé) d'un projet en BDD - * @author Guillaume * @param int $id l'id du projet * @return bool Est-ce que la requête s'est bien passée */ public function refuse(int $id){ $strRq = "UPDATE project - SET project_status= 'refusé' + SET project_status = 'refusé', + project_edit_date = NOW() WHERE project_id =".$id; return $this->_db->query($strRq); @@ -170,13 +170,13 @@ /** * Fonction de suppression d'un projet en BDD - * @author Guillaume * @param int $id l'id du projet * @return bool Est-ce que la requête s'est bien passée */ public function delete_soft_project(int $intId): bool { $strRq = "UPDATE project - SET project_deleted_at = NOW() + SET project_deleted_at = NOW(), + project_edit_date = NOW() WHERE project_id = :id"; $rqPrep = $this->_db->prepare($strRq); @@ -187,7 +187,6 @@ /** * Fonction de mise à jour d'un projet en BDD - * @author Guillaume * @param object $objProject L'objet utilisateur * @return bool Est-ce que la requête s'est bien passée */ @@ -197,7 +196,9 @@ SET project_title = :title, project_description = :description, project_content = :content, - project_thumbnail = :thumbnail + project_thumbnail = :thumbnail, + project_status = 'en_attente', + project_edit_date = NOW() WHERE project_id = :id"; $rqPrep = $this->_db->prepare($strRq); @@ -213,7 +214,6 @@ /** * Fonction de récupération d'image d'un projet en BDD - * @author Guillaume * @param int $objProject L'Id du projet choisit * @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 - * @author Guillaume * @param int $id L'Id de l'image choisit * @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 - * @author Guillaume * @param int $id L'Id de l'image choisit, string $status le status choisit * @return array Un tableau avec les informations de la bdd */ 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->bindValue(':status', $status, PDO::PARAM_STR); $rqPrep->bindValue(':id', $id, PDO::PARAM_INT); @@ -258,12 +258,12 @@ /** * Fonction de récupération d'image d'un projet en BDD - * @author Guillaume * @param int $id L'Id de l'image choisit * @return array Un tableau avec les informations de la bdd */ 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->bindValue(':id', $id, PDO::PARAM_INT); $rqPrep->execute(); @@ -273,7 +273,6 @@ /** * Ajoute une image liée à un projet dans la table 'image' - * @author Guillaume * @param string $fileName Nom du fichier image * @param int $projectId ID du projet parent * @param string $alt Texte alternatif diff --git a/models/user_model.php b/models/user_model.php index 9c6c7ce..65ab6da 100644 --- a/models/user_model.php +++ b/models/user_model.php @@ -80,13 +80,16 @@ date('Y-m-d H:i:s', time() + (15*24*60*60)) , PDO::PARAM_STR); return $rqPrep->execute(); - } + + 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->execute(['hash' => $hash]); return $strRq->fetch(); } + + public function deleteToken(string $hash){ $strRq = $this->_db->prepare("DELETE FROM tokens WHERE token_hash = :hash"); return $strRq->execute(['hash' => $hash]); diff --git a/uploads/projects/69a049e86a0f4.webp b/uploads/projects/69a049e86a0f4.webp new file mode 100644 index 0000000..c504287 Binary files /dev/null and b/uploads/projects/69a049e86a0f4.webp differ diff --git a/uploads/projects/69a049e8834a4_gallery.webp b/uploads/projects/69a049e8834a4_gallery.webp new file mode 100644 index 0000000..5cf64d5 Binary files /dev/null and b/uploads/projects/69a049e8834a4_gallery.webp differ diff --git a/views/_partial/preview.tpl b/views/_partial/preview.tpl index 8aceddd..8204c4f 100644 --- a/views/_partial/preview.tpl +++ b/views/_partial/preview.tpl @@ -33,14 +33,14 @@
- Colmar + Colmar