Hidden chapters are still accessible in visible books

Hidden chapters are still accessible in visible books

by Prateek Sachan -
Number of replies: 1
Can still access hidden chapters in added in mod book which is visible from student user type.

    // $id = chapter_id 

try { $chapter = $DB->get_record('book_chapters', array('id'=>$id), '*', MUST_EXIST); $book = $DB->get_record('book', array('id'=>$chapter->bookid), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('book', $book->id, $book->course, MUST_EXIST); $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); } catch (dml_missing_record_exception $ex) { return NULL; } try { $context = context_module::instance($cm->id); if (!$cm->visible && !has_capability('mod/book:viewhiddenchapters', $context)) { return NULL; } require_capability('mod/book:read', $context); } catch (moodle_exception $ex) { return NULL; }
return TRUE;

Average of ratings: -
In reply to Prateek Sachan

Re: Hidden chapters are still accessible in visible books

by Juan F -

I just upgraded to Moodle 2.8 and have this issue.  How do I fix it?

Thanks, Chris