/[drupal]/contributions/modules/fivestar/fivestar.module
ViewVC logotype

Diff of /contributions/modules/fivestar/fivestar.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.24, Wed Jul 1 02:43:58 2009 UTC revision 1.25, Wed Jul 1 03:06:11 2009 UTC
# Line 1  Line 1 
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
# Line 329  function _fivestar_cast_vote($type, $cid Line 329  function _fivestar_cast_vote($type, $cid
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    
# Line 621  function fivestar_form(&$form_state, $co Line 622  function fivestar_form(&$form_state, $co
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,
# Line 633  function fivestar_form(&$form_state, $co Line 642  function fivestar_form(&$form_state, $co
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',

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.2