Skip to content

Commit

Permalink
Added a few lines so that if modules set the module name in a hidden …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
gustav_delius committed Apr 28, 2005
1 parent 96aaed1 commit dba1f6b
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions admin/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -52,7 +67,7 @@
echo "<br />";

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();
Expand Down

0 comments on commit dba1f6b

Please sign in to comment.