public function getRatingForDefaultPlatform() { $platforms = $this->getPlatforms(); if (sizeof($platforms) == 0) { return Rating::getRatingForScore(Rating::$NOT_APPLICABLE_SCORE); } $chosen_platform = $platforms[0]; foreach ($platforms as $platform) { if ($platform->getName() == "windows") { $chosen_platform = $platform; } } $query = new RatingHeaderQuery(); $query->filterByGame($this); $result = $query->findOneByPlatformId($chosen_platform->getId()); return Rating::getRatingForScore($result->getScore()); }
$con = \Propel\Runtime\Propel::getConnection(); if (!array_key_exists("game", $_GET) || !array_key_exists("platform", $_GET)) { header("Location: /"); /* Redirect browser */ exit; } else { $con->beginTransaction(); $game = GameQuery::create()->filterByName($_GET["game"])->findOne($con); $platform = PlatformQuery::create()->filterByName($_GET["platform"])->findOne($con); if ($game == null || $platform == null) { header("Location: /"); /* Redirect browser */ exit; } } $header = RatingHeaderQuery::create()->filterByGame($game)->filterByPlatform($platform)->findOne($con); $categories = CategoryQuery::create()->orderBySequence()->find($con); $options = CategoryOptionQuery::create()->orderBySequence()->find($con); if (array_key_exists("rating_submit", $_POST)) { try { if ($header == null) { $header = new RatingHeader(); $header->setGame($game); $header->setPlatform($platform); $header->setCreated(new DateTime()); $header->save($con); } else { RatingValueQuery::create()->filterByRatingHeader($header)->delete($con); } $score = 0; RatingValueQuery::create()->filterByRatingHeader($header)->delete($con);