public function getRatingForDefaultPlatform() { $platforms = $this->getValidPlatforms(); if (sizeof($platforms) == 0) { return "n"; } $chosen_platform = $platforms[0]; foreach ($platforms as $platform) { if ($platform->getName() == "windows") { $chosen_platform = $platform; } } $query = new RatingHeadersQuery(); $query->filterByGames($this); $result = $query->findOneByGamePlatformId($chosen_platform->getId()); return Ratings::getRatingForScore($result->getScore()); }
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(); if ($header == null) { $header = new RatingHeaders(); $header->setGameId($game->getId()); $header->setCreated(new DateTime()); $header->setPlatforms($platform); } else { RatingCategoryValuesQuery::create()->filterByRatingHeaders($header)->deleteAll($con);