Index: plus1.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/plus1/plus1.install,v
retrieving revision 1.1.4.1
diff -u -r1.1.4.1 plus1.install
--- plus1.install	7 Sep 2008 22:14:32 -0000	1.1.4.1
+++ plus1.install	30 Dec 2010 00:19:50 -0000
@@ -1,32 +1,61 @@
 <?php
 // $Id: plus1.install,v 1.1.4.1 2008/09/07 22:14:32 chill35 Exp $
+
+/**
+ * @file
+ * A simple +1 voting widget module.
+ */
+
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  */
 function plus1_install() {
   // Create tables.
   drupal_install_schema('plus1');
 }
+
 /**
- * Implementation of hook_schema().
+ * Implements hook_schema().
  */
 function plus1_schema() {
   return array();
 }
+
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  */
 function plus1_uninstall() {
   // Remove tables.
   drupal_uninstall_schema('plus1');
+  
+  db_query("DELETE FROM {variable} WHERE name LIKE 'plus1\_%");
 }
 
 /**
  * Upgrade to using VotingAPI 2.
- * 
  */
-function fivestar_update_6200() {
+function plus1_update_6200() {
   $ret = array();
-  // db_drop_table($ret, 'plus1');
+  
+  if (db_table_exists('plus1_vote')) {
+    // Convert v1 style vote table to votingapi. See project page.
+    $result = db_query("SELECT * FROM {plus1_vote}");
+    while ($row = db_fetch_object($result)) {
+      $insert = db_query("INSERT INTO {votingapi_vote} (content_type, content_id, value, value_type, tag, uid, timestamp, vote_source) VALUES('node', $row->nid, $row->vote, 'points', 'vote', $row->uid, $row->created, '127.0.0.1')");
+      if ($insert !== FALSE) {
+        // Deleting the converted records allows this to be re-run if time runs out.
+        db_query("DELETE FROM {plus1_vote} WHERE uid = $row->uid AND nid = $row->nid AND created = $row->created");
+      }
+    }
+  
+    db_drop_table($ret, 'plus1_vote');
+
+    // Tell them how to update.
+    $ret[] = array('success' => TRUE, 'query' => t('Set your Votingapi "Vote tallying" option for cron-time and invoke cron. You may then set the option back.'));
+  }
+  else {
+    $ret[] = array('success' => TRUE, 'query' => t('This is not an update from version 1, so this update was bypassed.'));
+  }
+
   return $ret;
 }

