Index: fivestar.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/fivestar.module,v retrieving revision 1.2.2.24 diff -u -p -r1.2.2.24 fivestar.module --- fivestar.module 11 Sep 2007 16:24:05 -0000 1.2.2.24 +++ fivestar.module 17 Oct 2007 03:57:02 -0000 @@ -240,8 +240,9 @@ function theme_fivestar_preview_page() { * An XML chunk containing the results of the vote, for use by the client-side * javascript code. */ -function fivestar_vote($type, $cid, $value) { - $result = _fivestar_cast_vote($type, $cid, $value); +function fivestar_vote($type, $cid, $value, $tag = NULL) { + + $result = _fivestar_cast_vote($type, $cid, $value, $tag); if ($type == 'node') { $node = node_load($cid); @@ -275,7 +276,11 @@ function fivestar_vote($type, $cid, $val * Internal function to handle vote casting, flood control, XSS, IP based * voting, etc... */ -function _fivestar_cast_vote($type, $cid, $value) { +function _fivestar_cast_vote($type, $cid, $value, $tag) { + if (!isset($tag)) { + $tag = 'vote'; //If there is no tag, use the default 'vote' tag\axis. + } + global $user; // Bail out if the user's trying to vote on an invalid object. @@ -322,13 +327,13 @@ function _fivestar_cast_vote($type, $cid else { if ($uid) { // If the user is logged in, we'll look for votes from that uid. - $sql = "SELECT vote_id FROM {votingapi_vote} WHERE content_type='%s' AND content_id=%d AND value_type='percent' AND uid=%d"; - $result = db_query($sql, $type, $cid, $uid); + $sql = "SELECT vote_id FROM {votingapi_vote} WHERE content_type='%s' AND content_id=%d AND value_type='percent' AND uid=%d AND tag = '%s'"; + $result = db_query($sql, $type, $cid, $uid, $tag); } else { // Otherwise, we'll look for votes from the same IP address in the past day. - $sql = "SELECT vote_id FROM {votingapi_vote} WHERE content_type='%s' AND content_id=%d AND value_type='percent' AND uid=%d AND hostname='%s' AND timestamp > %d"; - $result = db_query($sql, $type, $cid, $uid, $hostname, time() - (60 * 60 * 24)); + $sql = "SELECT vote_id FROM {votingapi_vote} WHERE content_type='%s' AND content_id=%d AND value_type='percent' AND uid=%d AND tag = '%s' AND hostname='%s' AND timestamp > %d"; + $result = db_query($sql, $type, $cid, $uid, $tag, $hostname, time() - (60 * 60 * 24)); } } @@ -340,7 +345,7 @@ function _fivestar_cast_vote($type, $cid votingapi_change_vote($old_vote, $value); } elseif ($value != 0) { - votingapi_add_vote($type, $cid, $value, 'percent', 'vote', $uid); + votingapi_add_vote($type, $cid, $value, 'percent', $tag, $uid); } return votingapi_recalculate_results($type, $cid); } Index: fivestar_field.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/fivestar_field.inc,v retrieving revision 1.1.4.6 diff -u -p -r1.1.4.6 fivestar_field.inc --- fivestar_field.inc 9 Oct 2007 20:45:21 -0000 1.1.4.6 +++ fivestar_field.inc 17 Oct 2007 03:57:02 -0000 @@ -49,9 +49,17 @@ function fivestar_field_settings($op, $f '#value' => 1, ); } + + $form['axis'] = array( + '#type' => 'textarea', + '#title' => 'axis', + '#description' => t('The axis -- Used for VotingAPI Ratings'), + '#default_value' => $field['axis'], + ); + return $form; case 'save': - return array('stars', 'target', 'php'); + return array('stars', 'target', 'php', 'axis'); case 'database columns': $columns = array( 'target' => array('type' => 'int', 'default' => 'NULL'), @@ -78,13 +86,16 @@ function fivestar_field($op, &$node, $fi if ($field['php'] && !empty($item['target'])) { $items[$delta]['target'] = drupal_eval($item['target']); } + if (is_numeric($items[$delta]['target'])) { $target_node = node_load($items[$delta]['target']); if ($item['rating'] == 0) { votingapi_unset_vote('node', $target_node->nid); } + else { - _fivestar_cast_vote('node', $target_node->nid, $item['rating']); + + _fivestar_cast_vote('node', $target_node->nid, $item['rating'], $items[$delta]['axis']); } } } @@ -162,6 +173,10 @@ function fivestar_widget($op, &$node, $f '#type' => 'value', '#value' => $field['target'], ); + $form[$field['field_name']][0]['axis'] = array( + '#type' => 'value', + '#value' => $field['axis'], + ); return $form; } }