365406fb02abc3072d60acf29410aba697b5c645
 spaces.install              |   11 ++++++++++-
 spaces_og/spaces_og.install |   40 ++++++++++++++++++++++++++++++++++++++++
 spaces_og/spaces_og.module  |   27 ---------------------------
 3 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/spaces.install b/spaces.install
index 7663e6e..a54ca80 100644
--- a/spaces.install
+++ b/spaces.install
@@ -18,7 +18,7 @@ function spaces_uninstall() {
  * Implementaton of hook_enable().
  */
 function spaces_enable() {
-  db_query("UPDATE {system} SET weight = -1 WHERE name = 'spaces' AND type = 'module'");
+  db_query("UPDATE {system} SET weight = 1 WHERE name = 'spaces' AND type = 'module'");
 }
 
 /**
@@ -358,6 +358,15 @@ function spaces_update_6302() {
 }
 
 /**
+ * Increase the weight of spaces so hook_menu_alter runs later.
+ */
+function spaces_update_6303() {
+  $ret = array();
+  $ret[] = update_sql("UPDATE {system} SET weight = 1 WHERE name = 'spaces' AND type = 'module'");
+  return $ret;
+}
+
+/**
  * Helper function to update spaces 2 presets to spaces 3.
  * Expects spaces 3 schema to be fully installed.
  */
diff --git a/spaces_og/spaces_og.install b/spaces_og/spaces_og.install
new file mode 100644
index 0000000..b8d781d
--- /dev/null
+++ b/spaces_og/spaces_og.install
@@ -0,0 +1,40 @@
+<?php
+// $Id$
+
+/**
+ * Implementaton of hook_enable().
+ */
+function spaces_og_enable() {
+
+  // Configure purl, grab OG method, set to path if not configured.
+  $purl_types = variable_get('purl_types', array());
+  if (!variable_get('purl_method_spaces_og', FALSE)) {
+    $purl_types['path'] = 'path';
+    variable_set('purl_types', $purl_types);
+    variable_set('purl_method_spaces_og', 'path');
+  }
+
+  // The next 2 lines are for Simpletest, it won't have it otherwise.
+  // variable_get up top retrieves the settings from the host, while
+  // variable_set here writes into the test site. As a result,
+  // variable_get('purl_method_spaces_og') will retrieve the value of the host
+  // site. If it is present in the host site, the initial configuration is not
+  // being executed and the tests fail.
+  variable_set('purl_types', $purl_types);
+  variable_set('purl_method_spaces_og', variable_get('purl_method_spaces_og', FALSE));
+
+  // Weight spaces_og to be after OG
+  $weight = db_result(db_query("SELECT MAX(weight) FROM {system} WHERE type = 'module' AND name in ('og', 'spaces')"));
+  db_query("UPDATE {system} SET weight = %d WHERE name = 'spaces_og'", ($weight + 1));
+}
+
+/**
+ * Increase the weight of spaces_og so hook_menu_alter runs after spaces.
+ */
+function spaces_og_update_6301() {
+  $ret = array();
+  // Weight spaces_og to be after OG
+  $weight = db_result(db_query("SELECT MAX(weight) FROM {system} WHERE type = 'module' AND name in ('og', 'spaces')"));
+  $ret[] = update_sql("UPDATE {system} SET weight = " . ($weight + 1) . " WHERE name = 'spaces_og' AND type = 'module'");
+  return $ret;
+}
diff --git a/spaces_og/spaces_og.module b/spaces_og/spaces_og.module
index 7283bad..f43d7f7 100644
--- a/spaces_og/spaces_og.module
+++ b/spaces_og/spaces_og.module
@@ -13,33 +13,6 @@ function spaces_og_ctools_plugin_api($module, $api) {
 }
 
 /**
- * Implementaton of hook_enable().
- */
-function spaces_og_enable() {
-
-  // Configure purl, grab OG method, set to path if not configured.
-  $purl_types = variable_get('purl_types', array());
-  if (!variable_get('purl_method_spaces_og', FALSE)) {
-    $purl_types['path'] = 'path';
-    variable_set('purl_types', $purl_types);
-    variable_set('purl_method_spaces_og', 'path');
-  }
-
-  // The next 2 lines are for Simpletest, it won't have it otherwise.
-  // variable_get up top retrieves the settings from the host, while
-  // variable_set here writes into the test site. As a result,
-  // variable_get('purl_method_spaces_og') will retrieve the value of the host
-  // site. If it is present in the host site, the initial configuration is not
-  // being executed and the tests fail.
-  variable_set('purl_types', $purl_types);
-  variable_set('purl_method_spaces_og', variable_get('purl_method_spaces_og', FALSE));
-
-  // Weight spaces_og to be after OG
-  $weight = db_result(db_query("SELECT weight FROM {system} WHERE type = 'module' AND name = 'og'"));
-  db_query("UPDATE {system} SET weight = %d WHERE name = 'spaces_og'", ($weight + 1));
-}
-
-/**
  * Implementation of hook_purl_provider().
  */
 function spaces_og_purl_provider() {
