Commit 794604db authored by Mihail Geshoski's avatar Mihail Geshoski Committed by Juan Leyva
Browse files

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

parent 8e9e9a5f
......@@ -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'),
......
......@@ -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).
......
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