? fivestar_multi_v1.patch
Index: fivestar.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/fivestar.module,v
retrieving revision 1.2.2.56
diff -u -p -r1.2.2.56 fivestar.module
--- fivestar.module	22 Dec 2007 09:18:48 -0000	1.2.2.56
+++ fivestar.module	24 Dec 2007 21:48:09 -0000
@@ -508,6 +508,8 @@ function theme_fivestar_preview_wrapper(
 
 /**
  * Callback function for fivestar/vote path
+ * @param tag
+ *   Mulit-axis tag to allow multiple votes per node. 'vote' is the most common.
  * @param type
  *   A content-type to log the vote to. 'node' is the most common.
  * @param cid
@@ -518,7 +520,7 @@ function theme_fivestar_preview_wrapper(
  *  An XML chunk containing the results of the vote, for use by the client-side
  *  javascript code.
  */
-function fivestar_vote($type, $cid, $value, $tag = 'vote') {
+function fivestar_vote($tag, $type, $cid, $value) {
 
   $result = _fivestar_cast_vote($type, $cid, $value, $tag);
 
@@ -550,6 +552,7 @@ function fivestar_vote($type, $cid, $val
   $output .= '<value>'. $value .'</value>';
   $output .= '<type>'. $type .'</type>';
   $output .= '<id>'. $cid .'</id>';
+  $output .= '<tag>'. $tag .'</tag>';
   $output .= '</vote></xml>';
 
   drupal_set_header("Content-Type: text/xml");
@@ -702,11 +705,12 @@ function fivestar_nodeapi(&$node, $op, $
         else {
           $position = variable_get('fivestar_position_'. $node->type, 'above');
         }
+        if ($node->type == 'blog') {$tag = 'vote2';} else {$tag = 'vote';} // TEMPORARY LINE FOR TESTING -- Makes default tag for blog 'vote2' -- Should be configurable via admin settings
         switch ($position) {
           case 'above':
           case 'below':
             $node->content['fivestar_widget'] = array(
-              '#value' => fivestar_widget_form($node),
+              '#value' => fivestar_widget_form($node, $tag),
               '#weight' => $position == 'above' ? -10 : 50,
             );
             break;
@@ -714,7 +718,7 @@ function fivestar_nodeapi(&$node, $op, $
           case 'below_static':
             $stars = variable_get('fivestar_stars_'. $node->type, 5);
             $node->content['fivestar_widget'] = array(
-              '#value' => fivestar_static('node', $node->nid, $node->type),
+              '#value' => fivestar_static('node', $node->nid, $tag, $node->type), 
               '#weight' => $position == 'above_static' ? -10 : 50,
             );
             break;
@@ -749,8 +753,8 @@ function fivestar_block($op = 'list', $d
   }
 }
 
-function fivestar_widget_form($node) {
-  return drupal_get_form('fivestar_form_node_' . $node->nid, 'node', $node->nid);
+function fivestar_widget_form($node, $tag = 'vote') {
+  return drupal_get_form('fivestar_form_node_' . $node->nid . '_'. $tag, 'node', $node->nid, $tag);
 }
 
 /**
@@ -761,7 +765,7 @@ function fivestar_widget_form($node) {
 function fivestar_forms() {
   $args = func_get_args();
   if (strpos($args[0][0], 'fivestar_form') !== FALSE) {
-    if ($args[0][0] == 'fivestar_form_' . $args[0][1] . '_' . $args[0][2]) {
+    if ($args[0][0] == 'fivestar_form_' . $args[0][1] . '_' . $args[0][2] . '_' . $args[0][3]) {
       $forms[$args[0][0]] = array('callback' => 'fivestar_form');
       return $forms;
     }
@@ -773,7 +777,7 @@ function fivestar_forms() {
  * Note that this is not an implementation of hook_form(). We should probably
  * change the function to reflect that.
  */
-function fivestar_form($content_type, $content_id) {
+function fivestar_form($content_type, $content_id, $tag) {
   global $user;
 
   if ($content_type == 'node') {
@@ -785,10 +789,10 @@ function fivestar_form($content_type, $c
     }
   }
 
-  $current_avg = votingapi_get_voting_result($content_type, $content_id, 'percent', 'vote', 'average');
-  $current_count = votingapi_get_voting_result($content_type, $content_id, 'percent', 'vote', 'count');
+  $current_avg = votingapi_get_voting_result($content_type, $content_id, 'percent', $tag, 'average');
+  $current_count = votingapi_get_voting_result($content_type, $content_id, 'percent', $tag, 'count');
   if ($user->uid) {
-    $user_vote = votingapi_get_vote($content_type, $content_id, 'percent', 'vote', $user->uid);
+    $user_vote = votingapi_get_vote($content_type, $content_id, 'percent', $tag, $user->uid);
   }
   else {
     // If the user is anonymous, we never bother loading their existing votes.
@@ -808,6 +812,7 @@ function fivestar_form($content_type, $c
     'allow_clear' => variable_get('fivestar_unvote_'. $node->type, FALSE),
     'style' => variable_get('fivestar_style_'. $node->type, 'average'),
     'text' => variable_get('fivestar_text_'. $node->type, 'combo'),
+    'tag' => $tag,
     'content_type' => $content_type,
     'content_id' => $content_id,
     'autosubmit' => TRUE,
@@ -819,12 +824,12 @@ function fivestar_form($content_type, $c
   return fivestar_custom_widget($values, $settings);  
 }
 
-function fivestar_static($content_type, $content_id, $node_type = NULL) {
+function fivestar_static($content_type, $content_id, $tag = 'vote', $node_type = NULL) { 
   global $user;
 
-  $current_avg = votingapi_get_voting_result($content_type, $content_id, 'percent', 'vote', 'average');
-  $current_count = votingapi_get_voting_result($content_type, $content_id, 'percent', 'vote', 'count');
-  $user_vote = $user->uid ? votingapi_get_vote($content_type, $content_id, 'percent', 'vote', $user->uid) : 0;
+  $current_avg = votingapi_get_voting_result($content_type, $content_id, 'percent', $tag, 'average');
+  $current_count = votingapi_get_voting_result($content_type, $content_id, 'percent', $tag, 'count');
+  $user_vote = $user->uid ? votingapi_get_vote($content_type, $content_id, 'percent', $tag, $user->uid) : 0;
 
   if ($content_type == 'node') {
     $star_display = variable_get('fivestar_style_'. $node_type, 'average');
@@ -880,7 +885,7 @@ function fivestar_static($content_type, 
     $count_value = $current_count->value;
   }
 
-  $star_display = theme('fivestar_static', $star_value, $stars);
+  $star_display = theme('fivestar_static', $star_value, $stars, $tag);
   $text_display = theme('fivestar_summary', $user_value, $average_value, $count_value, $stars);
 
   return theme('fivestar_static_element', $star_display, $title, $text_display);
@@ -916,12 +921,13 @@ function fivestar_custom_widget($values,
     '#vote_count' => $values['count'],
     '#vote_average' => $values['average'],
     '#auto_submit' => isset($settings['autosubmit']) ? $settings['autosubmit'] : TRUE,
-    '#auto_submit_path' => 'fivestar/vote/' . $settings['content_type'] . '/' . $settings['content_id'],
+    '#auto_submit_path' => 'fivestar/vote/'. $settings['tag'] .'/'. $settings['content_type'] .'/'. $settings['content_id'],
     '#allow_clear' => $settings['allow_clear'],
     '#content_id' => $settings['content_id'],
     '#required' => isset($settings['required']) ? $settings['required'] : FALSE,
     '#labels_enable' => isset($settings['labels_enable']) ? $settings['labels_enable'] : TRUE,
     '#labels' => isset($settings['labels']) ? $settings['labels'] : NULL,
+    '#tag' => $settings['tag'],
   );
 
   $form['fivestar_submit'] = array(
@@ -971,7 +977,7 @@ function fivestar_custom_widget($values,
       $form['vote']['#default_value'] = $values['user'];
       $form['vote']['#attributes']['class'] .= ' fivestar-combo-stars';
       $form['#attributes']['class'] .= ' fivestar-combo-stars';
-      $static_average = theme('fivestar_static', $values['average'], $settings['stars']);
+      $static_average = theme('fivestar_static', $values['average'], $settings['stars'], $settings['tag']);
       $form['average'] = array(
         '#type' => 'markup',
         '#value' => theme('fivestar_static_element', $static_average, $settings['title'] !== FALSE ? t('Average') : NULL),
@@ -992,7 +998,7 @@ function fivestar_custom_widget($values,
       unset($form['average']['#title']);
     }
   }
-
+  
   return $form;
 }
 
@@ -1000,8 +1006,8 @@ function fivestar_custom_widget($values,
  * Submit handler for the above form
  */
 function fivestar_form_submit($form_id, $form_values) {
-  if ($form_id == 'fivestar_form_' . $form_values['content_type'] . '_' . $form_values['content_id']) {
-    _fivestar_cast_vote($form_values['content_type'], $form_values['content_id'], $form_values['vote']);
+  if ($form_id == 'fivestar_form_' . $form_values['content_type'] . '_' . $form_values['content_id'] .'_'. $form_values['vote']['#tag']) {
+    _fivestar_cast_vote($form_values['content_type'], $form_values['content_id'], $form_values['vote'], $form_values['vote']['#tag']);
   }
 }
 
@@ -1063,7 +1069,7 @@ function theme_fivestar_widget($form) {
   $output  = '';
   $output .= '<div class="fivestar-form-'. $form['content_id']['#value'] .'">';
   $output .= drupal_render($form);
-  $output .= '<div class="description fivestar-summary-'. $form['content_id']['#value'] .'">'. $description .'</div>';
+  $output .= '<div class="description fivestar-summary-'. $form['content_id']['#value'] .'-'. $form['vote']['#tag'] .' ">'. $description .'</div>';
   $output .= '</div>';
   return $output;
 }
@@ -1076,16 +1082,18 @@ function theme_fivestar_widget($form) {
  *   The desired rating to display out of 100 (i.e. 80 is 4 out of 5 stars)
  * @param $stars
  *   The total number of stars this rating is out of
+ * @param $tag
+ *   Allows multiple ratings per node
  * @return
  *   A themed HTML string representing the star widget
  * 
  */
-function theme_fivestar_static($rating, $stars = 5) {
+function theme_fivestar_static($rating, $stars = 5, $tag = 'vote') {
   // Add necessary CSS.
   fivestar_add_css();
 
   $output = '';
-  $output .= '<div class="fivestar-widget-static fivestar-widget-static-'. $stars .' clear-block">';
+  $output .= '<div class="fivestar-widget-static fivestar-widget-static-'. $stars .'-'. $tag .' clear-block">';
   $numeric_rating = $rating/(100/$stars);
   for ($n=1; $n <= $stars; $n++) {
     $star_value = ceil((100/$stars) * $n);
@@ -1272,7 +1280,7 @@ function fivestar_votingapi_views_format
   }
 }
 
-function fivestar_views_value_display_handler($op, $filter, $value, &$query) {
+function fivestar_views_value_display_handler($op, $filter, $value, &$query) {  // TODO: Add a tag input argument here?
   if ($value === NULL) {
     return $value;
   }
@@ -1288,6 +1296,6 @@ function fivestar_views_value_display_ha
       $type = db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $query->nid));
       $stars = variable_get('fivestar_stars_'. (!isset($type) ? 'default' : $type), 5);
     }
-    return theme('fivestar_static', $value, $stars);
+    return theme('fivestar_static', $value, $stars); // TODO: Add tag?
   }
 }
\ No newline at end of file
Index: jquery.rating.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/jquery.rating.js,v
retrieving revision 1.2.2.27
diff -u -p -r1.2.2.27 jquery.rating.js
--- jquery.rating.js	22 Dec 2007 09:18:48 -0000	1.2.2.27
+++ jquery.rating.js	24 Dec 2007 21:48:09 -0000
@@ -198,6 +198,7 @@
             },
             vote: {
               id: $("vote id", data).text(),
+              tag: $("vote tag", data).text(),
               type: $("vote type", data).text(),
               value: $("vote value", data).text()
             },
@@ -270,13 +271,14 @@
      * voteResult.result.summary.user The textual description of the user's current vote.
      * voteResult.vote.id The id of the item the vote was placed on (such as the nid)
      * voteResult.vote.type The type of the item the vote was placed on (such as 'node')
+     * voteResult.vote.tag The multi-axis tag the vote was placed on (such as 'vote')
      * voteResult.vote.average The average of the new vote saved
      * voteResult.display.stars The type of star display we're using. Either 'average', 'user', or 'combo'.
      * voteResult.display.text The type of text display we're using. Either 'average', 'user', or 'combo'.
      */
     function fivestarDefaultResult(voteResult) {
       // Update the summary text.
-      $('div.fivestar-summary-'+voteResult.vote.id).html(voteResult.result.summary[voteResult.display.text]);
+      $('div.fivestar-summary-'+voteResult.vote.id+'-'+voteResult.vote.tag).html(voteResult.result.summary[voteResult.display.text]);
       // If this is a combo display, update the average star display.
       if (voteResult.display.stars == 'combo') {
         $('div.fivestar-form-'+voteResult.vote.id).each(function() {
