Esempio n. 1
0
use src\ProjectWhisky\exceptions\CommentNotExistsException;
use src\ProjectWhisky\exceptions\FuckedUpException;
use Doctrine\Common\ClassLoader;
require_once "rolestarter.php";
// gives to user role = 0 on first visit of the website: role = 0 - guest
if (isset($_GET['id']) && is_int((int) $_GET['id']) && !empty($_GET['id'])) {
    /**
     * Connecting doctrine autoloader
     */
    require_once 'Doctrine/Common/ClassLoader.php';
    $classLoader = new ClassLoader("src");
    $classLoader->register();
    require_once "lib/Twig/Autoloader.php";
    Twig_Autoloader::register();
    $whiskyBiz = new WhiskyBusiness();
    $whisky = $whiskyBiz->getWhisky($_GET["id"]);
    $barrelBiz = new BarrelBusiness();
    $barrel = $barrelBiz->showBarrel($_GET["id"]);
    $distilleryBiz = new DistilleryBusiness();
    $distillery = $distilleryBiz->getByWhisky($_GET["id"]);
    $commentBiz = new CommentBusiness();
    $userBiz = new UserBusiness();
    /**
     * Put comments data with user info into an array $participatedUsers
     */
    if (!empty($commentBiz->showComments($_GET["id"]))) {
        foreach ($commentBiz->showComments($_GET["id"]) as $key => $comment) {
            $usersDataFromComments = $userBiz->getUserByComment($comment->getId());
            $participatedUsers[$key]['userId'] = $usersDataFromComments->getId();
            $participatedUsers[$key]['username'] = $usersDataFromComments->getUsername();
            $participatedUsers[$key]['imagePath'] = $usersDataFromComments->getImagePath();
Esempio n. 2
0
use src\ProjectWhisky\exceptions\EmptyDataException;
use src\ProjectWhisky\exceptions\NoImageException;
use src\ProjectWhisky\exceptions\FuckedUpException;
use Doctrine\Common\ClassLoader;
require_once "rolestarter.php";
require_once "adminRights.php";
// Redirects users ir guest from control panel to index.php if is not admin
require_once 'Doctrine/Common/ClassLoader.php';
$classLoader = new ClassLoader("src");
$classLoader->register();
require_once "lib/Twig/Autoloader.php";
Twig_Autoloader::register();
$whisky_id = $_GET["id"];
// Get Whisky Data
$whiskyBiz = new WhiskyBusiness();
$whisky_data = $whiskyBiz->getWhisky($whisky_id);
// Get Distillery Data
$distilleryBiz = new DistilleryBusiness();
$distillery_data = $distilleryBiz->getDistilleryList();
// Get Barrel Data
$barrelBiz = new BarrelBusiness();
$barrel_data = $barrelBiz->showAllBarrels();
/**
 * Initiate $_SESSION['savedData'] and $_SESSION['whiskyMessage']
 */
if (!isset($_SESSION['savedData'])) {
    $_SESSION['savedData'] = array();
    $_SESSION['whiskyMessage'] = array();
}
/**
 * Save new whisky