Merge branch 'main' of https://github.com/Yasder5/projet_php
This commit is contained in:
commit
03f2e90bdf
3 changed files with 41 additions and 37 deletions
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
use Smarty\Smarty;
|
use Smarty\Smarty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Le controller de la partie accessible uniquement par l'admin
|
||||||
|
* @author Yasser
|
||||||
|
*/
|
||||||
|
|
||||||
class MotherCtrl {
|
class MotherCtrl {
|
||||||
|
|
||||||
|
|
@ -11,25 +15,19 @@
|
||||||
* Méthode d'affichage des pages
|
* Méthode d'affichage des pages
|
||||||
*/
|
*/
|
||||||
protected function _display($strView, bool $boolDisplay = true){
|
protected function _display($strView, bool $boolDisplay = true){
|
||||||
// Création de l'objet Smarty
|
|
||||||
$objSmarty = new Smarty();
|
$objSmarty = new Smarty();
|
||||||
// Ajouter le var_dump au modificateur de smarty : vardump est le nom appelé après le |
|
|
||||||
$objSmarty->registerPlugin('modifier', 'vardump', 'var_dump');
|
$objSmarty->registerPlugin('modifier', 'vardump', 'var_dump');
|
||||||
// Désactiver la mise en cache
|
|
||||||
$objSmarty->caching = false;
|
$objSmarty->caching = false;
|
||||||
|
|
||||||
// Forcer la recompilation des templates
|
|
||||||
$objSmarty->force_compile = true;
|
$objSmarty->force_compile = true;
|
||||||
|
|
||||||
// Vérifier si les templates ont été modifiés
|
|
||||||
$objSmarty->compile_check = true;
|
$objSmarty->compile_check = true;
|
||||||
|
|
||||||
// Récupérer les variables
|
|
||||||
foreach($this->_arrData as $key=>$value){
|
foreach($this->_arrData as $key=>$value){
|
||||||
//$$key = $value;
|
|
||||||
$objSmarty->assign($key, $value);
|
$objSmarty->assign($key, $value);
|
||||||
}
|
}
|
||||||
// Message de succès
|
|
||||||
$objSmarty->assign("success_message", $_SESSION['success']??'');
|
$objSmarty->assign("success_message", $_SESSION['success']??'');
|
||||||
unset($_SESSION['success']);
|
unset($_SESSION['success']);
|
||||||
|
|
||||||
|
|
@ -43,14 +41,6 @@
|
||||||
}else{
|
}else{
|
||||||
return $objSmarty->fetch("views/".$strView.".tpl");
|
return $objSmarty->fetch("views/".$strView.".tpl");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// inclusion du header
|
|
||||||
/*include("views/_partial/header.php");
|
|
||||||
include("views/".$strView.".php");
|
|
||||||
include("views/_partial/footer.php");*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Le controler des Project
|
* Le controler des Project
|
||||||
* @author Yasser & Laura
|
* @author Yasser, Laura, Besnik & Guillaume
|
||||||
*/
|
*/
|
||||||
class ProjectCtrl extends MotherCtrl{
|
class ProjectCtrl extends MotherCtrl{
|
||||||
|
|
||||||
|
|
@ -114,10 +114,9 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction d'affichage de la page projet
|
* Fonction d'affichage de la page projet
|
||||||
* @author Christel adapter par Guillaume
|
|
||||||
*/
|
*/
|
||||||
public function addedit_project(){
|
public function addedit_project() {
|
||||||
if (!isset($_SESSION['user'])){ // Pas d'utilisateur connecté
|
if (!isset($_SESSION['user'])){
|
||||||
header("Location:index.php?ctrl=error&action=error_403");
|
header("Location:index.php?ctrl=error&action=error_403");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
@ -126,18 +125,20 @@
|
||||||
$objProjectModel = new ProjectModel;
|
$objProjectModel = new ProjectModel;
|
||||||
$objCategoryModel = new CategoryModel;
|
$objCategoryModel = new CategoryModel;
|
||||||
|
|
||||||
// Dans la cas de modif
|
|
||||||
if (isset($_GET['id'])){
|
if (isset($_GET['id'])){
|
||||||
$arrProject = $objProjectModel->findOne($_GET['id']);
|
$arrProject = $objProjectModel->findOne($_GET['id']);
|
||||||
|
if($_SESSION['user']['user_id'] != $arrProject['project_user_id']){
|
||||||
|
header("Location:index.php?ctrl=error&action=error_403");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
$objProject->hydrate($arrProject); // BDD
|
$objProject->hydrate($arrProject); // BDD
|
||||||
$this->_arrData['arrImages'] = $objProjectModel->getImagesByProjectId($objProject->getId());
|
$this->_arrData['arrImages'] = $objProjectModel->getImagesByProjectId($objProject->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tester le formulaire
|
|
||||||
$arrError = [];
|
$arrError = [];
|
||||||
if (count($_POST) > 0) {
|
if (count($_POST) > 0) {
|
||||||
|
|
||||||
$objProject->hydrate($_POST); // Formulaire
|
$objProject->hydrate($_POST);
|
||||||
if ($objProject->getTitle() == ""){
|
if ($objProject->getTitle() == ""){
|
||||||
$arrError['title'] = "Le titre est obligatoire";
|
$arrError['title'] = "Le titre est obligatoire";
|
||||||
}
|
}
|
||||||
|
|
@ -363,10 +364,11 @@
|
||||||
|
|
||||||
$this->_display('addedit_project');
|
$this->_display('addedit_project');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction d'affichage de projet
|
* Fonction d'affichage d'un projet
|
||||||
*/
|
*/
|
||||||
public function display() {
|
public function display() {
|
||||||
$intId = $_GET['id'] ?? null;
|
$intId = $_GET['id'] ?? null;
|
||||||
|
|
||||||
|
|
@ -397,12 +399,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction de partage de projet
|
* Fonction d'envoi d'email
|
||||||
*/
|
*/
|
||||||
public function shareProject(){
|
public function sendEmail(){
|
||||||
if (count($_POST) > 0)
|
if (count($_POST) > 0) {
|
||||||
{
|
|
||||||
$projectId = (int)($_POST['project_id'] ?? 0);
|
$projectId = (int)($_POST['project_id'] ?? 0);
|
||||||
$toEmail = trim($_POST['to_email'] ?? '');
|
$toEmail = trim($_POST['to_email'] ?? '');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,9 +159,21 @@
|
||||||
<p>Pas de résultats</p>
|
<p>Pas de résultats</p>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{foreach $arrProjectToDisplay as $objProject}
|
{foreach from=$arrProjectToDisplay item=objProject}
|
||||||
{include file="views/_partial/preview.tpl"}
|
|
||||||
{/foreach}
|
{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}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue