Skip to content

Commit

Permalink
Merge branch 'MDL-64737-master-attoprivacysql' of git://github.com/mu…
Browse files Browse the repository at this point in the history
…drd8mz/moodle
  • Loading branch information
stronk7 committed Jan 31, 2019
2 parents 479c681 + 599abfa commit f385378
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions lib/editor/atto/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,30 @@ public static function export_user_data(approved_contextlist $contextlist) {

$user = $contextlist->get_user();

// Firstly export all autosave records from all contexts in the list owned by the given user.

list($contextsql, $contextparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
$contextparams['userid'] = $user->id;

$sql = "SELECT *
FROM {editor_atto_autosave}
WHERE userid = :userid AND contextid {$contextsql}";

list($contextsql, $contextparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
$contextparams['userid'] = $contextlist->get_user()->id;
$autosaves = $DB->get_recordset_sql($sql, $contextparams);
self::export_autosaves($user, $autosaves);

$sql = "SELECT *
FROM {editor_atto_autosave}
JOIN {context} c ON c.id = eas.contextid
WHERE c.id {$contextsql} AND contextlevel = :contextuser AND c.instanceid = :userid";
// Additionally export all eventual records in the given user's context regardless the actual owner.
// We still consider them to be the user's personal data even when edited by someone else.

list($contextsql, $contextparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
$contextparams['userid'] = $contextlist->get_user()->id;
$contextparams['userid'] = $user->id;
$contextparams['contextuser'] = CONTEXT_USER;

$sql = "SELECT eas.*
FROM {editor_atto_autosave} eas
JOIN {context} c ON c.id = eas.contextid
WHERE c.id {$contextsql} AND c.contextlevel = :contextuser AND c.instanceid = :userid";

$autosaves = $DB->get_recordset_sql($sql, $contextparams);
self::export_autosaves($user, $autosaves);
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit f385378

Please sign in to comment.