From b4b46f68ce5f849afffdbb889a40d1556c5b5813 Mon Sep 17 00:00:00 2001 From: Stefan Topfstedt Date: Mon, 9 Sep 2024 15:00:31 -0700 Subject: [PATCH 1/3] re-implements privacy provider. the null provider doesn't cut it anymore, since we're tracking edits to sync jobs in tool_ilioscategoryassignment::usermodified. apart from declaring it as metadata, there's nothing actionable here, therefore most methods remain unimplemented. --- classes/privacy/provider.php | 91 ++++++++++++++++++++++-- lang/en/tool_ilioscategoryassignment.php | 3 +- 2 files changed, 86 insertions(+), 8 deletions(-) diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index ec7180d..3d0268e 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Privacy Subsystem implementation for filter_ucsfezproxy. + * Privacy Subsystem implementation for tool_ilioscategoryassignment. * * @package tool_ilioscategoryassignment * @copyright The Regents of the University of California @@ -23,20 +23,97 @@ */ namespace tool_ilioscategoryassignment\privacy; -use core_privacy\local\metadata\null_provider; + +use context; +use core_privacy\local\metadata\collection; +use core_privacy\local\metadata\provider as metadata_provider; +use core_privacy\local\request\approved_contextlist; +use core_privacy\local\request\approved_userlist; +use core_privacy\local\request\contextlist; +use core_privacy\local\request\core_userlist_provider; +use core_privacy\local\request\plugin\provider as data_provider; +use core_privacy\local\request\userlist; + /** - * Privacy Subsystem for tool_ilioscategoryassignment implementing null_provider. + * Privacy Subsystem for tool_ilioscategoryassignment. * * @package tool_ilioscategoryassignment * @copyright The Regents of the University of California * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class provider implements null_provider { +class provider implements core_userlist_provider, data_provider, metadata_provider { + + + /** + * Returns the metadata for the user data stored in this plugin. + * + * @param collection $collection The metadata collection to add items to. + * @return collection The updated metadata collection. + */ + public static function get_metadata(collection $collection): collection { + $collection->add_database_table( + 'tool_ilioscategoryassignment', + [ + 'usermodified' => 'privacy:metadata:usermodified', + ], + 'privacy:metadata:tool_ilioscategoryassignment', + ); + 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 { + // Return an empty context list. There are no contexts for the given user. + return new 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): void { + // Not implemented. There are no users in any given context. + } + + /** + * 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): void { + // Not implemented. There is no context that would allow deletion. + } + + /** + * 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): void { + // Not implemented. There is no context that would allow deletion. + } + + /** + * 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): void { + // Not implemented. There is no context that would allow deletion. + } /** - * {@inheritdoc} + * 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 get_reason(): string { - return 'privacy:metadata'; + public static function export_user_data(approved_contextlist $contextlist): void { + // Not implemented. There is nothing to export here. } } diff --git a/lang/en/tool_ilioscategoryassignment.php b/lang/en/tool_ilioscategoryassignment.php index fe2c5b7..b8337b3 100644 --- a/lang/en/tool_ilioscategoryassignment.php +++ b/lang/en/tool_ilioscategoryassignment.php @@ -49,7 +49,8 @@ $string['noassignableroles'] = 'There are currently no roles that can be used for assignment.'; $string['notfound'] = '[[ not found (id = {$a} ]]'; $string['pluginname'] = 'Ilios category assignment'; -$string['privacy:metadata'] = 'The Ilios category assignment plugin does not store any personal data.'; +$string['privacy:metadata:tool_ilioscategoryassignment'] = 'A sync job record.'; +$string['privacy:metadata:usermodified'] = 'The user who created or modified the record.'; $string['secret'] = 'Ilios secret'; $string['secret_desc'] = 'Enter the secret string generated by your Ilios server here.'; $string['selectcategory'] = 'Select category'; From c85d3ef677b6fc64b71ce9d67dd21d7c003d8e53 Mon Sep 17 00:00:00 2001 From: Stefan Topfstedt Date: Mon, 9 Sep 2024 15:07:28 -0700 Subject: [PATCH 2/3] version bump. --- version.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.php b/version.php index 22619b8..bbc4994 100644 --- a/version.php +++ b/version.php @@ -24,9 +24,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024083000; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2024090900; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2024041600; // Requires this Moodle version. $plugin->component = 'tool_ilioscategoryassignment'; // Full name of the plugin (used for diagnostics). -$plugin->release = 'v4.4-rc1'; +$plugin->release = 'v4.4-rc2'; $plugin->supported = [404, 404]; $plugin->maturity = MATURITY_RC; From 43e59f51c44496babc830ec2f6315d5b7d01e825 Mon Sep 17 00:00:00 2001 From: Stefan Topfstedt Date: Mon, 9 Sep 2024 15:26:01 -0700 Subject: [PATCH 3/3] provides test coverage for privacy provider. --- tests/privacy/provider_test.php | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/privacy/provider_test.php diff --git a/tests/privacy/provider_test.php b/tests/privacy/provider_test.php new file mode 100644 index 0000000..022b861 --- /dev/null +++ b/tests/privacy/provider_test.php @@ -0,0 +1,60 @@ +. + +/** + * Privacy provider tests for tool_ilioscategoryassignment. + * + * @package tool_ilioscategoryassignment + * @copyright The Regents of the University of California + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace tool_ilioscategoryassignment\privacy; + +use core_privacy\local\metadata\collection; +use core_privacy\tests\provider_testcase; + + +/** + * Privacy provider test case. + * + * @package tool_ilioscategoryassignment + * @copyright The Regents of the University of California + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \tool_ilioscategoryassignment\privacy\provider + */ +final class provider_test extends provider_testcase { + /** + * @var string This component's name. + */ + public const COMPONENT_NAME = 'tool_ilioscategoryassignment'; + + /** + * Test fetching information about user data stored. + */ + public function test_get_metadata(): void { + $collection = new collection(self::COMPONENT_NAME); + $newcollection = provider::get_metadata($collection); + $itemcollection = $newcollection->get_collection(); + $this->assertCount(1, $itemcollection); + + $table = reset($itemcollection); + $this->assertEquals('tool_ilioscategoryassignment', $table->get_name()); + $privacyfields = $table->get_privacy_fields(); + $this->assertCount(1, $privacyfields); + $this->assertArrayHasKey('usermodified', $privacyfields); + $this->assertEquals('privacy:metadata:tool_ilioscategoryassignment', $table->get_summary()); + } +}