diff -urp --strip-trailing-cr ../category/category_menu/category_menu.install ./category_menu/category_menu.install
--- ../category/category_menu/category_menu.install	2009-02-07 10:01:16.000000000 +0100
+++ ./category_menu/category_menu.install	2009-06-07 12:02:26.000000000 +0200
@@ -16,10 +16,26 @@ function category_menu_install() {
 }
 
 /**
+ * Implementation of hook_disable().
+ */
+function category_menu_disable() {
+  drupal_set_message(t('The <em>category_menu</em> module is now disabled. This means that generated menu items are no longer maintained. In order to avoid future problems with outdated menu items, it\'s highly recommended to either enable <em>category_menu</em>, or <a href="!url">uninstall</a> it entirely (removes all generated menu items).', array('!url' => url('admin/build/modules/uninstall'))), 'warning');
+}
+
+/**
  * Implementation of hook_uninstall().
  */
 function category_menu_uninstall() {
   drupal_uninstall_schema('category_menu');
+
+  $types = node_get_types('names');
+  foreach ($types as $type => $name) {
+    variable_del('category_menu_links_'. $type);
+  }
+  // Remove all generated menu links, as these are no longer maintained,
+  // and user can't delete them (only just disable).
+  db_query("DELETE FROM {menu_links} WHERE module = 'category_menu'");
+  menu_rebuild();
 }
 
 function category_menu_schema() {
diff -urp --strip-trailing-cr ../category/category_menu/category_menu.module ./category_menu/category_menu.module
--- ../category/category_menu/category_menu.module	2009-05-31 12:24:23.000000000 +0200
+++ ./category_menu/category_menu.module	2009-06-07 15:19:07.000000000 +0200
@@ -127,9 +127,38 @@ function category_menu_nodeapi(&$node, $
 }
 
 /**
+ * Implementation of hook_menu_link_alter().
+ *
+ * Deals with external changes to maintained menu links before they are saved,
+ * either by merging the changes back into category system, or disallowing
+ * the changes to be saved.
+ */
+function category_menu_menu_link_alter(&$item, $menu) {
+  if ($item['module'] == 'category_menu' && empty($item['options']['category_menu_unlock']) && !empty($item['mlid']) && $old_item = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $item['mlid']))) {
+    // Disallow changes to these values, because we cannot keep them: Next
+    // edit of the node is going to overwrite them.
+    foreach (array('expanded', 'plid', 'link_title', 'hidden') as $key) {
+      if ($item[$key] != $old_item[$key]) {
+        $item[$key] = $old_item[$key];
+      }
+    }
+    // Merge new menu item weight back to category, so that reordering of menus work.
+    // This is split into two queries, to avoid PgSQL compatibility issues on JOINs.
+    if ($item['weight'] != $old_item['weight']) {
+      $node = db_fetch_array(db_query("SELECT * FROM {category_menu_map} WHERE mlid = %d", $item['mlid']));
+      if (!empty($node['nid'])) {
+        db_query("UPDATE {category} SET weight = %d WHERE cid = %d", $item['weight'], $node['nid']);
+      }
+    }
+  }
+  unset($item['options']['category_menu_unlock']);
+}
+
+/**
  * Implementation of hook_form_alter().
  *
- * Adds the category menu settings to the container node form.
+ * Adds the category menu settings to the container node form,
+ * and alters menu overview screen for compatibility.
  */
 function category_menu_form_alter(&$form, $form_state, $form_id) {
   if (isset($form['type']) && isset($form['#node']) && $form['type']['#value']
@@ -149,6 +178,7 @@ function category_menu_form_alter(&$form
     $behavior = variable_get('category_behavior_'. $node->type, 0);
 
     if (!empty($behavior) && $behavior == 'container') {
+      $form['#submit'][] = 'category_menu_submit_container';
       $form['category']['menu'] = array(
         '#type' => 'fieldset',
         '#title' => t('Menu links'),
@@ -301,6 +331,49 @@ function category_menu_form_alter(&$form
       }
     }
   }
+
+  // Grey-out incompatible settings for maintained menu items on the menu overview
+  // screen, and swap edit link to point to corresponding node edit.
+  if ($form_id == 'menu_overview_form') {
+    $title = t('To change this item, you need to edit the corresponding node.');
+    foreach ($form as $key => $row) {
+      if (!empty($row['#item']['module']) && $row['#item']['module'] == 'category_menu') {
+        $form[$key]['hidden']['#disabled'] = TRUE;
+        $form[$key]['expanded']['#disabled'] = TRUE;
+        $form[$key]['operations']['edit']['#value'] = l(t('edit node'), $row['#item']['link_path'] .'/edit', array('query' => drupal_get_destination(), 'attributes' => array('title' => $title)));
+      }
+    }
+  }
+}
+
+/**
+ * Submit handler for the container node form.
+ *
+ * Shows a reminder to refresh site's data through category_resave, where needed.
+ */
+function category_menu_submit_container($form, &$form_state) {
+  // Edits affect the behavior only for pre-existing containers having categories,
+  // where fundamental menu links settings have been changed.
+  if ($form_state['values']['op'] == $form_state['values']['submit'] && !empty($form_state['values']['category']['cid']) && is_numeric($cid = $form_state['values']['category']['cid'])) {
+    if (db_fetch_array(db_query("SELECT * FROM {category} WHERE cnid = %d", $cid))) {
+      $affected = FALSE;
+      // Content types setting needs empty() check, due to encoding differences.
+      foreach ($form_state['values']['category']['menu']['links_for_nodes'] as $type => $enabled) {
+        $was_enabled = !empty($form['category']['menu']['links_for_nodes']['#default_value'][$type]);
+        if (!empty($enabled) != $was_enabled) {
+          $affected = TRUE;
+        }
+      }
+      foreach (array('links_for_cats', 'expanded_for_cats', 'menu_name') as $key) {
+        if ($form_state['values']['category']['menu'][$key] != $form['category']['menu'][$key]['#default_value']) {
+          $affected = TRUE;
+        }
+      }
+      if ($affected) {
+        drupal_set_message(t('Your changes affected behavior of generated menu links. To apply these changes properly, you need to refresh categories and/or nodes in this container now. The <em>category resave</em> module offers an easy way to perform this operation on existing content.'));
+      }
+    }
+  }
 }
 
 /**
@@ -585,7 +658,7 @@ function category_menu_map_load($mlid) {
  * during hook_nodeapi('load').
  */
 function category_menu_map_load_by_nid($nid) {
-  if ($item = db_fetch_array(db_query('SELECT ml.*, cmm.nid, m.* FROM {menu_links} ml INNER JOIN {category_menu_map} cmm ON cmm.mlid = ml.mlid LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE cmm.nid = %d', $nid))) {
+  if ($item = db_fetch_array(db_query('SELECT m.*, cmm.nid, ml.* FROM {menu_links} ml INNER JOIN {category_menu_map} cmm ON cmm.mlid = ml.mlid LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE cmm.nid = %d', $nid))) {
 
     $item['options'] = unserialize($item['options']);
     return $item;
@@ -650,6 +723,7 @@ function category_menu_map_save($node) {
     }
 
     $node->category_menu_map['expanded'] = $container_settings['expanded_for_cats'];
+    $node->category_menu_map['weight'] = $node->category['weight'];
   }
   // Logic for assigned node types.
   else {
@@ -692,6 +766,8 @@ function category_menu_map_save($node) {
     }
 
     $new_plid = $assigned_cat_menu_link['mlid'];
+    // Weight for nodes will be re-saved as is (if available), to keep possible
+    // menu order customizations.
   }
 
   $node->category_menu_map['menu_name'] = category_menu_menu_name($container_settings['menu_name'], $container_settings['cid']);
@@ -700,8 +776,10 @@ function category_menu_map_save($node) {
   $node->category_menu_map['parent_mismatch'] = FALSE;
   $node->category_menu_map['module'] = 'category_menu';
   $node->category_menu_map['plid'] = $new_plid;
+  $node->category_menu_map['hidden'] = (int) !$node->status;
   $menu_name = $node->category_menu_map['menu_name'];
 
+  $node->category_menu_map['options']['category_menu_unlock'] = TRUE;
   if (menu_link_save($node->category_menu_map)) {
     if ($new) {
       // Insert new.
