1 |
efrain |
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.
|
|
|
13 |
//
|
|
|
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/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Class containing data for a user's data requests.
|
|
|
19 |
*
|
|
|
20 |
* @package tool_dataprivacy
|
|
|
21 |
* @copyright 2018 Jun Pataleta
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
namespace tool_dataprivacy\output;
|
|
|
25 |
defined('MOODLE_INTERNAL') || die();
|
|
|
26 |
|
|
|
27 |
use coding_exception;
|
|
|
28 |
use dml_exception;
|
|
|
29 |
use moodle_exception;
|
|
|
30 |
use moodle_url;
|
|
|
31 |
use renderable;
|
|
|
32 |
use renderer_base;
|
|
|
33 |
use single_select;
|
|
|
34 |
use stdClass;
|
|
|
35 |
use templatable;
|
|
|
36 |
use tool_dataprivacy\api;
|
|
|
37 |
use tool_dataprivacy\local\helper;
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* Class containing data for a user's data requests.
|
|
|
41 |
*
|
|
|
42 |
* @copyright 2018 Jun Pataleta
|
|
|
43 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
44 |
*/
|
|
|
45 |
class data_requests_page implements renderable, templatable {
|
|
|
46 |
|
|
|
47 |
/** @var data_requests_table $table The data requests table. */
|
|
|
48 |
protected $table;
|
|
|
49 |
|
|
|
50 |
/** @var int[] $filters The applied filters. */
|
|
|
51 |
protected $filters = [];
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* Construct this renderable.
|
|
|
55 |
*
|
|
|
56 |
* @param data_requests_table $table The data requests table.
|
|
|
57 |
* @param int[] $filters The applied filters.
|
|
|
58 |
*/
|
|
|
59 |
public function __construct($table, $filters) {
|
|
|
60 |
$this->table = $table;
|
|
|
61 |
$this->filters = $filters;
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
* Export this data so it can be used as the context for a mustache template.
|
|
|
66 |
*
|
|
|
67 |
* @param renderer_base $output
|
|
|
68 |
* @return stdClass
|
|
|
69 |
* @throws coding_exception
|
|
|
70 |
* @throws dml_exception
|
|
|
71 |
* @throws moodle_exception
|
|
|
72 |
*/
|
|
|
73 |
public function export_for_template(renderer_base $output) {
|
|
|
74 |
$data = new stdClass();
|
|
|
75 |
$data->newdatarequesturl = new moodle_url('/admin/tool/dataprivacy/createdatarequest.php');
|
|
|
76 |
$data->newdatarequesturl->param('manage', true);
|
|
|
77 |
|
|
|
78 |
if (!is_https()) {
|
|
|
79 |
$httpwarningmessage = get_string('httpwarning', 'tool_dataprivacy');
|
|
|
80 |
$data->httpsite = array('message' => $httpwarningmessage, 'announce' => 1);
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
$url = new moodle_url('/admin/tool/dataprivacy/datarequests.php');
|
|
|
84 |
$filteroptions = helper::get_request_filter_options();
|
|
|
85 |
$filter = new request_filter($filteroptions, $this->filters, $url);
|
|
|
86 |
$data->filter = $filter->export_for_template($output);
|
|
|
87 |
|
|
|
88 |
ob_start();
|
|
|
89 |
$this->table->out($this->table->get_requests_per_page(), true);
|
|
|
90 |
$requests = ob_get_contents();
|
|
|
91 |
ob_end_clean();
|
|
|
92 |
|
|
|
93 |
$data->datarequests = $requests;
|
|
|
94 |
return $data;
|
|
|
95 |
}
|
|
|
96 |
}
|