Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.
   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 moodle_exception;
  29  use moodle_url;
  30  use renderable;
  31  use renderer_base;
  32  use single_select;
  33  use stdClass;
  34  use templatable;
  35  use tool_dataprivacy\data_request;
  36  use tool_dataprivacy\local\helper;
  37  
  38  /**
  39   * Class containing data for a user's data requests.
  40   *
  41   * @copyright  2018 Jun Pataleta
  42   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  43   */
  44  class data_deletion_page implements renderable, templatable {
  45  
  46      /** @var data_request[] $requests List of data requests. */
  47      protected $filter = null;
  48  
  49      /** @var data_request[] $requests List of data requests. */
  50      protected $expiredcontextstable = [];
  51  
  52      /**
  53       * Construct this renderable.
  54       *
  55       * @param \tool_dataprivacy\data_request[] $filter
  56       * @param expired_contexts_table $expiredcontextstable
  57       */
  58      public function __construct($filter, expired_contexts_table $expiredcontextstable) {
  59          $this->filter = $filter;
  60          $this->expiredcontextstable = $expiredcontextstable;
  61      }
  62  
  63      /**
  64       * Export this data so it can be used as the context for a mustache template.
  65       *
  66       * @param renderer_base $output
  67       * @return stdClass
  68       * @throws coding_exception
  69       * @throws moodle_exception
  70       */
  71      public function export_for_template(renderer_base $output) {
  72          $data = new stdClass();
  73  
  74          $url = new moodle_url('/admin/tool/dataprivacy/datadeletion.php');
  75          $options = [
  76              CONTEXT_USER => get_string('user'),
  77              CONTEXT_COURSE => get_string('course'),
  78              CONTEXT_MODULE => get_string('activitiesandresources', 'tool_dataprivacy'),
  79              CONTEXT_BLOCK => get_string('blocks'),
  80          ];
  81          $filterselector = new single_select($url, 'filter', $options, $this->filter, null);
  82          $data->filter = $filterselector->export_for_template($output);
  83  
  84          ob_start();
  85          $this->expiredcontextstable->out(helper::DEFAULT_PAGE_SIZE, true);
  86          $expiredcontexts = ob_get_contents();
  87          ob_end_clean();
  88          $data->expiredcontexts = $expiredcontexts;
  89  
  90          $data->existingcontexts = $this->expiredcontextstable->rawdata ? true : false;
  91  
  92          return $data;
  93      }
  94  }