From 794604db6d797e7923064087141771a18a3f73b5 Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Tue, 21 May 2019 11:35:26 +0800 Subject: [PATCH] MDL-65653 book: Display hidden chapters in WS when user has capability --- course/externallib.php | 1 + mod/book/lib.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/course/externallib.php b/course/externallib.php index 7f3a170a75b..d2ba0205416 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -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'), diff --git a/mod/book/lib.php b/mod/book/lib.php index 0b4887f80ba..bfd5223e3cc 100644 --- a/mod/book/lib.php +++ b/mod/book/lib.php @@ -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).