Commit 2c1e98e6 authored by Petr Skoda's avatar Petr Skoda
Browse files

conversion to 2.0

parent 3c5e59cb
Book module for Moodle Book module for Moodle
Copyright (C) 2004-2010 Petr Skoda (http:skodak.org) Copyright (C) 2004-2010 Petr Skoda (http://skodak.org)
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
...@@ -28,7 +28,6 @@ Installation: ...@@ -28,7 +28,6 @@ Installation:
* see http://docs.moodle.org/en/Installing_contributed_modules_or_plugins * see http://docs.moodle.org/en/Installing_contributed_modules_or_plugins
List of features - version 2.0: List of features - version 2.0:
* easy to use - new teachers can quickly create multipage study materials * easy to use - new teachers can quickly create multipage study materials
* two levels - only chapters and subchapters * two levels - only chapters and subchapters
* possible automatic chapter numbering * possible automatic chapter numbering
...@@ -39,11 +38,10 @@ List of features - version 2.0: ...@@ -39,11 +38,10 @@ List of features - version 2.0:
* support for global searching in study materials (see contrib/search) * support for global searching in study materials (see contrib/search)
* import from html files (relinking of images, flash, Java applets and * import from html files (relinking of images, flash, Java applets and
relative links) relative links)
* works with MySQL and PostgreSQL databases * works with all supported databases
Intentionally omitted features: Intentionally omitted features:
* more chapter levels - it would encourage teachers to write too much * more chapter levels - it would encourage teachers to write too much
complex and long books, better use standard standalone HTML editor and complex and long books, better use standard standalone HTML editor and
import it as Resource. DocBook format is another suitable solution. import it as Resource. DocBook format is another suitable solution.
...@@ -55,7 +53,7 @@ Intentionally omitted features: ...@@ -55,7 +53,7 @@ Intentionally omitted features:
Save page as... in print view Save page as... in print view
Future: Future:
* I like eXe editor, I would like to improve Book in this direction ... ;-) * I like eXe editor, I would like to improve Book in this direction ...
CHANGELOG: CHANGELOG:
== 1.1RC1 - 2004/11/15 ======================================================= == 1.1RC1 - 2004/11/15 =======================================================
......
...@@ -66,17 +66,7 @@ function xmldb_book_upgrade($oldversion) { ...@@ -66,17 +66,7 @@ function xmldb_book_upgrade($oldversion) {
$dbman->add_field($table, $field); $dbman->add_field($table, $field);
} }
// conditionally migrate to html format in intro $DB->set_field('book', 'introformat', FORMAT_HTML, array());
if ($CFG->texteditors !== 'textarea') {
$rs = $DB->get_recordset('book', array('introformat'=>FORMAT_MOODLE), '', 'id,intro,introformat');
foreach ($rs as $r) {
$r->intro = text_to_html($r->intro, false, false, true);
$r->introformat = FORMAT_HTML;
$DB->update_record('book', $r);
upgrade_set_timeout();
}
$rs->close();
}
// book savepoint reached // book savepoint reached
upgrade_mod_savepoint(true, 2010120802, 'book'); upgrade_mod_savepoint(true, 2010120802, 'book');
...@@ -114,6 +104,7 @@ function xmldb_book_upgrade($oldversion) { ...@@ -114,6 +104,7 @@ function xmldb_book_upgrade($oldversion) {
} }
//TODO: add contentformat into book_chapters
//TODO: migrate the legacy file.php links to new pluginfile.php and file areas per chapter //TODO: migrate the legacy file.php links to new pluginfile.php and file areas per chapter
......
<?php <?php
// This file is part of Book module for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
require('teacheraccess.php'); //page only for teachers /**
* Delete book chapter
*
* @package mod
* @subpackage book
* @copyright 2004-2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php');
require_once($CFG->dirroot.'/mod/book/locallib.php'); require_once($CFG->dirroot.'/mod/book/locallib.php');
$confirm = optional_param('confirm', 0, PARAM_BOOL); $id = required_param('id', PARAM_INT); // Course Module ID
$chapterid = required_param('chapterid', PARAM_INT); // Chapter ID
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
$book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST);
require_login($course, false, $cm);
require_sesskey();
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/book:edit', $context);
$chapter = $DB->get_record('book_chapters', array('id'=>$chapterid, 'bookid'=>$book->id), '*', MUST_EXIST);
///header and strings ///header and strings
...@@ -18,29 +54,26 @@ print_header("$course->shortname: $book->name", $course->fullname, $navigation); ...@@ -18,29 +54,26 @@ print_header("$course->shortname: $book->name", $course->fullname, $navigation);
///form processing ///form processing
if ($confirm) { // the operation was confirmed. if ($confirm) { // the operation was confirmed.
if (!$chapter->subchapter) { //delete all its subchapters if any if (!$chapter->subchapter) { //delete all its subchapters if any
$chapters = get_records('book_chapters', 'bookid', $book->id, 'pagenum', 'id, subchapter'); $chapters = $DB->get_records('book_chapters', array('bookid'=>$book->id), 'pagenum', 'id, subchapter');
$found = false; $found = false;
foreach($chapters as $ch) { foreach($chapters as $ch) {
if ($ch->id == $chapter->id) { if ($ch->id == $chapter->id) {
$found = true; $found = true;
} else if ($found and $ch->subchapter) { } else if ($found and $ch->subchapter) {
if (!delete_records('book_chapters', 'id', $ch->id)) { $DB->delete_records('book_chapters', array('id'=>$ch->id));
error('Could not update your book');
}
} else if ($found) { } else if ($found) {
break; break;
} }
} }
} }
if (!delete_records('book_chapters', 'id', $chapter->id)) { $DB->delete_records('book_chapters', array('id'=>$chapter->id));
error('Could not update your book');
}
add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->id, 'book '.$book->id); add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->id, 'book '.$book->id);
add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id, $book->id, $cm->id); add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id, $book->id, $cm->id);
book_check_structure($book->id); book_check_structure($book->id);
redirect('view.php?id='.$cm->id); redirect('view.php?id='.$cm->id);
die;
} else { } else {
// the operation has not been confirmed yet so ask the user to do so // the operation has not been confirmed yet so ask the user to do so
if ($chapter->subchapter) { if ($chapter->subchapter) {
......
<?php <?php
// This file is part of Book module for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Edit book chapter
*
* @package mod
* @subpackage book
* @copyright 2004-2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php'); require('../../config.php');
require_once($CFG->dirroot.'/mod/book/locallib.php'); require_once($CFG->dirroot.'/mod/book/locallib.php');
require_once('edit_form.php'); require_once($CFG->dirroot.'edit_form.php');
$cmid = required_param('cmid', PARAM_INT); // Book Course Module ID $cmid = required_param('cmid', PARAM_INT); // Book Course Module ID
$chapterid = optional_param('id', 0, PARAM_INT); // Chapter ID $chapterid = optional_param('id', 0, PARAM_INT); // Chapter ID
...@@ -13,30 +36,17 @@ $subchapter = optional_param('subchapter', 0, PARAM_BOOL); ...@@ -13,30 +36,17 @@ $subchapter = optional_param('subchapter', 0, PARAM_BOOL);
// security checks START - only teachers edit // security checks START - only teachers edit
// ========================================================================= // =========================================================================
if (!$cm = get_coursemodule_from_id('book', $cmid)) { $cm = get_coursemodule_from_id('book', $cmid, 0, false, MUST_EXIST);
error('Course Module ID was incorrect'); $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
} $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST);
if (!$course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
require_login($course, false, $cm); require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/book:edit', $context); require_capability('mod/book:edit', $context);
if (!$book = get_record('book', 'id', $cm->instance)) {
error('Course module is incorrect');
}
if ($chapterid) { if ($chapterid) {
if (!$chapter = get_record('book_chapters', 'id', $chapterid)) { $chapter = $DB->get_record('book_chapters', array('id'=>$chapterid, 'bookid'=>$book->id), '*', MUST_EXIST);
error('Incorrect chapter id');
}
if ($chapter->bookid != $book->id) {//chapter id not in this book!!!!
error('Chapter not part of this book!');
}
} else { } else {
$chapter = null; $chapter = null;
} }
...@@ -66,12 +76,11 @@ if ($mform->is_cancelled()) { ...@@ -66,12 +76,11 @@ if ($mform->is_cancelled()) {
redirect("view.php?id=$cm->id&chapterid=$chapter->id"); redirect("view.php?id=$cm->id&chapterid=$chapter->id");
} }
} else if ($data = $mform->get_data(false)) { } else if ($data = $mform->get_data()) {
if ($data->id) { if ($data->id) {
if (!update_record('book_chapters', addslashes_recursive($data))) { $DB->update_record('book_chapters', $data);
error('Could not update your book');
}
add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->id, 'book '.$book->id); add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->id, 'book '.$book->id);
add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id.'&chapterid='.$data->id, $book->id, $cm->id); add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id.'&chapterid='.$data->id, $book->id, $cm->id);
...@@ -84,21 +93,19 @@ if ($mform->is_cancelled()) { ...@@ -84,21 +93,19 @@ if ($mform->is_cancelled()) {
$data->importsrc = ''; $data->importsrc = '';
// make room for new page // make room for new page
$sql = "UPDATE {$CFG->prefix}book_chapters $sql = "UPDATE {book_chapters}
SET pagenum = pagenum + 1 SET pagenum = pagenum + 1
WHERE bookid = $book->id AND pagenum >= $data->pagenum"; WHERE bookid = ? AND pagenum >= ?";
execute_sql($sql, false); $DB->execute($sql, array($book->id, $data->pagenum));
$data->id = $DB->insert_record('book_chapters', $data);
if (!$data->id = insert_record('book_chapters', addslashes_recursive($data))) {
error('Could not insert a new chapter');
}
add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->id, 'book '.$book->id); add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->id, 'book '.$book->id);
add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id.'&chapterid='.$data->id, $book->id, $cm->id); add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id.'&chapterid='.$data->id, $book->id, $cm->id);
} }
book_check_structure($book->id); book_check_structure($book->id);
redirect("view.php?id=$cm->id&chapterid=$data->id"); redirect("view.php?id=$cm->id&chapterid=$data->id");
die;
} }
/// Otherwise fill and print the form. /// Otherwise fill and print the form.
......
<?php <?php
// This file is part of Book module for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Chapter edit form
*
* @package mod
* @subpackage book
* @copyright 2004-2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die; defined('MOODLE_INTERNAL') || die;
...@@ -8,7 +31,7 @@ class book_chapter_edit_form extends moodleform { ...@@ -8,7 +31,7 @@ class book_chapter_edit_form extends moodleform {
function definition() { function definition() {
global $CFG; global $CFG;
$mform =& $this->_form; $mform = $this->_form;
$cm = $this->_customdata; $cm = $this->_customdata;
$mform->addElement('header', 'general', get_string('edit')); $mform->addElement('header', 'general', get_string('edit'));
...@@ -21,7 +44,6 @@ class book_chapter_edit_form extends moodleform { ...@@ -21,7 +44,6 @@ class book_chapter_edit_form extends moodleform {
$mform->addElement('htmleditor', 'content', get_string('content', 'book'), array('cols'=>50, 'rows'=>30)); $mform->addElement('htmleditor', 'content', get_string('content', 'book'), array('cols'=>50, 'rows'=>30));
$mform->setType('content', PARAM_RAW); $mform->setType('content', PARAM_RAW);
$mform->setHelpButton('content', array('reading', 'writing', 'questions', 'richtext'), false, 'editorhelpbutton');
$mform->addElement('hidden', 'id'); $mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT); $mform->setType('id', PARAM_INT);
...@@ -42,7 +64,7 @@ class book_chapter_edit_form extends moodleform { ...@@ -42,7 +64,7 @@ class book_chapter_edit_form extends moodleform {
function definition_after_data() { function definition_after_data() {
global $CFG; global $CFG;
$mform =& $this->_form; $mform = $this->_form;
if ($mform->getElementValue('id')) { if ($mform->getElementValue('id')) {
if ($mform->elementExists('doimport')) { if ($mform->elementExists('doimport')) {
......
<?php <?php
// This file is part of Book module for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Book import
*
* @package mod
* @subpackage book
* @copyright 2004-2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php'); require('../../config.php');
require_once($CFG->dirroot.'/mod/book/locallib.php'); require_once($CFG->dirroot.'/mod/book/locallib.php');
...@@ -10,23 +33,15 @@ $id = required_param('id', PARAM_INT); // Course Module ID ...@@ -10,23 +33,15 @@ $id = required_param('id', PARAM_INT); // Course Module ID
// security checks START - only teachers edit // security checks START - only teachers edit
// ========================================================================= // =========================================================================
if (!$cm = get_coursemodule_from_id('book', $id)) { $cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST);
error('Course Module ID was incorrect'); $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
} $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST);
if (!$course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
require_login($course, false, $cm); require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/book:import', $context); require_capability('mod/book:import', $context);
if (!$book = get_record('book', 'id', $cm->instance)) {
error('Course module is incorrect');
}
//check all variables //check all variables
unset($id); unset($id);
...@@ -94,12 +109,9 @@ if ($mform->is_cancelled()) { ...@@ -94,12 +109,9 @@ if ($mform->is_cancelled()) {
foreach($refs as $ref) { foreach($refs as $ref) {
$chapter = book_read_chapter($coursebase, $ref); $chapter = book_read_chapter($coursebase, $ref);
if ($chapter) { if ($chapter) {
$chapter->title = addslashes($chapter->title); $chapter->bookid = $book->id;
$chapter->content = addslashes($chapter->content); $chapter->pagenum = $DB->count_records('book_chapters', array('bookid'=>$book->id)+1;
$chapter->importsrc = addslashes($chapter->importsrc); $chapter->timecreated = time();
$chapter->bookid = $book->id;
$chapter->pagenum = count_records('book_chapters', 'bookid', $book->id)+1;
$chapter->timecreated = time();
$chapter->timemodified = time(); $chapter->timemodified = time();
echo "imsrc:".$chapter->importsrc; echo "imsrc:".$chapter->importsrc;
if (($data->subchapter) || preg_match('/_sub\.htm/i', $chapter->importsrc)) { //if filename or directory starts with sub_* treat as subdirecotories if (($data->subchapter) || preg_match('/_sub\.htm/i', $chapter->importsrc)) { //if filename or directory starts with sub_* treat as subdirecotories
...@@ -107,9 +119,8 @@ if ($mform->is_cancelled()) { ...@@ -107,9 +119,8 @@ if ($mform->is_cancelled()) {
} else { } else {
$chapter->subchapter = 0; $chapter->subchapter = 0;
} }
if (!$chapter->id = insert_record('book_chapters', $chapter)) { $chapter->id = $DB->insert_record('book_chapters', $chapter);
error('Could not update your book');
}
add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->id, 'book '.$book->id); add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->id, 'book '.$book->id);
add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id.'&chapterid='.$chapter->id, $book->id, $cm->id); add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id.'&chapterid='.$chapter->id, $book->id, $cm->id);
} }
......
<?php <?php
// This file is part of Book module for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Book import form
*
* @package mod
* @subpackage book
* @copyright 2004-2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->libdir.'/formslib.php'); require_once($CFG->libdir.'/formslib.php');
...@@ -6,7 +29,7 @@ class book_import_form extends moodleform { ...@@ -6,7 +29,7 @@ class book_import_form extends moodleform {
function definition() { function definition() {
global $CFG; global $CFG;
$mform =& $this->_form; $mform = $this->_form;
$cm = $this->_customdata; $cm = $this->_customdata;
$mform->addElement('header', 'general', get_string('import')); $mform->addElement('header', 'general', get_string('import'));
...@@ -36,7 +59,7 @@ class book_import_form extends moodleform { ...@@ -36,7 +59,7 @@ class book_import_form extends moodleform {
$cm = $this->_customdata; $cm = $this->_customdata;
$errors = parent::validation($data, $files); $errors = parent::validation($data, $files);
$reference = stripslashes($data['reference']); $reference = $data['reference'];
if ($reference != '') { //null path is root if ($reference != '') { //null path is root
$reference = book_prepare_link($reference); $reference = book_prepare_link($reference);
......
...@@ -11,9 +11,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID ...@@ -11,9 +11,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID
// security checks START - teachers and students view // security checks START - teachers and students view
// ========================================================================= // =========================================================================
if (!$course = get_record('course', 'id', $id)) { $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
error('Course ID is incorrect');
}
require_course_login($course, true); require_course_login($course, true);
...@@ -65,7 +63,7 @@ $currentsection = ''; ...@@ -65,7 +63,7 @@ $currentsection = '';
foreach ($books as $book) { foreach ($books as $book) {
$nocleanoption = new object(); $nocleanoption = new object();
$nocleanoption->noclean = true; $nocleanoption->noclean = true;
$book->summary = format_text($book->summary, FORMAT_HTML, $nocleanoption, $course->id); $book->summary = format_text($book->intro, $book->introformat, $nocleanoption, $course->id);
$book->summary = '<span style="font-size:x-small;">'.$book->summary.'</span>'; $book->summary = '<span style="font-size:x-small;">'.$book->summary.'</span>';
if (!$book->visible) { if (!$book->visible) {
...@@ -76,7 +74,7 @@ foreach ($books as $book) { ...@@ -76,7 +74,7 @@ foreach ($books as $book) {
$link = '<a href="view.php?id='.$book->coursemodule.'">'.$book->name.'</a>'; $link = '<a href="view.php?id='.$book->coursemodule.'">'.$book->name.'</a>';
} }
$count = count_records('book_chapters', 'bookid', $book->id, 'hidden', '0'); $count = $DB->count_records('book_chapters', array('bookid'=>$book->id, 'hidden'=>'0'));
if ($course->format == 'weeks' or $course->format == 'topics') { if ($course->format == 'weeks' or $course->format == 'topics') {
$printsection = ''; $printsection = '';
......
...@@ -44,11 +44,16 @@ function book_get_numbering_types() { ...@@ -44,11 +44,16 @@ function book_get_numbering_types() {
/// Any other book functions go here. Each of them must have a name that /// Any other book functions go here. Each of them must have a name that
/// starts with book_ /// starts with book_
//check chapter ordering and /**
//make sure subchapter is not first in book * check chapter ordering and make sure subchapter is not first
//hidden chapter must have all subchapters hidden too * in book hidden chapter must have all subchapters hidden too
* @param int $id
* @return void
*/
function book_check_structure($bookid) { function book_check_structure($bookid) {
if ($chapters = get_records('book_chapters', 'bookid', $bookid, 'pagenum', 'id, pagenum, subchapter, hidden')) { global $DB;