From 6208bf4ff363aee334bfb19111dc9f16a42f4da5 Mon Sep 17 00:00:00 2001 From: Jane Adelmann Date: Mon, 20 Nov 2023 19:50:29 +0200 Subject: [PATCH] Add Privacy API implementation. Version 3.14.6 --- classes/privacy/provider.php | 90 +++++++++++++++++++++++++++++++++++- version.php | 4 +- 2 files changed, 91 insertions(+), 3 deletions(-) diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 955e2e2..133d9e2 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -26,6 +26,16 @@ namespace plagiarism_pchkorg\privacy; defined('MOODLE_INTERNAL') || die(); use core_privacy\local\metadata\collection; +use core_privacy\local\request\contextlist; +use core_privacy\local\request\approved_contextlist; +use core_privacy\local\request\userlist; +use core_privacy\local\request\approved_userlist; + +if (interface_exists('\core_privacy\local\request\userlist')) { + interface my_userlist extends \core_privacy\local\request\userlist{} +} else { + interface my_userlist {}; +} /** * Class provider @@ -33,8 +43,10 @@ use core_privacy\local\metadata\collection; * @package plagiarism_pchkorg\privacy */ class provider implements + my_userlist, \core_privacy\local\metadata\provider, - \core_privacy\local\request\plugin\provider { + \core_privacy\local\request\plugin\provider, + \core_privacy\local\request\core_userlist_provider { // This trait must be included. use \core_privacy\local\legacy_polyfill; @@ -92,4 +104,80 @@ class provider implements return $collection; } + + /** + * Get the list of contexts that contain user information for the specified user. + * + * @param int $userid The user to search. + * @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin. + */ + public static function _get_contexts_for_userid(int $userid) : contextlist { + $contextlist = new contextlist(); + $sql = "SELECT DISTINCT cm FROM {plagiarism_pchkorg_files} WHERE userid = :userid"; + $params = [ + 'userid' => $userid + ]; + $contextlist->add_from_sql($sql, $params); + + return $contextlist; + } + + /** + * Get the list of users who have data within a context. + * + * @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination. + */ + public static function get_users_in_context(userlist $userlist) { + $context = $userlist->get_context(); + if (!$context instanceof \context_module) { + return; + } + $params = [ + 'cm' => $context->instanceid, + ]; + $sql = "SELECT DISTINCT userid FROM {plagiarism_pchkorg_files} WHERE cm = :cm"; + $userlist->add_from_sql('userid', $sql, $params); + } + + /** + * Export all user data for the specified user, in the specified contexts. + * + * @param approved_contextlist $contextlist The approved contexts to export information for. + */ + public static function _export_user_data(approved_contextlist $contextlist) { + } + + /** + * Delete multiple users within a single context. + * + * @param approved_userlist $userlist The approved context and user information to delete information for. + */ + public static function delete_data_for_users(approved_userlist $userlist) { + } + + + /** + * Export all user preferences for the plugin. + * + * @param int $userid The userid of the user whose data is to be exported. + */ + public static function _export_user_preferences(int $userid) { + } + + + /** + * Delete all data for all users in the specified context. + * + * @param context $context The specific context to delete data for. + */ + public static function _delete_data_for_all_users_in_context(\context $context) { + } + + /** + * Delete all user data for the specified user, in the specified contexts. + * + * @param approved_contextlist $contextlist The approved contexts and user information to delete information for. + */ + public static function _delete_data_for_user(approved_contextlist $contextlist) { + } } diff --git a/version.php b/version.php index 7adc2b8..582f3ea 100644 --- a/version.php +++ b/version.php @@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die(); if (!isset($plugin)) { $plugin = new stdClass(); } -$plugin->version = 2023101216; +$plugin->version = 2023112019; $plugin->requires = 2020061501; // Requires Moodle 3.9 . -$plugin->release = 'v3.14.5'; +$plugin->release = 'v3.14.6'; $plugin->component = 'plagiarism_pchkorg'; $plugin->maturity = MATURITY_STABLE; $plugin->dependencies = array(