mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-60129 mod_forum: added reset tags functionality
This commit is contained in:
parent
19f8efd3be
commit
0b9249e63e
@ -7018,13 +7018,17 @@ function forum_reset_userdata($data) {
|
||||
|
||||
$forumssql = $forums = $rm = null;
|
||||
|
||||
if( $removeposts || !empty($data->reset_forum_ratings) ) {
|
||||
$forumssql = "$allforumssql $typesql";
|
||||
$forums = $forums = $DB->get_records_sql($forumssql, $params);
|
||||
// Check if we need to get additional data.
|
||||
if ($removeposts || !empty($data->reset_forum_ratings) || !empty($data->reset_forum_tags)) {
|
||||
// Set this up if we have to remove ratings.
|
||||
$rm = new rating_manager();
|
||||
$ratingdeloptions = new stdClass;
|
||||
$ratingdeloptions->component = 'mod_forum';
|
||||
$ratingdeloptions->ratingarea = 'post';
|
||||
|
||||
// Get the forums for actions that require it.
|
||||
$forumssql = "$allforumssql $typesql";
|
||||
$forums = $DB->get_records_sql($forumssql, $params);
|
||||
}
|
||||
|
||||
if ($removeposts) {
|
||||
@ -7045,6 +7049,8 @@ function forum_reset_userdata($data) {
|
||||
//remove ratings
|
||||
$ratingdeloptions->contextid = $context->id;
|
||||
$rm->delete_ratings($ratingdeloptions);
|
||||
|
||||
core_tag_tag::delete_instances('mod_forum', null, $context->id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7099,6 +7105,22 @@ function forum_reset_userdata($data) {
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all the tags.
|
||||
if (!empty($data->reset_forum_tags)) {
|
||||
if ($forums) {
|
||||
foreach ($forums as $forumid => $unused) {
|
||||
if (!$cm = get_coursemodule_from_instance('forum', $forumid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$context = context_module::instance($cm->id);
|
||||
core_tag_tag::delete_instances('mod_forum', null, $context->id);
|
||||
}
|
||||
}
|
||||
|
||||
$status[] = array('component' => $componentstr, 'item' => get_string('tagsdeleted', 'forum'), 'error' => false);
|
||||
}
|
||||
|
||||
// remove all digest settings unconditionally - even for users still enrolled in course.
|
||||
if (!empty($data->reset_forum_digests)) {
|
||||
$DB->delete_records_select('forum_digests', "forum IN ($allforumssql)", $params);
|
||||
@ -7155,6 +7177,9 @@ function forum_reset_course_form_definition(&$mform) {
|
||||
|
||||
$mform->addElement('checkbox', 'reset_forum_ratings', get_string('deleteallratings'));
|
||||
$mform->disabledIf('reset_forum_ratings', 'reset_forum_all', 'checked');
|
||||
|
||||
$mform->addElement('checkbox', 'reset_forum_tags', get_string('removeallforumtags', 'forum'));
|
||||
$mform->disabledIf('reset_forum_tags', 'reset_forum_all', 'checked');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user