diff options
-rw-r--r-- | includes/menu.inc | 9 | ||||
-rw-r--r-- | includes/module.inc | 6 | ||||
-rw-r--r-- | modules/admin.module | 6 | ||||
-rw-r--r-- | modules/system.module | 33 | ||||
-rw-r--r-- | modules/system/system.module | 33 |
5 files changed, 41 insertions, 46 deletions
diff --git a/includes/menu.inc b/includes/menu.inc index 13cad943e..58422702e 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -163,4 +163,13 @@ function menu_execute_action() { } } +function menu_build($type) { + + // Empty the existing menu tree (if any): + unset($GLOBALS["_gmenu"]); + + // Build the menu tree: + module_invoke_all("link", $type); +} + ?> diff --git a/includes/module.inc b/includes/module.inc index a3a1be482..a8214e49c 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -41,9 +41,13 @@ function module_invoke_all($hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL } // return array of module names (includes lazy module loading): -function module_list() { +function module_list($refresh = 0) { static $list; + if ($refresh) { + unset($list); + } + if (!$list) { $list = array("system" => "system", "user" => "user", "watchdog" => "watchdog"); $result = db_query("SELECT name, filename FROM system WHERE type = 'module' AND status = '1' ORDER BY name"); diff --git a/modules/admin.module b/modules/admin.module index 9fb1a34bb..866aec55b 100644 --- a/modules/admin.module +++ b/modules/admin.module @@ -44,7 +44,7 @@ function admin_page() { <?php // NOTE: we include a dummy "print.css" to remove the "flash of unstyled content" (FUOC) problems in IE. - module_invoke_all("link", "admin"); + menu_build("admin"); /* ** Body: @@ -79,8 +79,12 @@ function admin_page() { /* ** Menu: + ** We rebuild the admin menu once more because one might have + ** enabled/disabled themes or modules, changed permissions, etc. */ + menu_build("admin"); + print "<div id=\"menu\">"; echo "<h1><a href=\"index.php\">". variable_get("site_name", "drupal") ."</a></h1>"; print menu_tree("admin") ; diff --git a/modules/system.module b/modules/system.module index 2f351580d..636b61f3b 100644 --- a/modules/system.module +++ b/modules/system.module @@ -44,7 +44,8 @@ function system_link($type) { menu("admin/system", "site configuration", "system_admin", $help["general"], 3); menu("admin/system/themes", "themes", "system_admin", $help["themes"], 2); - foreach (theme_list() as $theme) { + foreach (theme_list(1) as $theme) { + // NOTE: refresh the list because some themes might have been enabled/disabled. include_once "$theme->filename"; $function = $theme->name ."_settings"; if (function_exists($function)) { @@ -53,7 +54,8 @@ function system_link($type) { } menu("admin/system/modules", "modules", "system_admin", $help["modules"], 3); - foreach (module_list() as $name) { + foreach (module_list(1) as $name) { + // NOTE: refresh the list because some modules might have been enabled/disabled. if (module_hook($name, "settings")) { menu("admin/system/modules/$name", $name, "system_admin", module_invoke($name, "system", "description")); } @@ -299,31 +301,18 @@ function system_listing($type, $directory, $required = array()) { return $output; } -function system_init() { - global $HTTP_POST_VARS, $REQUEST_URI, $system_init_status; +function system_admin() { + global $op, $edit; - session_register("system_init_status"); if (user_access("administer site configuration")) { - if (isset($HTTP_POST_VARS["op"]) && $HTTP_POST_VARS["op"] == t("Reset to defaults")) { - $system_init_status = status(system_reset_default($HTTP_POST_VARS["edit"])); - } - else if (isset($HTTP_POST_VARS["op"]) && $HTTP_POST_VARS["op"] == t("Save configuration")) { - $system_init_status = status(system_save_settings($HTTP_POST_VARS["edit"])); + if ($op == t("Reset to defaults")) { + print status(system_reset_default($edit)); } - else { - return; - } - drupal_goto("$REQUEST_URI"); - } -} -function system_admin() { - global $system_init_status; + if ($op == t("Save configuration")) { + print status(system_save_settings($edit)); + } - if (user_access("administer site configuration")) { - session_register("system_init_status"); - print $system_init_status; - session_unregister("system_init_status"); print system_view(arg(2), arg(3)); } else { diff --git a/modules/system/system.module b/modules/system/system.module index 2f351580d..636b61f3b 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -44,7 +44,8 @@ function system_link($type) { menu("admin/system", "site configuration", "system_admin", $help["general"], 3); menu("admin/system/themes", "themes", "system_admin", $help["themes"], 2); - foreach (theme_list() as $theme) { + foreach (theme_list(1) as $theme) { + // NOTE: refresh the list because some themes might have been enabled/disabled. include_once "$theme->filename"; $function = $theme->name ."_settings"; if (function_exists($function)) { @@ -53,7 +54,8 @@ function system_link($type) { } menu("admin/system/modules", "modules", "system_admin", $help["modules"], 3); - foreach (module_list() as $name) { + foreach (module_list(1) as $name) { + // NOTE: refresh the list because some modules might have been enabled/disabled. if (module_hook($name, "settings")) { menu("admin/system/modules/$name", $name, "system_admin", module_invoke($name, "system", "description")); } @@ -299,31 +301,18 @@ function system_listing($type, $directory, $required = array()) { return $output; } -function system_init() { - global $HTTP_POST_VARS, $REQUEST_URI, $system_init_status; +function system_admin() { + global $op, $edit; - session_register("system_init_status"); if (user_access("administer site configuration")) { - if (isset($HTTP_POST_VARS["op"]) && $HTTP_POST_VARS["op"] == t("Reset to defaults")) { - $system_init_status = status(system_reset_default($HTTP_POST_VARS["edit"])); - } - else if (isset($HTTP_POST_VARS["op"]) && $HTTP_POST_VARS["op"] == t("Save configuration")) { - $system_init_status = status(system_save_settings($HTTP_POST_VARS["edit"])); + if ($op == t("Reset to defaults")) { + print status(system_reset_default($edit)); } - else { - return; - } - drupal_goto("$REQUEST_URI"); - } -} -function system_admin() { - global $system_init_status; + if ($op == t("Save configuration")) { + print status(system_save_settings($edit)); + } - if (user_access("administer site configuration")) { - session_register("system_init_status"); - print $system_init_status; - session_unregister("system_init_status"); print system_view(arg(2), arg(3)); } else { |