Index: contrib/image_gallery/image_gallery.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_gallery/image_gallery.install,v
retrieving revision 1.10
diff -u -p -r1.10 image_gallery.install
--- contrib/image_gallery/image_gallery.install	22 Jan 2009 12:17:20 -0000	1.10
+++ contrib/image_gallery/image_gallery.install	12 Jul 2009 20:29:08 -0000
@@ -1,53 +1,39 @@
 <?php
 // $Id: image_gallery.install,v 1.10 2009/01/22 12:17:20 sun Exp $
 
-function image_gallery_install() {
-  // Nothing to do.
-}
-
 /**
- * Implementation of hook_requirements().
+ * Implementation of hook_enable().
  */
-function image_gallery_requirements($phase) {
-  $requirements = array();
-  if ($phase == 'runtime') {
-    // If no galleries are defined, indicate a warning.
-    $tree = taxonomy_get_tree(_image_gallery_get_vid());
-    $requirements['image_gallery'] = array('title' => t('Image gallery'));
-    if ($tree) {
-      $requirements['image_gallery']['value'] = t('Galleries defined');
-      $requirements['image_gallery']['severity'] = REQUIREMENT_OK;
-    }
-    else {
-      $requirements['image_gallery']['value'] = t('No galleries defined');
-      $requirements['image_gallery']['description'] =
-        t('The Image gallery module is enabled, but no galleries have been created. You should <a href="@create">create</a> at least one image gallery.',
-          array('@create' => url('admin/content/image/add')));
-      $requirements['image_gallery']['severity'] = REQUIREMENT_WARNING;
-    }
-  }
-  return $requirements;
+function image_gallery_enable() {
+  // Ensure a proper vocabulary after re-enabling the module.
+  drupal_load('module', 'image_gallery');
+  _image_gallery_get_vid();
 }
 
-
+/**
+ * Implementation of hook_uninstall().
+ */
 function image_gallery_uninstall() {
   if ($vid = variable_get('image_gallery_nav_vocabulary', FALSE)) {
     module_invoke('taxonomy', 'del_vocabulary', $vid);
   }
-
   variable_del('image_images_per_page');
   variable_del('image_gallery_nav_vocabulary');
   variable_del('image_gallery_node_info');
   variable_del('image_gallery_sort_order');
 }
 
+/**
+ * Re-assign image vocabularies to image_gallery module.
+ */
 function image_gallery_update_1() {
   $ret = array();
   if ($vid = variable_get('image_nav_vocabulary', '')) {
-    $ret[] = update_sql("UPDATE {vocabulary} SET module='image_gallery' WHERE vid=". (int) $vid);
+    $ret[] = update_sql("UPDATE {vocabulary} SET module = 'image_gallery' WHERE vid = " . (int) $vid);
   }
   else {
-    $ret[] = update_sql("UPDATE {vocabulary} SET module='image_gallery' WHERE module='image'");
+    $ret[] = update_sql("UPDATE {vocabulary} SET module = 'image_gallery' WHERE module = 'image'");
   }
   return $ret;
 }
+
Index: contrib/image_gallery/image_gallery.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_gallery/image_gallery.module,v
retrieving revision 1.34
diff -u -p -r1.34 image_gallery.module
--- contrib/image_gallery/image_gallery.module	12 Jul 2009 18:26:19 -0000	1.34
+++ contrib/image_gallery/image_gallery.module	12 Jul 2009 20:26:56 -0000
@@ -453,12 +453,34 @@ function theme_image_gallery_img($image,
  * Returns (and possibly creates) a new vocabulary for Image galleries.
  */
 function _image_gallery_get_vid() {
-  $vid = variable_get('image_gallery_nav_vocabulary', '');
-  if (empty($vid) || is_null(taxonomy_vocabulary_load($vid))) {
-    // Check to see if an image gallery vocabulary exists
-    $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='image_gallery'"));
-    if (!$vid) {
-      $vocabulary = array('name' => t('Image Galleries'), 'multiple' => '0', 'required' => '0', 'hierarchy' => '1', 'relations' => '0', 'module' => 'image_gallery', 'nodes' => array('image' => 1));
+  $vid = variable_get('image_gallery_nav_vocabulary', NULL);
+  // This is invoked from many locations and only D7 ensures that required
+  // modules are installed/enabled first.
+  // @todo Perhaps also disable image_gallery module and report an error?
+  if (!module_exists('taxonomy')) {
+    return $vid;
+  }
+  if (empty($vid) || !($vocabulary = taxonomy_vocabulary_load($vid))) {
+    // Check to see if an image gallery vocabulary exists.
+    $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module = 'image_gallery'"));
+    if (!$vid && !$vocabulary) {
+      $vocabulary = array(
+        'name' => t('Image Galleries'),
+        'multiple' => 0,
+        'required' => 0,
+        'hierarchy' => 1,
+        'relations' => 0,
+        'module' => 'image_gallery',
+        'nodes' => array('image' => 1),
+      );
+      taxonomy_save_vocabulary($vocabulary);
+      $vid = $vocabulary['vid'];
+    }
+    elseif ($vocabulary) {
+      // Existing install; ensure that image node type is still assigned.
+      // Keep all other node types intact there.
+      $vocabulary = (array) $vocabulary;
+      $vocabulary['nodes']['image'] = 1;
       taxonomy_save_vocabulary($vocabulary);
       $vid = $vocabulary['vid'];
     }
