From 8f5c4adbd71b476f58be8e8161b30e7221522075 Mon Sep 17 00:00:00 2001 From: vinkmar Date: Mon, 4 Sep 2006 21:38:23 +0000 Subject: [PATCH] Changed so that the settingpage titles are shown (see MDL-6402) --- admin/upgradesettings.php | 48 +++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/admin/upgradesettings.php b/admin/upgradesettings.php index 3638c3f326..6aada5879e 100644 --- a/admin/upgradesettings.php +++ b/admin/upgradesettings.php @@ -6,7 +6,7 @@ require_once('../config.php'); require_once($CFG->libdir.'/adminlib.php'); - $adminroot = admin_get_root(); +$adminroot = admin_get_root(); admin_externalpage_setup('adminnotifications', $adminroot); // we pretend to be the adminnotifications page... don't wanna show up in the menu :) // a caveat: we're depending on only having one admin access this page at once. why? the following line @@ -14,10 +14,10 @@ admin_externalpage_setup('adminnotifications', $adminroot); // we pretend to be // page is loaded (i.e. both when we're displaying the form and then when we process the form's input). // if the return values don't match, we could potentially lose changes that the admin is making. -$newsettings = find_new_settings(admin_get_root()); +$newsettingshtml = output_new_settings_by_page(admin_get_root()); // first we deal with the case where there are no new settings to be set -if (count($newsettings) === 0) { +if ($newsettingshtml == '') { redirect($CFG->wwwroot . '/' . $CFG->admin . '/index.php', get_string('nonewsettings','admin'),1); die; } @@ -26,6 +26,7 @@ if (count($newsettings) === 0) { if ($data = data_submitted()) { $data = (array)$data; if (confirm_sesskey()) { + $newsettings = find_new_settings(admin_get_root()); $errors = ''; foreach($newsettings as $newsetting) { @@ -61,9 +62,7 @@ print_simple_box_start('','100%','',5,'generalbox',''); print_heading(get_string('upgradesettings','admin')); echo '' . "\n"; echo ''; -foreach ($newsettings as $newsetting) { - echo $newsetting->output_html(); -} +echo $newsettingshtml; echo '
' . get_string('upgradesettingsintro','admin') . '
'; echo '
'; print_simple_box_end(); @@ -72,9 +71,6 @@ echo ''; admin_externalpage_print_footer($adminroot); - -// function that we use (vital to this page working) - /** * Find settings that have not been initialized (e.g. during initial install or an upgrade). * @@ -111,4 +107,38 @@ function find_new_settings(&$node) { } +function output_new_settings_by_page(&$node) { + + if (is_a($node, 'admin_category')) { + $entries = array_keys($node->children); + $return = ''; + foreach ($entries as $entry) { + $return .= output_new_settings_by_page($node->children[$entry]); + } + return $return; + } + + if (is_a($node, 'admin_settingpage')) { + $newsettings = array(); + foreach ($node->settings as $setting) { + if ($setting->get_setting() === NULL) { + $newsettings[] =& $setting; + } + unset($setting); // needed to prevent odd (imho) reference behaviour + // see http://www.php.net/manual/en/language.references.whatdo.php#AEN6399 + } + $return = ''; + if (count($newsettings) > 0) { + $return = '' . $node->visiblename . ''; + foreach ($newsettings as $newsetting) { + $return .= $newsetting->output_html(); + } + } + return $return; + } + + return ''; + +} + ?> \ No newline at end of file -- 2.39.5