forcelogin) { require_login(); } if (!$cm = get_record('course_modules', 'id', $id)) { error('Course Module ID was incorrect'); } if (!$course = get_record('course', 'id', $cm->course)) { error('Course is misconfigured'); } if ($course->category) { require_login($course->id); } if (!$cm->visible and !isteacher($course->id)) { notice(get_string('activityiscurrentlyhidden')); } if (!$book = get_record('book', 'id', $cm->instance)) { error('Course module is incorrect'); } if ($book->disableprinting) { error('Printing is disabled'); } //check all variables if ($chapterid) { //single chapter printing if (!$chapter = get_record('book_chapters', 'id', $chapterid)) { error('Incorrect chapter ID'); } if ($chapter->bookid != $book->id) {//chapter id not in this book!!!! error('Chapter not in this book!'); } if ($chapter->hidden) { error('Only visible chapters can be printed'); } } else { //complete book $chapter = false; } unset($id); unset($chapterid); // ========================================================================= // security checks END // ========================================================================= $strbooks = get_string('modulenameplural', 'book'); $strbook = get_string('modulename', 'book'); $strtop = get_string('top', 'book'); if (!empty($CFG->unicode)) { $encoding = 'utf-8'; } else { $encoding = get_string('thischarset'); } moodle_setlocale(); //workaround for buggy forced course language @header('Cache-Control: private, pre-check=0, post-check=0, max-age=0'); @header('Pragma: no-cache'); @header('Expires: '); @header('Accept-Ranges: none'); @header('Content-type: text/html; charset='.$encoding); $formatoptions = new stdClass; $formatoptions->noclean = true; if ($chapter) { add_to_log($course->id, 'book', 'print', 'print.php?id='.$cm->id.'&chapterid='.$chapter->id, $book->id, $cm->id); $chapters = get_records('book_chapters', 'bookid', $book->id, 'pagenum, title'); $print = 0; $edit = 0; require('toc.php'); /// page header ?> <?PHP echo str_replace('"', '"', $book->name) ?> name) ?>" />
customtitles) { if ($currsubtitle == ' ') { echo '

'.$currtitle.'

'; } else { echo '

'.$currtitle.'
'.$currsubtitle.'

'; } } echo format_text($chapter->content, FORMAT_HTML, $formatoptions, $course->id); echo '
'; echo ' '; } else { add_to_log($course->id, 'book', 'print', 'print.php?id='.$cm->id, $book->id, $cm->id); $site = get_record('course','id',1); $chapters = get_records('book_chapters', 'bookid', $book->id, 'pagenum'); /// page header ?> <?PHP echo str_replace('"', '"', $book->name) ?> name) ?>" />

name) ?>

summary) ?>

: fullname) ?>
: fullname) ?>
: name) ?>
:
:
wwwroot.'/mod/book/view.php?id='.$course->id.'&chapterid='; $link2 = $CFG->wwwroot.'/mod/book/view.php?id='.$course->id; foreach ($chapters as $ch) { if (!$ch->hidden) { echo '
'; if (!$book->customtitles) { echo '

'.$titles[$ch->id].'

'; } $content = str_replace($link1, '#ch', $ch->content); $content = str_replace($link2, '#top', $content); echo format_text($content, FORMAT_HTML, $formatoptions, $course->id); echo '
'; //echo ''.$strtop.''; } } echo ' '; } ?>