Index: fivestar.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/fivestar.module,v retrieving revision 1.32.2.2 diff -u -p -r1.32.2.2 fivestar.module --- fivestar.module 7 Feb 2011 21:20:01 -0000 1.32.2.2 +++ fivestar.module 18 Feb 2011 07:59:10 -0000 @@ -502,8 +502,19 @@ function fivestar_nodeapi(&$node, $op, $ NODE_BUILD_SEARCH_RESULT, NODE_BUILD_RSS, ); + $user_has_voted = 0; + global $user; + if (!in_array($node->build_mode, array(NODE_BUILD_PREVIEW, NODE_BUILD_SEARCH_INDEX)) && !isset($node->modr8_form_teaser) && fivestar_widget_enabled('fivestar_'. $node->type)) { foreach (fivestar_get_tags() as $tag) { + $settings = fivestar_get_settings($node->type, $tag); + if (!$settings['unvote_enable']) { + // Since we are providing the $user->uid, if this returns an un-empty array, the $user->uid has already voted. + $votes = votingapi_select_votes(array('uid' => $user->uid, 'content_id' => $node->nid, 'tag' => $tag)); + if (count($votes) > 0) { + $user_has_voted = 1; + } + } $position = fivestar_get_position($node->type, $teaser, $tag); switch ($position) { case 'above': @@ -511,7 +522,12 @@ function fivestar_nodeapi(&$node, $op, $ if (user_access('rate content')) { $content = ''; if (fivestar_validate_target('node', $node->nid, $tag)) { - $content .= fivestar_widget_form($node, $tag); + if ($user_has_voted) { + $content .= fivestar_static('node', $node->nid, $node->type, $tag, TRUE); + } + else { + $content .= fivestar_widget_form($node, $tag); + } } if ($content) { $node->content['fivestar_widget_' . $tag] = array( @@ -712,7 +728,7 @@ function fivestar_form(&$form_state, $co * Optional. The voting tag that will be retreived. Defaults to "vote" if none * is specified. */ -function fivestar_static($content_type, $content_id, $node_type = NULL, $tag = 'vote') { +function fivestar_static($content_type, $content_id, $node_type = NULL, $tag = 'vote', $user_voted_already = FALSE) { global $user; $criteria = array( @@ -733,6 +749,7 @@ function fivestar_static($content_type, $settings = fivestar_get_settings($node_type, $tag); $stars = $settings['stars']; + switch ($settings['star_display']) { case 'average': case 'dual': @@ -748,6 +765,10 @@ function fivestar_static($content_type, $title = $settings['title_display'] ? $votes['user']['value'] ? t('Your rating') : t('Average') : NULL; break; } + + if ($user_voted_already) { + $title = t('Thank You for Your Rating'); + } if ($tag != 'vote') { $title .= ' (' . ucfirst($tag) . ')'; Index: includes/fivestar.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/includes/fivestar.admin.inc,v retrieving revision 1.2.2.1 diff -u -p -r1.2.2.1 fivestar.admin.inc --- includes/fivestar.admin.inc 6 Feb 2011 03:34:29 -0000 1.2.2.1 +++ includes/fivestar.admin.inc 18 Feb 2011 07:59:10 -0000 @@ -283,9 +283,9 @@ function fivestar_node_type_tag_form(&$f $form['direct']['fivestar_unvote'] = array( '#type' => 'checkbox', - '#title' => t('Allow users to undo their votes'), + '#title' => t('Allow users to undo their votes. If this is not checked, the user will be presented with a static widget if they return to the page after previously submitting their vote.'), '#default_value' => $settings['unvote_enable'], - '#return_value' => 1, + '#return_value' => 0, ); $form['direct']['fivestar_position_teaser'] = array(