diff --git a/controllers/project_controller.php b/controllers/project_controller.php index e5eecb1..7395647 100644 --- a/controllers/project_controller.php +++ b/controllers/project_controller.php @@ -181,7 +181,7 @@ $objProject->hydrate($arrProject); $this->_arrData["objProject"] = $objProject; - $this->_display("projet_display"); + $this->_display("project_display"); } else { header("Location: index.php?ctrl=project&action=home"); exit; diff --git a/controllers/user_controller.php b/controllers/user_controller.php index b6938e1..be15ddc 100644 --- a/controllers/user_controller.php +++ b/controllers/user_controller.php @@ -3,6 +3,8 @@ require("models/user_model.php"); require("entities/user_entity.php"); require("mother_controller.php"); + require("./models/project_model.php"); + require("./entities/project_entity.php"); class UserCtrl extends MotherCtrl { @@ -147,4 +149,43 @@ class UserCtrl extends MotherCtrl { // Affichage de la vue inscription $this->_display("inscription"); } + + /** + * le controlleur affichage de la page user + */ + public function user(){ + + $intId = isset($_GET['id']) ? (int)$_GET['id'] : 0; + + if ($intId <= 0) { + header("Location: index.php"); + exit; + } + + //affichage info utilisateur + $objUserModel = new UserModel; + $arrUserData = $objUserModel->findUserById($intId); + + if ($arrUserData === false) { + header("Location: index.php"); + exit; + } + $objUser = new User; + $objUser->hydrate($arrUserData); + + //affichage projet de l'utilisateur + $objProjectModel = new ProjectModel; + $arrProjects = $objProjectModel->findAll(0,'',$intId); + + $arrProjectToDisplay = array(); + foreach($arrProjects as $projectData) { + $objProject = new Project(); + $objProject->hydrate($projectData); + $arrProjectToDisplay[] = $objProject; + } + + $this->_arrData['user'] = $objUser; + $this->_arrData['arrProjectToDisplay'] = $arrProjectToDisplay; + $this->_display("user"); + } } diff --git a/models/project_model.php b/models/project_model.php index 058788a..d6bce18 100644 --- a/models/project_model.php +++ b/models/project_model.php @@ -104,9 +104,9 @@ /** * Fonction de recherche d'un seul projet * @param int $intId - * @return + * @return array */ - public function findOne(int $intId) { + public function findOne(int $intId) :array{ $strRq = "SELECT project.*, CONCAT(users.user_firstname, ' ', users.user_name) AS 'project_creatorname', users.user_image, @@ -150,4 +150,26 @@ return $this->_db->query($strRq); } + + /** + * Fonction de mise à jour d'un projet en BDD + * @param object $objProject L'objet utilisateur + * @return bool Est-ce que la requête s'est bien passée + */ + public function updateProject(object $objProject):bool{ + + $strRq = "UPDATE project + SET project_title = :title, project_description = :description, project_content = :content + WHERE project_id = :id"; + + $rqPrep = $this->_db->prepare($strRq); + + $rqPrep->bindValue(":title", $objProject->getTitle(), PDO::PARAM_STR); + $rqPrep->bindValue(":description", $objProject->getDescription(), PDO::PARAM_STR); + $rqPrep->bindValue(":content", $objProject->getContent(), PDO::PARAM_STR); + + + // Executer la requête + return $rqPrep->execute(); + } } \ No newline at end of file diff --git a/models/user_model.php b/models/user_model.php index d20b743..baa46dd 100644 --- a/models/user_model.php +++ b/models/user_model.php @@ -116,5 +116,21 @@ $rqPrep = $this->_db->prepare($strRq); $rqPrep->bindValue(":id", $intId, PDO::PARAM_INT); return $rqPrep->execute(); - } + } + + /** + * Récupère les informations d'un utilisateur par son ID + * @param int $intId L'identifiant de l'utilisateur + * @return array Tableau associatif (ou false si pas trouvé) + */ + public function findUserById(int $intId): array|bool { + + $strRq = "SELECT * FROM users WHERE user_id = :id"; + + $prep = $this->_db->prepare($strRq); + $prep->bindValue(':id', $intId, PDO::PARAM_INT); + $prep->execute(); + + return $prep->fetch(); + } } diff --git a/templates_c/32d027bc6f198a0e3016434b0dddc13d6ee22b4c_0.file_user.tpl.php b/templates_c/32d027bc6f198a0e3016434b0dddc13d6ee22b4c_0.file_user.tpl.php new file mode 100644 index 0000000..d919b98 --- /dev/null +++ b/templates_c/32d027bc6f198a0e3016434b0dddc13d6ee22b4c_0.file_user.tpl.php @@ -0,0 +1,99 @@ +getCompiled()->isFresh($_smarty_tpl, array ( + 'version' => '5.7.0', + 'unifunc' => 'content_698b36e931d9d8_07796633', + 'has_nocache_code' => false, + 'file_dependency' => + array ( + '32d027bc6f198a0e3016434b0dddc13d6ee22b4c' => + array ( + 0 => 'views/user.tpl', + 1 => 1770729421, + 2 => 'file', + ), + ), + 'includes' => + array ( + 'file:views/_partial/preview.tpl' => 1, + ), +))) { +function content_698b36e931d9d8_07796633 (\Smarty\Template $_smarty_tpl) { +$_smarty_current_dir = 'C:\\wamp64\\www\\DWWM_2025\\projet2\\views'; +$_smarty_tpl->getInheritance()->init($_smarty_tpl, true); +?> + + +getInheritance()->instanceBlock($_smarty_tpl, 'Block_2035018945698b36e930efe0_69529586', "content"); +$_smarty_tpl->getInheritance()->endChild($_smarty_tpl, "views/layout.tpl", $_smarty_current_dir); +} +/* {block "content"} */ +class Block_2035018945698b36e930efe0_69529586 extends \Smarty\Runtime\Block +{ +public function callBlock(\Smarty\Template $_smarty_tpl) { +$_smarty_current_dir = 'C:\\wamp64\\www\\DWWM_2025\\projet2\\views'; +?> + + +
+
+
+ Avatar de <?php echo $_smarty_tpl->getValue('user')->getPseudo();?>
+ +
+
+

getValue('user')->getPseudo();?> +

+

getValue('user')->getMail();?> +

+ + getValue('user')->getWork()) {?> +

getValue('user')->getWork();?> +

+ + + getValue('user')->getLocation()) {?> +

getValue('user')->getLocation();?> +

+ + +

getValue('user')->getDescription();?> +

+
+
+
+ +
+

Les projets de getValue('user')->getPseudo();?> +

+ +
+ getSmarty()->getModifierCallback('count')($_smarty_tpl->getValue('arrProjectToDisplay')) > 0) {?> + getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('arrProjectToDisplay'), 'objProject'); +$foreach0DoElse = true; +foreach ($_from ?? [] as $_smarty_tpl->getVariable('objProject')->value) { +$foreach0DoElse = false; +?> +
+ renderSubTemplate("file:views/_partial/preview.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), (int) 0, $_smarty_current_dir); +?> +
+ getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?> + +

Cet utilisateur n'a pas encore publié de projets.

+ +
+
+ +getCompiled()->isFresh($_smarty_tpl, array ( 'version' => '5.7.0', - 'unifunc' => 'content_698ae9a3ee5104_18468093', + 'unifunc' => 'content_698b26e1f18ff9_58457550', 'has_nocache_code' => false, 'file_dependency' => array ( @@ -21,18 +21,18 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array ( 'file:../app/views/partials/preview.tpl' => 1, ), ))) { -function content_698ae9a3ee5104_18468093 (\Smarty\Template $_smarty_tpl) { +function content_698b26e1f18ff9_58457550 (\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'C:\\wamp64\\www\\DWWM_2025\\projet2\\views'; $_smarty_tpl->getInheritance()->init($_smarty_tpl, true); ?> getInheritance()->instanceBlock($_smarty_tpl, 'Block_2126029828698ae9a3edc808_29541958', "content"); +$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_1455455414698b26e1f12061_00705481', "content"); $_smarty_tpl->getInheritance()->endChild($_smarty_tpl, "views/layout.tpl", $_smarty_current_dir); } /* {block "content"} */ -class Block_2126029828698ae9a3edc808_29541958 extends \Smarty\Runtime\Block +class Block_1455455414698b26e1f12061_00705481 extends \Smarty\Runtime\Block { public function callBlock(\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'C:\\wamp64\\www\\DWWM_2025\\projet2\\views'; diff --git a/templates_c/947d9aa54bf412a952e2af2d8a8255035d91b950_0.file_layout.tpl.php b/templates_c/947d9aa54bf412a952e2af2d8a8255035d91b950_0.file_layout.tpl.php index 781b34d..f131330 100644 --- a/templates_c/947d9aa54bf412a952e2af2d8a8255035d91b950_0.file_layout.tpl.php +++ b/templates_c/947d9aa54bf412a952e2af2d8a8255035d91b950_0.file_layout.tpl.php @@ -1,11 +1,11 @@ getCompiled()->isFresh($_smarty_tpl, array ( 'version' => '5.7.0', - 'unifunc' => 'content_698aed2fd402f7_78850375', + 'unifunc' => 'content_698b36e945e8a9_68963664', 'has_nocache_code' => false, 'file_dependency' => array ( @@ -22,21 +22,21 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array ( 'file:views/_partial/footer.tpl' => 1, ), ))) { -function content_698aed2fd402f7_78850375 (\Smarty\Template $_smarty_tpl) { +function content_698b36e945e8a9_68963664 (\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'C:\\wamp64\\www\\DWWM_2025\\projet2\\views'; $_smarty_tpl->getInheritance()->init($_smarty_tpl, false); $_smarty_tpl->renderSubTemplate("file:views/_partial/header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), (int) 0, $_smarty_current_dir); ?> getInheritance()->instanceBlock($_smarty_tpl, 'Block_691069574698aed2fd3d8f8_28027733', "content"); +$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_1250254212698b36e945d469_86185066', "content"); ?> renderSubTemplate("file:views/_partial/footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), (int) 0, $_smarty_current_dir); } /* {block "content"} */ -class Block_691069574698aed2fd3d8f8_28027733 extends \Smarty\Runtime\Block +class Block_1250254212698b36e945d469_86185066 extends \Smarty\Runtime\Block { public function callBlock(\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'C:\\wamp64\\www\\DWWM_2025\\projet2\\views'; diff --git a/templates_c/ac77f39f91cdf26a0eb3f0963ead4008a7bda8fb_0.file_admin.tpl.php b/templates_c/ac77f39f91cdf26a0eb3f0963ead4008a7bda8fb_0.file_admin.tpl.php index d4498ba..80215d3 100644 --- a/templates_c/ac77f39f91cdf26a0eb3f0963ead4008a7bda8fb_0.file_admin.tpl.php +++ b/templates_c/ac77f39f91cdf26a0eb3f0963ead4008a7bda8fb_0.file_admin.tpl.php @@ -1,18 +1,18 @@ getCompiled()->isFresh($_smarty_tpl, array ( 'version' => '5.7.0', - 'unifunc' => 'content_698aed2fac7079_66630300', + 'unifunc' => 'content_698b2a791a5267_98917235', 'has_nocache_code' => false, 'file_dependency' => array ( 'ac77f39f91cdf26a0eb3f0963ead4008a7bda8fb' => array ( 0 => 'views/admin.tpl', - 1 => 1770712365, + 1 => 1770728055, 2 => 'file', ), ), @@ -20,213 +20,138 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array ( array ( ), ))) { -function content_698aed2fac7079_66630300 (\Smarty\Template $_smarty_tpl) { +function content_698b2a791a5267_98917235 (\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'C:\\wamp64\\www\\DWWM_2025\\projet2\\views'; $_smarty_tpl->getInheritance()->init($_smarty_tpl, true); ?> getInheritance()->instanceBlock($_smarty_tpl, 'Block_701047722698aed2faa98f9_91663021', "content"); +$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_510378351698b2a7919aa53_66812766', "content"); $_smarty_tpl->getInheritance()->endChild($_smarty_tpl, "views/layout.tpl", $_smarty_current_dir); } /* {block "content"} */ -class Block_701047722698aed2faa98f9_91663021 extends \Smarty\Runtime\Block +class Block_510378351698b2a7919aa53_66812766 extends \Smarty\Runtime\Block { public function callBlock(\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'C:\\wamp64\\www\\DWWM_2025\\projet2\\views'; ?> -
- - - -
-
- -
- -
-
-
-

Dashboard

-
- -
-
-

Gestion de l'utilsateur

-

Changer le statut ou supprimer un utilisateur

-
-
- -
-
-
- + + getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('arrUserToDisplay'), 'user'); $foreach0DoElse = true; foreach ($_from ?? [] as $_smarty_tpl->getVariable('user')->value) { $foreach0DoElse = false; ?> - - getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?> - - + + getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('arrAuthorisationToDisplay'), 'arrDetAuthorisation'); $foreach1DoElse = true; foreach ($_from ?? [] as $_smarty_tpl->getVariable('arrDetAuthorisation')->value) { $foreach1DoElse = false; ?> - - getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?> - -
-
- - -
-
-
+
-
- -
-
-

Gestion des catégories

-
-
-
-

Modifier une catégorie existante

- + + getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('arrCategoryToDisplay'), 'category'); $foreach2DoElse = true; foreach ($_from ?? [] as $_smarty_tpl->getVariable('category')->value) { $foreach2DoElse = false; ?> - - getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?> - -
-
- - -
- -
-
-
+
-
-
- -
-
-

Créer une nouvelle catégorie

-
- - -
-
- -
-
-
+
+ +
-
- + + +
+
+
+
+
+ +
+
+

Créer une nouvelle catégorie

+
+ + +
+
+ +
+
+
-
+
-
+ + +
Connecté avec le compte : + + + getCompiled()->isFresh($_smarty_tpl, array ( 'version' => '5.7.0', - 'unifunc' => 'content_698aed2fea7fd1_77495932', + 'unifunc' => 'content_698b36e981e641_42574835', 'has_nocache_code' => false, 'file_dependency' => array ( @@ -20,7 +20,7 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array ( array ( ), ))) { -function content_698aed2fea7fd1_77495932 (\Smarty\Template $_smarty_tpl) { +function content_698b36e981e641_42574835 (\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'C:\\wamp64\\www\\DWWM_2025\\projet2\\views\\_partial'; ?>
+ getValue('objProject')->getStatus() == "en_attente") {?> +
+ Accepter + Refuser + Supprimer +
+ getValue('projectStatus') == "refusé") {?> +

Portfolio refusé

+ getCompiled()->isFresh($_smarty_tpl, array ( 'version' => '5.7.0', - 'unifunc' => 'content_698ada80e47fc8_23614044', + 'unifunc' => 'content_698b32a2af19c0_80830560', 'has_nocache_code' => false, 'file_dependency' => array ( @@ -21,18 +21,18 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array ( 'file:views/_partial/preview.tpl' => 1, ), ))) { -function content_698ada80e47fc8_23614044 (\Smarty\Template $_smarty_tpl) { +function content_698b32a2af19c0_80830560 (\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'C:\\wamp64\\www\\DWWM_2025\\projet2\\views'; $_smarty_tpl->getInheritance()->init($_smarty_tpl, true); ?> getInheritance()->instanceBlock($_smarty_tpl, 'Block_1614324265698ada80a61e02_00521357', "content"); +$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_1683455369698b32a2adef91_98812453', "content"); $_smarty_tpl->getInheritance()->endChild($_smarty_tpl, "views/layout.tpl", $_smarty_current_dir); } /* {block "content"} */ -class Block_1614324265698ada80a61e02_00521357 extends \Smarty\Runtime\Block +class Block_1683455369698b32a2adef91_98812453 extends \Smarty\Runtime\Block { public function callBlock(\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'C:\\wamp64\\www\\DWWM_2025\\projet2\\views'; diff --git a/views/_partial/preview.tpl b/views/_partial/preview.tpl index 3ed2470..e247ef4 100644 --- a/views/_partial/preview.tpl +++ b/views/_partial/preview.tpl @@ -26,13 +26,24 @@ - – {$objProject->getCreatorname()} + – + + {$objProject->getCreatorname()} + - Lire la suite → + class="stretched-link small"> + Lire la suite → + {if $smarty.session.user.user_id == $objProject->getUser()} + + Editer + + {/if} diff --git a/views/admin.tpl b/views/admin.tpl index af91005..7b0fefe 100644 --- a/views/admin.tpl +++ b/views/admin.tpl @@ -2,164 +2,89 @@ {block name="content"} -
- - - -
-
-
- -
-
-
-

Dashboard

-
- -
-
-

Gestion de l'utilsateur

-

Changer le statut ou supprimer un utilisateur

-
+ +
+
+

Gestion des catégories

+
+
+
+

Modifier une catégorie existante

+ +
+
+ + +
+ +
+
+
+
+
+
+ +
+
+

Créer une nouvelle catégorie

+
+ + +
- +
- -
- - -
-
- - -
-
-
+
- -
-
-

Gestion des catégories

-
-
-
-

Modifier une catégorie existante

- -
-
- - -
- -
-
-
-
-
-
- -
-
-

Créer une nouvelle catégorie

-
- - -
-
- -
-
-
-
-
- -
-
+
-
+ + +
Connecté avec le compte : {$smarty.session.user.user_name} {$smarty.session.user.user_firstname} + {/block} \ No newline at end of file diff --git a/views/projet_display.tpl b/views/project_display.tpl similarity index 87% rename from views/projet_display.tpl rename to views/project_display.tpl index 21301dc..181802c 100644 --- a/views/projet_display.tpl +++ b/views/project_display.tpl @@ -58,11 +58,11 @@
- - - + + +
{$objProject->getCreatorName()}

diff --git a/views/user.tpl b/views/user.tpl new file mode 100644 index 0000000..f295280 --- /dev/null +++ b/views/user.tpl @@ -0,0 +1,43 @@ +{extends file="views/layout.tpl"} + +{block name="content"} + +

+ +
+

Les projets de {$user->getPseudo()}

+ +
+ {if count($arrProjectToDisplay) > 0} + {foreach $arrProjectToDisplay as $objProject} +
+ {include file="views/_partial/preview.tpl"} +
+ {/foreach} + {else} +

Cet utilisateur n'a pas encore publié de projets.

+ {/if} +
+
+ +{/block} \ No newline at end of file