Automatic installer.php lang files by installer_builder (20070202)
[moodle.git] / admin / filter.php
blob4b571fb6ed8efe764d9e3b2475aa0c6b8056160e
1 <?php // $Id$
2 // filter.php
3 // Edit text filter settings
5 require_once('../config.php');
6 require_once($CFG->libdir.'/tablelib.php');
8 // check for allowed access
9 require_login();
10 if (!isadmin()) {
11 error( 'Only administrators can use the filters administration page' );
13 if (!$site = get_site()) {
14 error( 'Site is not defined in filters administration page' );
17 // get parameters
18 $param = new Object;
20 $param->filter = required_param('filter', PARAM_PATH);
21 $param->submit = optional_param('submit', 0, PARAM_BOOL);
22 $param->reset = optional_param('reset', 0, PARAM_BOOL);
24 $filtername = substr($param->filter, strpos( $param->filter, '/' )+1 ) ;
26 // $CFG->pagepath is used to generate the body and id attributes for the body tag
27 // of the page. It is also used to generate the link to the Moodle Docs for this view.
28 $CFG->pagepath = 'filter/' . $filtername . '/config';
30 // get translated strings for use on page
31 $txt = new Object;
32 $txt->managefilters = get_string( 'managefilters' );
33 $txt->administration = get_string( 'administration' );
34 $txt->configuration = get_string( 'configuration' );
36 //======================
37 // Process Actions
38 //======================
40 // if reset pressed let filter config page handle it
41 $forcereset = false;
42 if (!empty($param->reset)) {
43 $forcereset = true;
45 else
46 if ($config = data_submitted()) {
48 // check session key
49 if (!confirm_sesskey()) {
50 error( get_string('confirmsesskeybad', 'error' ) );
53 $configpath = $CFG->dirroot.'/filter/'.$filtername.'/filterconfig.php';
54 if (file_exists($configpath)) {
55 require_once($configpath);
56 $functionname = $filtername.'_process_config';
57 if (function_exists($functionname)) {
58 $functionname($config);
59 $saved = true;
63 if (empty($saved)) {
64 // run through submitted data
65 // reject if does not start with filter_
66 foreach ($config as $name => $value) {
67 set_config( $name,$value );
70 redirect( "$CFG->wwwroot/$CFG->admin/filters.php", get_string('changessaved'), 1);
71 exit;
74 //==============================
75 // Display logic
76 //==============================
78 $filtername = ucfirst($filtername);
79 print_header( "$site->shortname: $txt->managefilters", "$site->fullname",
80 "<a href=\"index.php\">$txt->administration</a> -> <a href=\"configure.php\">$txt->configuration</a> " .
81 "-> <a href=\"filters.php\">$txt->managefilters</a> -> $filtername" );
83 print_heading( $txt->managefilters );
85 print_simple_box("<center>".get_string("configwarning", "admin")."</center>", "center", "50%");
86 echo "<br />";
88 print_simple_box_start("center",'');
91 <form action="filter.php?filter=<?php echo urlencode($param->filter); ?>" method="post">
92 <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
94 <?php include "$CFG->dirroot/$param->filter/filterconfig.html"; ?>
96 <center>
97 <input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" />
98 <input type="submit" name="reset" value="<?php echo print_string('resettodefaults'); ?>" />
99 </center>
100 </form>
102 <?php
103 print_simple_box_end();
105 print_simple_box_end();
107 print_footer();