Skip to content

Commit

Permalink
MDL-61743 core_privacy: Reduce context specificty
Browse files Browse the repository at this point in the history
Deletion is called for a context against all components, not just
modules.
  • Loading branch information
andrewnicols authored and David Monllao committed Apr 6, 2018
1 parent 2bd2660 commit fa9243c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions privacy/classes/local/request/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ public static function export_data_for_null_provider(approved_contextlist $conte
* @param context $context The specific context to delete data for.
*/
public static function delete_data_for_all_users_in_context(string $component, \context $context) {
if (strpos($component, 'mod_') === 0) {
// Activity modules support data stored by core about them - for example, activity completion.
static::delete_data_for_all_users_in_context_course_module($component, $context);
}
// Activity modules support data stored by core about them - for example, activity completion.
static::delete_data_for_all_users_in_context_course_module($component, $context);
}

/**
Expand All @@ -106,10 +104,8 @@ public static function delete_data_for_all_users_in_context(string $component, \
public static function delete_data_for_user(approved_contextlist $contextlist) {
$component = $contextlist->get_component();

if (strpos($component, 'mod_') === 0) {
// Activity modules support data stored by core about them - for example, activity completion.
static::delete_data_for_user_in_course_module($contextlist);
}
// Activity modules support data stored by core about them - for example, activity completion.
static::delete_data_for_user_in_course_module($contextlist);
}

/**
Expand Down Expand Up @@ -270,13 +266,15 @@ protected static function export_context_module_files(\context_module $context,
* This will handle deletion for things such as activity completion.
*
* @param string $component The component being deleted for.
* @param \context_module $context The context to delete all data for.
* @param \context $context The context to delete all data for.
*/
public static function delete_data_for_all_users_in_context_course_module(string $component, \context_module $context) {
public static function delete_data_for_all_users_in_context_course_module(string $component, \context $context) {
global $DB;

// Delete course completion data for this context.
$DB->delete_records('course_modules_completion', ['coursemoduleid' => $context->instanceid]);
if ($context instanceof \context_module) {
// Delete course completion data for this context.
$DB->delete_records('course_modules_completion', ['coursemoduleid' => $context->instanceid]);
}
}

/**
Expand All @@ -290,11 +288,13 @@ protected static function delete_data_for_user_in_course_module(approved_context
global $DB;

foreach ($contextlist as $context) {
// Delete course completion data for this context.
$DB->delete_records('course_modules_completion', [
'coursemoduleid' => $context->instanceid,
'userid' => $contextlist->get_user()->id,
]);
if ($context instanceof \context_module) {
// Delete course completion data for this context.
$DB->delete_records('course_modules_completion', [
'coursemoduleid' => $context->instanceid,
'userid' => $contextlist->get_user()->id,
]);
}
}

}
Expand Down

0 comments on commit fa9243c

Please sign in to comment.