diff --git fivestar.module fivestar.module index 4d3a0a3..f872915 100644 --- fivestar.module +++ fivestar.module @@ -780,7 +780,7 @@ function fivestar_get_votes($type, $cid, $tag = 'vote', $uid = NULL) { $votes['count'] = $result; } } - if ($user->uid) { + if ($uid !== FALSE && $user->uid) { $user_vote = votingapi_select_votes($criteria += array('uid' => $user->uid)); if ($user_vote) { $votes['user'] = $user_vote[0]; @@ -1007,8 +1007,6 @@ function fivestar_static($content_type, $content_id, $node_type = NULL) { 'tag' => 'vote', ); - $votes = fivestar_get_votes($content_type, $content_id); - if ($content_type == 'node') { // Content type should always be passed to avoid this node load. if (!isset($node_type)) { @@ -1024,17 +1022,23 @@ function fivestar_static($content_type, $content_id, $node_type = NULL) { switch ($star_display) { case 'average': case 'dual': + $votes = fivestar_get_votes($content_type, $content_id, 'vote', FALSE); $star_value = $votes['average']['value']; $title = $title_display ? t('Average') : NULL; break; case 'user': + $votes = fivestar_get_votes($content_type, $content_id); $star_value = $votes['user']['value']; $title = $title_display ? t('Your rating') : NULL; break; case 'smart': + $votes = fivestar_get_votes($content_type, $content_id); $star_value = $votes['user']['value'] ? $votes['user']['value'] : $votes['average']['value']; $title = $title_display ? $votes['user']['value'] ? t('Your rating') : t('Average') : NULL; break; + default: + $votes = fivestar_get_votes($content_type, $content_id); + break; } // Set all text values, then unset the unnecessary ones. @@ -1060,6 +1064,7 @@ function fivestar_static($content_type, $content_id, $node_type = NULL) { } // Possibly add other content types here (comment, user, etc). else { + $votes = fivestar_get_votes($content_type, $content_id); $stars = 5; $star_value = $votes['average']['value']; $user_value = $votes['user']['value'];