</p> <h2><?php echo Text::getText("Rating"); ?> </h2> <? if (Rating::havePermission("ADD")) { ?> <form action="<?php echo $smellyfish_base_uri; ?> rate.php" onsubmit="return rate(this);" id="rate" style="display: inline"> <input type="hidden" name="recipe_id" value="<?php echo $id; ?> "/> <? $rating = Rating::getForRecipeAndUser($r->getId()); ?> <div> <select name="rating"> <? if ($rating == NULL) { ?> <option value=""><?php echo Text::getText("RateThisRecipe"); ?> </option> <? } ?> <? for ($i = 5; $i > 0; $i--) { ?> <option value="<?php echo $i; ?> "<? if ($rating->value == $i) { ?>selected<? } ?>><?php echo $i; ?>
<? require_once('classes/Rating.php'); require_once('classes/Text.php'); $recipe_id = $_REQUEST['recipe_id']; $value = $_REQUEST['rating']; $comment = $_REQUEST['comment']; $rating = Rating::getForRecipeAndUser($recipe_id); if ($rating == NULL && $value > 0) { $rating = new Rating(); $rating->recipe_id = $recipe_id; } if ($value < 0 && $rating != NULL) { $rating->delete(); } if ($value > 0) { $rating->value = $value; $rating->comment = $comment; $rating->save(); } echo 'OK';//Text::getText('ThankYou'); ?>