| 1 |
<?php |
<?php |
| 2 |
// $Id: fivestar.module,v 1.23 2009/07/01 02:18:13 quicksketch Exp $ |
// $Id: fivestar.module,v 1.24 2009/07/01 02:43:58 quicksketch Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 329 |
|
|
| 330 |
function fivestar_get_votes($type, $cid, $tag = 'vote', $uid = NULL) { |
function fivestar_get_votes($type, $cid, $tag = 'vote', $uid = NULL) { |
| 331 |
global $user; |
global $user; |
| 332 |
if (empty($uid)) { |
|
| 333 |
|
if (!isset($uid)) { |
| 334 |
$uid = $user->uid; |
$uid = $user->uid; |
| 335 |
} |
} |
| 336 |
|
|
| 622 |
} |
} |
| 623 |
|
|
| 624 |
$suffix = fivestar_get_suffix($node->type, $tag); |
$suffix = fivestar_get_suffix($node->type, $tag); |
| 625 |
|
$star_display = variable_get('fivestar_style' . $suffix, 'average'); |
| 626 |
|
$text_display = variable_get('fivestar_text' . $suffix, 'dual'); |
| 627 |
|
|
| 628 |
$votes = fivestar_get_votes($content_type, $content_id, $tag); |
if ($star_display == 'average' && ($text_display == 'average' || $text_display == 'none')) { |
| 629 |
|
// Save a query and don't retrieve the user vote unnecessarily. |
| 630 |
|
$votes = fivestar_get_votes($content_type, $content_id, $tag, 0); |
| 631 |
|
} |
| 632 |
|
else { |
| 633 |
|
$votes = fivestar_get_votes($content_type, $content_id, $tag); |
| 634 |
|
} |
| 635 |
|
|
| 636 |
$values = array( |
$values = array( |
| 637 |
'user' => isset($votes['user']['value']) ? $votes['user']['value'] : 0, |
'user' => isset($votes['user']['value']) ? $votes['user']['value'] : 0, |
| 642 |
$settings = array( |
$settings = array( |
| 643 |
'stars' => variable_get('fivestar_stars' . $suffix, 5), |
'stars' => variable_get('fivestar_stars' . $suffix, 5), |
| 644 |
'allow_clear' => variable_get('fivestar_unvote' . $suffix, FALSE), |
'allow_clear' => variable_get('fivestar_unvote' . $suffix, FALSE), |
| 645 |
'style' => variable_get('fivestar_style' . $suffix, 'average'), |
'style' => $star_display, |
| 646 |
'text' => variable_get('fivestar_text' . $suffix, 'dual'), |
'text' => $text_display, |
| 647 |
'content_type' => $content_type, |
'content_type' => $content_type, |
| 648 |
'content_id' => $content_id, |
'content_id' => $content_id, |
| 649 |
'tag' => 'vote', |
'tag' => 'vote', |