From dba1f6bcdbe28af6b9e75f4c1698ec147f88b698 Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Thu, 28 Apr 2005 07:40:21 +0000 Subject: [PATCH] Added a few lines so that if modules set the module name in a hidden field in their config.html then the form does not have to prefix all its variables. That makes it simpler to produce config.html by copy and paste from mod.html. Also then if the module provides a function modulename_process_options then the form variables can be processed by the module before being stored in $CFG. --- admin/module.php | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/admin/module.php b/admin/module.php index dccac9c1a9b..f5c4522b2bd 100644 --- a/admin/module.php +++ b/admin/module.php @@ -20,21 +20,36 @@ if (!confirm_sesskey()) { error(get_string('confirmsesskeybad', 'error')); } + + if ($module = optional_param('module', '', PARAM_CLEANFILE)) { + // if the config.html contains a hidden form field giving + // the module name then the form does not have to prefix all + // its variable names, we will do it here. + $moduleprefix = $module.'_'; + // let the module process the form data if it has to, + // $config is passed to this function by reference + require_once("$CFG->dirroot/mod/$module/lib.php"); + $moduleconfig = $module.'_process_options'; + if (function_exists($moduleconfig)) { + $moduleconfig($config); + } + } else { + $moduleprefix = ''; + } + print_header(); + foreach ($config as $name => $value) { - set_config($name, $value); + set_config($moduleprefix.$name, $value); } redirect("$CFG->wwwroot/$CFG->admin/modules.php", get_string("changessaved"), 1); exit; - } + } /// Otherwise print the form. - require_variable($module); - - $module = clean_filename($module); - require_once("$CFG->dirroot/mod/$module/lib.php"); - + $module = required_param('module', '', PARAM_CLEANFILE); + require_once("$CFG->dirroot/mod/$module/lib.php"); $stradmin = get_string("administration"); $strconfiguration = get_string("configuration"); @@ -52,7 +67,7 @@ echo "
"; print_simple_box_start("center", ""); - include("$CFG->dirroot/mod/$module/config.html"); + include("$CFG->dirroot/mod/$module/config.html"); print_simple_box_end(); print_footer();