mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
MDL-61743 core_privacy: Add context level checks for all users deletion
This commit is contained in:
parent
fa9243cd85
commit
3650af761a
@ -153,6 +153,11 @@ class provider implements
|
||||
* @param context $context The specific context to delete data for.
|
||||
*/
|
||||
public static function delete_data_for_all_users_in_context(\context $context) {
|
||||
|
||||
if (!$context instanceof \context_block) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The only way to delete data for the html block is to delete the block instance itself.
|
||||
blocks_delete_instance(static::get_instance_from_context($context));
|
||||
}
|
||||
@ -165,6 +170,10 @@ class provider implements
|
||||
public static function delete_data_for_user(approved_contextlist $contextlist) {
|
||||
// The only way to delete data for the html block is to delete the block instance itself.
|
||||
foreach ($contextlist as $context) {
|
||||
|
||||
if (!$context instanceof \context_block) {
|
||||
continue;
|
||||
}
|
||||
blocks_delete_instance(static::get_instance_from_context($context));
|
||||
}
|
||||
}
|
||||
|
@ -184,6 +184,11 @@ class provider implements
|
||||
if (empty($context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$context instanceof \context_module) {
|
||||
return;
|
||||
}
|
||||
|
||||
$instanceid = $DB->get_field('course_modules', 'instance', ['id' => $context->instanceid], MUST_EXIST);
|
||||
$DB->delete_records('choice_answers', ['choiceid' => $instanceid]);
|
||||
}
|
||||
@ -202,6 +207,10 @@ class provider implements
|
||||
|
||||
$userid = $contextlist->get_user()->id;
|
||||
foreach ($contextlist->get_contexts() as $context) {
|
||||
|
||||
if (!$context instanceof \context_module) {
|
||||
return;
|
||||
}
|
||||
$instanceid = $DB->get_field('course_modules', 'instance', ['id' => $context->instanceid], MUST_EXIST);
|
||||
$DB->delete_records('choice_answers', ['choiceid' => $instanceid, 'userid' => $userid]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user