? .DS_Store
? enable_image_gallery_470720.patch
? image-44057_2.patch
? image-HEAD.access_0.patch
? image.enable.patch
? image_gallery-409974-2_1.patch
? joachim-image.enable.patch
? contrib/.DS_Store
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.13
diff -u -p -r1.13 image_gallery.install
--- contrib/image_gallery/image_gallery.install	9 Aug 2009 17:03:03 -0000	1.13
+++ contrib/image_gallery/image_gallery.install	9 Aug 2009 17:05:33 -0000
@@ -10,27 +10,12 @@ function image_gallery_install() {
 }
 
 /**
- * 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();
 }
 
 /**
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.40
diff -u -p -r1.40 image_gallery.module
--- contrib/image_gallery/image_gallery.module	9 Aug 2009 17:03:03 -0000	1.40
+++ contrib/image_gallery/image_gallery.module	9 Aug 2009 17:05:34 -0000
@@ -505,12 +505,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'];
     }
