mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-60129 mod_book: added reset tags functionality
This commit is contained in:
parent
23ab0d7788
commit
19f8efd3be
1 changed files with 35 additions and 1 deletions
|
@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue