2003-08-18 17:21:53 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
// module.php - allows admin to edit all local configuration variables for a module
|
|
|
|
|
2006-03-06 14:25:26 +00:00
|
|
|
require_once('../config.php');
|
|
|
|
|
2003-08-18 17:21:53 +00:00
|
|
|
require_login();
|
|
|
|
|
|
|
|
if (!isadmin()) {
|
|
|
|
error("Only an admin can use this page");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$site = get_site()) {
|
|
|
|
error("Site isn't defined!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/// If data submitted, then process and store.
|
|
|
|
|
2005-01-22 19:53:28 +00:00
|
|
|
if ($config = data_submitted()) {
|
2006-03-16 10:11:06 +00:00
|
|
|
$module = optional_param('module', '', PARAM_SAFEDIR);
|
2005-01-22 19:53:28 +00:00
|
|
|
|
|
|
|
if (!confirm_sesskey()) {
|
|
|
|
error(get_string('confirmsesskeybad', 'error'));
|
|
|
|
}
|
2006-03-06 14:25:26 +00:00
|
|
|
|
2006-03-16 10:11:06 +00:00
|
|
|
if ($module != '') {
|
|
|
|
require_once("$CFG->dirroot/mod/$module/lib.php");
|
2005-04-28 07:40:21 +00:00
|
|
|
// 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
|
|
|
|
$moduleconfig = $module.'_process_options';
|
|
|
|
if (function_exists($moduleconfig)) {
|
|
|
|
$moduleconfig($config);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$moduleprefix = '';
|
|
|
|
}
|
|
|
|
|
2006-03-16 10:22:40 +00:00
|
|
|
unset($config->sesskey);
|
|
|
|
unset($config->module);
|
|
|
|
|
2003-08-18 17:21:53 +00:00
|
|
|
foreach ($config as $name => $value) {
|
2005-04-28 07:40:21 +00:00
|
|
|
set_config($moduleprefix.$name, $value);
|
2003-08-18 17:21:53 +00:00
|
|
|
}
|
|
|
|
redirect("$CFG->wwwroot/$CFG->admin/modules.php", get_string("changessaved"), 1);
|
|
|
|
exit;
|
2005-04-28 07:40:21 +00:00
|
|
|
}
|
2003-08-18 17:21:53 +00:00
|
|
|
|
|
|
|
/// Otherwise print the form.
|
2006-03-16 10:11:06 +00:00
|
|
|
$module = required_param('module', PARAM_SAFEDIR);
|
|
|
|
require_once("$CFG->dirroot/mod/$module/lib.php");
|
2003-08-18 17:21:53 +00:00
|
|
|
|
|
|
|
$stradmin = get_string("administration");
|
|
|
|
$strconfiguration = get_string("configuration");
|
|
|
|
$strmanagemodules = get_string("managemodules");
|
|
|
|
$strmodulename = get_string("modulename", $module);
|
2006-03-03 03:32:15 +00:00
|
|
|
|
|
|
|
// $CFG->pagepath is used to generate the body and id attributes for the body tag
|
|
|
|
// of the page. It is also used to generate the link to the Moodle Docs for this view.
|
|
|
|
$CFG->pagepath = 'mod/' . $module . '/config';
|
|
|
|
|
2003-10-06 18:02:35 +00:00
|
|
|
print_header("$site->shortname: $strmodulename: $strconfiguration", $site->fullname,
|
2003-08-18 17:21:53 +00:00
|
|
|
"<a href=\"index.php\">$stradmin</a> -> ".
|
|
|
|
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
2003-10-09 08:45:10 +00:00
|
|
|
"<a href=\"modules.php\">$strmanagemodules</a> -> $strmodulename");
|
2003-08-18 17:21:53 +00:00
|
|
|
|
|
|
|
print_heading($strmodulename);
|
|
|
|
|
2006-03-12 19:14:56 +00:00
|
|
|
print_simple_box("<center>".get_string("configwarning", 'admin')."</center>", "center", "60%");
|
2003-08-20 12:04:18 +00:00
|
|
|
echo "<br />";
|
|
|
|
|
2005-01-25 17:08:05 +00:00
|
|
|
print_simple_box_start("center", "");
|
2005-04-28 07:40:21 +00:00
|
|
|
include("$CFG->dirroot/mod/$module/config.html");
|
2003-08-18 17:21:53 +00:00
|
|
|
print_simple_box_end();
|
|
|
|
|
|
|
|
print_footer();
|
|
|
|
|
|
|
|
?>
|