Fonctionnalité de modification/ajout de projet terminer
This commit is contained in:
parent
9c19aa5525
commit
374085d0fe
149 changed files with 12892 additions and 657 deletions
|
|
@ -26,7 +26,7 @@
|
|||
Pour passer sur le serveur de YASS:
|
||||
*"mysql:host=boulayoune.com;dbname=projet_folliow", // Serveur et BDD
|
||||
"projet_user", //Nom d'utilisateur de la base de données
|
||||
"F0lliowRules!",// Mot de passe de la base de données
|
||||
"F0lliowRules!",// Mot de passe de la base de données
|
||||
Site pour BDD: https://phpmyadmin.boulayoune.com/index.php?route=/sql&pos=0&db=projet_folliow&table=project
|
||||
|
||||
Pour passer en local:
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
string $strEndDate='', int $intCategory=0, bool $bool6Months=false):array{
|
||||
|
||||
$strRq = "SELECT project.*,
|
||||
CONCAT(user_firstname, ' ', user_name) AS 'project_creatorname',
|
||||
user_pseudo AS 'project_creatorname',
|
||||
user_image
|
||||
FROM project
|
||||
INNER JOIN users ON user_id = project_user_id";
|
||||
|
|
@ -103,7 +103,16 @@
|
|||
$rqPrep->bindValue(":project_user_id", $objProject->getUser_id(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":project_category", $objProject->getCategory(), PDO::PARAM_STR);
|
||||
|
||||
return $rqPrep->execute();
|
||||
// On met une variable boolOk pour récupérer l'id du projet
|
||||
$boolOk = $rqPrep->execute();
|
||||
|
||||
// Si boolOk est remplis
|
||||
if ($boolOk) {
|
||||
// On récupère l'ID auto-incrémenté et on l'injecte dans l'objet
|
||||
$objProject->setId($this->_db->lastInsertId());
|
||||
}
|
||||
|
||||
return $boolOk;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -200,10 +209,16 @@
|
|||
return $rqPrep->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function getImagesByProjectId(int $projectId): array {
|
||||
$strRq = "SELECT image_id, image_name, image_alt
|
||||
$strRq = "SELECT image_id, image_name, image_alt, image_status
|
||||
FROM image
|
||||
WHERE image_project = :id AND image_status = 1";
|
||||
WHERE image_project = :id";
|
||||
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
$rqPrep->bindValue(":id", $projectId, PDO::PARAM_INT);
|
||||
|
|
@ -212,6 +227,56 @@
|
|||
return $rqPrep->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 deleteImage(int $id): bool {
|
||||
$strRq = "DELETE FROM image WHERE image_id = :id";
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
$rqPrep->bindValue(':id', $id, PDO::PARAM_INT);
|
||||
return $rqPrep->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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";
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
$rqPrep->bindValue(':status', $status, PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(':id', $id, PDO::PARAM_INT);
|
||||
return $rqPrep->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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";
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
$rqPrep->bindValue(':id', $id, PDO::PARAM_INT);
|
||||
$rqPrep->execute();
|
||||
return $rqPrep->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return bool
|
||||
*/
|
||||
public function addImageInProject(string $fileName, int $projectId, string $alt = "Image projet"): bool {
|
||||
$strRq = "INSERT INTO image (
|
||||
image_name,
|
||||
|
|
@ -225,9 +290,10 @@
|
|||
|
||||
$rqPrep->bindValue(":name", $fileName, PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":alt", $alt, PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":status", "en_attente", PDO::PARAM_STR); // Valeur string brute
|
||||
// On met le statut par défaut en "en_attente" pour la modération
|
||||
$rqPrep->bindValue(":status", "en_attente", PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":project", $projectId, PDO::PARAM_INT);
|
||||
|
||||
return $rqPrep->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
* @return array
|
||||
*/
|
||||
public function findAllUsers():array{
|
||||
$strRq = "SELECT user_id, user_firstname, user_name, user_image, user_status, authorisation_name
|
||||
$strRq = "SELECT user_id, user_firstname, user_name, user_image, user_status, authorisation_name, user_pseudo
|
||||
FROM users INNER JOIN authorisation ON authorisation.authorisation_id = users.user_status
|
||||
WHERE user_deleted_at IS NULL";
|
||||
return $this->_db->query($strRq)->fetchAll();
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
public function verifUser(string $strMail, string $strPwd):array|bool{
|
||||
|
||||
$strRq = "SELECT user_id, user_name, user_firstname, user_password, user_image, user_status, authorisation_name
|
||||
$strRq = "SELECT user_id, user_name, user_firstname, user_password, user_image, user_status, authorisation_name, user_pseudo
|
||||
FROM users INNER JOIN authorisation ON authorisation.authorisation_id = users.user_status
|
||||
WHERE user_mail = '".$strMail."'";
|
||||
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
*/
|
||||
public function insert(object $objUser):bool{
|
||||
|
||||
$strRq = "INSERT INTO users (user_name, user_firstname, user_pseudo, user_mail, user_password, user_phone, user_work, user_location, user_description)
|
||||
$strRq = "INSERT INTO users (user_name, user_firstname, user_pseudo, user_mail, user_password, user_phone, user_work, user_location, user_description)
|
||||
VALUES (:name, :firstname, :pseudo,:mail, :pwd, :phone, :work, :location,:description)";
|
||||
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
|
|
@ -70,6 +70,37 @@
|
|||
return $rqPrep->execute();
|
||||
}
|
||||
|
||||
public function update(object $objUser):bool{
|
||||
$strRq = "UPDATE users SET
|
||||
user_name = :name,
|
||||
user_firstname = :firstname,
|
||||
user_pseudo = :pseudo,
|
||||
user_mail = :mail,
|
||||
user_phone = :phone,
|
||||
user_work = :work,
|
||||
user_location = :location,
|
||||
user_description = :description,
|
||||
user_image = :image
|
||||
WHERE user_id = :id";
|
||||
|
||||
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
|
||||
$rqPrep->bindValue(":id", $objUser->getId(), PDO::PARAM_INT);
|
||||
$rqPrep->bindValue(":name", $objUser->getName(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":firstname", $objUser->getFirstname(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":pseudo", $objUser->getPseudo(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":mail", $objUser->getMail(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(':phone', $objUser->getPhone() ?? "", PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(':work', $objUser->getWork() ?? "", PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(':location', $objUser->getLocation() ?? "", PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(':description', $objUser->getDescription() ?? "", PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(':image', $objUser->getImage() ?? "", PDO::PARAM_STR);
|
||||
|
||||
return $rqPrep->execute();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction de vérification de mail
|
||||
* @param string $mail
|
||||
|
|
@ -125,7 +156,9 @@
|
|||
*/
|
||||
public function findUserById(int $intId): array|bool {
|
||||
|
||||
$strRq = "SELECT * FROM users WHERE user_id = :id";
|
||||
$strRq = "SELECT user_id,user_status ,user_image ,user_name, user_firstname, user_pseudo, user_mail, user_phone, user_work, user_location, user_description, authorisation_name
|
||||
FROM users INNER JOIN authorisation ON authorisation.authorisation_id = users.user_status
|
||||
WHERE user_id = :id";
|
||||
|
||||
$prep = $this->_db->prepare($strRq);
|
||||
$prep->bindValue(':id', $intId, PDO::PARAM_INT);
|
||||
|
|
@ -133,4 +166,26 @@
|
|||
|
||||
return $prep->fetch();
|
||||
}
|
||||
|
||||
public function findUserByPseudo(string $strPseudo): array|bool {
|
||||
|
||||
$strRq = "SELECT user_id,user_image, user_status ,user_name, user_firstname, user_pseudo, user_mail, user_phone, user_work, user_location, user_description, authorisation_name
|
||||
FROM users INNER JOIN authorisation ON authorisation.authorisation_id = users.user_status
|
||||
WHERE user_pseudo = :pseudo";
|
||||
|
||||
$prep = $this->_db->prepare($strRq);
|
||||
$prep->bindValue(':pseudo', $strPseudo, PDO::PARAM_STR);
|
||||
$prep->execute();
|
||||
|
||||
return $prep->fetch();
|
||||
}
|
||||
|
||||
public function pseudoExists(string $pseudo): bool{
|
||||
|
||||
$rq = $this->_db->prepare("SELECT 1 FROM users WHERE user_pseudo = :pseudo LIMIT 1");
|
||||
$rq->bindValue(":pseudo", $pseudo, PDO::PARAM_STR);
|
||||
$rq->execute();
|
||||
|
||||
return $rq->fetchColumn();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue