Exemple #1
0
 public function getRatingForCategory(RatingCategories $category)
 {
     return RatingCategoryValuesQuery::create()->filterByRatingHeaders($this)->findOneByRatingCategoryId($category->getId());
 }
Exemple #2
0
$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);
        }
        $header->setUpdated(new DateTime());
        $header->setUserId($user->getId());
        $header->save($con);
        $score = 0;
        $query = new RatingCategoriesQuery();
        $categories = $query->find($con);
        foreach ($categories as $category) {
            if (!array_key_exists('category_options_' . $category->getId(), $_POST)) {
                throw new Exception("No value found for category #" . $category->getId());
            }
            $selected = $_POST['category_options_' . $category->getId()];
            $query = new RatingCategoryOptionsQuery();
            $option = $query->findOneById($selected);
            if ($option == null) {