From aa681b9418660cb68311ed55d5d2c40d47384251 Mon Sep 17 00:00:00 2001
Message-Id: <aa681b9418660cb68311ed55d5d2c40d47384251.1341853266.git.dmitriy.trt@gmail.com>
From: "Dmitriy.trt" <dmitriy.trt@gmail.com>
Date: Tue, 10 Jul 2012 00:01:00 +0700
Subject: [PATCH] Issue #1677074: Keep settings of forms made in D6

---
 honeypot.install |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/honeypot.install b/honeypot.install
index cb7b1eb..3b5ad38 100644
--- a/honeypot.install
+++ b/honeypot.install
@@ -40,3 +40,33 @@ function honeypot_uninstall() {
     }
   }
 }
+
+/**
+ * Update form names after upgrade from 6.x version.
+ */
+function honeypot_update_7002() {
+  $map = array(
+    'user_register' => 'user_register_form',
+    'contact_mail_page' => 'contact_site_form',
+    'contact_mail_user' => 'contact_personal_form',
+  );
+  foreach ($map as $d6_name => $d7_name) {
+    $value = variable_get('honeypot_form_' . $d6_name, 0);
+    if ($value) {
+      variable_set('honeypot_form_' . $d7_name, $value);
+    }
+    variable_del('honeypot_form_' . $d6_name);
+  }
+
+  $comment_form_value = variable_get('honeypot_form_comment_form', 0);
+  if ($comment_form_value) {
+    $types = node_type_get_types();
+    if (!empty($types)) {
+      foreach ($types as $type) {
+        $d7_name = 'honeypot_form_comment_node_' . $type->type . '_form';
+        varaible_set($d7_name, $comment_form_value);
+      }
+    }
+  }
+  variable_del('honeypot_form_comment_form');
+}
-- 
1.7.10.4

