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;
37 use tool_dataprivacy\output\expired_contexts_table;
40 * Class containing data for a user's data requests.
42 * @copyright 2018 Jun Pataleta
43 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
45 class data_deletion_page implements renderable, templatable {
47 /** The default number of results to be shown per page. */
48 const DEFAULT_PAGE_SIZE = 20;
50 /** @var data_request[] $requests List of data requests. */
51 protected $filter = null;
53 /** @var data_request[] $requests List of data requests. */
54 protected $expiredcontextstable = [];
57 * Construct this renderable.
59 * @param \tool_dataprivacy\data_request[] $filter
60 * @param \tool_dataprivacy\expired_contexts_table $expiredcontextstable
62 public function __construct($filter, expired_contexts_table $expiredcontextstable) {
63 $this->filter = $filter;
64 $this->expiredcontextstable = $expiredcontextstable;
68 * Export this data so it can be used as the context for a mustache template.
70 * @param renderer_base $output
72 * @throws coding_exception
73 * @throws dml_exception
74 * @throws moodle_exception
76 public function export_for_template(renderer_base $output) {
77 $data = new stdClass();
79 $url = new moodle_url('/admin/tool/dataprivacy/datadeletion.php');
81 CONTEXT_USER => get_string('user'),
82 CONTEXT_COURSE => get_string('course'),
83 CONTEXT_MODULE => get_string('activitiesandresources', 'tool_dataprivacy'),
84 CONTEXT_BLOCK => get_string('blocks'),
86 $filterselector = new single_select($url, 'filter', $options, $this->filter, null);
87 $data->filter = $filterselector->export_for_template($output);
90 $this->expiredcontextstable->out(self::DEFAULT_PAGE_SIZE, true);
91 $expiredcontexts = ob_get_contents();
93 $data->expiredcontexts = $expiredcontexts;
95 $data->existingcontexts = $this->expiredcontextstable->rawdata ? true : false;