MDL-11517 reserved word MOD used in table alias in questions backup code
[moodle-pu.git] / admin / filter.php
blobc372dda28a8843f2a4af84e91c7fe2fcd609ef1d
1 <?php // $Id$
2 // filter.php
3 // Edit text filter settings
5 require_once('../config.php');
6 require_once($CFG->libdir.'/adminlib.php');
7 require_once($CFG->libdir.'/tablelib.php');
9 admin_externalpage_setup('managefilters');
11 // get parameters
12 $param = new Object;
14 $param->filter = required_param('filter', PARAM_PATH);
15 $param->submit = optional_param('submit', 0, PARAM_BOOL);
16 $param->reset = optional_param('reset', 0, PARAM_BOOL);
18 $filtername = substr($param->filter, strpos( $param->filter, '/' )+1 ) ;
20 // $CFG->pagepath is used to generate the body and id attributes for the body tag
21 // of the page. It is also used to generate the link to the Moodle Docs for this view.
22 $CFG->pagepath = 'filter/' . $filtername . '/config';
24 // get translated strings for use on page
25 $txt = new Object;
26 $txt->managefilters = get_string( 'managefilters' );
27 $txt->administration = get_string( 'administration' );
28 $txt->configuration = get_string( 'configuration' );
30 //======================
31 // Process Actions
32 //======================
34 // if reset pressed let filter config page handle it
35 $forcereset = false;
36 if (!empty($param->reset)) {
37 $forcereset = true;
39 else
40 if ($config = data_submitted()) {
42 // check session key
43 if (!confirm_sesskey()) {
44 error( get_string('confirmsesskeybad', 'error' ) );
47 $configpath = $CFG->dirroot.'/filter/'.$filtername.'/filterconfig.php';
48 if (file_exists($configpath)) {
49 require_once($configpath);
50 $functionname = $filtername.'_process_config';
51 if (function_exists($functionname)) {
52 $functionname($config);
53 $saved = true;
57 if (empty($saved)) {
58 // run through submitted data
59 // reject if does not start with filter_
60 foreach ($config as $name => $value) {
61 set_config($name, stripslashes($value));
64 redirect("$CFG->wwwroot/$CFG->admin/filters.php");
65 exit;
68 //==============================
69 // Display logic
70 //==============================
72 $filtername = ucfirst($filtername);
73 admin_externalpage_print_header();
74 print_heading( $filtername );
76 print_simple_box(get_string("configwarning", "admin"), "center", "50%");
77 echo "<br />";
79 print_simple_box_start("center",'');
82 <form action="filter.php?filter=<?php echo urlencode($param->filter); ?>" method="post">
83 <div style="text-align: center">
84 <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
86 <?php include "$CFG->dirroot/$param->filter/filterconfig.html"; ?>
88 <input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" />
89 <input type="submit" name="reset" value="<?php echo print_string('resettodefaults'); ?>" />
90 </div>
91 </form>
93 <?php
94 print_simple_box_end();
96 admin_externalpage_print_footer();