Commit 4ad174c4 authored by Dries's avatar Dries

- Eliminated system_init(), the session stuff, and made it possible to
  rebuild the menu.
parent 127c6fd4
......@@ -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);
}
?>
......@@ -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");
......
......@@ -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") ;
......
......@@ -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 {
......
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment