Commit 19f8efd3 authored by Mark Nelson's avatar Mark Nelson
Browse files

MDL-60129 mod_book: added reset tags functionality

parent 23ab0d77
......@@ -164,10 +164,44 @@ function book_print_recent_activity($course, $viewfullnames, $timestart) {
* @return array status array
*/
function book_reset_userdata($data) {
global $DB;
// Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
// See MDL-9367.
return array();
$status = [];
if (!empty($data->reset_book_tags)) {
// Loop through the books and remove the tags from the chapters.
if ($books = $DB->get_records('book', array('course' => $data->courseid))) {
foreach ($books as $book) {
if (!$cm = get_coursemodule_from_instance('book', $book->id)) {
continue;
}
$context = context_module::instance($cm->id);
core_tag_tag::delete_instances('mod_book', null, $context->id);
}
}
$status[] = [
'component' => get_string('modulenameplural', 'book'),
'item' => get_string('tagsdeleted', 'book'),
'error' => false
];
}
return $status;
}
/**
* The elements to add the course reset form.
*
* @param moodleform $mform
*/
function book_reset_course_form_definition(&$mform) {
$mform->addElement('header', 'bookheader', get_string('modulenameplural', 'book'));
$mform->addElement('checkbox', 'reset_book_tags', get_string('removeallbooktags', 'book'));
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment