Пример #1
0
<?php

$guid = (int) get_input('id');
$vote = (int) get_input('vote');
if (!$vote && ($rate = (int) get_input('rate_avg'))) {
    $vote = $rate;
}
$msg = elggx_fivestar_vote($guid, $vote);
// Get the new rating
$rating = elggx_fivestar_getRating($guid);
$rating['msg'] = $msg;
if (!(int) get_input('vote') && (int) get_input('rate_avg')) {
    system_message(elgg_echo("elggx_fivestar:rating_saved"));
    forward(REFERER);
} else {
    header('Content-type: application/json');
    echo json_encode($rating);
    exit;
}
exit;
Пример #2
0
/**
 * Set the current rating for an entity
 *
 * @param  object   $entity  The entity to set the rating on
 * @return array    Includes the current rating and number of votes
 */
function elggx_fivestar_setRating($entity)
{
    $access = elgg_set_ignore_access(true);
    $rating = elggx_fivestar_getRating($entity->guid);
    $entity->elggx_fivestar_rating = $rating['rating'];
    elgg_set_ignore_access($access);
    return;
}