diff -urp nodevote-5/nodevote.info nodevote-6/nodevote.info
--- nodevote-5/nodevote.info	2008-07-08 02:12:20.000000000 +0200
+++ nodevote-6/nodevote.info	2008-07-13 16:06:25.000000000 +0200
@@ -1,10 +1,7 @@
-; $Id: nodevote.info,v 1.1.2.1 2007/06/18 23:06:54 dww Exp $
 name = Nodevote
 description = Allows users to vote on nodes.
-package = 
-
-; Information added by drupal.org packaging script on 2008-07-08
-version = "5.x-1.x-dev"
+package = Voting
+version = "6.x-1.x-dev"
 project = "nodevote"
 datestamp = "1215475940"
-
+core = 6.x
\ No newline at end of file
diff -urp nodevote-5/nodevote.install nodevote-6/nodevote.install
--- nodevote-5/nodevote.install	2007-05-08 03:56:18.000000000 +0200
+++ nodevote-6/nodevote.install	2008-07-13 16:06:26.000000000 +0200
@@ -1,37 +1,50 @@
 <?php
-// $Id: nodevote.install,v 1.5.2.1 2007/05/08 01:56:18 kbahey Exp $
-
+/**
+ * Implementation of hook_install().
+ */
 function nodevote_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysqli':
-    case 'mysql':
-      $query = db_query("
-        CREATE TABLE {nodevote} (
-          uid        int(10) NOT NULL default '0',
-          nid        int(10) NOT NULL default '0',
-          vote       int(2)  NOT NULL default '0',
-          timestamp  int(11) NOT NULL default '0',
-          PRIMARY KEY (uid, nid),
-          KEY node_id (nid),
-          KEY user_id (uid)
-        )  /*!40100 DEFAULT CHARACTER SET utf8 */;");
-
-      break;
-
-    case 'pgsql':
-      $query = db_query("CREATE TABLE {nodevote} (
-        uid int NOT NULL default '0',
-        nid int NOT NULL default '0',
-        vote int NOT NULL default '0',
-        timestamp int NOT NULL default '0',
-        PRIMARY KEY (uid, nid)
-      )");
-      db_query("CREATE INDEX {nodevote}_node_id_idx ON {nodevote} (nid)");
-      db_query("CREATE INDEX {nodevote}_user_id_idx ON {nodevote} (uid)");
-      break;
-  }
+  drupal_install_schema('nodevote');
 }
 
+/**
+ * Implementation of hook_schema().
+ */
+function nodevote_schema() {
+  $schema = array();
+  $schema['nodevote'] = array(
+    'description' => t('Stores the users\' votes about a node'),
+    'fields' => array(
+      'uid' => array(
+        'description' => t('User ID'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'nid' => array(
+        'description' => t('Node ID'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'vote' => array(
+        'description' => t('Amount'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'timestamp' => array(
+        'description' => t('Timestamp'),
+        'type' => 'int',
+        'length' => 2,
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+    ),
+    'primary key' => array('uid', 'nid'),
+    'indexes' => array('node_nid' => array('nid'), 'user_id' => array('uid')),
+  );
+  return $schema;
+}
 
 function nodevote_update_1() {
   return _system_update_utf8(array('nodevote'));
@@ -39,17 +52,15 @@ function nodevote_update_1() {
 
 function nodevote_update_2() {
   $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysqli':
-    case 'mysql':
-      $ret = update_sql("ALTER TABLE {nodevote} ADD COLUMN timestamp int(11) NOT NULL default '0'");
-      break;
-  }
+  $ret[] = update_sql("ALTER TABLE {nodevote} ADD COLUMN timestamp int(11) NOT NULL default '0'");
 
   return $ret;
 }
 
-function nodevote_uninstall () {
-  db_query('DROP TABLE {nodevote}');
+/**
+* Implementation of hook_uninstall().
+*/
+function nodevote_uninstall() {
+  drupal_uninstall_schema('nodevote');
 }
 
diff -urp nodevote-5/nodevote.module nodevote-6/nodevote.module
--- nodevote-5/nodevote.module	2008-06-22 18:11:59.000000000 +0200
+++ nodevote-6/nodevote.module	2008-07-13 16:06:27.000000000 +0200
@@ -20,8 +20,10 @@ define('NODEVOTE_BLOCK_COUNT',          
 define('NODEVOTE_HIGHEST_BLOCK_THRESHOLD', 'nodevote_highest_block_threshold');
 define('NODEVOTE_USERPOINTS',              'nodevote_userpoints');
 
-function nodevote_help($section) {
-  switch ($section) {
+function nodevote_help($path, $arg) {
+  $output = '';
+
+  switch ($path) {
     case 'admin/settings/nodevote':
       $output = t('This module provides the facility to vote on certain node types using several criteria.');
       break;
@@ -29,34 +31,36 @@ function nodevote_help($section) {
   return $output;
 }
 
-function nodevote_menu($may_cache) {
-  $nid = (int)arg(1);
-
+function nodevote_menu() {
   $items = array();
 
-  $items[] = array(
-    'path'     => "nodevote/$nid/add",
-    'callback' => 'nodevote_page',
-    'title'    => t('Nodevote add'),
-    'access'   => user_access(NODEVOTE_PERM_USE),
-    'type'     => MENU_CALLBACK);
-
-  $items[] = array(
-    'path'     => 'nodevote/' . $nid,
-    'callback' => 'nodevote_page',
-    'title'    => t('Nodevote view'),
-    'access'   => user_access(NODEVOTE_PERM_VIEW),
-    'type'     => MENU_CALLBACK);
+  $items['nodevote/%node/add'] = array(
+    'page callback' => 'nodevote_page',
+    'page arguments' => array(1),
+    'title' => t('Nodevote add'),
+    'access callback' => 'user_access',
+    'access arguments' => array(NODEVOTE_PERM_USE),
+    'type' => MENU_CALLBACK
+  );
+
+  $items['nodevote/%node'] = array(
+    'page callback' => 'nodevote_page',
+    'page arguments' => array(1),
+    'title' => t('Nodevote view'),
+    'access callback' => 'user_access',
+    'access arguments' => array(NODEVOTE_PERM_VIEW),
+    'type' => MENU_CALLBACK
+  );
 
- $items[] = array(
-    'path' => 'admin/settings/nodevote',
+  $items['admin/settings/nodevote'] = array(
     'title' => t('Nodevote'),
     'description' => t('Change settings for voting on nodes.'),
-    'callback' => 'drupal_get_form',
-    'callback arguments' => 'nodevote_admin_settings',
-    'access' => user_access('administer site configuration'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('nodevote_admin_settings'),
+    'access callback' => 'user_access',
+    'access arguments' => array('administer site configuration'),
     'type' => MENU_NORMAL_ITEM, // optional
-   );
+  );
 
    return $items;
 }
@@ -71,7 +75,7 @@ function nodevote_admin_settings() {
     '#type' => 'fieldset',
     '#title' => t('Enable voting for these node types:'),
   );
-  
+
   foreach(node_get_types() as $type => $name) {
     $form[$set][NODEVOTE_TYPE . $type] = array(
       '#type' => 'checkbox',
@@ -80,13 +84,13 @@ function nodevote_admin_settings() {
       '#default_value' => variable_get(NODEVOTE_TYPE . $type, '0'),
     );
   }
-  
-  $set = 'setting'; 
+
+  $set = 'setting';
   $form[$set] = array(
     '#type' => 'fieldset',
     '#title' => t('Settings'),
   );
-  
+
   $_display = array(
     0 => t('Text'),
     1 => t('Stars'),
@@ -94,10 +98,10 @@ function nodevote_admin_settings() {
   );
   $form[$set][NODEVOTE_RESULT_DISPLAY_PAGE]= array(
     '#type'          => 'radios',
-    '#title'         => t('Vote result display (page view)'), 
+    '#title'         => t('Vote result display (page view)'),
     '#default_value' => variable_get(NODEVOTE_RESULT_DISPLAY_PAGE, 0),
     '#options'       =>  $_display,
-    '#description'   => t('Select which format the results of the vote will be displayed in when in node view.'));   
+    '#description'   => t('Select which format the results of the vote will be displayed in when in node view.'));
 
   $_display = array(
     0 => t('Text'),
@@ -106,11 +110,11 @@ function nodevote_admin_settings() {
     3 => t('None'));
   $form[$set][NODEVOTE_RESULT_DISPLAY_TEASER]= array(
     '#type'          => 'radios',
-    '#title'         => t('Vote result display (teaser view)'), 
+    '#title'         => t('Vote result display (teaser view)'),
     '#default_value' => variable_get(NODEVOTE_RESULT_DISPLAY_TEASER, 0),
     '#options'       =>  $_display,
-    '#description'   => t('Select which format the results of the vote will be displayed in when in teaser view.'));   
-            
+    '#description'   => t('Select which format the results of the vote will be displayed in when in teaser view.'));
+
   $set='advance';
   $form[$set] = array(
     '#type'  => 'fieldset',
@@ -121,19 +125,19 @@ function nodevote_admin_settings() {
     '#title' => t('Show vote results only if user has voted on node.'),
     '#return_value' => 1,
     '#default_value' => variable_get(NODEVOTE_RESULT_VOTED, 0),
-  );   
+  );
   $form[$set][NODEVOTE_CHANGE_VOTE] = array(
     '#type' => 'checkbox',
     '#title' => t('Allow user to vote again.'),
     '#return_value' => 1,
     '#default_value' => variable_get(NODEVOTE_CHANGE_VOTE, 0),
-  ); 
+  );
   $form[$set][NODEVOTE_VOTE_OWN_NODE] = array(
     '#type' => 'checkbox',
     '#title' => t('Allow user to vote on his own node.'),
     '#return_value' => 1,
     '#default_value' => variable_get(NODEVOTE_VOTE_OWN_NODE, 0),
-  ); 
+  );
   $form[$set][NODEVOTE_DAILY_THRESHOLD] = array(
     '#type' => 'select',
     '#title' => t('Daily threshold'),
@@ -155,9 +159,9 @@ function nodevote_admin_settings() {
     '#default_value' => variable_get(NODEVOTE_HIGHEST_BLOCK_THRESHOLD, 3),
     '#description' => t('Nodes must have the given number of votes before they show in the highest block.'),
   );
-   
+
   return system_settings_form($form);
-}  
+}
 
 /**
  * Check if the current voter has cast his maximum daily votes.
@@ -171,7 +175,7 @@ function nodevote_admin_settings() {
  *   True if the user did not exceed the threshold.  False otherwise.
  */
 function _nodevote_within_threshold($uid, $threshold) {
-  $number = db_num_rows(db_query("SELECT uid FROM {nodevote} WHERE uid = '%s' AND timestamp > '%d'", $uid, time() - 86400));
+  $number = db_result(db_query("SELECT count(uid) FROM {nodevote} WHERE uid = '%s' AND timestamp > '%d'", $uid, time() - 86400));
   return ($number < $threshold ? TRUE : FALSE);
 }
 
@@ -179,7 +183,7 @@ function nodevote_link($type, $node, $te
   if ($type == 'node' && $teaser) {
     if (_nodevote_is_votable($node)) {
       $links['nodevote_link'] = array(
-        'title' => t('Vote on it'), 
+        'title' => t('Vote on it'),
         'href'  => "node/$node->nid"
         );
     }
@@ -188,6 +192,8 @@ function nodevote_link($type, $node, $te
 }
 
 function nodevote_user($op) {
+  global $user;
+
   switch($op) {
     case 'delete':
       db_query('DELETE FROM {nodevote} WHERE uid = %d', $user->uid);
@@ -257,42 +263,40 @@ function nodevote_block($op = 'list', $d
   }
 }
 
-function nodevote_page() {
+function nodevote_page($node) {
   global $user;
   $edit = $_POST;
 
-  $nid = (int)arg(1);
   $op  = arg(2);
 
   switch($op) {
     case 'add':
       $vote = $edit['vote'];
-
       if (_nodevote_validate_vote($vote)) {
-        if (_nodevote_user_voted($user->uid, $nid)){ 
-          $result = db_query("UPDATE {nodevote} SET  vote = $vote WHERE  uid = %d AND nid = %d" , $user->uid , $nid);
+        if (_nodevote_user_voted($user->uid, $node->nid)){
+          $result = db_query("UPDATE {nodevote} SET  vote = $vote WHERE  uid = %d AND nid = %d" , $user->uid , $node->nid);
         }
         else {
           // check to see if the user has voted too many times today
           if(_nodevote_within_threshold($user->uid, variable_get(NODEVOTE_DAILY_THRESHOLD, 10))) {
             // log the vote
-            $result = db_query("INSERT INTO {nodevote} VALUES (%d, %d, %d, %d)", $user->uid, $nid, $vote, time());
+            $result = db_query("INSERT INTO {nodevote} VALUES (%d, %d, %d, %d)", $user->uid, $node->nid, $vote, time());
             // do the userpoints dance
             nodevote_do_userpoints();
-          }  
+          }
         else {
           // if they've voted too many times today, show a message
           $output = t("You can only vote %number times in 24 hours. Please try again later.", array('%number' => variable_get(NODEVOTE_DAILY_THRESHOLD, 10)));
           drupal_set_message($output, 'error');
         }
-        $o = l(t('Back to node'), 'node/' . $nid);
+        $o = l(t('Back to node'), 'node/' . $node->nid);
         }
-        drupal_goto("node/" . $nid);
+        drupal_goto("node/" . $node->nid);
       }
       else {
         drupal_set_message(t('You must select a valid vote score.'), 'error');
       }
-      $o = l(t('Back to node'), 'node/' . $nid);
+      $o = l(t('Back to node'), 'node/' . $node->nid);
       break;
 
     case 'view':
@@ -320,9 +324,9 @@ function nodevote_nodeapi(&$node, $op, $
         }
       }
       return $extra;
-     
+
     case 'view':
-      if (variable_get(NODEVOTE_TYPE . $node->type, 0)) { 
+      if (variable_get(NODEVOTE_TYPE . $node->type, 0)) {
         if ($node->nodevote->vote_display) {
           $vote_data = _nodevote_get_vote_data($node->nid, $page);
           $node->content['nodevote_display'] = array(
@@ -331,7 +335,7 @@ function nodevote_nodeapi(&$node, $op, $
           );
         }
       }
-                       
+
       if ($page) {
         if ($node->nodevote->vote_do) {
           $vote = theme('nodevote_do_vote', $node);
@@ -341,7 +345,7 @@ function nodevote_nodeapi(&$node, $op, $
         }
       }
       break;
-    
+
     case 'alter':
       if(!$page) {
         if (variable_get(NODEVOTE_RESULT_DISPLAY_TEASER, 0) != 3) {
@@ -353,7 +357,7 @@ function nodevote_nodeapi(&$node, $op, $
 		    }
       }
       break;
-      
+
     case 'delete':
       db_query('DELETE FROM {nodevote} WHERE nid = %d', $node->nid);
       break;
@@ -361,7 +365,7 @@ function nodevote_nodeapi(&$node, $op, $
 }
 
 function _nodevote_user_voted($uid, $nid) {
-  if (db_num_rows(db_query('SELECT * FROM {nodevote} WHERE uid = %d AND nid = %d', $uid, $nid))) {
+  if (db_result(db_query('SELECT count(nid) FROM {nodevote} WHERE uid = %d AND nid = %d', $uid, $nid))) {
     return TRUE;
   }
   else {
@@ -371,15 +375,15 @@ function _nodevote_user_voted($uid, $nid
 
 function _nodevote_get_vote_data($nid, $page = TRUE) {
   $result = db_fetch_array(db_query('SELECT COUNT(*) AS votes, AVG(vote) AS score FROM {nodevote} WHERE nid = %d', $nid));
-  
+
   $score = $result['score'];
   $votes = $result['votes'];
-  
+
   if ($page) {
-    $vote_display = variable_get(NODEVOTE_RESULT_DISPLAY_PAGE, 0); 
+    $vote_display = variable_get(NODEVOTE_RESULT_DISPLAY_PAGE, 0);
   }
   else {
-    $vote_display = variable_get(NODEVOTE_RESULT_DISPLAY_TEASER, 0); 
+    $vote_display = variable_get(NODEVOTE_RESULT_DISPLAY_TEASER, 0);
   }
 
   return array('score' => $score, 'votes' => $votes, 'vote_display' => $vote_display);
@@ -394,21 +398,21 @@ function theme_nodevote_display_vote($vo
     case 1:
       $result  = _nodevote_display_stars($votes, $score);
       break;
- 
+
     case 2:
-      $result  = _nodevote_display_stars($votes, $score);    
+      $result  = _nodevote_display_stars($votes, $score);
       $result .= _nodevote_display_number($votes, $score);
       break;
-          
+
     case 0:
-    default: 
-      $result  = _nodevote_display_number($votes, $score);  
-      break;    
+    default:
+      $result  = _nodevote_display_number($votes, $score);
+      break;
   }
 
   $output .= '<div id="nodevote result">';
   $output .= '<h3>' . t('Vote Result') . '</h3>';
-  $output .= $result; 
+  $output .= $result;
   $output .= '</div>';
 
   return $output;
@@ -430,7 +434,7 @@ function _nodevote_display_stars($votes,
       $alt = '-';
     }
     $stars .='<img src="' . $base_path . drupal_get_path('module', 'nodevote') . '/star_' . $val . '.png" alt="' . $alt . '" />';
-  };    
+  };
 
   return $stars;
 }
@@ -447,7 +451,7 @@ function _nodevote_is_votable($node) {
       // Does the user has permission to vote?
       if (user_access(NODEVOTE_PERM_USE)) {
         // Is the node posted by someone else?
-        if (($node->uid != $user->uid) || (variable_get(NODEVOTE_VOTE_OWN_NODE, 0))) {      
+        if (($node->uid != $user->uid) || (variable_get(NODEVOTE_VOTE_OWN_NODE, 0))) {
           // Did the user already vote on this node?
           if ((!_nodevote_user_voted($user->uid, $node->nid)) || (variable_get(NODEVOTE_CHANGE_VOTE, 0))){
             $ret = TRUE;
@@ -475,11 +479,25 @@ function _nodevote_vote_is_visible($node
   return $ret;
 }
 
+/**
+ * Implementation of hook_theme().
+ */
+function nodevote_theme() {
+  return array(
+    'nodevote_display_vote' => array(
+      'arguments' => array('vote_data' => NULL),
+    ),
+    'nodevote_do_vote' => array(
+      'arguments' => array('node' => NULL),
+    ),
+  );
+}
+
 function theme_nodevote_do_vote($node) {
   return drupal_get_form('nodevote_rate_form', $node);
 }
 
-function nodevote_rate_form($node) {
+function nodevote_rate_form($form_state, $node) {
   global $user;
   $score = array();
   $r = 0;
@@ -488,7 +506,7 @@ function nodevote_rate_form($node) {
      $r = db_result(db_query("SELECT vote FROM {nodevote} WHERE uid = %d AND nid = %d" , $user->uid ,$node->nid));
      $score[] =$r;
   }
-  
+
   for($j=NODEVOTE_MIN_SCORE; $j<NODEVOTE_MAX_SCORE+1; $j++) {
     $score[$j] = $j;
   }
@@ -501,7 +519,7 @@ function nodevote_rate_form($node) {
     '#prefix' => '<div id="nodevote vote">',
     '#suffix' => '</div>',
    );
-  
+
   $form[$set]['vote'] = array(
     '#type' => 'select',
     '#title' => t('Score'),
@@ -512,12 +530,12 @@ function nodevote_rate_form($node) {
     '#type'  => 'submit',
     '#value' => t('Vote'),
   );
-  
+
   $form['#method'] = 'post';
   $form['#action'] = url('nodevote/' . $node->nid . '/add');
   $form['#attributes'] = array('class' => 'nodevote-form');
-  
-  return $form;  
+
+  return $form;
 }
 
 function _nodevote_validate_vote($vote) {
