diff --git a/Controllers/RecipeController.php b/Controllers/RecipeController.php
index 00118e7..9fea79c 100644
--- a/Controllers/RecipeController.php
+++ b/Controllers/RecipeController.php
@@ -15,6 +15,8 @@ final class RecipeController
return View::show("errors/404");
}
+ $A_returnArray["ADMIN"] = Session::is_admin();
+
View::show("recipe/view", $A_returnArray);
// print_r($A_urlParams);
diff --git a/Models/ApprModel.php b/Models/ApprModel.php
index d1bc917..e716e52 100644
--- a/Models/ApprModel.php
+++ b/Models/ApprModel.php
@@ -1,13 +1,34 @@
prepare("SELECT * FROM APPRECIATION WHERE ID = :recipe_id");
- $stmt->bindParam("recipe_id",$I_recipe_id);
+ $stmt = $O_model->prepare("
+ SELECT APPRECIATION.*, USER.USERNAME as AUTHOR_NAME FROM APPRECIATION
+ JOIN USER ON USER.ID = APPRECIATION.AUTHOR_ID
+ WHERE RECIPE_ID = :recipe_id
+ ");
+ $stmt->bindParam("recipe_id", $I_recipe_id);
$stmt->execute();
- return $stmt->fetch();
+
+ $rows = $stmt->fetchAll();
+
+ foreach($rows as &$row) {
+ $row["AUTHOR_IMG_LINK"] = "/static/img/user.jpg";
+ }
+
+ return $rows;
+ }
+
+ public function searchRecipeApprs($I_recipe_id)
+ {
+ $O_model = Model::get();
+ $stmt = $O_model->prepare("SELECT * FROM APPRECIATION WHERE RECIPE_ID = :recipe_id");
+ $stmt->bindParam("recipe_id", $I_recipe_id);
+ $stmt->execute();
+ return $stmt->fetchAll();
}
public function createAppr($I_user_id, $I_recipe_id, $S_Comment, $I_score)
diff --git a/Models/RecipeModel.php b/Models/RecipeModel.php
index 0a2010b..1bc0641 100644
--- a/Models/RecipeModel.php
+++ b/Models/RecipeModel.php
@@ -15,7 +15,7 @@ final class RecipeModel
return $row;
}
- public function getFullRecipeWithApprs($I_id)
+ public function getFullRecipe($I_id)
{
$A_recipe = self::getRecipeByID($I_id);
if ($A_recipe === null)return null;
@@ -34,6 +34,17 @@ final class RecipeModel
return $A_recipe;
}
+ public function getFullRecipeWithApprs($I_id)
+ {
+ $A_recipe = self::getFullRecipe($I_id);
+
+ $O_apprModel = new ApprModel();
+
+ $A_recipe["APPRS"] = $O_apprModel->searchRecipeApprsWithAuthors($I_id);
+
+ return $A_recipe;
+ }
+
public function searchRecipesByName($S_query)
{
diff --git a/Views/appreciations/appreciation.php b/Views/appreciations/appreciation.php
index f0d18b1..04ec6b7 100644
--- a/Views/appreciations/appreciation.php
+++ b/Views/appreciations/appreciation.php
@@ -1,7 +1,7 @@
= $A_view["COMMENT"] ?> = $A_view["NOTE"] ?> " alt="profile picture">
-
= $A_view["NAME"] ?>
+ " alt="profile picture">
+
= $A_view["AUTHOR_NAME"] ?>
By = $A_view["AUTHOR_USERNAME"] ?>
"test", - "PROFILE_IMG" => "/static/img/users/1.jpg", - "COMMENT" => "j'me présente, je m'appelle henry", - "NOTE" => "2", - "DATE" => DATE("2020-07-08") - ), - array( - "NAME" => "test", - "PROFILE_IMG" => "/static/img/users/1.jpg", - "COMMENT" => "j'me présente, je m'appelle henry", - "NOTE" => "2", - "DATE" => DATE("2020-07-08") - ), - array( - "NAME" => "test", - "PROFILE_IMG" => "/static/img/users/1.jpg", - "COMMENT" => "j'me présente, je m'appelle henry", - "NOTE" => "2", - "DATE" => DATE("2020-07-08") - ), - array( - "NAME" => "AAAA", - "PROFILE_IMG" => "/static/img/users/1.jpg", - "COMMENT" => "j'me présente, je m'appelle henry", - "NOTE" => "2", - "DATE" => DATE("2020-07-08") - ), + "APPRS" => $A_view["APPRS"], + "ADMIN" => $A_view["ADMIN"] + ) ); - View::show("appreciations/view", $appreciations)//need to be linked with recipe? ?>