Skip to content

Commit

Permalink
Merge pull request #24 from ilios/privacy-provider-update
Browse files Browse the repository at this point in the history
re-implements privacy provider.
  • Loading branch information
stopfstedt authored Sep 9, 2024
2 parents e4fb8af + 43e59f5 commit 179a4f4
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 10 deletions.
91 changes: 84 additions & 7 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,105 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Privacy Subsystem implementation for filter_ucsfezproxy.
* Privacy Subsystem implementation 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\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.
}
}
3 changes: 2 additions & 1 deletion lang/en/tool_ilioscategoryassignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
60 changes: 60 additions & 0 deletions tests/privacy/provider_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* 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());
}
}
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 179a4f4

Please sign in to comment.