Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.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   * This file contains the polyfill to allow a plugin to operate with Moodle 3.3 up.
  19   *
  20   * @package core_privacy
  21   * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
  22   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  namespace core_privacy\local;
  25  
  26  use \core_privacy\local\metadata\collection;
  27  use \core_privacy\local\request\contextlist;
  28  use \core_privacy\local\request\approved_contextlist;
  29  
  30  defined('MOODLE_INTERNAL') || die();
  31  
  32  /**
  33   * The trait used to provide a backwards compatability for third-party plugins.
  34   *
  35   * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
  36   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  37   */
  38  trait legacy_polyfill {
  39  
  40      /**
  41       * Get the language string identifier with the component's language
  42       * file to explain why this plugin stores no data.
  43       *
  44       * @return  string
  45       */
  46      public static function get_reason() : string {
  47          return static::_get_reason();
  48      }
  49  
  50      /**
  51       * Get the list of items.
  52       *
  53       * @param   collection     $collection The initialised collection to add items to.
  54       * @return  collection     A listing of user data stored through this system.
  55       */
  56      public static function get_metadata(collection $collection) : collection  {
  57          return static::_get_metadata($collection);
  58      }
  59  
  60      /**
  61       * Export all user preferences for the plugin.
  62       *
  63       * @param   int         $userid The userid of the user whose data is to be exported.
  64       */
  65      public static function export_user_preferences(int $userid) {
  66          return static::_export_user_preferences($userid);
  67      }
  68  
  69      /**
  70       * Get the list of contexts that contain user information for the specified user.
  71       *
  72       * @param   int         $userid     The user to search.
  73       * @return  contextlist   $contextlist  The contextlist containing the list of contexts used in this plugin.
  74       */
  75      public static function get_contexts_for_userid(int $userid) : contextlist {
  76          return static::_get_contexts_for_userid($userid);
  77      }
  78  
  79      /**
  80       * Export all user data for the specified user, in the specified contexts.
  81       *
  82       * @param   approved_contextlist    $contextlist    The approved contexts to export information for.
  83       */
  84      public static function export_user_data(approved_contextlist $contextlist) {
  85          return static::_export_user_data($contextlist);
  86      }
  87  
  88      /**
  89       * Delete all data for all users in the specified context.
  90       *
  91       * @param   context         $context   The specific context to delete data for.
  92       */
  93      public static function delete_data_for_all_users_in_context(\context $context) {
  94          return static::_delete_data_for_all_users_in_context($context);
  95      }
  96  
  97      /**
  98       * Delete all user data for the specified user, in the specified contexts.
  99       *
 100       * @param   approved_contextlist    $contextlist    The approved contexts and user information to delete information for.
 101       */
 102      public static function delete_data_for_user(approved_contextlist $contextlist) {
 103          return static::_delete_data_for_user($contextlist);
 104      }
 105  }