MDL-11515:
[moodle-linuxchix.git] / admin / module.php
blob396cf85479f422fc472d6299b63d7f70620dd32b
1 <?PHP // $Id$
2 // module.php - allows admin to edit all local configuration variables for a module
4 require_once('../config.php');
5 require_once($CFG->libdir.'/adminlib.php');
7 admin_externalpage_setup('managemodules');
9 /// If data submitted, then process and store.
11 if ($config = data_submitted()) {
12 $module = optional_param('module', '', PARAM_SAFEDIR);
14 if (!confirm_sesskey()) {
15 error(get_string('confirmsesskeybad', 'error'));
18 if ($module != '') {
19 require_once("$CFG->dirroot/mod/$module/lib.php");
20 // if the config.html contains a hidden form field giving
21 // the module name then the form does not have to prefix all
22 // its variable names, we will do it here.
23 $moduleprefix = $module.'_';
24 // let the module process the form data if it has to,
25 // $config is passed to this function by reference
26 $moduleconfig = $module.'_process_options';
27 if (function_exists($moduleconfig)) {
28 $moduleconfig($config);
30 } else {
31 $moduleprefix = '';
34 unset($config->sesskey);
35 unset($config->module);
37 foreach ($config as $name => $value) {
38 set_config($moduleprefix.$name, $value);
40 redirect("$CFG->wwwroot/$CFG->admin/modules.php", get_string("changessaved"), 1);
41 exit;
44 /// Otherwise print the form.
45 $module = required_param('module', PARAM_SAFEDIR);
46 require_once("$CFG->dirroot/mod/$module/lib.php");
48 $strmodulename = get_string("modulename", $module);
50 // $CFG->pagepath is used to generate the body and id attributes for the body tag
51 // of the page. It is also used to generate the link to the Moodle Docs for this view.
52 $CFG->pagepath = 'mod/' . $module . '/config';
54 admin_externalpage_print_header();
56 print_heading($strmodulename);
58 print_simple_box(get_string("configwarning", 'admin'), "center", "60%");
59 echo "<br />";
61 print_simple_box_start("center", "");
62 include("$CFG->dirroot/mod/$module/config.html");
63 print_simple_box_end();
65 admin_externalpage_print_footer();