| 1 |
<?php |
<?php |
| 2 |
// $Id: fivestar.module,v 1.13.2.63 2009/07/01 02:17:46 quicksketch Exp $ |
// $Id: fivestar.module,v 1.13.2.64 2009/07/01 02:43:31 quicksketch Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 780 |
|
|
| 781 |
function fivestar_get_votes($type, $cid, $tag = 'vote', $uid = NULL) { |
function fivestar_get_votes($type, $cid, $tag = 'vote', $uid = NULL) { |
| 782 |
global $user; |
global $user; |
| 783 |
if (empty($uid)) { |
|
| 784 |
|
if (!isset($uid)) { |
| 785 |
$uid = $user->uid; |
$uid = $user->uid; |
| 786 |
} |
} |
| 787 |
|
|
| 1046 |
} |
} |
| 1047 |
} |
} |
| 1048 |
|
|
| 1049 |
|
$star_display = variable_get('fivestar_style_'. $node->type, 'average'); |
| 1050 |
|
$text_display = variable_get('fivestar_text_'. $node->type, 'dual'); |
| 1051 |
|
|
| 1052 |
$votes = fivestar_get_votes($content_type, $content_id); |
if ($star_display == 'average' && ($text_display == 'average' || $text_display == 'none')) { |
| 1053 |
|
// Save a query and don't retrieve the user vote unnecessarily. |
| 1054 |
|
$votes = fivestar_get_votes($content_type, $content_id, 'vote', 0); |
| 1055 |
|
} |
| 1056 |
|
else { |
| 1057 |
|
$votes = fivestar_get_votes($content_type, $content_id); |
| 1058 |
|
} |
| 1059 |
|
|
| 1060 |
$values = array( |
$values = array( |
| 1061 |
'user' => isset($votes['user']['value']) ? $votes['user']['value'] : 0, |
'user' => isset($votes['user']['value']) ? $votes['user']['value'] : 0, |
| 1066 |
$settings = array( |
$settings = array( |
| 1067 |
'stars' => variable_get('fivestar_stars_'. $node->type, 5), |
'stars' => variable_get('fivestar_stars_'. $node->type, 5), |
| 1068 |
'allow_clear' => variable_get('fivestar_unvote_'. $node->type, FALSE), |
'allow_clear' => variable_get('fivestar_unvote_'. $node->type, FALSE), |
| 1069 |
'style' => variable_get('fivestar_style_'. $node->type, 'average'), |
'style' => $star_display, |
| 1070 |
'text' => variable_get('fivestar_text_'. $node->type, 'dual'), |
'text' => $text_display, |
| 1071 |
'content_type' => $content_type, |
'content_type' => $content_type, |
| 1072 |
'content_id' => $content_id, |
'content_id' => $content_id, |
| 1073 |
'tag' => 'vote', |
'tag' => 'vote', |