Index: nodehierarchy.module =================================================================== --- nodehierarchy.module (revision 454) +++ nodehierarchy.module (working copy) @@ -403,6 +403,25 @@ function nodehierarchy_insert_node(&$nod * Delete the nodehierarchy information when a node is deleted. */ function nodehierarchy_delete_node($node) { + // Also delete corresponding menu item if nodehierarchy_menu_noadmin is true + // Do this before actually removing the node from the hierarchy, else + // we can't get it's descendants anymore + if (function_exists('menu_node_form_delete') && + variable_get('nodehierarchy_menus', TRUE) && + variable_get('nodehierarchy_menu_noadmin', FALSE)) { + menu_node_form_delete($node); + + // Also delete all it descendant menu items, since they'll just end op + // somewhere where you don't want them (at root of this or another menu) + $node_descendants = nodehierarchy_get_descendant_list($node->nid); + foreach ($node_descendants as $node_descendant_id) { + $node_descendant = node_load($node_descendant_id); + menu_node_form_delete($node_descendant); + } + + menu_rebuild(); + } + db_query('DELETE FROM {nodehierarchy} WHERE nid = %d OR parent = %d', $node->nid, $node->nid); } @@ -1044,4 +1063,4 @@ function _nodehierarchy_get_parent_types } } return $types; -} \ No newline at end of file +}