Ejemplo n.º 1
0
 public function getRatingForCategory(Category $category)
 {
     return RatingValueQuery::create()->filterByRatingHeader($this)->findOneByCategoryId($category->getId());
 }
Ejemplo n.º 2
0
$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);
        foreach ($options as $option) {
            if (array_key_exists('option_' . $option->getId(), $_POST)) {
                $selected = $_POST['option_' . $option->getId()];
                if ($selected == "na") {
                    continue;
                }
                $value = new RatingValue();
                $value->setRatingHeader($header);
                $value->setCategoryOption($option);
                $value->setOriginalValue($option->getValue());
                if ($selected == "adns") {
                    $value->setDoNotScore(true);
                }
                if (array_key_exists('comment_' . $option->getId(), $_POST)) {
                    $value->setComments($_POST['comment_' . $option->getId()]);