From b11f67793a2b02bba4e65f801ce1360591d66125 Mon Sep 17 00:00:00 2001 From: Yasder5 <102179445+Yasder5@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:10:24 +0100 Subject: [PATCH] modification pour afficher user par pseudo et non par id --- controllers/user_controller.php | 15 +++++++++++++-- models/project_model.php | 2 +- models/user_model.php | 11 +++++++++++ ...d01d94486bfa02ee91c2c5fe68_0.file_home.tpl.php | 10 +++++----- ...220f82584009ce981aa35e0b_0.file_layout.tpl.php | 10 +++++----- ...c5fa56e3cf6837f9df55d7fb_0.file_footer.tpl.php | 6 +++--- ...f8782993687bad91a1cf0f6_0.file_preview.tpl.php | 10 +++++----- ...5e36947735d13c8d176ec944_0.file_header.tpl.php | 6 +++--- views/_partial/preview.tpl | 2 +- 9 files changed, 47 insertions(+), 25 deletions(-) diff --git a/controllers/user_controller.php b/controllers/user_controller.php index 8e185a6..ee19f09 100644 --- a/controllers/user_controller.php +++ b/controllers/user_controller.php @@ -151,7 +151,7 @@ class UserCtrl extends MotherCtrl { */ public function user(){ - $intId = isset($_GET['id']) ? (int)$_GET['id'] : 0; + /**$intId = isset($_GET['id']) ? (int)$_GET['id'] : 0; if ($intId <= 0) { header("Location: index.php"); @@ -162,16 +162,27 @@ class UserCtrl extends MotherCtrl { $objUserModel = new UserModel; $arrUserData = $objUserModel->findUserById($intId); + if ($arrUserData === false) { + header("Location: index.php"); + exit; + }*/ + + $strPseudo = $_GET['pseudo']??''; + + $objUserModel = new UserModel; + $arrUserData = $objUserModel->findUserByPseudo($strPseudo); + 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); + $arrProjects = $objProjectModel->findAll(0,'',$objUser->getId()); $arrProjectToDisplay = array(); foreach($arrProjects as $projectData) { diff --git a/models/project_model.php b/models/project_model.php index 56b88d2..afa8380 100644 --- a/models/project_model.php +++ b/models/project_model.php @@ -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"; diff --git a/models/user_model.php b/models/user_model.php index e229af6..253c2f2 100644 --- a/models/user_model.php +++ b/models/user_model.php @@ -162,4 +162,15 @@ return $prep->fetch(); } + + public function findUserByPseudo(string $strPseudo): array|bool { + + $strRq = "SELECT * FROM users WHERE user_pseudo = :pseudo"; + + $prep = $this->_db->prepare($strRq); + $prep->bindValue(':pseudo', $strPseudo, PDO::PARAM_STR); + $prep->execute(); + + return $prep->fetch(); + } } diff --git a/templates_c/0f54e8b5c9bcafd01d94486bfa02ee91c2c5fe68_0.file_home.tpl.php b/templates_c/0f54e8b5c9bcafd01d94486bfa02ee91c2c5fe68_0.file_home.tpl.php index 72d7240..1ca88db 100644 --- a/templates_c/0f54e8b5c9bcafd01d94486bfa02ee91c2c5fe68_0.file_home.tpl.php +++ b/templates_c/0f54e8b5c9bcafd01d94486bfa02ee91c2c5fe68_0.file_home.tpl.php @@ -1,11 +1,11 @@ getCompiled()->isFresh($_smarty_tpl, array ( 'version' => '5.7.0', - 'unifunc' => 'content_69976682c1c284_75435092', + 'unifunc' => 'content_69976def59c414_70095814', 'has_nocache_code' => false, 'file_dependency' => array ( @@ -21,20 +21,20 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array ( 'file:views/_partial/preview.tpl' => 1, ), ))) { -function content_69976682c1c284_75435092 (\Smarty\Template $_smarty_tpl) { +function content_69976def59c414_70095814 (\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'D:\\projetphp\\views'; $_smarty_tpl->getInheritance()->init($_smarty_tpl, true); ?> getInheritance()->instanceBlock($_smarty_tpl, 'Block_144579886869976682c18113_46108017', "content"); +$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_133394531269976def598252_85195320', "content"); ?> getInheritance()->endChild($_smarty_tpl, "views/layout.tpl", $_smarty_current_dir); } /* {block "content"} */ -class Block_144579886869976682c18113_46108017 extends \Smarty\Runtime\Block +class Block_133394531269976def598252_85195320 extends \Smarty\Runtime\Block { public function callBlock(\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'D:\\projetphp\\views'; diff --git a/templates_c/1c51ad9f5c349145220f82584009ce981aa35e0b_0.file_layout.tpl.php b/templates_c/1c51ad9f5c349145220f82584009ce981aa35e0b_0.file_layout.tpl.php index 79b8088..b1983b7 100644 --- a/templates_c/1c51ad9f5c349145220f82584009ce981aa35e0b_0.file_layout.tpl.php +++ b/templates_c/1c51ad9f5c349145220f82584009ce981aa35e0b_0.file_layout.tpl.php @@ -1,11 +1,11 @@ getCompiled()->isFresh($_smarty_tpl, array ( 'version' => '5.7.0', - 'unifunc' => 'content_69976689b01014_92688396', + 'unifunc' => 'content_69976e0ca03d67_47539078', '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_69976689b01014_92688396 (\Smarty\Template $_smarty_tpl) { +function content_69976e0ca03d67_47539078 (\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'D:\\projetphp\\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_210858053669976689aff6c2_11310529', "content"); +$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_27929295869976e0ca01fb9_36548139', "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_210858053669976689aff6c2_11310529 extends \Smarty\Runtime\Block +class Block_27929295869976e0ca01fb9_36548139 extends \Smarty\Runtime\Block { public function callBlock(\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'D:\\projetphp\\views'; diff --git a/templates_c/264314e384c04e79c5fa56e3cf6837f9df55d7fb_0.file_footer.tpl.php b/templates_c/264314e384c04e79c5fa56e3cf6837f9df55d7fb_0.file_footer.tpl.php index 27fa401..7a9242a 100644 --- a/templates_c/264314e384c04e79c5fa56e3cf6837f9df55d7fb_0.file_footer.tpl.php +++ b/templates_c/264314e384c04e79c5fa56e3cf6837f9df55d7fb_0.file_footer.tpl.php @@ -1,11 +1,11 @@ getCompiled()->isFresh($_smarty_tpl, array ( 'version' => '5.7.0', - 'unifunc' => 'content_69976689ccd1e8_62225255', + 'unifunc' => 'content_69976e0cbdbc02_44067705', 'has_nocache_code' => false, 'file_dependency' => array ( @@ -20,7 +20,7 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array ( array ( ), ))) { -function content_69976689ccd1e8_62225255 (\Smarty\Template $_smarty_tpl) { +function content_69976e0cbdbc02_44067705 (\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'D:\\projetphp\\views\\_partial'; ?>