diff --git a/Controllers/RecipeController.php b/Controllers/RecipeController.php index 57e62f9..ede024f 100644 --- a/Controllers/RecipeController.php +++ b/Controllers/RecipeController.php @@ -35,16 +35,25 @@ final class RecipeController } $O_recipeModel = new RecipeModel(); - $A_returnArray = $O_recipeModel->getFullRecipe($A_urlParams[0]); - if ($A_returnArray === null) { + $A_recipe = $O_recipeModel->getFullRecipe($A_urlParams[0]); + if ($A_recipe === null) { throw new HTTPSpecialCaseException(404); } - if ($A_returnArray["AUTHOR_ID"] !== $_SESSION["ID"]) { - throw new HTTPSpecialCaseException(400, "You are not the owner of this recipe"); + if ($A_recipe["AUTHOR_ID"] !== $_SESSION["ID"]) { + if(!Session::is_admin()){ + throw new HTTPSpecialCaseException(400, "You are not the owner of this recipe"); + } } - View::show("recipe/edit", $A_returnArray); + View::show("recipe/edit", array("POST_URI" => "/recipe/update", "RECIPE" => $A_recipe)); + } + + public function newAction(Array $A_urlParams = null, Array $A_postParams = null) + { + Session::login_or_die(); + + View::show("recipe/edit", array("POST_URI" => "/recipe/create", "RECIPE" => array())); } public function searchAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null) diff --git a/Views/common/header.php b/Views/common/header.php index 2bee9e0..5d2967a 100644 --- a/Views/common/header.php +++ b/Views/common/header.php @@ -2,7 +2,7 @@ $array_header = array( 'Logo' => "/", "Recette" => "/Recipe/view/36", - "+" => "/recipe/edit", + "+" => "/recipe/new", "Rechercher" => "rechercher", '' => "/user/view" ); diff --git a/Views/recipe/edit.php b/Views/recipe/edit.php index 3182faf..452122c 100644 --- a/Views/recipe/edit.php +++ b/Views/recipe/edit.php @@ -1,9 +1,11 @@ -
+ " method="post"> - " required> + " required>

- +

Informations alimentaires

Type de plat : - > + > - > + > - > + >
- " required> + " required>
@@ -60,7 +62,7 @@ function getOrEmpty($A_Dict, $S_keyName) {