2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
18 * Class containing data for a user's data requests.
20 * @package tool_dataprivacy
21 * @copyright 2018 Jun Pataleta
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 namespace tool_dataprivacy\output
;
25 defined('MOODLE_INTERNAL') ||
die();
36 use tool_dataprivacy\data_request
;
39 * Class containing data for a user's data requests.
41 * @copyright 2018 Jun Pataleta
42 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
44 class data_deletion_page
implements renderable
, templatable
{
46 /** The default number of results to be shown per page. */
47 const DEFAULT_PAGE_SIZE
= 20;
49 /** @var data_request[] $requests List of data requests. */
50 protected $filter = null;
52 /** @var data_request[] $requests List of data requests. */
53 protected $expiredcontextstable = [];
56 * Construct this renderable.
58 * @param expired_contexts_table $expiredcontextstable
60 public function __construct($filter, $expiredcontextstable) {
61 $this->filter
= $filter;
62 $this->expiredcontextstable
= $expiredcontextstable;
66 * Export this data so it can be used as the context for a mustache template.
68 * @param renderer_base $output
70 * @throws coding_exception
71 * @throws dml_exception
72 * @throws moodle_exception
74 public function export_for_template(renderer_base
$output) {
75 $data = new stdClass();
77 $url = new moodle_url('/admin/tool/dataprivacy/datadeletion.php');
79 CONTEXT_USER
=> get_string('user'),
80 CONTEXT_COURSE
=> get_string('course'),
81 CONTEXT_MODULE
=> get_string('activitiesandresources', 'tool_dataprivacy'),
82 CONTEXT_BLOCK
=> get_string('blocks'),
84 $filterselector = new single_select($url, 'filter', $options, $this->filter
, null);
85 $data->filter
= $filterselector->export_for_template($output);
88 $this->expiredcontextstable
->out(self
::DEFAULT_PAGE_SIZE
, true);
89 $expiredcontexts = ob_get_contents();
91 $data->expiredcontexts
= $expiredcontexts;
93 $data->existingcontexts
= $this->expiredcontextstable
->rawdata ?
true : false;