Index: custom_vote.admin.inc
===================================================================
RCS file: custom_vote.admin.inc
diff -N custom_vote.admin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ custom_vote.admin.inc	2 May 2009 16:38:39 -0000
@@ -0,0 +1,33 @@
+<?php
+// $Id$
+
+/**
+ * Menu callback for the settings form.
+ */
+function custom_vote_settings() {
+  $form = array();
+  $node_types = node_get_types();
+  foreach ($node_types as $key => $obj) {
+    $node_types[$key] = $obj->name;
+  }
+  $form['custom_vote_node_types'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Allowed node types'),
+    '#options' => $node_types,
+    '#default' => array(),
+  );
+
+  $form['custom_vote_options'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Voting options'),
+    '#description' => t('Enter a list of voting options. Each new options should be on a new line, along with the number of points its worth. For example: <br />Excellent<br />3<br />Good<br />1'),
+    '#default' => '',
+  );
+
+  foreach ($form as $key => $item) {
+    $form[$key]['#default_value'] = variable_get($key, $item['#default']);
+    unset($form[$key]['#default']);
+  }
+
+  return system_settings_form($form);
+}
\ No newline at end of file
Index: custom_vote.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/custom_vote/custom_vote.info,v
retrieving revision 1.1
diff -u -p -r1.1 custom_vote.info
--- custom_vote.info	1 Apr 2008 03:41:38 -0000	1.1
+++ custom_vote.info	2 May 2009 16:42:37 -0000
@@ -1,5 +1,6 @@
 ; $Id: custom_vote.info,v 1.1 2008/04/01 03:41:38 cwgordon7 Exp $
 name = Custom vote
 description = Allows administrators to define custom voting patterns for nodes.
+core = 6.x
 package = Voting
-dependencies = votingapi
\ No newline at end of file
+dependencies[] = votingapi
\ No newline at end of file
Index: custom_vote.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/custom_vote/custom_vote.module,v
retrieving revision 1.1
diff -u -p -r1.1 custom_vote.module
--- custom_vote.module	1 Apr 2008 03:41:38 -0000	1.1
+++ custom_vote.module	2 May 2009 17:57:01 -0000
@@ -2,59 +2,38 @@
 // $Id: custom_vote.module,v 1.1 2008/04/01 03:41:38 cwgordon7 Exp $
 
 /**
- * Implementation of hook_perm
+ * Implementation of hook_perm().
  */
 function custom_vote_perm() {
   return array('administer custom vote', 'cast custom votes', 'view custom votes');
 }
 
 /**
- * Implementation of hook_menu().
+ * Implementation of hook_theme().
  */
-function custom_vote_menu($may_cache) {
-  $items = array();
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/settings/custom_vote',
-      'title' => 'Custom vote',
-      'description' => 'Configure settings for the custom vote module.',
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('custom_vote_settings'),
-      'access' => user_access('administer custom vote'),
-    );
-  }
-  return $items;
+function custom_vote_theme($existing, $type, $theme, $path) {
+  return array(
+    'custom_vote_details' => array(
+      'arguments' => array('results' => NULL, 'options' => NULL),
+    ),
+  );
 }
 
+
 /**
- * Menu callback for the settings form.
+ * Implementation of hook_menu().
  */
-function custom_vote_settings() {
-  $form = array();
-  $node_types = node_get_types();
-  foreach ($node_types as $key => $obj) {
-    $node_types[$key] = $obj->name;
-  }
-  $form['custom_vote_node_types'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Allowed node types'),
-    '#options' => $node_types,
-    '#default' => array(),
-  );
-
-  $form['custom_vote_options'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Voting options'),
-    '#description' => t('Enter a list of voting options. Each new options should be on a new line, along with the number of points its worth. For example: <br />Excellent<br />3<br />Good<br />1'),
-    '#default' => '',
+function custom_vote_menu() {
+  $items = array();
+  $items['admin/settings/custom_vote'] = array(
+    'title' => 'Custom vote',
+    'description' => 'Configure settings for the custom vote module.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('custom_vote_settings'),
+    'access arguments' => array('administer custom vote'),
+    'file' => 'custom_vote.admin.inc',
   );
-
-  foreach ($form as $key => $item) {
-    $form[$key]['#default_value'] = variable_get($key, $item['#default']);
-    unset($form[$key]['#default']);
-  }
-
-  return system_settings_form($form);
+  return $items;
 }
 
 /**
@@ -68,24 +47,37 @@ function custom_vote_nodeapi(&$node, $op
         return;
       }
       $options = custom_vote_options();
-      if (user_access('cast custom votes')) {
-        $user_vote = votingapi_get_user_votes('node', $node->nid);
-        if (is_array($user_vote)) {
-          $user_vote = array_pop($user_vote);
+      if (user_access('cast custom votes') && count($options)) {
+        global $user;
+        $votes = votingapi_select_votes(array('content_type' => 'node', 'content_id' => $node->nid, 'uid' => $user->uid));
+        if (!empty($votes)) {
+          $user_vote = array_pop($votes);
+          $user_vote = $user_vote['value'];
         }
-        $user_vote = $user_vote->value;
-        if (count($options)) {
-          $node->content['custom_vote'] = array(
-            '#value' => drupal_get_form('custom_vote_form', $options, $node->nid, $user_vote),
-            '#weight' => 40,
-          );
+        else {
+          $user_vote = NULL;
         }
+        $node->content['custom_vote'] = array(
+          '#value' => drupal_get_form('custom_vote_form', $options, $node->nid, $user_vote),
+          '#weight' => 40,
+        );
       }
       if (user_access('view custom votes')) {
-        $current_count = votingapi_get_voting_result('node', $node->nid, 'points', 'vote', 'count');
-        $count = $current_count->value;
-        $current_total = votingapi_get_voting_result('node', $node->nid, 'points', 'vote', 'sum');
-        $total = $current_total->value;
+        $results = votingapi_select_results(array('content_type' => 'node', 'content_id' => $node->nid, 'tag' => 'vote', 'value_type' => 'points'));
+        if (empty($results)) {
+          $count = 0;
+          $sum = 0;
+        }
+        else {
+          foreach ($results as $result) {
+            if ($result['function'] == 'count') {
+              $count = $result['value'];
+            }
+            if ($result['function'] == 'sum') {
+              $total = $result['value'];
+            }
+          }
+        }
         $node->content['custom_vote']['votes'] = array(
           '#value' => t('<strong>Current status:</strong><br />@total', array('@total' => $total, '@count' => $count)) . format_plural($count, ' (@count vote)', ' (@count votes)'),
           '#weight' => 50,
@@ -94,7 +86,7 @@ function custom_vote_nodeapi(&$node, $op
         if ($count == 0) {
           return;
         }
-        $results = votingapi_get_content_votes('node', $node->nid);
+        $results = votingapi_select_votes(array('content_type' => 'node', 'content_id' => $node->nid, 'tag' => 'vote', 'value_type' => 'points'));
         $node->content['custom_vote']['details'] = array(
           '#value' => theme('custom_vote_details', $results, $options),
           '#weight' => 60,
@@ -135,7 +127,7 @@ function custom_vote_options() {
 /**
  * FAPI callback. Returns the actual voting form.
  */
-function custom_vote_form($options, $nid, $user_vote) {
+function custom_vote_form($form_state, $options, $nid, $user_vote) {
   $string = 'Choose one of the voting options below.';
   $args = array();
   if (isset($user_vote)) {
@@ -164,7 +156,8 @@ function custom_vote_form($options, $nid
 /**
  * Handle vote submissions.
  */
-function custom_vote_form_submit($form_id, $form_values) {
+function custom_vote_form_submit($form, &$form_state) {
+  $form_values = $form_state['values'];
   $op = $form_values['op'];
   $nid = $form_values['nid'];
   foreach (array('op', 'form_token', 'form_id', 'nid') as $unwanted) {
@@ -172,18 +165,23 @@ function custom_vote_form_submit($form_i
   }
   foreach ($form_values as $value => $label) {
     if ($label == $op) {
-      $vote = array();
-      $vote['value'] = (int)$value;
-      $vote['value_type'] = 'points';
-      $vote['tag'] = VOTINGAPI_VALUE_DEFAULT_TAG;
-      $vote = (object)$vote;
-      if ($vote->value != 0) {
-        votingapi_set_vote('node', $nid, $vote);
-        drupal_set_message(t("Your vote for %label has been recorded", array('%label' => $label)));
+      if ((int)$value != 0) {
+        $vote = array();
+        $vote['value'] = (int)$value;
+        $vote['value_type'] = 'points';
+        $vote['content_type'] = 'node';
+        $vote['content_id'] = $nid;
+        $votes = array($vote);
+        votingapi_set_votes($votes);
+        drupal_set_message(t('Your vote for %label has been recorded.', array('%label' => $label)));
       }
       else {
-        votingapi_unset_vote('node', $nid);
-        drupal_set_message(t('Your vote has been canceled'));
+        global $user;
+        $vote_id = db_result(db_query("SELECT vote_id FROM {votingapi_vote} WHERE uid = %d AND content_type = 'node' AND content_id = %d AND tag = 'vote' AND value_type = 'points'", $user->uid, $nid));
+        $vote = array('vote_id' => $vote_id);
+        $votes = array($vote);
+        votingapi_delete_votes($votes);
+        drupal_set_message(t('Your vote has been canceled.'));
       }
       break;
     }
@@ -198,16 +196,14 @@ function custom_vote_form_submit($form_i
 function theme_custom_vote_details($results, $options) {
   $headers = array(t('Users'), t('Votes'));
   $rows = array();
-  foreach ($results as $result) {
-    foreach ($result as $vote) {
-      if ($vote->value_type == 'points' && $vote->tag == VOTINGAPI_VALUE_DEFAULT_TAG) {
-        $row = array();
-        $user = user_load(array('uid' => $vote->uid));
-        $row['username'] = theme('username', $user);
-        $row['vote_cast'] = $options[$vote->value];
-        $rows[] = $row;
-      }
+  foreach ($results as $vote) {
+    if ($vote['value_type'] == 'points' && $vote['tag'] == 'vote') {
+      $row = array();
+      $user = user_load(array('uid' => $vote['uid']));
+      $row['username'] = theme('username', $user);
+      $row['vote_cast'] = check_plain($options[$vote['value']]);
+      $rows[] = $row;
     }
   }
-  return $pre . theme('table', $headers, $rows);
+  return theme('table', $headers, $rows);
 }
\ No newline at end of file
