Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
19f8efd3
Commit
19f8efd3
authored
Sep 20, 2017
by
Mark Nelson
Browse files
MDL-60129 mod_book: added reset tags functionality
parent
23ab0d77
Changes
1
Hide whitespace changes
Inline
Side-by-side
mod/book/lib.php
View file @
19f8efd3
...
...
@@ -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'
));
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment