Merge branch 'MDL-61743_master' of git://github.com/dmonllao/moodle
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,9 +118,14 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l
|
||||
/**
|
||||
* Delete all use data which matches the specified deletion_criteria.
|
||||
*
|
||||
* @param context $context A user context.
|
||||
* @param context $context A context.
|
||||
*/
|
||||
public static function delete_data_for_all_users_in_context(\context $context) {
|
||||
|
||||
if (!$context instanceof \context_user) {
|
||||
return;
|
||||
}
|
||||
|
||||
static::delete_data($context->instanceid);
|
||||
}
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
@@ -90,10 +90,8 @@ class helper {
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,10 +104,8 @@ class helper {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,13 +266,15 @@ class helper {
|
||||
* 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]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,11 +288,13 @@ class helper {
|
||||
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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user