Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue#110 fixed delete operations in privacy provider #112

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace tool_securityquestions\privacy;
use core_privacy\local\metadata\collection;
use core_privacy\local\request\contextlist;
use core_privacy\local\request\approved_contextlist;
Expand Down Expand Up @@ -219,32 +218,13 @@ public static function delete_data_for_all_users_in_context(\context $context) {
public static function delete_data_for_user(approved_contextlist $contextlist) {
global $DB;
$userid = $contextlist->get_user()->id;

foreach ($contextlist as $context) {

// If not in user context, exit loop.
if ($context->contextlevel == CONTEXT_SYSTEM) {

$sql = "
DELETE
FROM {tool_securityquestions_ans} l
WHERE l.userid = :userid";

$DB->execute($sql, ['userid' => $userid]);

$sql = "
DELETE
FROM {tool_securityquestions_loc} l
WHERE l.userid = :userid";

$DB->execute($sql, ['userid' => $userid]);

$sql = "
DELETE
FROM {tool_securityquestions_res} l
WHERE l.userid = :userid";

$DB->execute($sql, ['userid' => $userid]);
$DB->delete_records('tool_securityquestions_res', ['userid' => $userid]);
$DB->delete_records('tool_securityquestions_ans', ['userid' => $userid]);
$DB->delete_records('tool_securityquestions_loc', ['userid' => $userid]);
}
}
}
Expand Down
Loading