Index: merci.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/merci/merci.install,v
retrieving revision 1.1
diff -u -p -r1.1 merci.install
--- merci.install	23 Jan 2009 21:16:22 -0000	1.1
+++ merci.install	20 Mar 2009 20:05:28 -0000
@@ -15,9 +15,66 @@ function merci_install() {
   drupal_load('module', 'merci');
   // Create tables.
   drupal_install_schema('merci');
+
   //db_query("UPDATE {system} SET weight = 1 WHERE name = 'merci'");
 
-  // Create the date field for the reservation.
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function merci_uninstall() {
+
+  // Remove all MERCI variables.
+  $variables = db_query("SELECT name FROM {variable} WHERE name LIKE 'merci_%'");
+  while ($variable = db_fetch_object($variables)) {
+    variable_del($variable->name);
+  }
+
+  // Remove all MERCI content types and all associated nodes.
+  $content_types = db_query("SELECT type FROM {merci_node_type} WHERE type_setting <> 'disabled'");
+  while ($content_type = db_fetch_object($content_types)) {
+    $nodes = db_query("SELECT nid FROM {node} WHERE type = '%s'", $content_type->type);
+    while ($node = db_fetch_object($nodes)) {
+      node_delete($node->nid);
+    }
+  	node_type_delete($content_type->type);
+  }
+
+  // Remove the programatically created reservation node type
+  // and all associated nodes.
+  $nodes = db_query("SELECT nid FROM {node} WHERE type = 'merci_reservation'");
+  while ($node = db_fetch_object($nodes)) {
+    node_delete($node->nid);
+  }
+  node_type_delete('merci_reservation');
+
+  // You'd think the uninstall submit function would take care of this
+  // but it doesn't look like it.
+  node_types_rebuild();
+  menu_rebuild();
+
+  // Remove field_merci_date.
+  module_load_include('inc', 'content', 'includes/content.crud');
+  content_field_instance_delete('field_merci_date', 'merci_reservation');
+
+  // Remove tables.
+  drupal_uninstall_schema('merci');
+}
+
+/**
+ * Implementation of hook_enable().
+ */
+function merci_enable() {
+
+  // Not sure if we need this.
+  module_enable(array('date'));
+  // Create the date field for the reservation, if not yet created.
+
+  $field = content_fields('field_merci_date');
+
+  if(!isset($field)){
+
   $field = array(
     'field_name' => 'field_merci_date',
     'type_name' => 'merci_reservation',
@@ -103,54 +160,7 @@ function merci_install() {
   // Create the field.
   content_field_instance_create($field);
 
-}
-
-/**
- * Implementation of hook_uninstall().
- */
-function merci_uninstall() {
-
-  // Remove all MERCI variables.
-  $variables = db_query("SELECT name FROM {variable} WHERE name LIKE 'merci_%'");
-  while ($variable = db_fetch_object($variables)) {
-    variable_del($variable->name);
-  }
-
-  // Remove all MERCI content types and all associated nodes.
-  $content_types = db_query("SELECT type FROM {merci_node_type} WHERE type_setting <> 'disabled'");
-  while ($content_type = db_fetch_object($content_types)) {
-    $nodes = db_query("SELECT nid FROM {node} WHERE type = '%s'", $content_type->type);
-    while ($node = db_fetch_object($nodes)) {
-      node_delete($node->nid);
-    }
-  	node_type_delete($content_type->type);
-  }
-
-  // Remove the programatically created reservation node type
-  // and all associated nodes.
-  $nodes = db_query("SELECT nid FROM {node} WHERE type = 'merci_reservation'");
-  while ($node = db_fetch_object($nodes)) {
-    node_delete($node->nid);
   }
-  node_type_delete('merci_reservation');
-
-  // You'd think the uninstall submit function would take care of this
-  // but it doesn't look like it.
-  node_types_rebuild();
-  menu_rebuild();
-
-  // Remove field_merci_date.
-  module_load_include('inc', 'content', 'includes/content.crud');
-  content_field_instance_delete('field_merci_date', 'merci_reservation');
-
-  // Remove tables.
-  drupal_uninstall_schema('merci');
-}
-
-/**
- * Implementation of hook_enable().
- */
-function merci_enable() {
   // Add any node types to the MERCI tables that aren't already there.
   $existing_types = db_query("SELECT type FROM {merci_node_type}");
   $types = array();
