Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400]

   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    message_email
  21   * @copyright  2018 Mihail Geshoski <mihail@moodle.com>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace message_email\privacy;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  use \core_privacy\local\metadata\collection;
  30  use \core_privacy\local\request\contextlist;
  31  use \core_privacy\local\request\approved_contextlist;
  32  use core_privacy\local\request\userlist;
  33  use core_privacy\local\request\writer;
  34  use \core_privacy\local\request\approved_userlist;
  35  
  36  /**
  37   * Privacy class for requesting user data.
  38   *
  39   * @package    message_email
  40   * @copyright  2018 Mihail Geshoski <mihail@moodle.com>
  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\core_userlist_provider,
  46          \core_privacy\local\request\user_preference_provider,
  47          \core_privacy\local\request\plugin\provider {
  48  
  49      /**
  50       * Returns meta data about this system.
  51       *
  52       * @param   collection $collection The initialised collection to add items to.
  53       * @return  collection A listing of user data stored through this system.
  54       */
  55      public static function get_metadata(collection $collection) : collection {
  56          $messageemailmessages = [
  57              'useridto' => 'privacy:metadata:message_email_messages:useridto',
  58              'conversationid' => 'privacy:metadata:message_email_messages:conversationid',
  59              'messageid' => 'privacy:metadata:message_email_messages:messageid',
  60          ];
  61          // Note - this data gets deleted once the scheduled task runs.
  62          $collection->add_database_table('message_email_messages',
  63              $messageemailmessages, 'privacy:metadata:message_email_messages');
  64  
  65          $collection->link_external_location('smtp', [
  66                  'recipient' => 'privacy:metadata:recipient',
  67                  'userfrom' => 'privacy:metadata:userfrom',
  68                  'subject' => 'privacy:metadata:subject',
  69                  'fullmessage' => 'privacy:metadata:fullmessage',
  70                  'fullmessagehtml' => 'privacy:metadata:fullmessagehtml',
  71                  'attachment' => 'privacy:metadata:attachment',
  72                  'attachname' => 'privacy:metadata:attachname',
  73                  'replyto' => 'privacy:metadata:replyto',
  74                  'replytoname' => 'privacy:metadata:replytoname'
  75          ], 'privacy:metadata:externalpurpose');
  76  
  77          return $collection;
  78      }
  79  
  80      /**
  81       * Get the list of contexts that contain user information for the specified user.
  82       *
  83       * @param   int         $userid     The user to search.
  84       * @return  contextlist $contextlist  The contextlist containing the list of contexts used in this plugin.
  85       */
  86      public static function get_contexts_for_userid(int $userid) : contextlist {
  87          $contextlist = new contextlist();
  88          return $contextlist;
  89      }
  90  
  91      /**
  92       * Get the list of users who have data within a context.
  93       *
  94       * @param   userlist    $userlist   The userlist containing the list of users who have data in this context/plugin combination.
  95       */
  96      public static function get_users_in_context(userlist $userlist) {
  97      }
  98  
  99      /**
 100       * Export all user data for the specified user, in the specified contexts.
 101       *
 102       * @param approved_contextlist $contextlist The approved contexts to export information for.
 103       */
 104      public static function export_user_data(approved_contextlist $contextlist) {
 105      }
 106  
 107      /**
 108       * Delete all use data which matches the specified deletion_criteria.
 109       *
 110       * @param   context $context A user context.
 111       */
 112      public static function delete_data_for_all_users_in_context(\context $context) {
 113      }
 114  
 115      /**
 116       * Delete multiple users within a single context.
 117       *
 118       * @param   approved_userlist       $userlist The approved context and user information to delete information for.
 119       */
 120      public static function delete_data_for_users(approved_userlist $userlist) {
 121      }
 122  
 123      /**
 124       * Delete all user data for the specified user, in the specified contexts.
 125       *
 126       * @param   approved_contextlist    $contextlist    The approved contexts and user information to delete information for.
 127       */
 128      public static function delete_data_for_user(approved_contextlist $contextlist) {
 129      }
 130  
 131      /**
 132       * Export all user preferences for the plugin
 133       *
 134       * @param int $userid
 135       */
 136      public static function export_user_preferences(int $userid) {
 137          $preference = get_user_preferences('message_processor_email_email', null, $userid);
 138          if (!empty($preference)) {
 139              writer::export_user_preference(
 140                  'message_email',
 141                  'email',
 142                  $preference,
 143                  get_string('privacy:preference:email', 'message_email')
 144              );
 145          }
 146      }
 147  }