Skip to content

Commit

Permalink
Merge pull request #112 from JackBoylan97/issue110
Browse files Browse the repository at this point in the history
issue#110 fixed delete operations in privacy provider
  • Loading branch information
Peterburnett authored Jan 19, 2024
2 parents 25192bc + 7ff6894 commit 675debd
Showing 1 changed file with 3 additions and 23 deletions.
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

0 comments on commit 675debd

Please sign in to comment.