Skip to content

Commit

Permalink
MDL-62035 core_blog: Update to blog with comments.
Browse files Browse the repository at this point in the history
This makes blog use the updated delete methods in the
comments provider.
  • Loading branch information
abgreeve committed Apr 20, 2018
1 parent 1b33e41 commit 8c6fae4
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions blog/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,8 @@ public static function delete_data_for_all_users_in_context(context $context) {
$DB->delete_records('blog_association', ['contextid' => $context->id]);
break;
}

// Delete all the comments.
\core_comment\privacy\provider::delete_comments_for_all_users_in_context($context);
\core_comment\privacy\provider::delete_comments_for_all_users($context, 'blog', 'format_blog');
}

/**
Expand All @@ -383,21 +382,21 @@ 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;
$associationcontextids = [];

foreach ($contextlist as $context) {
if ($context->contextlevel == CONTEXT_USER && $context->instanceid == $userid) {
static::delete_all_user_data($context);

\core_comment\privacy\provider::delete_comments_for_all_users($context, 'blog', 'format_blog');
} else if ($context->contextlevel == CONTEXT_COURSE) {
// Only delete the course associations.
$associationcontextids[] = $context->id;

} else if ($context->contextlevel == CONTEXT_MODULE) {
// Only delete the module associations.
$associationcontextids[] = $context->id;
} else {
\core_comment\privacy\provider::delete_comments_for_user($contextlist, 'blog', 'format_blog');
}
}

Expand All @@ -416,9 +415,6 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
list($insql, $inparams) = $DB->get_in_or_equal($associds, SQL_PARAMS_NAMED, 'param', true);
$DB->delete_records_select('blog_association', "id $insql", $inparams);
}

// Delete the comments.
\core_comment\privacy\provider::delete_comments_for_user($contextlist);
}

/**
Expand All @@ -443,9 +439,6 @@ protected static function delete_all_user_data(context_user $usercontext) {
// Delete all external blogs, and their associated tags.
$DB->delete_records('blog_external', ['userid' => $userid]);
core_tag_tag::delete_instances('core', 'blog_external', $usercontext->id);

// Delete all comments made in this context.
$DB->delete_records('comments', ['contextid' => $usercontext->id, 'component' => 'blog', 'commentarea' => 'format_blog']);
}

/**
Expand Down

0 comments on commit 8c6fae4

Please sign in to comment.