-
Notifications
You must be signed in to change notification settings - Fork 7
/
manage.php
83 lines (63 loc) · 2.37 KB
/
manage.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
<?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/>.
/**
* Prints the Accessibility Tool user preference page.
*
* @package local_accessibilitytool
* @author Mark Sharp <[email protected]>
* @copyright 2018 University of Chichester {@link https://www.chi.ac.uk}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace local_accessibilitytool;
use moodle_url;
require_once("../../config.php");
require_once("lib.php");
require_login();
$PAGE->set_context(\context_system::instance());
$renderer = $PAGE->get_renderer('local_accessibilitytool');
$atr = optional_param("atr", "", PARAM_RAW);
$urlparts = [];
if ($atr == "") {
if (isset($_SERVER['HTTP_REFERER'])) {
$urlparts = parse_url($_SERVER['HTTP_REFERER']);
} else {
$urlparts = parse_url($CFG->wwwroot . '/local/accessibilitytool/manage.php');
}
} else {
$urlparts = parse_url(urldecode($atr));
}
$queryparams = [];
if (isset($urlparts['query'])) {
$queryparts = explode('&', $urlparts['query']);
foreach ($queryparts as $part) {
list($key, $val) = explode('=', $part);
$queryparams[$key] = $val;
}
}
$returnurl = new \moodle_url($urlparts['path'], $queryparams);
$menu = new \local_accessibilitytool\output\menu();
$menu->set_returnurl($returnurl);
$section = optional_param("k", "", PARAM_ALPHA);
if ($section !== "") {
$value = required_param("v", PARAM_ALPHANUMEXT);
$menu->set_user_preference($section, $value);
}
$PAGE->set_url('/local/accessibilitytool/manage.php');
$PAGE->set_title(get_string("accessibilitytool", "local_accessibilitytool"));
$PAGE->set_heading(get_string("accessibilitytool", "local_accessibilitytool"));
echo $OUTPUT->header();
echo $renderer->render($menu);
echo $OUTPUT->footer();