-
Notifications
You must be signed in to change notification settings - Fork 24
/
settings.php
88 lines (74 loc) · 3.82 KB
/
settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* local_cleanurls plugin settings
*
* @package local_cleanurls
* @author Brendan Heywood <brendan@catalyst-au.net>
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
if ($hassiteconfig) {
$settings = new admin_settingpage('local_cleanurls', get_string('pluginname', 'local_cleanurls'));
$webservertesturl = new moodle_url('/local/cleanurls/webservertest.php');
$ADMIN->add('localplugins', new admin_externalpage(
'local_cleanurls_webservertest',
new lang_string('webservertest', 'local_cleanurls'),
$webservertesturl
));
$ADMIN->add('localplugins', $settings);
if (!during_initial_install()) {
$section = optional_param('section', '', PARAM_RAW);
$test = '';
// If we are on the settings page then also run a router test.
if ($section == 'local_cleanurls') {
$passed = \local_cleanurls\test\webserver\webtest::check_available_tests_pass();
if ($passed) {
$test .= $OUTPUT->notification(get_string('routerok', 'local_cleanurls'), 'notifysuccess');
} else {
$test .= $OUTPUT->notification(get_string('routerbroken', 'local_cleanurls'), 'notifyerror');
}
}
$rewritetest = false;
$result = isset($CFG->urlrewriteclass) && $CFG->urlrewriteclass == '\local_cleanurls\url_rewriter';
// Now test that not only is the router configured but it is cleaning urls correctly. Note
// that this particular test url is cleaned even if cleaning is off.
if ($result) {
$result = substr((new moodle_url('/local/cleanurls/tests/foo.php'))->out(false), -4) == '/bar';
if ($result) {
$test .= $OUTPUT->notification(get_string('rewriteok', 'local_cleanurls'), 'notifysuccess');
} else {
$test .= $OUTPUT->notification(get_string('rewritebroken', 'local_cleanurls'), 'notifyerror');
}
} else {
$test .= $OUTPUT->notification(get_string('rewritenoconfig', 'local_cleanurls'), 'notifyerror');
}
$cleaningonhelp = new lang_string('cleaningonhelp', 'local_cleanurls') .
' <a href="' . $webservertesturl . '">' .
new lang_string('cleaningonhelpdebug', 'local_cleanurls') .
'</a><br />' . $test;
$settings->add(new admin_setting_configcheckbox('local_cleanurls/cleaningon',
new lang_string('cleaningon', 'local_cleanurls'),
$cleaningonhelp, 0));
$settings->add(new admin_setting_configcheckbox('local_cleanurls/cleanusernames',
new lang_string('cleanusernames', 'local_cleanurls'),
new lang_string('cleanusernameshelp', 'local_cleanurls'), 0));
$settings->add( new admin_setting_configcheckbox('local_cleanurls/debugging',
new lang_string('debugging', 'local_cleanurls'),
new lang_string('debugginghelp', 'local_cleanurls'), 0));
}
}