mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 03:46:42 +02:00
MDL-61937 mod_data: fix commentarea name
This commit is contained in:
parent
763db71ad3
commit
7e34297bc4
1 changed files with 11 additions and 13 deletions
|
@ -48,9 +48,6 @@ class provider implements
|
||||||
// This plugin is a core_user_data_provider.
|
// This plugin is a core_user_data_provider.
|
||||||
\core_privacy\local\request\plugin\provider {
|
\core_privacy\local\request\plugin\provider {
|
||||||
|
|
||||||
/** @var array stores list of records marked for deletion */
|
|
||||||
protected static $deletedrecords = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the fields which contain personal data.
|
* Return the fields which contain personal data.
|
||||||
*
|
*
|
||||||
|
@ -324,6 +321,7 @@ class provider implements
|
||||||
if (!$context instanceof \context_module) {
|
if (!$context instanceof \context_module) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$recordstobedeleted = [];
|
||||||
|
|
||||||
$sql = "SELECT " . self::sql_fields() . "
|
$sql = "SELECT " . self::sql_fields() . "
|
||||||
FROM {course_modules} cm
|
FROM {course_modules} cm
|
||||||
|
@ -337,10 +335,11 @@ class provider implements
|
||||||
$rs = $DB->get_recordset_sql($sql, ['cmid' => $context->instanceid, 'modname' => 'data']);
|
$rs = $DB->get_recordset_sql($sql, ['cmid' => $context->instanceid, 'modname' => 'data']);
|
||||||
foreach ($rs as $row) {
|
foreach ($rs as $row) {
|
||||||
self::mark_data_content_for_deletion($context, $row);
|
self::mark_data_content_for_deletion($context, $row);
|
||||||
|
$recordstobedeleted[$row->recordid] = $row->recordid;
|
||||||
}
|
}
|
||||||
$rs->close();
|
$rs->close();
|
||||||
|
|
||||||
self::delete_data_records($context);
|
self::delete_data_records($context, $recordstobedeleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -356,6 +355,7 @@ class provider implements
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $contextlist->get_user();
|
$user = $contextlist->get_user();
|
||||||
|
$recordstobedeleted = [];
|
||||||
|
|
||||||
foreach ($contextlist->get_contexts() as $context) {
|
foreach ($contextlist->get_contexts() as $context) {
|
||||||
$sql = "SELECT " . self::sql_fields() . "
|
$sql = "SELECT " . self::sql_fields() . "
|
||||||
|
@ -372,13 +372,14 @@ class provider implements
|
||||||
'modname' => 'data', 'userid' => $user->id]);
|
'modname' => 'data', 'userid' => $user->id]);
|
||||||
foreach ($rs as $row) {
|
foreach ($rs as $row) {
|
||||||
self::mark_data_content_for_deletion($context, $row);
|
self::mark_data_content_for_deletion($context, $row);
|
||||||
|
$recordstobedeleted[$row->recordid] = $row->recordid;
|
||||||
}
|
}
|
||||||
$rs->close();
|
$rs->close();
|
||||||
self::delete_data_records($context);
|
self::delete_data_records($context, $recordstobedeleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Additionally remove comments this user made on other entries.
|
// Additionally remove comments this user made on other entries.
|
||||||
\core_comment\privacy\provider::delete_comments_for_user($contextlist, 'mod_data', 'entry');
|
\core_comment\privacy\provider::delete_comments_for_user($contextlist, 'mod_data', 'database_entry');
|
||||||
|
|
||||||
// We do not delete ratings made by this user on other records because it may change grades.
|
// We do not delete ratings made by this user on other records because it may change grades.
|
||||||
}
|
}
|
||||||
|
@ -405,8 +406,6 @@ class provider implements
|
||||||
[$context, $recordobj, $fieldobj, $contentobj]);
|
[$context, $recordobj, $fieldobj, $contentobj]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$deletedrecords[$recordobj->id] = $recordobj->id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -417,14 +416,15 @@ class provider implements
|
||||||
* Deletes records from data_content and data_records tables, associated files, tags, comments and ratings.
|
* Deletes records from data_content and data_records tables, associated files, tags, comments and ratings.
|
||||||
*
|
*
|
||||||
* @param \context $context
|
* @param \context $context
|
||||||
|
* @param array $recordstobedeleted list of ids of the data records that need to be deleted
|
||||||
*/
|
*/
|
||||||
protected static function delete_data_records($context) {
|
protected static function delete_data_records($context, $recordstobedeleted) {
|
||||||
global $DB;
|
global $DB;
|
||||||
if (empty(self::$deletedrecords)) {
|
if (empty($recordstobedeleted)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($sql, $params) = $DB->get_in_or_equal(self::$deletedrecords, SQL_PARAMS_NAMED);
|
list($sql, $params) = $DB->get_in_or_equal($recordstobedeleted, SQL_PARAMS_NAMED);
|
||||||
|
|
||||||
// Delete files.
|
// Delete files.
|
||||||
get_file_storage()->delete_area_files_select($context->id, 'mod_data', 'data_records',
|
get_file_storage()->delete_area_files_select($context->id, 'mod_data', 'data_records',
|
||||||
|
@ -439,7 +439,5 @@ class provider implements
|
||||||
\core_comment\privacy\provider::delete_comments_for_all_users_select($context, 'mod_data', 'database_entry', $sql, $params);
|
\core_comment\privacy\provider::delete_comments_for_all_users_select($context, 'mod_data', 'database_entry', $sql, $params);
|
||||||
// Delete ratings.
|
// Delete ratings.
|
||||||
\core_rating\privacy\provider::delete_ratings_select($context, 'mod_data', 'entry', $sql, $params);
|
\core_rating\privacy\provider::delete_ratings_select($context, 'mod_data', 'entry', $sql, $params);
|
||||||
|
|
||||||
self::$deletedrecords = [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue