Merge branch 'MDL-66273-MOODLE-311-v2' of https://github.com/golenkovm/moodle into...
[moodle.git] / admin / tool / dataprivacy / mydatarequests.php
blob037e244708e64a55e1ea0de2c8dc18e03e0e6b26
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Prints the contact form to the site's Data Protection Officer
20 * @copyright 2018 onwards Jun Pataleta
21 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
22 * @package tool_dataprivacy
25 require_once("../../../config.php");
26 require_once('lib.php');
28 $courseid = optional_param('course', 0, PARAM_INT);
30 $url = new moodle_url('/admin/tool/dataprivacy/mydatarequests.php');
31 if ($courseid) {
32 $url->param('course', $courseid);
35 $PAGE->set_url($url);
37 require_login();
38 if (isguestuser()) {
39 print_error('noguest');
42 $usercontext = context_user::instance($USER->id);
43 $PAGE->set_context($usercontext);
45 if ($profilenode = $PAGE->settingsnav->find('myprofile', null)) {
46 $profilenode->make_active();
49 $title = get_string('datarequests', 'tool_dataprivacy');
50 $PAGE->navbar->add($title);
52 // Return URL.
53 $params = ['id' => $USER->id];
54 if ($courseid) {
55 $params['course'] = $courseid;
57 $returnurl = new moodle_url('/user/profile.php', $params);
59 $PAGE->set_heading($title);
60 $PAGE->set_title($title);
61 echo $OUTPUT->header();
62 echo $OUTPUT->heading($title);
64 $requests = tool_dataprivacy\api::get_data_requests($USER->id, [], [], [], 'timecreated DESC');
65 $requestlist = new tool_dataprivacy\output\my_data_requests_page($requests);
66 $requestlistoutput = $PAGE->get_renderer('tool_dataprivacy');
67 echo $requestlistoutput->render($requestlist);
69 echo $OUTPUT->footer();