merge laura->main

This commit is contained in:
Yasder5 2026-02-24 13:57:21 +01:00
commit 9f69345f42
4 changed files with 69 additions and 49 deletions

4
env
View file

@ -5,3 +5,7 @@ DB_HOSTNAME=boulayoune.com
DB_DATABASE=projet_folliow DB_DATABASE=projet_folliow
DB_USERNAME= DB_USERNAME=
DB_PASSWORD= DB_PASSWORD=
# image path
IMG_PROJECT_PATH = uploads/projects/
IMG_USER_PATH = uploads/profiles/

View file

@ -23,14 +23,14 @@
} }
/** /**
Pour passer sur le serveur de YASS: *Pour passer sur le serveur de YASS:
*"mysql:host=boulayoune.com;dbname=projet_folliow", // Serveur et BDD *"mysql:host=boulayoune.com;dbname=projet_folliow", // Serveur et BDD
"projet_user", //Nom d'utilisateur de la base de données *"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 *Site pour BDD: https://phpmyadmin.boulayoune.com/index.php?route=/sql&pos=0&db=projet_folliow&table=project
Pour passer en local: *Pour passer en local:
"mysql:host=localhost;dbname=projet_folliow", // Serveur et BDD *"mysql:host=localhost;dbname=projet_folliow", // Serveur et BDD
"root", //Nom d'utilisateur de la base de données *"root", //Nom d'utilisateur de la base de données
"",// Mot de passe de la base de données *"",// Mot de passe de la base de données
*/ */

View file

@ -16,60 +16,45 @@
* @return array * @return array
*/ */
public function findAll(int $intLimit=0, string $strKeywords='', int $intAuthor=0, public function findAll(int $intLimit=0, string $strKeywords='', int $intAuthor=0,
int $intPeriod=0, string $strDate='', string $strStartDate='', int $intPeriod=0, string $strDate='', string $strStartDate='',
string $strEndDate='', int $intCategory=0, bool $bool6Months=false):array{ string $strEndDate='', int $intCategory=0, bool $boolOlderThan6Months=false): array {
$strRq = "SELECT project.*, $strRq = "SELECT project.*,
user_pseudo AS 'project_creatorname', user_pseudo AS 'project_creatorname',
user_image user_image
FROM project FROM project
INNER JOIN users ON user_id = project_user_id"; INNER JOIN users ON user_id = project_user_id
WHERE 1=1";
$strWhere = " WHERE ";
// Recherche par mot clé avec quote pour éviter bug du '
if ($strKeywords != '') { if ($strKeywords != '') {
$strRq .= " AND (project_title LIKE :keywords OR project_content LIKE :keywords)";
$strSafeKeywords = $this->_db->quote("%" . $strKeywords . "%");
$strRq .= " WHERE (project_title LIKE ".$strSafeKeywords."
OR project_content LIKE ".$strSafeKeywords.") ";
//$boolWhere = true;
$strWhere = " AND ";
} }
// Recherche par auteur
if ($intAuthor > 0){ if ($intAuthor > 0){
$strRq .= $strWhere." user_id = ".$intAuthor; $strRq .= " AND project_user_id = :author";
$strWhere = " AND ";
} }
// Recherche par catégorie
if ($intCategory > 0){ if ($intCategory > 0){
$strRq .= $strWhere." project_category = ".$intCategory; $strRq .= " AND project_category = :category";
$strWhere = " AND ";
} }
//recherche par ancienneté if ($boolOlderThan6Months === true) {
if ($bool6Months === true) { $strRq .= " AND project_creation_date <= DATE_SUB(NOW(), INTERVAL 6 MONTH)";
$strRq .= $strWhere . " project_creation_date <= DATE_SUB(NOW(), INTERVAL 6 MONTH) ";
$strWhere = " AND ";
} }
// Recherche par dates
if ($intPeriod == 0){ if ($intPeriod == 0){
if ($strDate != ''){ if ($strDate != ''){
$strRq .= $strWhere." project_creation_date = '".$strDate."'"; $strRq .= " AND project_creation_date = :date_exacte";
} }
}else{ } else {
if ($strStartDate != '' && $strEndDate != ''){ if ($strStartDate != '' && $strEndDate != ''){
$strRq .= $strWhere." project_creation_date BETWEEN '".$strStartDate."' AND '".$strEndDate."'"; $strRq .= " AND project_creation_date BETWEEN :date_debut AND :date_fin";
}else{ } else {
if ($strStartDate != ''){ if ($strStartDate != ''){
$strRq .= $strWhere." project_creation_date >= '".$strStartDate."'"; $strRq .= " AND project_creation_date >= :date_debut";
}else if ($strEndDate != ''){ } else if ($strEndDate != ''){
$strRq .= $strWhere." project_creation_date <= '".$strEndDate."'"; $strRq .= " AND project_creation_date <= :date_fin";
} }
} }
} }
@ -77,12 +62,45 @@
$strRq .= " ORDER BY project_creation_date DESC"; $strRq .= " ORDER BY project_creation_date DESC";
if ($intLimit > 0){ if ($intLimit > 0){
$strRq .= " LIMIT ".$intLimit; $strRq .= " LIMIT :limit";
} }
return $this->_db->query($strRq)->fetchAll(); $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();
} }
/** /**
* Fonction d'insertion d'un nouveau projet dans la bdd * Fonction d'insertion d'un nouveau projet dans la bdd
* @param object $objProject l'objet projet * @param object $objProject l'objet projet
@ -136,12 +154,10 @@
*/ */
public function accept(int $id){ public function accept(int $id){
//SQL pour changer le status en accept
$strRq = "UPDATE project $strRq = "UPDATE project
SET project_status= 'publié' SET project_status= 'publié'
WHERE project_id =".$id; WHERE project_id =".$id;
//retourne la commande
return $this->_db->query($strRq); return $this->_db->query($strRq);
} }

View file

@ -72,7 +72,7 @@
name="toRefused">Refuser</a> name="toRefused">Refuser</a>
<a class="btn btn-sm btn-danger flex-fill" <a class="btn btn-sm btn-danger flex-fill"
href="?ctrl=project&action=delete&id={$objProject->getId()}" href="?ctrl=project&action=delete&id={$objProject->getId()}"
name="toDelete">Supprimer</a> name="toDelete" onclick="return confirm('Attention ! Êtes-vous sûr de vouloir supprimer ce projet ? Cette action est irréversible.');">Supprimer</a>
</div> </div>
</div> </div>
{elseif $objProject->getStatus() == "refusé"} {elseif $objProject->getStatus() == "refusé"}