--- ed_classified.module_old	2007-08-05 10:30:05.000000000 -0700
+++ ed_classified.module	2007-09-22 10:02:06.000000000 -0700
@@ -1263,6 +1263,24 @@ function _ed_classified_ad_expires_soon(
 function _ed_classified_ad_expired_already($expiration_date) {
   return $expiration_date <= time();
 }
+
+/**
+ * Implementation of hook_enable.
+ *
+ * Make sure there is a vocabulary. If the module was disabled ad re-enabled,
+ * see if there's an existing vocabulary and associate it with this node type.
+ */
+function ed_classified_enable() {
+  $vid = _ed_classified_get_vid();
+  $vid_node_type = db_result(db_query("SELECT vid FROM {vocabulary_node_types} WHERE vid = '%d' AND type = '%s'", $vid, EDI_CLASSIFIED_MODULE_NAME));
+      
+  if (!$vid_node_type) {
+    db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $vid, EDI_CLASSIFIED_MODULE_NAME);
+  }
+  
+}
+
+
 /**
  * Returns (and possibly creates) a new vocabulary for classified
  * Lifted from image.module.
@@ -1270,7 +1288,7 @@ function _ed_classified_ad_expired_alrea
  */
 function _ed_classified_get_vid() {
   $vid = _ed_classified_variable_get('vocabulary', '');
-  if (empty($vid)) {
+  if (empty($vid) || !taxonomy_get_vocabulary($vid)) {
     // Check to see if classified ads vocabulary exists
     $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='%s'", EDI_CLASSIFIED_MODULE_NAME)); 
     if (!$vid) {
@@ -1285,10 +1303,26 @@ function _ed_classified_get_vid() {
                 'module' => EDI_CLASSIFIED_MODULE_NAME, 
                 'nodes' => array(EDI_CLASSIFIED_MODULE_NAME => 1)); 
       taxonomy_save_vocabulary($vocabulary);
-      $vid = $vocabulary['vid'];
-      $msg = "Classified Ads taxonomy" . $vocabulary->name . " (id=$vid) created.";
-      _edi_wd($msg);
-      drupal_set_message($msg);
+      if ($vid = $vocabulary['vid']) {
+        $sale = array(
+          'name' => t('For Sale'),
+          'description' => t('A generic category for selling items. Edit this term to personalize your classifieds.'),
+          'vid' => $vid,
+        );
+        
+        $want = array(
+          'name' => ('Wanted'),
+          'description' => t('A generic category for wanted items. Edit this term to personalize your classifieds.'),
+          'vid' => $vid,
+        );
+        
+        taxonomy_save_term($sale);
+        taxonomy_save_term($want);
+      
+        $msg = "Classified Ads taxonomy" . $vocabulary->name . " (id=$vid) created.";
+        _edi_wd($msg);
+        drupal_set_message($msg);
+      }
       // TODO: create standard terms and subterms specified in external file (or, at a minimum, create a few standard categories)
       // taxonomy_save_term(...);
     }
