if (!Auth::checkIfAdmin()) { header("Location: /"); /* Redirect browser */ } $user = Auth::getCurrentUser(); $game = null; $platform = null; if (!array_key_exists("game", $_GET) || !array_key_exists("platform", $_GET)) { header("Location: /"); /* Redirect browser */ exit; } else { $query = new GamesQuery(); $game = $query->findOneByName($_GET["game"]); $query = new PlatformsQuery(); $platform = $query->findOneByName($_GET["platform"]); if ($game == null || $platform == null) { header("Location: /"); /* Redirect browser */ exit; } } $header = RatingHeadersQuery::create()->filterByGames($game)->filterByPlatforms($platform)->findOne(); if (array_key_exists("category_options_1", $_POST)) { $con = \Propel\Runtime\Propel::getConnection(); $con->beginTransaction(); try { if (!Auth::checkIfAuthenticated()) { throw new Exception("User not authenticated"); } $user = Auth::getCurrentUser();
} else { $query = new GamesQuery(); $game = $query->findOneByName($_GET["name"]); if ($game == null) { header("Location: /"); /* Redirect browser */ exit; } } if (!array_key_exists("platform", $_GET)) { $platform = "windows"; } else { $platform = $_GET["platform"]; } $query = new PlatformsQuery(); $platform = $query->findOneByName($platform); if ($platform == null) { throw new Exception("Invalid platform specified"); } // Getting the rating queries the database each time, so we do it once here: $header = $game->getRatingHeaderForPlatform($platform); $rating = $game->getRatingForPlatform($platform); $user = Auth::getCurrentUser(); if (Auth::checkIfAuthenticated() && array_key_exists("submit_game_review", $_POST) && array_key_exists("submit_game_rating", $_POST)) { $new_review = $_POST["submit_game_review"]; $new_rating = $_POST["submit_game_rating"]; $review = UserReviews::getUserReview($game, $platform, $user); if ($review == null) { $review = new UserReviews(); $review->setGames($game); $review->setPlatforms($platform);