Merge pull request #33 from Yasder5/guillaume

Guillaume
This commit is contained in:
Yass 2026-02-26 20:28:21 +01:00 committed by GitHub
commit fd3e97b6d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 667 additions and 92 deletions

98
README.md Normal file
View file

@ -0,0 +1,98 @@
# Folliow Projet PHP
A platform for sharing portfolios and projects, designed as a mix between Behance and LinkedIn. Folliow focuses on highlighting real projects while making it easy to connect with other users.
This project was developed as part of the **DWWM (Développeur Web et Web Mobile)** training.
---
## Features
- User authentication and profile management
- Portfolio and project creation
- Project showcase with descriptions and technologies
- User connections / follow system
- Project feed and discovery
- Profile and project search
---
## Tech Stack
**Client:** HTML, CSS, JavaScript
**Server:** PHP (MVC architecture)
**Database:** MySQL
**Web Server:** Apache
---
## Project Structure
```text
folliow/
├── app/
│ ├── controllers/
│ ├── models/
│ └── views/
├── public/
│ ├── assets/
│ └── index.php
├── config/
│ └── database.php
├── sql/
│ └── folliow.sql
└── README.md
```
---
## Installation
Clone the project
```bash
git clone https://github.com/Yasder5/projet_php.git
```
Go to the project directory
```bash
cd projet_php
```
Import the database
- Use the SQL file located in the `sql/` directory
Configure database access
- Update credentials in `config/database.php`
Run the project
- Use a local server (XAMPP, WAMP, or Apache on Linux)
---
## Learning Objectives
- Build a complete PHP web application
- Apply MVC architecture
- Manage a relational database
- Design a user-oriented portfolio platform
---
## Future Improvements
- Private messaging
- Likes and comments on projects
- Tags and categories
- Improved responsive design
- Advanced authentication and roles
---
## License
This project is for educational purposes.

View file

@ -506,13 +506,22 @@
* @author Guillaume
*/
public function delete(){
//Vérif utilisateur soit bien modérateur
if (!isset($_SESSION['user']) || $_SESSION['user']['user_status'] != 2) {
header("Location: index.php");
exit;
}
//Récupéré l'id dans l'url
$intId = $_GET['id'];
$intId = $_GET['id'] ?? null;
//Je créer un nouveau model pour exec la commande SQL
$objProjectModel = new ProjectModel;
$objProjectModel->delete($intId);
if ($intId) {
$objProjectModel = new ProjectModel();
if ($objProjectModel->delete_soft_project((int) $intId)) {
$_SESSION['success'] = "Le projet a été archivé avec succès.";
} else {
$_SESSION['error'] = "Une erreur est survenue lors de l'archivage.";
}
}
//Redirection vers la page
header("Location: index.php");

0
database/.gitkeep Normal file
View file

253
database/database.sql Normal file
View file

@ -0,0 +1,253 @@
CREATE DATABASE IF NOT EXISTS `projet_folliow`
DEFAULT CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
USE `projet_folliow`;
/*M!999999\- enable the sandbox mode */
-- MariaDB dump 10.19 Distrib 10.11.14-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: projet_folliow
-- ------------------------------------------------------
-- Server version 10.11.14-MariaDB-0+deb12u2
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `authorisation`
--
DROP TABLE IF EXISTS `authorisation`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `authorisation` (
`authorisation_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Identifiant unique des autorisations',
`authorisation_name` varchar(30) NOT NULL COMMENT 'Administrateur, modérateur, utilisateur',
PRIMARY KEY (`authorisation_id`),
UNIQUE KEY `uk_authorisation_name` (`authorisation_name`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `authorisation`
--
LOCK TABLES `authorisation` WRITE;
/*!40000 ALTER TABLE `authorisation` DISABLE KEYS */;
INSERT INTO `authorisation` VALUES
(1,'Administrateur'),
(2,'Modérateur'),
(3,'Utilisateur');
/*!40000 ALTER TABLE `authorisation` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `category`
--
DROP TABLE IF EXISTS `category`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `category` (
`category_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Identifiant unique des catégorie du projet',
`category_name` varchar(150) NOT NULL COMMENT 'Nom de chaque catégorie',
`category_parent` int(10) unsigned DEFAULT NULL COMMENT 'ID de la catégorie parente (NULL = catégorie principale)',
PRIMARY KEY (`category_id`),
UNIQUE KEY `uk_category_name_parent` (`category_name`,`category_parent`),
KEY `fk_category_parent` (`category_parent`),
CONSTRAINT `fk_category_parent` FOREIGN KEY (`category_parent`) REFERENCES `category` (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=54 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `category`
--
LOCK TABLES `category` WRITE;
/*!40000 ALTER TABLE `category` DISABLE KEYS */;
INSERT INTO `category` VALUES
(32,'3D',4),
(34,'Aquarelle',4),
(5,'Architecture',NULL),
(36,'Architecture d\'Intérieur',5),
(35,'Architecture Moderne',5),
(24,'Backend',2),
(33,'Bande Dessinée',4),
(1,'Design',NULL),
(2,'Développement Web',NULL),
(31,'Digital Art',4),
(30,'Événementiel',3),
(23,'Frontend',2),
(25,'Full-Stack',2),
(4,'Illustration',NULL),
(20,'Logo & Identité Visuelle',1),
(39,'Marketing',NULL),
(46,'Marketing',NULL),
(26,'Mobile',2),
(21,'Motion Design',1),
(38,'Patrimoine',5),
(28,'Paysage',3),
(3,'Photographie',NULL),
(27,'Portrait',3),
(22,'Print Design',1),
(40,'Rédaction',NULL),
(47,'Rédaction',NULL),
(29,'Sport',3),
(19,'UI/UX Design',1),
(37,'Urbanisme',5),
(41,'Vidéo',NULL),
(48,'Vidéo',NULL);
/*!40000 ALTER TABLE `category` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `image`
--
DROP TABLE IF EXISTS `image`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `image` (
`image_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'identifiant unique des images',
`image_name` varchar(150) NOT NULL COMMENT 'Chemin de l''image enregistrée',
`image_alt` varchar(255) DEFAULT NULL COMMENT 'Alt de l''image',
`image_status` varchar(50) NOT NULL DEFAULT 'en_attente' COMMENT 'Statut de modération de l''image',
`image_project` int(10) unsigned DEFAULT NULL COMMENT 'Identifiant du projet où se trouve l''image',
PRIMARY KEY (`image_id`),
KEY `fk_image_project` (`image_project`),
CONSTRAINT `fk_image_project` FOREIGN KEY (`image_project`) REFERENCES `project` (`project_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `chk_image_status` CHECK (`image_status` in ('en_attente','approuvé','rejeté'))
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `image`
--
LOCK TABLES `image` WRITE;
/*!40000 ALTER TABLE `image` DISABLE KEYS */;
INSERT INTO `image` VALUES
(1,'/uploads/projects/ecommerce-01.jpg','Page d\'accueil du site e-commerce refondu','approuvé',1),
(2,'/uploads/projects/ecommerce-02.jpg','Interface mobile du processus de commande','approuvé',1),
(3,'/uploads/projects/taskmanager-01.jpg','Vue kanban de l\'application','approuvé',2),
(4,'/uploads/projects/urban-01.jpg','Architecture moderne à La Défense','en_attente',3);
/*!40000 ALTER TABLE `image` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `project`
--
DROP TABLE IF EXISTS `project`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `project` (
`project_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Identifiant unique du projet',
`project_title` varchar(150) NOT NULL COMMENT 'Titre du projet',
`project_description` text DEFAULT NULL COMMENT 'Description du projet',
`project_thumbnail` varchar(150) DEFAULT NULL COMMENT 'Image miniature du projet',
`project_content` text DEFAULT NULL COMMENT 'Contenu du projet',
`project_creation_date` date NOT NULL COMMENT 'Date de création du projet',
`project_status` varchar(30) NOT NULL DEFAULT 'brouillon' COMMENT 'Statut du projet : brouillon, publié, en_attente',
`project_user` int(10) unsigned DEFAULT NULL COMMENT 'Identifiant de l''user',
`project_category` int(10) unsigned DEFAULT NULL COMMENT 'Identifiant de la catégorie',
PRIMARY KEY (`project_id`),
KEY `fk_project_user` (`project_user`),
KEY `fk_project_category` (`project_category`),
KEY `idx_project_status` (`project_status`),
KEY `idx_project_creation_date` (`project_creation_date`),
CONSTRAINT `fk_project_category`
FOREIGN KEY (`project_category`)
REFERENCES `category` (`category_id`)
ON DELETE SET NULL
ON UPDATE CASCADE,
CONSTRAINT `fk_project_user`
FOREIGN KEY (`project_user`)
REFERENCES `users` (`user_id`)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `project`
--
LOCK TABLES `project` WRITE;
/*!40000 ALTER TABLE `project` DISABLE KEYS */;
INSERT INTO `project` VALUES
(1,'Refonte du site e-commerce','Refonte complète de l\'interface utilisateur d\'une boutique en ligne avec focus sur l\'expérience mobile','/uploads/projects/ecommerce-thumb.jpg','Ce projet visait à moderniser entièrement l\'interface d\'un site e-commerce existant. Les principales améliorations incluent une navigation simplifiée, un processus de commande optimisé et une interface responsive.','2025-12-01','publié',1,1),
(2,'Application de gestion de tâches','Développement d\'une application web pour la gestion collaborative de projets','/uploads/projects/taskmanager-thumb.jpg','Application web développée en React et Node.js permettant aux équipes de gérer leurs projets de manière collaborative. Fonctionnalités : kanban, calendrier, notifications en temps réel.','2025-12-15','publié',2,2),
(3,'Série photo urbaine','Collection de photographies capturant l\'architecture moderne de Paris','/uploads/projects/urban-thumb.jpg','Série de 30 photographies prises dans différents quartiers de Paris, mettant en valeur le contraste entre architecture classique et moderne. Travail sur la lumière naturelle et les perspectives.','2026-01-05','en_attente',3,3);
/*!40000 ALTER TABLE `project` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`user_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Identifiant unique de l''utilisateur',
`user_name` varchar(100) NOT NULL COMMENT 'Nom de l''utilisateur',
`user_firstname` varchar(100) NOT NULL COMMENT 'Prénom de l''utilisateur',
`user_pseudo` varchar(30) NOT NULL COMMENT 'Pseudo de l''utilisateur',
`user_image` varchar(150) DEFAULT NULL COMMENT 'Photo de profil de l''utilisateur',
`user_mail` varchar(100) NOT NULL COMMENT 'Mail de l''utilisateur',
`user_password` varchar(255) NOT NULL COMMENT 'Mot de passe de l''utilisateur',
`user_phone` varchar(20) DEFAULT NULL COMMENT 'Téléphone de l''utilisateur',
`user_work` varchar(50) DEFAULT NULL COMMENT 'Profession de l''utilisateur',
`user_birth` date DEFAULT NULL COMMENT 'Date de naissance de l''utilisateur',
`user_location` varchar(150) DEFAULT NULL COMMENT 'Localisation de l''utilisateur',
`user_description` varchar(255) DEFAULT NULL COMMENT 'Phrase d''accroche de l''utilisateur',
`user_account_creation` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Date et heure de création du compte',
`user_status` int(10) unsigned DEFAULT NULL COMMENT 'identifiant de niveau d''autorisation',
PRIMARY KEY (`user_id`),
UNIQUE KEY `uk_user_mail` (`user_mail`),
UNIQUE KEY `uk_user_pseudo` (`user_pseudo`),
KEY `fk_users_authorisation` (`user_status`),
KEY `idx_user_mail` (`user_mail`),
CONSTRAINT `fk_users_authorisation` FOREIGN KEY (`user_status`) REFERENCES `authorisation` (`authorisation_id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES
(1,'Dupont','Marie','marie_design','/uploads/users/marie.jpg','marie.dupont@example.com','$2y$10$T5kWRD3NBqXKWtQqrBG3We1Qpq2Odum0/xYAoT2SaCclG7h2Y0Gvq','0612345678','Designer UI/UX','1995-03-15','Paris, France','Passionnée de design et d\'expérience utilisateur','2024-01-15 10:30:00',1),
(2,'Martin','Thomas','thomas_dev','/uploads/users/thomas.jpg','thomas.martin@example.com','$2y$10$T5kWRD3NBqXKWtQqrBG3We1Qpq2Odum0/xYAoT2SaCclG7h2Y0Gvq','0623456789','Développeur Full-Stack','1992-07-22','Lyon, France','Créateur d\'applications web modernes','2024-02-20 14:45:00',2),
(3,'Dubois','Sophie','sophie_photo','/uploads/users/sophie.jpg','sophie.dubois@example.com','$2y$10$T5kWRD3NBqXKWtQqrBG3We1Qpq2Odum0/xYAoT2SaCclG7h2Y0Gvq','0634567890','Photographe','1998-11-08','Marseille, France','Capturer l\'instant présent est ma passion','2024-03-10 09:15:00',3);
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2026-01-09 17:33:08

View file

@ -7,17 +7,18 @@ 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;
private ?string $_project_deleted_at = null;
/**
@ -217,5 +218,19 @@ class Project extends Entity{
$this->_user_image = $user_image;
}
/**
* Récupération de la date du projet supprimer
* @return string date du projet
*/
public function getProject_deleted_at(){
return $this->_project_deleted_at;
}
/**
* Mise à jour de la date de suppression de projet
* @param string date du projet
*/
public function setProject_deleted_at($project_deleted_at){
$this->_project_deleted_at = $project_deleted_at;
}
}

View file

@ -24,37 +24,51 @@
user_pseudo AS 'project_creatorname',
user_image
FROM project
INNER JOIN users ON user_id = project_user_id
WHERE 1=1";
INNER JOIN users ON user_id = project_user_id";
$strRq .= " WHERE project_deleted_at IS NULL";
$strAnd = " AND ";
// Recherche par mot clé avec quote pour éviter bug du '
if ($strKeywords != '') {
$strRq .= " AND (project_title LIKE :keywords OR project_content LIKE :keywords)";
$strSafeKeywords = $this->_db->quote("%" . $strKeywords . "%");
$strRq .= $strAnd. " (project_title LIKE ".$strSafeKeywords."
OR project_content LIKE ".$strSafeKeywords.") ";
}
// Recherche par auteur
if ($intAuthor > 0){
$strRq .= " AND project_user_id = :author";
$strRq .= $strAnd." user_id = ".$intAuthor;
}
// Recherche par catégorie
if ($intCategory > 0){
$strRq .= " AND project_category = :category";
$strRq .= $strAnd." project_category = ".$intCategory;
}
//recherche par ancienneté
if ($boolOlderThan6Months === true) {
$strRq .= " AND project_creation_date <= DATE_SUB(NOW(), INTERVAL 6 MONTH)";
$strRq .= $strAnd . " project_creation_date <= DATE_SUB(NOW(), INTERVAL 6 MONTH) ";
}
// Recherche par dates
if ($intPeriod == 0){
if ($strDate != ''){
$strRq .= " AND project_creation_date = :date_exacte";
$strRq .= $strAnd." project_creation_date = '".$strDate."'";
}
} else {
}else{
if ($strStartDate != '' && $strEndDate != ''){
$strRq .= " AND project_creation_date BETWEEN :date_debut AND :date_fin";
} else {
$strRq .= $strAnd." project_creation_date BETWEEN '".$strStartDate."' AND '".$strEndDate."'";
}else{
if ($strStartDate != ''){
$strRq .= " AND project_creation_date >= :date_debut";
} else if ($strEndDate != ''){
$strRq .= " AND project_creation_date <= :date_fin";
$strRq .= $strAnd." project_creation_date >= '".$strStartDate."'";
}else if ($strEndDate != ''){
$strRq .= $strAnd." project_creation_date <= '".$strEndDate."'";
}
}
}
@ -62,42 +76,10 @@
$strRq .= " ORDER BY project_creation_date DESC";
if ($intLimit > 0){
$strRq .= " LIMIT :limit";
$strRq .= " LIMIT ".$intLimit;
}
$rqPrep = $this->_db->prepare($strRq);
if ($strKeywords != '') {
$rqPrep->bindValue(':keywords', '%' . $strKeywords . '%', PDO::PARAM_STR);
}
if ($intAuthor > 0){
$rqPrep->bindValue(':author', $intAuthor, PDO::PARAM_INT);
}
if ($intCategory > 0){
$rqPrep->bindValue(':category', $intCategory, PDO::PARAM_INT);
}
if ($intPeriod == 0){
if ($strDate != ''){
$rqPrep->bindValue(':date_exacte', $strDate, PDO::PARAM_STR);
}
} else {
if ($strStartDate != '' && $strEndDate != ''){
$rqPrep->bindValue(':date_debut', $strStartDate, PDO::PARAM_STR);
$rqPrep->bindValue(':date_fin', $strEndDate, PDO::PARAM_STR);
} else {
if ($strStartDate != ''){
$rqPrep->bindValue(':date_debut', $strStartDate, PDO::PARAM_STR);
} else if ($strEndDate != ''){
$rqPrep->bindValue(':date_fin', $strEndDate, PDO::PARAM_STR);
}
}
}
if ($intLimit > 0){
$rqPrep->bindValue(':limit', $intLimit, PDO::PARAM_INT);
}
$rqPrep->execute();
return $rqPrep->fetchAll();
return $this->_db->query($strRq)->fetchAll();
}
@ -146,7 +128,8 @@
FROM project
INNER JOIN users ON users.user_id = project.project_user_id
LEFT JOIN category ON category.category_id = project.project_category
WHERE project.project_id = :id";
WHERE project.project_id = :id
AND project.project_deleted_at IS NULL";
$rqPrep = $this->_db->prepare($strRq);
$rqPrep->bindValue(":id", $intId, PDO::PARAM_INT);
@ -157,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);
@ -172,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);
@ -187,21 +170,23 @@
/**
* 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(int $id){
public function delete_soft_project(int $intId): bool {
$strRq = "UPDATE project
SET project_deleted_at = NOW(),
project_edit_date = NOW()
WHERE project_id = :id";
$strRq = "DELETE FROM project
WHERE project_id =".$id;
$rqPrep = $this->_db->prepare($strRq);
$rqPrep->bindValue(":id", $intId, PDO::PARAM_INT);
return $this->_db->query($strRq);
return $rqPrep->execute();
}
/**
* 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
*/
@ -211,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);
@ -227,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
*/
@ -245,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
*/
@ -258,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);
@ -272,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();
@ -287,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
@ -312,4 +297,5 @@
return $rqPrep->execute();
}
}

View file

@ -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]);

0
sfq.txt Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -33,14 +33,14 @@
</a>
</p>
<p class="small text-muted mb-0">
<i class="bi bi-geo-alt"></i> Colmar
<i class="bi bi-geo-alt">Colmar</i>
</p>
</div>
</div>
<div class="d-flex justify-content-between align-items-center mt-3">
<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>
{if $objProject->getStatus() != "refusé"}
<a href="index.php?ctrl=project&action=display&id={$objProject->getId()}"
@ -74,8 +74,10 @@
href="?ctrl=project&action=refuse&id={$objProject->getId()}"
name="toRefused">Refuser</a>
<a class="btn btn-sm btn-danger flex-fill"
href="?ctrl=project&action=delete&id={$objProject->getId()}"
name="toDelete" onclick="return confirm('Attention ! Êtes-vous sûr de vouloir supprimer ce projet ? Cette action est irréversible.');">Supprimer</a>
href="index.php?ctrl=project&action=delete&id={$objProject->getId()}"
name="toDelete"
onclick="return confirm('Attention ! Êtes-vous sûr de vouloir supprimer ce projet ? Cette action est irréversible.');">
Supprimer</a>
</div>
</div>
{elseif $objProject->getStatus() == "refusé"}

View file

@ -26,8 +26,20 @@
<h2 class="visually-hidden">Les 4 derniers articles</h2>
<div class="row mb-2">
{foreach from=$arrProjectToDisplay item=objProject}
{include file="views/_partial/preview.tpl"}
{foreach from=$arrProjectToDisplay item=objProject}
{assign var="isAuthor" value=(isset($smarty.session.user) && $smarty.session.user.user_id == $objProject->getUser_id())}
{assign var="isModerator" value=(isset($smarty.session.user) && $smarty.session.user.user_status == 2)}
{assign var="isDeleted" value=($objProject->getProject_deleted_at() !== null)}
{assign var="isRefused" value=($objProject->getStatus() == "refusé")}
{if $isModerator
|| ($isAuthor && !$isDeleted)
|| (!$isRefused && !$isDeleted)}
{include file="views/_partial/preview.tpl"}
{/if}
{/foreach}
</section>
{/block}

197
views/inscription.tpl Normal file
View file

@ -0,0 +1,197 @@
{extends file="views/layout.tpl"}
{block name="content"}
<!-- Page : Inscription -->
<main class="container py-5">
<!-- Centrage horizontal du formulaire -->
<div class="row justify-content-center position-relative">
<div class="col-12 col-md-10 col-lg-6">
<!-- Carte contenant le formulaire d'inscription -->
<div class="card shadow-sm border-0 rounded-4 p-4 p-lg-5">
<!-- Titre principal de la page -->
<h1 class="h3 fw-bold mb-1">Inscription</h1>
<!-- Texte descriptif -->
<p class="text-secondary mb-4">
Créez votre compte utilisateur.
</p>
{if (isset($arrError) && count($arrError) > 0) }
<div class="alert alert-danger">
{foreach $arrError as $strError}
<p>{$strError}</p>
{/foreach}
</div>
{/if}
<!-- Formulaire d'inscription -->
<!-- Les données seront traitées côté serveur en PHP via la méthode POST -->
<form method="POST">
<div class="row g-3">
<!-- Champ : prénom de l'utilisateur -->
<div class="col-md-6">
<label class="form-label" for="user_firstname">
Prénom *
</label>
<input
class="form-control"
type="text"
id="user_firstname"
name="user_firstname"
required >
</div>
<!-- Champ : nom de l'utilisateur -->
<div class="col-md-6">
<label class="form-label" for="user_name">
Nom *
</label>
<input
class="form-control"
type="text"
id="user_name"
name="user_name"
required
>
</div>
<!-- Champ : pseudo -->
<div class="col-12">
<label class="form-label" for="user_pseudo">
Pseudo *
</label>
<div class="input-group">
<span class="input-group-text">@</span>
<input
class="form-control"
type="text"
id="user_pseudo"
name="user_pseudo"
required
>
</div>
</div>
<!-- Champ : adresse e-mail -->
<div class="col-12">
<label class="form-label" for="user_mail">
Adresse e-mail *
</label>
<input
class="form-control"
type="email"
id="user_mail"
name="user_mail"
required
>
</div>
<!-- Champ : mot de passe -->
<div class="col-12">
<label class="form-label" for="user_password">
Mot de passe *
</label>
<input
class="form-control"
type="password"
id="user_password"
name="user_password"
required
>
</div>
<!-- Champ : confirmer le mot de passe -->
<div class="col-12">
<label class="form-label" for="pwd_confirm">
Confirmer le Mot de passe *
</label>
<input
class="form-control"
type="password"
id="pwd_confirm"
name="pwd_confirm"
required
>
</div>
<!-- Champ optionnel : numéro de téléphone -->
<div class="col-12">
<label class="form-label" for="user_phone">
Téléphone
</label>
<input
class="form-control"
type="text"
id="user_phone"
name="user_phone"
>
</div>
<!-- Champ optionnel : profession de l'utilisateur -->
<div class="col-12">
<label class="form-label" for="user_work">
Profession
</label>
<input
class="form-control"
type="text"
id="user_work"
name="user_work"
>
</div>
<!-- Champ optionnel : localisation de l'utilisateur -->
<div class="col-12">
<label class="form-label" for="user_location">
Localisation
</label>
<input
class="form-control"
type="text"
id="user_location"
name="user_location"
>
</div>
<!-- Champ optionnel : phrase d'accroche -->
<div class="col-12">
<label class="form-label" for="user_description">
Phrase d'accroche
</label>
<textarea
class="form-control"
id="user_description"
name="user_description"
rows="3"
></textarea>
</div>
<!-- Bouton de soumission du formulaire -->
<div class="col-12 d-grid mt-2">
<button type="submit" class="btn btn-primary btn-lg rounded-3">
Créer mon compte
</button>
</div>
<!-- Lien vers la page de connexion -->
<div class="col-12 text-center">
<small class="text-secondary">
Déjà un compte ?
<a href="index.php?ctrl=user&action=login">Se connecter</a>
</small>
</div>
</form>
</div>
</div>
</div>
</div>
</main>
{/block}