Beispiel #1
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_set_rating(ElggEntity $entity)
{
    $result = false;
    if (!empty($entity) && elgg_instanceof($entity)) {
        $access = elgg_set_ignore_access(true);
        $rating = elggx_fivestar_get_rating($entity->getGUID());
        $entity->elggx_fivestar_rating = (double) elgg_extract("rating", $rating, 0);
        elgg_set_ignore_access($access);
    }
    return $result;
}
Beispiel #2
0
<?php

elgg_load_js("jquery.ui.stars");
$guid = elgg_extract("fivestar_guid", $vars);
if (empty($guid) && ($entity = elgg_extract("entity", $vars))) {
    $guid = $entity->getGUID();
}
// we must have a guid to assing the vote to
if (!$guid) {
    return;
}
$rating = elggx_fivestar_get_rating($guid);
$stars = elggx_fivestar_get_configured_stars();
$pps = 100 / $stars;
$checked = '';
$disabled = '';
if (!elgg_is_logged_in()) {
    $disabled = 'disabled="disabled"';
}
if (!elggx_fivestar_cancel_change_allowed() && elggx_fivestar_has_voted($guid)) {
    $disabled = 'disabled="disabled"';
}
$subclass = elgg_extract("subclass", $vars);
$outerId = elgg_extract("outerId", $vars);
$ratingText = elgg_extract("ratingTextClass", $vars);
?>
<div id='<?php 
echo $outerId;
?>
' class="fivestar-ratings fivestar-ratings-<?php 
echo $guid . $subclass;