MDL-65653 book: Display hidden chapters in WS when user has capability

This commit is contained in:
Mihail Geshoski 2019-05-21 11:35:26 +08:00 committed by Juan Leyva
parent 8e9e9a5f7e
commit 794604db6d
2 changed files with 3 additions and 1 deletions

View file

@ -489,6 +489,7 @@ class core_course_external extends external_api {
VALUE_OPTIONAL),
'repositorytype' => new external_value(PARAM_PLUGIN, 'The repository type for external files.',
VALUE_OPTIONAL),
'ishidden' => new external_value(PARAM_BOOL, 'Whether the content is hidden.', VALUE_OPTIONAL),
// copyright related info
'userid' => new external_value(PARAM_INT, 'User who added this content to moodle'),

View file

@ -570,7 +570,7 @@ function book_export_contents($cm, $baseurl) {
$currentchapter = 0;
foreach ($chapters as $chapter) {
if ($chapter->hidden) {
if ($chapter->hidden && !has_capability('mod/book:viewhiddenchapters', $context)) {
continue;
}
@ -612,6 +612,7 @@ function book_export_contents($cm, $baseurl) {
$chapterindexfile['author'] = null;
$chapterindexfile['license'] = null;
$chapterindexfile['tags'] = \core_tag\external\util::get_item_tags('mod_book', 'book_chapters', $chapter->id);
$chapterindexfile['ishidden'] = (bool) $chapter->hidden;
$contents[] = $chapterindexfile;
// Chapter files (images usually).