Skip to content
Snippets Groups Projects
Unverified Commit 51dcf1fa authored by Justus Dieckmann's avatar Justus Dieckmann Committed by GitHub
Browse files

Merge pull request #156 from PhMemmel/Add_privacy_providers

Add privacy providers
parents e0d21fec 8ed2607f
Branches
No related tags found
No related merge requests found
Showing
with 725 additions and 0 deletions
<?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/>.
namespace lifecyclestep_createbackup\privacy;
use core_privacy\local\metadata\null_provider;
/**
* Privacy subsystem implementation for lifecyclestep_createbackup.
*
* @package lifecyclestep_createbackup
* @copyright 2022 ISB Bayern
* @author Philipp Memmel
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string the reason
*/
public static function get_reason() : string {
return 'privacy:metadata';
}
}
...@@ -23,5 +23,6 @@ ...@@ -23,5 +23,6 @@
*/ */
$string['pluginname'] = 'Kurssicherungs-Schritt'; $string['pluginname'] = 'Kurssicherungs-Schritt';
$string['privacy:metadata'] = 'Dieses Subplugin speichert keine persönlichen Daten.';
$string['maximumbackupspercron'] = 'Maximale Anzahl an Sicherungen per cron'; $string['maximumbackupspercron'] = 'Maximale Anzahl an Sicherungen per cron';
...@@ -23,5 +23,6 @@ ...@@ -23,5 +23,6 @@
*/ */
$string['pluginname'] = 'Create backup step'; $string['pluginname'] = 'Create backup step';
$string['privacy:metadata'] = 'This subplugin does not store any personal data.';
$string['maximumbackupspercron'] = 'Maximum number of backups per cron'; $string['maximumbackupspercron'] = 'Maximum number of backups per cron';
<?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/>.
namespace lifecyclestep_deletecourse\privacy;
use core_privacy\local\metadata\null_provider;
/**
* Privacy subsystem implementation for lifecyclestep_deletecourse.
*
* @package lifecyclestep_deletecourse
* @copyright 2022 ISB Bayern
* @author Philipp Memmel
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string the reason
*/
public static function get_reason() : string {
return 'privacy:metadata';
}
}
...@@ -23,5 +23,6 @@ ...@@ -23,5 +23,6 @@
*/ */
$string['pluginname'] = 'Kurslöschen-Schritt'; $string['pluginname'] = 'Kurslöschen-Schritt';
$string['privacy:metadata'] = 'Dieses Subplugin speichert keine persönlichen Daten.';
$string['deletecourse_maximumdeletionspercron'] = 'Maximale Anzahl an Kurslöschungen per cron'; $string['deletecourse_maximumdeletionspercron'] = 'Maximale Anzahl an Kurslöschungen per cron';
...@@ -23,5 +23,6 @@ ...@@ -23,5 +23,6 @@
*/ */
$string['pluginname'] = 'Delete course step'; $string['pluginname'] = 'Delete course step';
$string['privacy:metadata'] = 'This subplugin does not store any personal data.';
$string['deletecourse_maximumdeletionspercron'] = 'Maximum number of courses deleted per cron'; $string['deletecourse_maximumdeletionspercron'] = 'Maximum number of courses deleted per cron';
<?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/>.
namespace lifecyclestep_duplicate\privacy;
use core_privacy\local\metadata\null_provider;
/**
* Privacy subsystem implementation for lifecyclestep_duplicate.
*
* @package lifecyclestep_duplicate
* @copyright 2022 ISB Bayern
* @author Philipp Memmel
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string the reason
*/
public static function get_reason() : string {
return 'privacy:metadata';
}
}
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
$string['pluginname'] = 'Kurs-Duplizieren-Schritt'; $string['pluginname'] = 'Kurs-Duplizieren-Schritt';
$string['privacy:metadata'] = 'Dieses Subplugin speichert keine persönlichen Daten.';
$string['duplicate_form'] = 'Daten eingeben'; $string['duplicate_form'] = 'Daten eingeben';
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
$string['pluginname'] = 'Duplicate step'; $string['pluginname'] = 'Duplicate step';
$string['privacy:metadata'] = 'This subplugin does not store any personal data.';
$string['duplicate_form'] = 'Enter data'; $string['duplicate_form'] = 'Enter data';
......
<?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/>.
namespace lifecyclestep_email\privacy;
use context;
use context_course;
use context_system;
use core_privacy\local\metadata\collection;
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\userlist;
use core_privacy\local\request\writer;
use dml_exception;
/**
* Privacy provider for lifecyclestep_email.
*
* @package lifecyclestep_email
* @copyright 2022 ISB Bayern
* @author Philipp Memmel
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\provider,
\core_privacy\local\request\plugin\provider,
core_userlist_provider {
/**
* Returns metadata about lifecyclestep_email.
*
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored by lifecyclestep_email.
*/
public static function get_metadata(collection $collection): collection {
$collection->add_database_table(
'lifecyclestep_email',
[
'touser' => 'privacy:metadata:lifecyclestep_email:touser',
'courseid' => 'privacy:metadata:lifecyclestep_email:courseid',
'instanceid' => 'privacy:metadata:lifecyclestep_email:instanceid'
],
'privacy:metadata:lifecyclestep_email:summary'
);
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
*/
public static function get_contexts_for_userid(int $userid): contextlist {
$contextlist = new contextlist();
$contextlist->add_system_context();
$sql = "SELECT c.id FROM {context} c JOIN {lifecyclestep_email} e ON c.instanceid = e.courseid "
. "WHERE contextlevel = :coursecontextlevel "
. "AND e.touser = :touser";
$contextlist->add_from_sql($sql, ['coursecontextlevel' => CONTEXT_COURSE, 'touser' => $userid]);
return $contextlist;
}
/**
* Export all user data for the specified user, in the specified contexts.
*
* @param approved_contextlist $contextlist The approved contexts to export information for
* @throws dml_exception
*/
public static function export_user_data(approved_contextlist $contextlist): void {
global $DB;
foreach ($contextlist->get_contexts() as $context) {
if ($context instanceof context_system) {
$records = $DB->get_records('lifecyclestep_email', ['touser' => $contextlist->get_user()->id]);
$writer = writer::with_context($context);
foreach ($records as $record) {
$subcontext = ['lifecyclestep_email-' . $record->id];
$writer->export_data($subcontext, $record);
}
} else if ($context instanceof context_course) {
$records = $DB->get_records('lifecyclestep_email',
['courseid' => $context->instanceid, 'touser' => $contextlist->get_user()->id]);
$writer = writer::with_context($context);
foreach ($records as $record) {
$subcontext = ['lifecyclestep_email-' . $record->id];
$writer->export_data($subcontext, $record);
}
}
}
}
/**
* 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 {
if ($userlist->get_context() instanceof context_system) {
$sql = "SELECT touser FROM {lifecyclestep_email}";
$userlist->add_from_sql('touser', $sql, []);
} else if ($userlist->get_context() instanceof context_course) {
$sql = "SELECT touser FROM {lifecyclestep_email} WHERE courseid = :courseid";
$userlist->add_from_sql('touser', $sql, ['courseid' => $userlist->get_context()->instanceid]);
}
}
/**
* Delete data of multiple users within a single context.
*
* @param approved_userlist $userlist The approved context and user information to delete information for.
* @throws dml_exception
*/
public static function delete_data_for_users(approved_userlist $userlist): void {
global $DB;
foreach ($userlist->get_userids() as $userid) {
if ($userlist->get_context() instanceof context_system) {
$DB->delete_records('lifecyclestep_email', ['touser' => $userid]);
} else if ($userlist->get_context() instanceof context_course) {
$DB->delete_records('lifecyclestep_email', ['touser' => $userid,
'courseid' => $userlist->get_context()->instanceid]);
}
}
}
/**
* Delete all data for all users in the specified context.
*
* @param context $context The specific context to delete data for.
* @throws dml_exception
*/
public static function delete_data_for_all_users_in_context(context $context): void {
global $DB;
if ($context instanceof context_system) {
$DB->delete_records('lifecyclestep_email');
} else if ($context instanceof context_course) {
$DB->delete_records('lifecyclestep_email', ['courseid' => $context->instanceid]);
}
}
/**
* 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
* @throws dml_exception
*/
public static function delete_data_for_user(approved_contextlist $contextlist): void {
global $DB;
$user = $contextlist->get_user();
foreach ($contextlist as $context) {
if ($context instanceof context_system) {
$DB->delete_records('lifecyclestep_email', ['touser' => $user->id]);
} else if ($context instanceof context_course) {
$DB->delete_records('lifecyclestep_email', ['touser' => $user->id, 'courseid' => $context->instanceid]);
}
}
}
}
...@@ -49,3 +49,8 @@ $string['email:preventdeletion'] = 'Löschen verhindern'; ...@@ -49,3 +49,8 @@ $string['email:preventdeletion'] = 'Löschen verhindern';
$string['keep_course'] = 'Kurs behalten'; $string['keep_course'] = 'Kurs behalten';
$string['status_message_requiresattention'] = 'Kurs ist zum Löschen vorgemerkt'; $string['status_message_requiresattention'] = 'Kurs ist zum Löschen vorgemerkt';
$string['action_prevented_deletion'] = '{$a} verhinderte Löschung'; $string['action_prevented_deletion'] = '{$a} verhinderte Löschung';
$string['privacy:metadata:lifecyclestep_email:courseid'] = 'Die ID des Kurses, zu dem E-Mail-Benachrichtigungen versandt werden';
$string['privacy:metadata:lifecyclestep_email:instanceid'] = 'Die ID der Schritt-Instanz, der E-Mails verschickt';
$string['privacy:metadata:lifecyclestep_email:summary'] = 'Informationen, welche Benutzer per E-Mail benachrichtigt werden';
$string['privacy:metadata:lifecyclestep_email:touser'] = 'Die ID des Benutzers, an den eine E-Mail verschickt wird';
...@@ -49,3 +49,8 @@ $string['email:preventdeletion'] = 'Prevent deletion'; ...@@ -49,3 +49,8 @@ $string['email:preventdeletion'] = 'Prevent deletion';
$string['keep_course'] = 'Keep course'; $string['keep_course'] = 'Keep course';
$string['status_message_requiresattention'] = 'Course is marked for deletion'; $string['status_message_requiresattention'] = 'Course is marked for deletion';
$string['action_prevented_deletion'] = '{$a} prevented deletion'; $string['action_prevented_deletion'] = '{$a} prevented deletion';
$string['privacy:metadata:lifecyclestep_email:courseid'] = 'ID of the course, emails will be sent for';
$string['privacy:metadata:lifecyclestep_email:instanceid'] = 'ID of the step instance sending emails';
$string['privacy:metadata:lifecyclestep_email:summary'] = 'Information about whhich users will be informed by email';
$string['privacy:metadata:lifecyclestep_email:touser'] = 'ID of the user who is being notified via email';
<?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/>.
/**
* Unit tests for the lifecyclestep_email implementation of the privacy API.
*
* @package lifecyclestep_email
* @copyright 2022 ISB Bayern
* @author Philipp Memmel
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace lifecyclestep_email\privacy;
use context_course;
use context_system;
use core_privacy\local\request\approved_contextlist;
use core_privacy\local\request\approved_userlist;
use core_privacy\local\request\userlist;
use core_privacy\local\request\writer;
use core_privacy\tests\provider_testcase;
use dml_exception;
use stdClass;
use tool_lifecycle\local\entity\step_subplugin;
use tool_lifecycle\local\manager\step_manager;
use tool_lifecycle\local\manager\workflow_manager;
/**
* Unit tests for the lifecyclestep_email implementation of the privacy API.
*
* @package lifecyclestep_email
* @copyright 2022 ISB Bayern
* @author Philipp Memmel
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider_test extends provider_testcase {
/**
* Basic setup for the provider tests.
*
* @return void
* @throws dml_exception
*/
public function setUp(): void {
global $DB;
$this->resetAfterTest();
$this->user1 = $this->getDataGenerator()->create_user();
$this->user2 = $this->getDataGenerator()->create_user();
$this->user3 = $this->getDataGenerator()->create_user();
$this->course1 = $this->getDataGenerator()->create_course();
$this->course2 = $this->getDataGenerator()->create_course();
$this->course3 = $this->getDataGenerator()->create_course();
// Create a lifecycle email step.
$testworkflow = workflow_manager::create_workflow('testworkflow');
$step = new step_subplugin('test email', 'email', $testworkflow->id);
step_manager::insert_or_update($step);
// Add some entries.
$record = new stdClass();
$record->touser = $this->user1->id;
$record->courseid = $this->course1->id;
$record->instanceid = $step->id;
$DB->insert_record('lifecyclestep_email', $record);
$record = new stdClass();
$record->touser = $this->user1->id;
$record->courseid = $this->course2->id;
$record->instanceid = $step->id;
$DB->insert_record('lifecyclestep_email', $record);
$record = new stdClass();
$record->touser = $this->user2->id;
$record->courseid = $this->course1->id;
$record->instanceid = $step->id;
$DB->insert_record('lifecyclestep_email', $record);
$record = new stdClass();
$record->touser = $this->user2->id;
$record->courseid = $this->course2->id;
$record->instanceid = $step->id;
$DB->insert_record('lifecyclestep_email', $record);
$record = new stdClass();
$record->touser = $this->user2->id;
$record->courseid = $this->course3->id;
$record->instanceid = $step->id;
$DB->insert_record('lifecyclestep_email', $record);
$record = new stdClass();
$record->touser = $this->user3->id;
$record->courseid = $this->course3->id;
$record->instanceid = $step->id;
$DB->insert_record('lifecyclestep_email', $record);
// We now have 6 entries in the table, 2 for user1, 3 for user2 and 1 for user3.
}
/**
* Tests \block_lifecyclealert\privacy\provider::get_contexts_for_userid.
*
* @covers \lifecyclestep_email\privacy\provider::get_contexts_for_userid
*/
public function test_get_contexts_for_userid(): void {
$contextlist = provider::get_contexts_for_userid($this->user1->id);
$this->assertEquals(3, $contextlist->count());
$this->assertTrue(in_array(context_system::instance(), $contextlist->get_contexts()));
$this->assertTrue(in_array(context_course::instance($this->course1->id), $contextlist->get_contexts()));
$this->assertTrue(in_array(context_course::instance($this->course2->id), $contextlist->get_contexts()));
}
/**
* Tests \lifecyclestep_email\privacy\provider::export_user_data.
*
* @covers \lifecyclestep_email\privacy\provider::export_user_data
* @return void
* @throws dml_exception
*/
public function test_export_user_data(): void {
global $DB;
$course1context = context_course::instance($this->course1->id);
$course2context = context_course::instance($this->course2->id);
$approvedcontextlist = new approved_contextlist($this->user1, 'lifecyclestep_email',
[context_system::instance()->id, $course1context->id, $course2context->id]);
provider::export_user_data($approvedcontextlist);
$writer = writer::with_context(context_system::instance());
$this->assertTrue($writer->has_any_data());
$recordids = $DB->get_records('lifecyclestep_email', ['touser' => $this->user1->id], '', 'id');
foreach ($recordids as $id) {
$exportedrecord = $writer->get_data(['lifecyclestep_email-' . $id->id]);
$this->assertEquals($this->user1->id, $exportedrecord->touser);
$this->assertTrue(in_array($exportedrecord->courseid, [$this->course1->id, $this->course2->id]));
}
$writer = writer::with_context($course1context);
$this->assertTrue($writer->has_any_data());
$recordids = $DB->get_records('lifecyclestep_email', ['touser' => $this->user1->id,
'courseid' => $this->course1->id], '', 'id');
foreach ($recordids as $id) {
$exportedrecord = $writer->get_data(['lifecyclestep_email-' . $id->id]);
$this->assertEquals($this->user1->id, $exportedrecord->touser);
$this->assertEquals($exportedrecord->courseid, $this->course1->id);
}
$writer = writer::with_context($course2context);
$this->assertTrue($writer->has_any_data());
$recordids = $DB->get_records('lifecyclestep_email', ['touser' => $this->user1->id,
'courseid' => $this->course2->id], '', 'id');
foreach ($recordids as $id) {
$exportedrecord = $writer->get_data(['lifecyclestep_email-' . $id->id]);
$this->assertEquals($this->user1->id, $exportedrecord->touser);
$this->assertEquals($exportedrecord->courseid, $this->course2->id);
}
}
/**
* Tests \lifecyclestep_email\privacy\provider::get_users_in_context.
*
* @covers \lifecyclestep_email\privacy\provider::get_users_in_context
* @return void
* @throws dml_exception
*/
public function test_get_users_in_context(): void {
$userlist = new userlist(context_system::instance(), 'lifecyclestep_email');
provider::get_users_in_context($userlist);
$this->assertCount(3, $userlist->get_userids());
$userlist = new userlist(context_course::instance($this->course1->id), 'lifecyclestep_email');
provider::get_users_in_context($userlist);
$this->assertEquals(2, count($userlist->get_userids()));
$this->assertTrue(in_array($this->user1->id, $userlist->get_userids()));
$this->assertTrue(in_array($this->user2->id, $userlist->get_userids()));
}
/**
* Tests \lifecyclestep_email\privacy\provider::delete_data_for_users with system context.
*
* @covers \lifecyclestep_email\privacy\provider::delete_data_for_users
* @return void
* @throws dml_exception
*/
public function test_delete_data_for_users() {
global $DB;
$approveduserlist = new approved_userlist(context_system::instance(), 'lifecyclestep_email',
[$this->user1->id, $this->user2->id]);
$this->assertEquals(6, count($DB->get_records('lifecyclestep_email')));
provider::delete_data_for_users($approveduserlist);
// Only user3 should be left.
$this->assertEquals(1, count($DB->get_records('lifecyclestep_email')));
foreach ($DB->get_records('lifecyclestep_email') as $record) {
// This should really only be one record.
$this->assertNotEquals($this->user1->id, $record->touser);
$this->assertNotEquals($this->user2->id, $record->touser);
}
}
/**
* Tests \lifecyclestep_email\privacy\provider::delete_data_for_users with a course context.
*
* @covers \lifecyclestep_email\privacy\provider::delete_data_for_users
* @return void
* @throws dml_exception
*/
public function test_delete_data_for_users_coursecontext() {
global $DB;
$approveduserlist = new approved_userlist(context_course::instance($this->course1->id), 'lifecyclestep_email',
[$this->user1->id, $this->user2->id]);
$this->assertEquals(2, count($DB->get_records('lifecyclestep_email', ['courseid' => $this->course1->id])));
provider::delete_data_for_users($approveduserlist);
$this->assertEquals(0, count($DB->get_records('lifecyclestep_email', ['courseid' => $this->course1->id])));
// Other entries should still exist.
$this->assertEquals(4, count($DB->get_records('lifecyclestep_email')));
}
/**
* Tests \lifecyclestep_email\privacy\provider::delete_data_for_all_users_in_context.
*
* @covers \lifecyclestep_email\privacy\provider::delete_data_for_all_users_in_context
* @return void
* @throws dml_exception
*/
public function test_delete_data_for_all_users_in_context(): void {
global $DB;
$this->assertEquals(6, count($DB->get_records('lifecyclestep_email')));
provider::delete_data_for_all_users_in_context(context_system::instance());
$this->assertEmpty($DB->get_records('lifecyclestep_email'));
}
/**
* Tests \lifecyclestep_email\privacy\provider::delete_data_for_all_users_in_context with a course context.
*
* @covers \lifecyclestep_email\privacy\provider::delete_data_for_all_users_in_context
* @return void
* @throws dml_exception
*/
public function test_delete_data_for_all_users_in_context_coursecontext(): void {
global $DB;
$this->assertEquals(2, count($DB->get_records('lifecyclestep_email', ['courseid' => $this->course1->id])));
provider::delete_data_for_all_users_in_context(context_course::instance($this->course1->id));
$this->assertEmpty($DB->get_records('lifecyclestep_email', ['courseid' => $this->course1->id]));
}
/**
* Tests \lifecyclestep_email\privacy\provider::delete_data_for_user.
*
* @covers \lifecyclestep_email\privacy\provider::delete_data_for_user
* @return void
* @throws dml_exception
*/
public function test_delete_data_for_user(): void {
global $DB;
$approvedcontextlist = new approved_contextlist($this->user2, 'lifecyclestep_email',
[context_system::instance()->id]);
$this->assertEquals(6, count($DB->get_records('lifecyclestep_email')));
provider::delete_data_for_user($approvedcontextlist);
$this->assertEquals(3, count($DB->get_records('lifecyclestep_email')));
foreach ($DB->get_records('lifecyclestep_email') as $record) {
// This should really only be one record.
$this->assertNotEquals($this->user2->id, $record->touser);
}
}
/**
* Tests \lifecyclestep_email\privacy\provider::delete_data_for_user.
*
* @covers \lifecyclestep_email\privacy\provider::delete_data_for_user
* @return void
* @throws dml_exception
*/
public function test_delete_data_for_user_coursecontext(): void {
global $DB;
$approvedcontextlist = new approved_contextlist($this->user1, 'lifecyclestep_email',
[context_course::instance($this->course1->id)->id, context_course::instance($this->course2->id)->id]);
$this->assertEquals(6, count($DB->get_records('lifecyclestep_email')));
provider::delete_data_for_user($approvedcontextlist);
$this->assertEquals(0, count($DB->get_records('lifecyclestep_email',
['courseid' => $this->course1->id, 'touser' => $this->user1->id])));
$this->assertEquals(0, count($DB->get_records('lifecyclestep_email',
['courseid' => $this->course2->id, 'touser' => $this->user1->id])));
}
}
<?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/>.
namespace lifecycletrigger_categories\privacy;
use core_privacy\local\metadata\null_provider;
/**
* Privacy subsystem implementation for lifecycletrigger_categories.
*
* @package lifecycletrigger_categories
* @copyright 2022 ISB Bayern
* @author Philipp Memmel
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string the reason
*/
public static function get_reason() : string {
return 'privacy:metadata';
}
}
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
$string['pluginname'] = 'Kategorie-Trigger'; $string['pluginname'] = 'Kategorie-Trigger';
$string['privacy:metadata'] = 'Dieses Subplugin speichert keine persönlichen Daten.';
$string['categories'] = 'Kategorien, für die der Workflow ausgelöst werden soll.'; $string['categories'] = 'Kategorien, für die der Workflow ausgelöst werden soll.';
$string['categories_noselection'] = 'Bitte wählen sie mindestens eine Kategorie aus.'; $string['categories_noselection'] = 'Bitte wählen sie mindestens eine Kategorie aus.';
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
$string['pluginname'] = 'Categories trigger'; $string['pluginname'] = 'Categories trigger';
$string['privacy:metadata'] = 'This subplugin does not store any personal data.';
$string['categories'] = 'Categories, for which the workflow should be triggered'; $string['categories'] = 'Categories, for which the workflow should be triggered';
$string['categories_noselection'] = 'Please choose at least one category.'; $string['categories_noselection'] = 'Please choose at least one category.';
......
<?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/>.
namespace lifecycletrigger_delayedcourses\privacy;
use core_privacy\local\metadata\null_provider;
/**
* Privacy subsystem implementation for lifecycletrigger_delayedcourses.
*
* @package lifecycletrigger_delayedcourses
* @copyright 2022 ISB Bayern
* @author Philipp Memmel
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string the reason
*/
public static function get_reason() : string {
return 'privacy:metadata';
}
}
...@@ -23,5 +23,6 @@ ...@@ -23,5 +23,6 @@
*/ */
$string['pluginname'] = 'Verzögerte Kurse ausschließen - Trigger'; $string['pluginname'] = 'Verzögerte Kurse ausschließen - Trigger';
$string['privacy:metadata'] = 'Dieses Subplugin speichert keine persönlichen Daten.';
$string['delay'] = 'Dieser Trigger wird alle Kurse ausschließen, die durch Nutzerinteraktion verzögert wurden.'; $string['delay'] = 'Dieser Trigger wird alle Kurse ausschließen, die durch Nutzerinteraktion verzögert wurden.';
...@@ -23,5 +23,6 @@ ...@@ -23,5 +23,6 @@
*/ */
$string['pluginname'] = 'Exclude delayed courses trigger'; $string['pluginname'] = 'Exclude delayed courses trigger';
$string['privacy:metadata'] = 'This subplugin does not store any personal data.';
$string['delay'] = 'This module will exclude all courses, which were delayed by user interaction'; $string['delay'] = 'This module will exclude all courses, which were delayed by user interaction';
<?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/>.
namespace lifecycletrigger_manual\privacy;
use core_privacy\local\metadata\null_provider;
/**
* Privacy subsystem implementation for lifecycletrigger_manual.
*
* @package lifecycletrigger_manual
* @copyright 2022 ISB Bayern
* @author Philipp Memmel
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string the reason
*/
public static function get_reason() : string {
return 'privacy:metadata';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment