<?php

require_once "includes/header.php";
require_once "includes/recipe.php";
require_once "includes/recipeManager.php";
require_once "includes/form.php";
require_once "includes/comments.php";
$aAllTypes = RecipeTypeManager::getAllTypes();
if (isset($_SESSION["UserID"]) == true) {
    $oCustomer = new User();
    $oCustomer->load($_SESSION["UserID"]);
    $oCustomer->userID;
}
$iRecipeID = 5;
if (isset($_GET["RecipeID"])) {
    $iRecipeID = $_GET["RecipeID"];
}
$oRecipe = new Recipe();
$oRecipe->load($iRecipeID);
// construct comment box
$oCommentForm = new Form();
if (isset($_POST["comment"])) {
    if (isset($_SESSION["UserID"]) == false) {
        header("Location:recipePage.php?message=signIn&RecipeID=" . $iRecipeID);
        exit;
        // terminates request
    }
    $oCommentForm->data = $_POST;
    $oComment = new Comment();
    $oComment->comment = $_POST["commentBox"];
    $oComment->userID = $oCustomer->userID;