summaryrefslogtreecommitdiff
path: root/includes/install.inc
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-08-29 20:46:18 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-08-29 20:46:18 +0000
commit2765d143c03bb4b811f09a83fcff41a9e9ec53ac (patch)
tree33a667115a3011c22771d8b7373d0b9e948387bb /includes/install.inc
parent82fe475b60d652da877ceb9383315a7efa6f2729 (diff)
downloadbrdo-2765d143c03bb4b811f09a83fcff41a9e9ec53ac.tar.gz
brdo-2765d143c03bb4b811f09a83fcff41a9e9ec53ac.tar.bz2
#147657 by chx: menu module update function
Diffstat (limited to 'includes/install.inc')
-rw-r--r--includes/install.inc26
1 files changed, 26 insertions, 0 deletions
diff --git a/includes/install.inc b/includes/install.inc
index 6d273bac8..8676b03bc 100644
--- a/includes/install.inc
+++ b/includes/install.inc
@@ -353,6 +353,32 @@ function drupal_install_modules($module_list = array()) {
function drupal_uninstall_module($module) {
module_load_install($module);
module_invoke($module, 'uninstall');
+
+ // Remove menu links for paths declared by this module.
+ drupal_load('module', $module);
+ $paths = module_invoke($module, 'menu');
+ if (!empty($paths)) {
+ $paths = array_keys($paths);
+ // Clean out the names of load functions.
+ foreach($paths as $index => $path) {
+ $parts = explode('/', $path, MENU_MAX_PARTS);
+ foreach ($parts as $k => $part) {
+ if (preg_match('/^%[a-z_]*$/', $part)) {
+ $parts[$k] = '%';
+ }
+ }
+ $paths[$index] = implode('/', $parts);
+ }
+ $placeholders = implode(', ', array_fill(0, count($paths), "'%s'"));
+
+ $result = db_query('SELECT * FROM {menu_links} WHERE router_path IN ('. $placeholders .') AND external = 0 ORDER BY depth DESC', $paths);
+ // Remove all such items. Starting from those with the greatest depth will
+ // minimize the amount of re-parenting done by menu_link_delete().
+ while ($item = db_fetch_array($result)) {
+ _menu_delete_item($item, TRUE);
+ }
+ }
+
drupal_set_installed_schema_version($module, SCHEMA_UNINSTALLED);
}