Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

   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   * Privacy class for requesting user data.
  19   *
  20   * @package    core
  21   * @category   privacy
  22   * @copyright  2018 Andrew Nicols <andrew@nicols.co.uk>
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  namespace core\privacy;
  27  
  28  defined('MOODLE_INTERNAL') || die();
  29  
  30  use core_privacy\local\metadata\collection;
  31  use core_privacy\local\request\approved_contextlist;
  32  use core_privacy\local\request\approved_userlist;
  33  use core_privacy\local\request\contextlist;
  34  use core_privacy\local\request\userlist;
  35  
  36  /**
  37   * Privacy class for requesting user data.
  38   *
  39   * @package    core
  40   * @copyright  2018 Andrew Nicols <andrew@nicols.co.uk>
  41   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  42   */
  43  class provider implements
  44          \core_privacy\local\metadata\provider,
  45          \core_privacy\local\request\subsystem\provider,
  46          \core_privacy\local\request\core_userlist_provider {
  47  
  48      /**
  49       * Returns information about the user data stored in this component.
  50       *
  51       * @param  collection $collection A list of information about this component
  52       * @return collection The collection object filled out with information about this component.
  53       */
  54      public static function get_metadata(collection $collection) : collection {
  55          // These tables are really data about site configuration and not user data.
  56  
  57          // The config_log includes information about which user performed a configuration change.
  58          // The value and oldvalue may contain sensitive information such as accounts for service passwords..
  59          // This is not considered to be user data.
  60          $collection->add_database_table('config_log', [
  61                  'userid'        => 'privacy:metadata:config_log:userid',
  62                  'timemodified'  => 'privacy:metadata:config_log:timemodified',
  63                  'plugin'        => 'privacy:metadata:config_log:plugin',
  64                  'name'          => 'privacy:metadata:config_log:name',
  65                  'value'         => 'privacy:metadata:config_log:value',
  66                  'oldvalue'      => 'privacy:metadata:config_log:oldvalue',
  67              ], 'privacy:metadata:config_log');
  68  
  69          // The upgrade_log includes information about which user performed an upgrade.
  70          // This is not considered to be user data.
  71          $collection->add_database_table('upgrade_log', [
  72                  'type'          => 'privacy:metadata:upgrade_log:type',
  73                  'plugin'        => 'privacy:metadata:upgrade_log:plugin',
  74                  'version'       => 'privacy:metadata:upgrade_log:version',
  75                  'targetversion' => 'privacy:metadata:upgrade_log:targetversion',
  76                  'info'          => 'privacy:metadata:upgrade_log:info',
  77                  'details'       => 'privacy:metadata:upgrade_log:details',
  78                  'backtrace'     => 'privacy:metadata:upgrade_log:backtrace',
  79                  'userid'        => 'privacy:metadata:upgrade_log:userid',
  80                  'timemodified'  => 'privacy:metadata:upgrade_log:timemodified',
  81              ], 'privacy:metadata:upgrade_log');
  82  
  83          // The task_adhoc includes information about pending adhoc tasks, some of which may be run as a user.
  84          // These are removed as the task completes.
  85          $collection->add_database_table('task_adhoc', [
  86                  'component'     => 'privacy:metadata:task_adhoc:component',
  87                  'nextruntime'   => 'privacy:metadata:task_adhoc:nextruntime',
  88                  'userid'        => 'privacy:metadata:task_adhoc:userid',
  89              ], 'privacy:metadata:task_adhoc');
  90  
  91          // The task_log table stores debugging data for tasks.
  92          // These are cleaned regularly and intended purely for debugging.
  93          $collection->add_database_table('task_log', [
  94                  'component'     => 'privacy:metadata:task_log:component',
  95                  'userid'        => 'privacy:metadata:task_log:userid',
  96              ], 'privacy:metadata:task_log');
  97  
  98          // The events_queue includes information about pending events tasks.
  99          // These are stored for short periods whilst being processed into other locations.
 100          $collection->add_database_table('events_queue', [
 101                  'eventdata'     => 'privacy:metadata:events_queue:eventdata',
 102                  'stackdump'     => 'privacy:metadata:events_queue:stackdump',
 103                  'userid'        => 'privacy:metadata:events_queue:userid',
 104                  'timecreated'   => 'privacy:metadata:events_queue:timecreated',
 105              ], 'privacy:metadata:events_queue');
 106  
 107          // The log table is defined in core but used in logstore_legacy.
 108          $collection->add_database_table('log', [
 109              'time' => 'privacy:metadata:log:time',
 110              'userid' => 'privacy:metadata:log:userid',
 111              'ip' => 'privacy:metadata:log:ip',
 112              'action' => 'privacy:metadata:log:action',
 113              'url' => 'privacy:metadata:log:url',
 114              'info' => 'privacy:metadata:log:info'
 115          ], 'privacy:metadata:log');
 116  
 117          return $collection;
 118      }
 119  
 120      /**
 121       * Get the list of contexts that contain user information for the specified user.
 122       *
 123       * @param   int $userid The user to search.
 124       * @return  contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
 125       */
 126      public static function get_contexts_for_userid(int $userid) : contextlist {
 127          return new contextlist();
 128      }
 129  
 130      /**
 131       * Get the list of users who have data within a context.
 132       *
 133       * @param   userlist    $userlist   The userlist containing the list of users who have data in this context/plugin combination.
 134       */
 135      public static function get_users_in_context(userlist $userlist) {
 136          // Don't add any user.
 137      }
 138  
 139      /**
 140       * Export all user data for the specified user, in the specified contexts.
 141       *
 142       * @param approved_contextlist $contextlist The approved contexts to export information for.
 143       */
 144      public static function export_user_data(approved_contextlist $contextlist) {
 145          // None of the core tables should be exported.
 146      }
 147  
 148      /**
 149       * Delete all data for all users in the specified context.
 150       *
 151       * @param context $context The specific context to delete data for.
 152       */
 153      public static function delete_data_for_all_users_in_context(\context $context) {
 154          // None of the the data from these tables should be deleted.
 155      }
 156  
 157      /**
 158       * Delete all user data for the specified user, in the specified contexts.
 159       *
 160       * @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
 161       */
 162      public static function delete_data_for_user(approved_contextlist $contextlist) {
 163          // None of the the data from these tables should be deleted.
 164          // Note: Although it may be tempting to delete the adhoc task data, do not do so.
 165          // The delete process is run as an adhoc task.
 166      }
 167  
 168      /**
 169       * Delete multiple users within a single context.
 170       *
 171       * @param   approved_userlist       $userlist The approved context and user information to delete information for.
 172       */
 173      public static function delete_data_for_users(approved_userlist $userlist) {
 174          // None of the the data from these tables should be deleted.
 175          // Note: Although it may be tempting to delete the adhoc task data, do not do so.
 176          // The delete process is run as an adhoc task.
 177      }
 178  }