? 889410_comments.patch
Index: uuid.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uuid/uuid.install,v
retrieving revision 1.4
diff -u -p -r1.4 uuid.install
--- uuid.install	11 Jun 2010 04:06:52 -0000	1.4
+++ uuid.install	21 Aug 2010 00:33:09 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: uuid.install,v 1.4 2010/06/11 04:06:52 recidive Exp $
+// $Id: uuid.install,v 1.1.2.8 2010/04/02 02:20:38 recidive Exp $
 
 /**
  * @file
@@ -107,3 +107,14 @@ function uuid_update_6002() {
 
   return $ret;
 }
+
+/**
+ * Create uuid_comment table.
+ */
+function uuid_update_6003() {
+  $ret = array();
+
+  db_create_table($ret, 'uuid_comment', uuid_table_schema('comments', 'cid'));
+
+  return $ret;
+}
Index: uuid.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uuid/uuid.module,v
retrieving revision 1.4
diff -u -p -r1.4 uuid.module
--- uuid.module	11 Jun 2010 04:06:52 -0000	1.4
+++ uuid.module	21 Aug 2010 00:33:09 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: uuid.module,v 1.4 2010/06/11 04:06:52 recidive Exp $
+// $Id: uuid.module,v 1.1.2.10 2010/04/02 02:17:52 recidive Exp $
 
 /**
  * @file
@@ -200,6 +200,39 @@ function uuid_taxonomy($op, $type, $arra
 }
 
 /**
+ * Implementation of hook_comment().
+ */
+function uuid_comment(&$a1, $op) {
+  switch ($op) {
+    // Make sure that a new entry gets made in the comments_uuid table when new content
+    // is added.
+    case 'insert':
+      if (!empty($a1['uuid']) && uuid_is_valid($a1['uuid'])) {
+        db_query("INSERT INTO {uuid_comments} (cid, uuid) VALUES (%d, '%s')", $a1['cid'], $a1['uuid']);
+      }
+      else if (variable_get('uuid_automatic_for_comments', FALSE)) {
+        db_query("INSERT INTO {uuid_comments} (cid, uuid) VALUES (%d, '%s')", $a1['cid'], uuid_uuid());
+      }
+      break;
+      
+    case 'update':
+      if (isset($a1['uuid']) && uuid_is_valid($a1['uuid'])) {
+        $exists = db_result(db_query('SELECT 1 FROM {uuid_comments} WHERE uid = %d', $a1['cid']));
+
+        if (!$exists && variable_get('uuid_automatic_for_comments', FALSE)))) {
+          db_query("INSERT INTO {uuid_comments} (cid, uuid) VALUES (%d, '%s')", $a1['cid'], uuid_uuid());
+        }
+      }
+      break;
+
+    // Clean up comments_uuid table when content is deleted.
+    case 'delete':
+      db_query("DELETE FROM {uuid_comments} WHERE cid = %d", $a1->cid);
+      break;
+  }
+}
+
+/**
  * Determines if a UUID is valid.
  */
 function uuid_is_valid($uuid) {
